From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2D3DC433EF for ; Sun, 8 May 2022 18:03:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E3D086B0072; Sun, 8 May 2022 14:03:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DEC006B0073; Sun, 8 May 2022 14:03:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CDAD66B0074; Sun, 8 May 2022 14:03:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id BE5AC6B0072 for ; Sun, 8 May 2022 14:03:48 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 8CE9380992 for ; Sun, 8 May 2022 18:03:48 +0000 (UTC) X-FDA: 79443348936.30.D5DABA9 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf29.hostedemail.com (Postfix) with ESMTP id 7CF21120033 for ; Sun, 8 May 2022 18:03:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=LasmEg2rUBS72wUE19EKxuY+AQYVJSkN1z6eFcojeaU=; b=uSEwp/+iuBdu5CaOAO2cQ0XAsx 3bSQuW2tYAqJSzYarBs5DSvOQ143R5KJH6zJhC99HVjTFa+C5LE8h8zk+eVr9KrSJiHVwgZ2KGM2b DgGtHjHONznLxHAer27E+90GqIgUYuRaYK1vgwELwOrHQPyXDWxnEdulbmoyhV3xhlNe+wtoXz0mE /B5aQ4oGrORlr7a5ZY+BJNUFWzTOZ9HAPAWYvI+4s5vxdnmqIg2bWWHiTXLsV+kZDTXF4Boa+MRgA SC3qLu90w2sf9if0jbK/hu2/4S7BI0j0oGnRe47Rf54/geRFo40hfL2Z1BFXdSYpwM0pSn5Mv+RWe R0dHvA7Q==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nnlFo-002he6-Vz; Sun, 08 May 2022 18:03:37 +0000 Date: Sun, 8 May 2022 19:03:36 +0100 From: Matthew Wilcox To: cgel.zte@gmail.com Cc: akpm@linux-foundation.org, keescook@chromium.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, ran.xiaokai@zte.com.cn, wang.yong12@zte.com.cn, xu.xin16@zte.com.cn, yang.yang29@zte.com.cn, zhang.yunkai@zte.com.cn Subject: Re: [PATCH v5] mm/ksm: introduce ksm_force for each process Message-ID: References: <20220507105926.d4423601230f698b0f5228d1@linux-foundation.org> <20220508092710.930126-1-xu.xin16@zte.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220508092710.930126-1-xu.xin16@zte.com.cn> X-Stat-Signature: udq7pontrhgudroaps3f8jy7jmrx6yak Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="uSEwp/+i"; spf=none (imf29.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 7CF21120033 X-HE-Tag: 1652033021-558291 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sun, May 08, 2022 at 09:27:10AM +0000, cgel.zte@gmail.com wrote: > If ksm_force is set to 0, cancel the feature of ksm_force of this > process and unmerge those merged pages belonging to VMAs which is not > madvised as MADV_MERGEABLE of this process, but leave MADV_MERGEABLE > areas merged. Is that actually a useful feature? Otherwise, we could simply turn on/off the existing MMF_VM_MERGEABLE flag instead of introducing this new bool. > +Controlling KSM with procfs > +=========================== > + > +KSM can also operate on anonymous areas of address space of those processes's > +knob ``/proc//ksm_force`` is on, even if app codes doesn't call madvise() > +explicitly to advise specific areas as MADV_MERGEABLE. > + > +You can set ksm_force to 1 to force all anonymous and qualified VMAs of > +this process to be involved in KSM scanning. But It is effective only when the > +klob of ``/sys/kernel/mm/ksm/run`` is set as 1. I think that last sentence doesn't really add any value. > + memset(buffer, 0, sizeof(buffer)); > + if (count > sizeof(buffer) - 1) > + count = sizeof(buffer) - 1; > + if (copy_from_user(buffer, buf, count)) { > + err = -EFAULT; > + goto out_return; This feels a bit unnecessary. Just 'return -EFAULT' here. > + } > + > + err = kstrtoint(strstrip(buffer), 0, &force); > + > + if (err) > + goto out_return; 'return err' > + if (force != 0 && force != 1) { > + err = -EINVAL; > + goto out_return; 'return -EINVAL' > + } > + > + task = get_proc_task(file_inode(file)); > + if (!task) { > + err = -ESRCH; > + goto out_return; 'return -ESRCH'