Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1383304pxy; Sun, 1 Aug 2021 23:29:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfLeF76k2I0NTPgAH+q/eCxgs1h74g1PIWd4kMGqUpiHtk6/yS/TzuPSFA7PxMLGHvk0xN X-Received: by 2002:a5e:8519:: with SMTP id i25mr598142ioj.152.1627885755818; Sun, 01 Aug 2021 23:29:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627885755; cv=none; d=google.com; s=arc-20160816; b=Z/11+BKF40kfrFm16h3kTFK6TIBUJ5ccL3Lp9U1PCl8kM7SZG8zcvJO8ozdx5X+QAL BigHPzoDl9YTzJqwEnjpptarC5FlyMk5m4xycxQueRPgnB65H00NijRdvOyE8gXt8FOX os4MhUxfbRwgBwynGm1wxxoHTeWdHrXrKqFA39ePGonmkneaC8rbNqRBfT4cl5JVKFG0 EYdTSXxUNsSkXg4H5GucLsgujaKvgCsCNq1l052o0VPVg7MSS8aTYFdNTfYxaG8R/SZC OTBY414fQ0vcmf7B2tsRWw0g7nu5rJAZdbDxwmTEWgidCKIPZriIevCaM84DivKFZZ4R RFMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=6O4ovfEUNzace1WQB0NeGLBJmSbRWBaTfA/jz5eGKhU=; b=yL7ZW29tSa4ALfqHGbf9aGYGviJFq69MDiqzvS73a+NK/hTXniQdl82vPudUvz16ey u+AATyv4TeFZpAps4ZfMeg8B/xY+wkByJOp3NxNGFw8vkl3TGa5Tosd47LbHKwW64fN5 ATr5rnx3iis8KSsPKBGVXz5mYkI2dj02BYqmAYRpH/ZtvjpIN/k3YyuOHEzNVDLHQW9A Fhzgz1Ye56EezBH5Oo7QjCJVZYiwWAA3M+hH8c6+eJ4m5eCbkoC0RnqXyEscOaLrPkhs EHAd8sWmpuBUafv26NDNXHZz4Ta5NOLkPFG/ZgB8/rt9gu2HTL1w33qWWezVN+OHmZ25 nmVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="iekKpJ/F"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s8si12648505ilo.76.2021.08.01.23.29.04; Sun, 01 Aug 2021 23:29:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="iekKpJ/F"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232220AbhHBG2a (ORCPT + 99 others); Mon, 2 Aug 2021 02:28:30 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:60272 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230432AbhHBG23 (ORCPT ); Mon, 2 Aug 2021 02:28:29 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id E07CA1FF2C; Mon, 2 Aug 2021 06:28:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1627885694; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6O4ovfEUNzace1WQB0NeGLBJmSbRWBaTfA/jz5eGKhU=; b=iekKpJ/FslvYsDvvZ82fpdm2vUtlLGMkBtK78wzaekb+Qk7ht7qwOi8jim1KAZlT5MBqOw /D4TEqIau7O5ebh+Rxwe4sF7sa2tsnufabuAG+xPb3GZ28ayU+B4ptzFRqQfydNDQqp4BV e5bwJxE3QHXGF43kpWrhdtZDLtlByAo= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id BC5BBA3BBE; Mon, 2 Aug 2021 06:28:13 +0000 (UTC) Date: Mon, 2 Aug 2021 08:28:13 +0200 From: Michal Hocko To: Waiman Long Cc: Johannes Weiner , Vladimir Davydov , Andrew Morton , Tejun Heo , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Roman Gushchin , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Shakeel Butt , Muchun Song , Alex Shi , Chris Down , Yafang Shao , Wei Yang , Masayoshi Mizuma , Xing Zhengjun , Matthew Wilcox Subject: Re: [PATCH] mm/memcg: Fix incorrect flushing of lruvec data in obj_stock Message-ID: References: <20210802022827.10192-1-longman@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210802022827.10192-1-longman@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun 01-08-21 22:28:27, Waiman Long wrote: > When mod_objcg_state() is called with a pgdat that is different from > that in the obj_stock, the old lruvec data cached in obj_stock are > flushed out. Unfortunately, they were flushed to the new pgdat and > hence the wrong node, not the one cached in obj_stock. It would be great to explicitly mention user observable problems here. I do assume this will make slab stats skewed but the effect wouldn't be very big, right? > Fix that by flushing the data to the cached pgdat instead. > > Fixes: 68ac5b3c8db2 ("mm/memcg: cache vmstat data in percpu memcg_stock_pcp") > Signed-off-by: Waiman Long Acked-by: Michal Hocko > --- > mm/memcontrol.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index ae1f5d0cb581..881ec4ddddcd 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -3106,17 +3106,19 @@ void mod_objcg_state(struct obj_cgroup *objcg, struct pglist_data *pgdat, > stock->cached_pgdat = pgdat; > } else if (stock->cached_pgdat != pgdat) { > /* Flush the existing cached vmstat data */ > + struct pglist_data *oldpg = stock->cached_pgdat; > + > + stock->cached_pgdat = pgdat; > if (stock->nr_slab_reclaimable_b) { > - mod_objcg_mlstate(objcg, pgdat, NR_SLAB_RECLAIMABLE_B, > + mod_objcg_mlstate(objcg, oldpg, NR_SLAB_RECLAIMABLE_B, > stock->nr_slab_reclaimable_b); > stock->nr_slab_reclaimable_b = 0; > } > if (stock->nr_slab_unreclaimable_b) { > - mod_objcg_mlstate(objcg, pgdat, NR_SLAB_UNRECLAIMABLE_B, > + mod_objcg_mlstate(objcg, oldpg, NR_SLAB_UNRECLAIMABLE_B, > stock->nr_slab_unreclaimable_b); > stock->nr_slab_unreclaimable_b = 0; > } > - stock->cached_pgdat = pgdat; Minor nit. Is there any reason to move the cached_pgdat? TBH I found the original way better from the readability POV. > } > > bytes = (idx == NR_SLAB_RECLAIMABLE_B) ? &stock->nr_slab_reclaimable_b > -- > 2.18.1 -- Michal Hocko SUSE Labs