From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D52C7C3F2D1 for ; Wed, 4 Mar 2020 08:18:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A2DD62166E for ; Wed, 4 Mar 2020 08:18:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A2DD62166E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3F0E96B0005; Wed, 4 Mar 2020 03:18:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 379F16B0006; Wed, 4 Mar 2020 03:18:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 269B86B0007; Wed, 4 Mar 2020 03:18:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 0A3EE6B0005 for ; Wed, 4 Mar 2020 03:18:26 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id B2E09181AC9C6 for ; Wed, 4 Mar 2020 08:18:25 +0000 (UTC) X-FDA: 76556977770.09.ants15_83be3fcad8f1d X-HE-Tag: ants15_83be3fcad8f1d X-Filterd-Recvd-Size: 5942 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Wed, 4 Mar 2020 08:18:25 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id B7E83B1D4; Wed, 4 Mar 2020 08:18:22 +0000 (UTC) Subject: Re: [PATCH 2/2 v3] mm/compaction: Disable compact_unevictable_allowed on RT To: Sebastian Andrzej Siewior , Andrew Morton Cc: linux-mm@kvack.org, Thomas Gleixner , Luis Chamberlain , Kees Cook , Iurii Zaikin , Mel Gorman , Linux API References: <20200115161035.893221-1-bigeasy@linutronix.de> <4cf4507b-0632-34e6-5985-df933559af9f@suse.cz> <20200302173516.iysuejilava37psk@linutronix.de> <20200302132531.59a2c9dffe2515d78abaf909@linux-foundation.org> <20200303175910.ichnkjkgmz5y2ipb@linutronix.de> <20200303202054.gsosv7fsx2ma3cic@linutronix.de> <20200303202225.nhqc3v5gwlb7x6et@linutronix.de> From: Vlastimil Babka Message-ID: Date: Wed, 4 Mar 2020 09:18:21 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200303202225.nhqc3v5gwlb7x6et@linutronix.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable 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 3/3/20 9:22 PM, Sebastian Andrzej Siewior wrote: > Since commit > 5bbe3547aa3ba ("mm: allow compaction of unevictable pages") >=20 > it is allowed to examine mlocked pages and compact them by default. > On -RT even minor pagefaults are problematic because it may take a few > 100us to resolve them and until then the task is blocked. >=20 > Make compact_unevictable_allowed =3D 0 default and issue a warning on R= T > if it is changed. >=20 > Link: https://lore.kernel.org/linux-mm/20190710144138.qyn4tuttdq6h7kqx@= linutronix.de/ > Signed-off-by: Sebastian Andrzej Siewior > --- > v2=E2=80=A6v3: - Allow to modify the value but issue a warning if it is= changed. >=20 > v1=E2=80=A6v2: - Make the proc file RO instead removing it. > - Mention this change in Documentation/=E2=80=A6/vm.rst. >=20 > Documentation/admin-guide/sysctl/vm.rst | 3 +++ > kernel/sysctl.c | 27 ++++++++++++++++++++++++- > mm/compaction.c | 4 ++++ > 3 files changed, 33 insertions(+), 1 deletion(-) >=20 > diff --git a/Documentation/admin-guide/sysctl/vm.rst b/Documentation/ad= min-guide/sysctl/vm.rst > index 64aeee1009cab..0329a4d3fa9ec 100644 > --- a/Documentation/admin-guide/sysctl/vm.rst > +++ b/Documentation/admin-guide/sysctl/vm.rst > @@ -128,6 +128,9 @@ allowed to examine the unevictable lru (mlocked pag= es) for pages to compact. > This should be used on systems where stalls for minor page faults are = an > acceptable trade for large contiguous free memory. Set to 0 to preven= t > compaction from moving pages that are unevictable. Default value is 1= . > +On CONFIG_PREEMPT_RT the default value is 0 in order to avoid a page f= ault, due > +to compaction, which would block the task from becomming active until = the fault > +is resolved. > =20 > =20 > dirty_background_bytes > diff --git a/kernel/sysctl.c b/kernel/sysctl.c > index 982203101f961..3ace90b6ac57f 100644 > --- a/kernel/sysctl.c > +++ b/kernel/sysctl.c > @@ -212,6 +212,11 @@ static int proc_do_cad_pid(struct ctl_table *table= , int write, > void __user *buffer, size_t *lenp, loff_t *ppos); > static int proc_taint(struct ctl_table *table, int write, > void __user *buffer, size_t *lenp, loff_t *ppos); > +#ifdef CONFIG_COMPACTION > +static int proc_dointvec_warn_RT_change(struct ctl_table *table, int w= rite, > + void __user *buffer, size_t *lenp, > + loff_t *ppos); > +#endif > #endif > =20 > #ifdef CONFIG_PRINTK > @@ -1484,7 +1489,7 @@ static struct ctl_table vm_table[] =3D { > .data =3D &sysctl_compact_unevictable_allowed, > .maxlen =3D sizeof(int), > .mode =3D 0644, > - .proc_handler =3D proc_dointvec_minmax, > + .proc_handler =3D proc_dointvec_warn_RT_change, > .extra1 =3D SYSCTL_ZERO, > .extra2 =3D SYSCTL_ONE, > }, > @@ -2572,6 +2577,26 @@ int proc_dointvec(struct ctl_table *table, int w= rite, > return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL)= ; > } > =20 > +#ifdef CONFIG_COMPACTION > +static int proc_dointvec_warn_RT_change(struct ctl_table *table, int w= rite, > + void __user *buffer, size_t *lenp, > + loff_t *ppos) > +{ > + int ret, old; > + > + if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write) > + return proc_dointvec(table, write, buffer, lenp, ppos); Shouldn't you use her proc_dointvec_minmax() per Patch 1/2 ? > + > + old =3D *(int *)table->data; > + ret =3D proc_dointvec(table, write, buffer, lenp, ppos); And here. > + if (ret) > + return ret; > + WARN_ONCE(old !=3D *(int *)table->data, "sysctl attribute %s changed.= ", > + table->procname); > + return ret; > +} > +#endif > + > /** > * proc_douintvec - read a vector of unsigned integers > * @table: the sysctl table > diff --git a/mm/compaction.c b/mm/compaction.c > index 672d3c78c6abf..ba77809a1666e 100644 > --- a/mm/compaction.c > +++ b/mm/compaction.c > @@ -1590,7 +1590,11 @@ typedef enum { > * Allow userspace to control policy on scanning the unevictable LRU f= or > * compactable pages. > */ > +#ifdef CONFIG_PREEMPT_RT > +int sysctl_compact_unevictable_allowed __read_mostly =3D 0; > +#else > int sysctl_compact_unevictable_allowed __read_mostly =3D 1; > +#endif > =20 > static inline void > update_fast_start_pfn(struct compact_control *cc, unsigned long pfn) >=20