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 466B4C433FE for ; Fri, 11 Mar 2022 02:23:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9E40E8D0002; Thu, 10 Mar 2022 21:23:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9924E8D0001; Thu, 10 Mar 2022 21:23:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 883748D0002; Thu, 10 Mar 2022 21:23:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id 7B65F8D0001 for ; Thu, 10 Mar 2022 21:23:30 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4D81E207D0 for ; Fri, 11 Mar 2022 02:23:30 +0000 (UTC) X-FDA: 79230508980.15.67826F5 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf23.hostedemail.com (Postfix) with ESMTP id B8D92140011 for ; Fri, 11 Mar 2022 02:23:29 +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 ams.source.kernel.org (Postfix) with ESMTPS id 8710DB829B8; Fri, 11 Mar 2022 02:23:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA8ADC340EB; Fri, 11 Mar 2022 02:23:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1646965407; bh=EZzrBJ4hQDIygZtNGzoC1Q6zoHDCYzlMFZolsDUGoBA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=BpsWv5p4wyLA24xXf09Mn3kdws6vC92Grfbi28n+jFypV7W9p/VoGTOjmpsTqG9YK DWu473+2nsyjRjNKRB4bNvGBqx4QXjWpyZ6uqS8xAtkT8pEmcxsl9h/pzd+mi+/Bey G8sNA4Y2ZD2BAK5gaEGIgjpnKq8PV2pwIQUqkyfE= Date: Thu, 10 Mar 2022 18:23:26 -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 v5] mm: lru_cache_disable: replace work queue synchronization with synchronize_rcu Message-Id: <20220310182326.5b375da6b86e95f7e71acd90@linux-foundation.org> In-Reply-To: References: <20220304163554.8872fe5d5a9d634f7a2884f5@linux-foundation.org> 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-Stat-Signature: jp5xmw8yp7nw4uihqag6xbs6kex61ixe Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=BpsWv5p4; spf=pass (imf23.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: B8D92140011 X-HE-Tag: 1646965409-353756 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 Thu, 10 Mar 2022 10:22:12 -0300 Marcelo Tosatti wrote: > > On systems that run FIFO:1 applications that busy loop, > any SCHED_OTHER task that attempts to execute > on such a CPU (such as work threads) will not > be scheduled, which leads to system hangs. > > 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. > > To fix this, replace the usage of work items with synchronize_rcu, > which provides the same 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. Permitting a realtime thread to hang the entire system warrants a -stable backport, I think. That's just rude. I'm inclined to send this upstream for 5.18-rc1, with that -stable tag. But if agreeable, how far can we backport this? Paul, do we know which kernel version(s) have the desired synchronize_rcu() behaviour? Now, we don't want -stable people backporting this into kernels where synchronize_rcu() doesn't do what we want it to do. So a sneaky thing we could do is to identify the change which added the desired synchronize_rcu() behaviour and make this patch Fixes:thatpatch. That should prevent people from backporting it too far.