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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 052CBC433F5 for ; Sat, 5 Mar 2022 00:35:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 594BC8D0002; Fri, 4 Mar 2022 19:35:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5437B8D0001; Fri, 4 Mar 2022 19:35:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 40CA68D0002; Fri, 4 Mar 2022 19:35:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0122.hostedemail.com [216.40.44.122]) by kanga.kvack.org (Postfix) with ESMTP id 32D268D0001 for ; Fri, 4 Mar 2022 19:35:58 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id CCE16181C9BAD for ; Sat, 5 Mar 2022 00:35:57 +0000 (UTC) X-FDA: 79208465154.16.72086C3 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf09.hostedemail.com (Postfix) with ESMTP id 4CB07140003 for ; Sat, 5 Mar 2022 00:35:57 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 571F961F2B; Sat, 5 Mar 2022 00:35:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 604A8C340E9; Sat, 5 Mar 2022 00:35:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1646440555; bh=mwjsS+YMGajXXQMaUkaiH/3MXku41Jx+TRuzkQ6Y6Jg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=e8ct/L1e1A16OfW/iQ8Zgh+spt2H9t+3S0zaHsjY0h00LqO852i10s5evccJvhiLF UONEs4TjVYWKHIagAmMk1b5Sh97NXXUgx8gKFFLTGu56sjbSKAJ4uD0Kf2+1Aj4fE6 9f3S2dNGVFnHOvAZ89DsE/iV3Wl33YhneVHDRfnw= Date: Fri, 4 Mar 2022 16:35:54 -0800 From: Andrew Morton To: Marcelo Tosatti Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Minchan Kim , Matthew Wilcox , Mel Gorman , Nicolas Saenz Julienne , Juri Lelli , Thomas Gleixner , Sebastian Andrzej Siewior , "Paul E. McKenney" Subject: Re: [patch v4] mm: lru_cache_disable: replace work queue synchronization with synchronize_rcu Message-Id: <20220304163554.8872fe5d5a9d634f7a2884f5@linux-foundation.org> In-Reply-To: References: X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 4CB07140003 X-Stat-Signature: rh85h9zupafd7us6hecuwgfd98dk5j8h Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b="e8ct/L1e"; spf=pass (imf09.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspam-User: X-HE-Tag: 1646440557-555891 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 Fri, 4 Mar 2022 13:29:31 -0300 Marcelo Tosatti wrote: > > On systems that run FIFO:1 applications that busy loop > on isolated CPUs, executing tasks on such CPUs under > lower priority is undesired (since that will either > hang the system, or cause longer interruption to the > FIFO task due to execution of lower priority task > with very small sched slices). > > Commit d479960e44f27e0e52ba31b21740b703c538027c ("mm: disable LRU > pagevec during the migration temporarily") relies on > queueing work items on all online CPUs to ensure visibility > of lru_disable_count. > > However, its possible to use synchronize_rcu which will provide the same > guarantees (see comment this patch modifies on lru_cache_disable). > > Fixes: > > ... > > --- a/mm/swap.c > +++ b/mm/swap.c > @@ -831,8 +831,7 @@ inline void __lru_add_drain_all(bool force_all_cpus) > for_each_online_cpu(cpu) { > struct work_struct *work = &per_cpu(lru_add_drain_work, cpu); > > - if (force_all_cpus || > - pagevec_count(&per_cpu(lru_pvecs.lru_add, cpu)) || > + if (pagevec_count(&per_cpu(lru_pvecs.lru_add, cpu)) || Please changelog this alteration? > data_race(pagevec_count(&per_cpu(lru_rotate.pvec, cpu))) || > pagevec_count(&per_cpu(lru_pvecs.lru_deactivate_file, cpu)) || > pagevec_count(&per_cpu(lru_pvecs.lru_deactivate, cpu)) || > @@ -876,15 +875,21 @@ atomic_t lru_disable_count = ATOMIC_INIT(0); > void lru_cache_disable(void) > { > atomic_inc(&lru_disable_count); > -#ifdef CONFIG_SMP > /* > - * lru_add_drain_all in the force mode will schedule draining on > - * all online CPUs so any calls of lru_cache_disabled wrapped by > - * local_lock or preemption disabled would be ordered by that. > - * The atomic operation doesn't need to have stronger ordering > - * requirements because that is enforced by the scheduling > - * guarantees. > + * Readers of lru_disable_count are protected by either disabling > + * preemption or rcu_read_lock: > + * > + * preempt_disable, local_irq_disable [bh_lru_lock()] > + * rcu_read_lock [rt_spin_lock CONFIG_PREEMPT_RT] > + * preempt_disable [local_lock !CONFIG_PREEMPT_RT] > + * > + * Since v5.1 kernel, synchronize_rcu() is guaranteed to wait on > + * preempt_disable() regions of code. So any CPU which sees > + * lru_disable_count = 0 will have exited the critical > + * section when synchronize_rcu() returns. > */ > + synchronize_rcu(); > +#ifdef CONFIG_SMP > __lru_add_drain_all(true); > #else > lru_add_and_bh_lrus_drain();