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 8347FC433F5 for ; Fri, 1 Apr 2022 01:11:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E28396B0071; Thu, 31 Mar 2022 21:11:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DD75D6B0072; Thu, 31 Mar 2022 21:11:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CC6F26B0073; Thu, 31 Mar 2022 21:11:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0058.hostedemail.com [216.40.44.58]) by kanga.kvack.org (Postfix) with ESMTP id BDB206B0071 for ; Thu, 31 Mar 2022 21:11:41 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 5E682A7AE9 for ; Fri, 1 Apr 2022 01:11:31 +0000 (UTC) X-FDA: 79306532382.21.863B641 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf29.hostedemail.com (Postfix) with ESMTP id A8B3A12000E for ; Fri, 1 Apr 2022 01:11:30 +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 04612B82294; Fri, 1 Apr 2022 01:11:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71832C340ED; Fri, 1 Apr 2022 01:11:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1648775487; bh=kPYuo0O3P1pMhQvBEEQcVJ3OAmVbxM9vWnBjNrOncrU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=hClwJ+lYs+R1QchPXW1nnSVLmD1IB/7eMQy0Bh11A5Kf9sRFBQoeUxLM5Q/BhJ2ga D7Q5EQhO2XI9cOw7YQSr46jQc10PrkAL+YSpGN5DW5402FOjYio/zBA5g5Ll+HwrTu AUYM3LdN97vcSg4IZ0wzn8HfNWgF5uYllmoKZeEQ= Date: Thu, 31 Mar 2022 18:11:26 -0700 From: Andrew Morton To: Michal Hocko Cc: Shakeel Butt , Roman Gushchin , Waiman Long , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Muchun Song Subject: Re: [PATCH v2] mm/list_lru: Fix possible race in memcg_reparent_list_lru_node() Message-Id: <20220331181126.815cfe2b05b4281d32b7bf49@linux-foundation.org> In-Reply-To: References: <20220330191440.1cc1b2de2b849d1ba93d2ba7@linux-foundation.org> <89B53D3A-FCC5-4107-8D49-81D5B9AE5172@linux.dev> <20220331063956.5uqnab64cqnmcwyr@google.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Rspam-User: X-Stat-Signature: 77ft5xxmi8jb4e6pweco1ju1fij8xawz Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=hClwJ+lY; spf=pass (imf29.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-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: A8B3A12000E X-HE-Tag: 1648775490-684820 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 Thu, 31 Mar 2022 09:46:52 +0200 Michal Hocko wrote: > On Thu 31-03-22 06:39:56, Shakeel Butt wrote: > > On Wed, Mar 30, 2022 at 07:48:45PM -0700, Roman Gushchin wrote: > > >=20 > > >=20 > > [...] > > >=20 > > >=20 > > > But honestly, I=E2=80=99d drop the original optimization together w= ith > > > the fix, if only there is no _real world_ data on the problem and > > > the improvement. It seems like it has started as a nice simple > > > improvement, but the race makes it complex and probably not worth > > > the added complexity and fragility. > >=20 > > I agree with dropping the original optimization as it is not really > > fixing an observed issue which may justify adding some complexity. >=20 > Completely agreed. The patch as it is proposed is not really acceptable > IMHO and I have to say I am worried that this is not the first time we > are in a situation when a follow up fixes or unrelated patches are > growing in complexity to fit on top of a performance optimizations whic= h > do not refer to any actual numbers. Yup. I did this: From: Andrew Morton Subject: mm/list_lru.c: revert "mm/list_lru: optimize memcg_reparent_list= _lru_node()" 405cc51fc1049c73 ("mm/list_lru: optimize memcg_reparent_list_lru_node()") has subtle races which are proving ugly to fix. Revert the original optimization. If quantitative testing indicates that we have a significant problem here then other implementations can be looked at. Fixes: 405cc51fc1049c73 ("mm/list_lru: optimize memcg_reparent_list_lru_n= ode()") Cc: Waiman Long Cc: Roman Gushchin Cc: Muchun Song Cc: Michal Hocko Cc: Johannes Weiner Cc: Shakeel Butt Signed-off-by: Andrew Morton --- mm/list_lru.c | 6 ------ 1 file changed, 6 deletions(-) --- a/mm/list_lru.c~revert-1 +++ a/mm/list_lru.c @@ -395,12 +395,6 @@ static void memcg_reparent_list_lru_node struct list_lru_one *src, *dst; =20 /* - * If there is no lru entry in this nlru, we can skip it immediately. - */ - if (!READ_ONCE(nlru->nr_items)) - return; - - /* * Since list_lru_{add,del} may be called under an IRQ-safe lock, * we have to use IRQ-safe primitives here to avoid deadlock. */ _