Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1350924pxb; Fri, 1 Apr 2022 10:57:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwJ+AT/h0gUaLZ+bhm2MYAfSFNxJWxEep2VRXLSWpUpyt/SCPQixAR8ZJDvSgFdMgeMd2v X-Received: by 2002:a17:907:3f03:b0:6df:b04b:8712 with SMTP id hq3-20020a1709073f0300b006dfb04b8712mr886729ejc.290.1648835820413; Fri, 01 Apr 2022 10:57:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648835820; cv=none; d=google.com; s=arc-20160816; b=eHDCuXOcmimhwCi9IbhJ2LT0fB54s2wH6r+1aZiNv00VySPJzUsVwqOi3v9jFGDSXH r0qZlvPpsRxrcqZFyRlfDK8448JlUHZ4KwIuhBA819SHWYVifQABOsdNwf31Ue4+aSx0 pGJmQCx/uij9wy46snx69nslbnZF3TnaI06F1vWBS5Yk9BG1Q/zJ/Yb/zab/OmyZMrVp jgDGD7NQW78iS6Pa4nnYMvmKY3tCFDjJwW78ATrRhOh/w+eFYq79/VCI0DT97tStn3Zh blk+ktAEljPrTg6KKfPfYygEmq8jmY9XQsAawTjGMrl6dF9rpMBXbf/6XTmfzv/Y9OFZ aykw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=q3RNcxFKe9JDt0ZtDAgkpeR3yJPWQ8XjPMxmH2wkKR4=; b=ChGiM8ikIOUnI3ST2wdmP3bMhdh+l5YbKOhl0kgZhELHMKhvx0OoeENNeh4FDzXiCi fgAy24bbf3oQQENWgARhQpSsq1X56o2oJX3zu8evi3I31Pis3pJG9aaEDgh9rJEKtxJK lp7zcVJWS4floTpVjTW+kWstLw3LLBfmFaNL8gZTi3bSfMJEvW9kA8oc9BiHAJ6Un2P8 v3U+CLoHKUKAZs4f+PUFt0MTeKLsquqO5m3mvKuDBspGc+JWRf5ZLpsSXF6ZXKLD86U2 NTNk+znDdDPTGIH50dSXGm3nUaQmMFwUNv5ZWj2kmR4v5ZjCxKqWmR05iervcJe59y3D Nv1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=hClwJ+lY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fi2-20020a1709073ac200b006df76385de9si1763095ejc.649.2022.04.01.10.56.11; Fri, 01 Apr 2022 10:57:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=hClwJ+lY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241818AbiDABNY (ORCPT + 99 others); Thu, 31 Mar 2022 21:13:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231201AbiDABNT (ORCPT ); Thu, 31 Mar 2022 21:13:19 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89AE1231922 for ; Thu, 31 Mar 2022 18:11:30 -0700 (PDT) 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 28410B822B1 for ; 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: > > > > > > > > [...] > > > > > > > > > But honestly, I’d drop the original optimization together with > > > 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. > > > > I agree with dropping the original optimization as it is not really > > fixing an observed issue which may justify adding some complexity. > > 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 which > 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_node()") 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; /* - * 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. */ _