Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1278592pxy; Sun, 1 Aug 2021 19:30:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDVu++oPdS3pg7D9AZp0qC5bN2DGe4s6K9/0TxiIwQEXNrMwO3E2swz/nIBHXPp18kGkbb X-Received: by 2002:a05:6638:1036:: with SMTP id n22mr9031704jan.81.1627871423388; Sun, 01 Aug 2021 19:30:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627871423; cv=none; d=google.com; s=arc-20160816; b=x+jroACdbGhbzIqzmXA3bUwI1ChSePIDCOgK/3/XjDKAzg1dxwYUt5e3R9dCpUGPDj SBRCua/rkVvkN6Bo4HQ0II9T7evLNrdWnS8iuuDj4u/0pLRuA+DuPCU6LQDYZIufZX1M kZWoWTpk9lNAjcvHcfFBFFuX4MIYxdA6rBNmtGvv+kRIlzxMj7ZChHpSwv44GqPcozcJ xCwmdReg80PYlRiLNkNF8Q4l6UhZnWbSBdlTnu7TB73LFSDVqSh0MY6oZl+WAHhlkIrf cEv+KUEaslvSrWCyCHNrheqKpX8SQv8zNRz4wkM6DZFBuopHo9rHUlxrlgeE1llASNzx JiDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=We5uPnQeByis91o/AyYOCOo9vmw3X7xwMVyvzEdXeeY=; b=C8L/rjwqFpmHDXnlaRYbwKsNJOMDnNBbqYn+sq/5fTkXkUuX/JdBxXoV+h8lLtKzqe F0jmQQoXBdEoqYvtXYWfHDENh1fZuwC1tEaBqOoYf7LzyDdOfQY5YqD7/8ljfRe9VGc6 Jntqr9/kas0oRodpB/ntW2pP3EX3tj/6GJ2vhCxy65jSEQo7SEKcnysNTPibkFayXMTm VfELdlASZDgNjZQUKnQdGqaM9z25hh95fUDNLJ6LwQicrlLYev9C/VaLq+3MulIrZQsZ Nnk+Ib2JY5imRMGP0KR0uADsyR2tDoxTqs4cOR9BpprO0AyUJ/57BxEAXwSBXOGjNf9+ 31sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YUiZKimB; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v19si11497542jat.76.2021.08.01.19.30.08; Sun, 01 Aug 2021 19:30:23 -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=@redhat.com header.s=mimecast20190719 header.b=YUiZKimB; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229915AbhHBC3G (ORCPT + 99 others); Sun, 1 Aug 2021 22:29:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:42633 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229908AbhHBC3F (ORCPT ); Sun, 1 Aug 2021 22:29:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1627871336; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=We5uPnQeByis91o/AyYOCOo9vmw3X7xwMVyvzEdXeeY=; b=YUiZKimBiV9cFsQUeSGSLbLIFvAL4m8W9NK/p8jvZnznyInzzVA+j6QxSuHivUkgtY3qlj S5dKBSkGJyH6OiCMWAnkZ+jWAZsukcjBFOvpip57RVzQML9jXljw+e5ix3xJNcQLUMsRv3 XmBmQs19ITpbRriCkzWEW3lFDnqG3UI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-19-Ts4DyE5DPWyoOBve8zP2Qg-1; Sun, 01 Aug 2021 22:28:53 -0400 X-MC-Unique: Ts4DyE5DPWyoOBve8zP2Qg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ACA0C1853027; Mon, 2 Aug 2021 02:28:48 +0000 (UTC) Received: from llong.com (unknown [10.22.16.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2424427CB4; Mon, 2 Aug 2021 02:28:41 +0000 (UTC) From: Waiman Long To: Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Tejun Heo , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Roman Gushchin Cc: 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 , Waiman Long Subject: [PATCH] mm/memcg: Fix incorrect flushing of lruvec data in obj_stock Date: Sun, 1 Aug 2021 22:28:27 -0400 Message-Id: <20210802022827.10192-1-longman@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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 --- 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; } bytes = (idx == NR_SLAB_RECLAIMABLE_B) ? &stock->nr_slab_reclaimable_b -- 2.18.1