Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1636018pxu; Sun, 6 Dec 2020 02:21:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4UelyZpyWV3s7+P4p7UoqashzafFDpwGZJT9uZKrD4TrqSmi2DUprQjufSZdbv5HHD/vx X-Received: by 2002:a05:6402:3c3:: with SMTP id t3mr15522751edw.86.1607250117681; Sun, 06 Dec 2020 02:21:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607250117; cv=none; d=google.com; s=arc-20160816; b=QFefXlcLw5BMln7AlXjYz4nRIjIaAljxsKfe6Arp0PmJ309+FVRyGJHDNZuYKWwwe1 no/hqSl3Fy8wlIeHzhSELyezq+XKdm1euUpnJzLouVozlXReAxHYXDZkm04v6Fn9Eumu tov/nKISrupuv6x3Y/EM4xKPeroEAqecz7gxessrNVjATcEzO60OUyxTTvxZ5wx337zF oNYFHlr+wWErTvPmL+bGuLPKBztSOr6s9U26H9kzov4hkU1F6Gxc7x1ZTDEoV3pRS+Z6 jdamUl/u6iu4z0ooUoWYSzqiXf7lrURoLiDLpKDppOXnfu5XBzndUnWbP+F8R+EmRqct /jFA== 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:date:subject:cc:to:from :dkim-signature; bh=jxjzCofAcULr7bnQMbpOvZCW6tNXMo722rzO5X3X+g0=; b=FrATVHBFlQyVGei4SP6Ekw6DR4ClJVlZa/c2ZGMG7sJzI8v+QZB2T07G1k0OEBcFUV wtyxc9OL78sIzq1AjVvMwmLtgTJQoNK5e161bXsziz72tT4CXXK0ZYzT2Ll0aFHSSvNt A/WWME59K4kNR2sHjGSA4XwxLD3a+ACIkZDF85r6qx8H+Yg3Ahk3u5vLC8Y5WRj5YII+ /kyne6f8/Dz4fb8r8TtmjPK4sjL4ktJEQqqLzqwrFYKpm2xwMXGJnWDKfcbSZVEQ18OA l2c2+qiBvupqwQqUuKDbqo30tYJh90r4hyYP610mHbPandDhVx+EQHJEMQOk0a7CqONP EEsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=l0t429mz; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x25si6275455edi.388.2020.12.06.02.21.35; Sun, 06 Dec 2020 02:21:57 -0800 (PST) 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=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=l0t429mz; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727418AbgLFKSp (ORCPT + 99 others); Sun, 6 Dec 2020 05:18:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727240AbgLFKSp (ORCPT ); Sun, 6 Dec 2020 05:18:45 -0500 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C82CC094242 for ; Sun, 6 Dec 2020 02:18:14 -0800 (PST) Received: by mail-pl1-x644.google.com with SMTP id p6so5585245plo.6 for ; Sun, 06 Dec 2020 02:18:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jxjzCofAcULr7bnQMbpOvZCW6tNXMo722rzO5X3X+g0=; b=l0t429mzGcnZFwxy/27EHeyds85DHU2/SvU/cTTFIMKpTZQ13vGzScVjnNJc1Qfgdl tq3J8LH2Po4yAdE4Qo1uNZ9GfP2dCXBM7HpnjMHacvON/LTEfdfapf3sJCtF6f1t+m// Rdasl44TWp0U1bs3j6e3qWDr9Qn4cvq1JzncWvKY7tQL+4hmLSOUSIIajJobIPEmCai1 ok61QC0poafIrVv2iaxO+AbBLSIJ7BNrJjU/r+EtWVpKKiZe8qX3AGUSS983k1LeN9AL G+VQSyqTH4X1j0tI7iZy9yvMHaPD1FXpVWoKPjzR3GdmseCxF/0+PH5flDA0QOufjbFW Swlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jxjzCofAcULr7bnQMbpOvZCW6tNXMo722rzO5X3X+g0=; b=qH3jXm4mIilgWLgKsABVM7y7Y6GzxnMiIUq72e+gKXIIhQ+CQ9mfKLQ1Jsx61MxzOh YjmZcIzZ5xI/YO7L+AaKcKigXZxaL8S7zN1o53rRV8xZrmu/JZlq+8SCh10ISZ+ijaF7 VVENIBe77E1dNlkOz8PEyQfM5exEDvoUWB7bGpXsIUNZ2eT7NZc5Rdxrs1FyI+PIDbvh sNVsSCzUguRPOyPJzTpRAc+Irw4Z13NFq32IEBRvFSpCZw/R0nn4Ll73GoQMjyO4TLsX +P/GynJDUJ29goj4U50RWTbe502UzhdZs942hPUec6KObeF0S/QA4gST9ImWx8trqYQM C7kg== X-Gm-Message-State: AOAM533Z2DBNg2jmhUPpd/4ZEJ36/StrKmWdlAy9TUJ1GcyjYcu6V3V+ Wuj/IGAixHvsFbbqx+vo8d24Bg== X-Received: by 2002:a17:90b:390b:: with SMTP id ob11mr11955031pjb.66.1607249893914; Sun, 06 Dec 2020 02:18:13 -0800 (PST) Received: from localhost.localdomain ([103.136.221.70]) by smtp.gmail.com with ESMTPSA id g16sm10337657pfb.201.2020.12.06.02.18.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 Dec 2020 02:18:13 -0800 (PST) From: Muchun Song To: gregkh@linuxfoundation.org, rafael@kernel.org, adobriyan@gmail.com, akpm@linux-foundation.org, hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, hughd@google.com, will@kernel.org, guro@fb.com, rppt@kernel.org, tglx@linutronix.de, esyr@redhat.com, peterx@redhat.com, krisman@collabora.com, surenb@google.com, avagin@openvz.org, elver@google.com, rdunlap@infradead.org, iamjoonsoo.kim@lge.com Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, Muchun Song Subject: [RESEND PATCH v2 09/12] mm: memcontrol: convert vmstat slab counters to bytes Date: Sun, 6 Dec 2020 18:14:48 +0800 Message-Id: <20201206101451.14706-10-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20201206101451.14706-1-songmuchun@bytedance.com> References: <20201206101451.14706-1-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org the global and per-node counters are stored in pages, however memcg and lruvec counters are stored in bytes. This scheme looks weird. So convert all vmstat slab counters to bytes. Signed-off-by: Muchun Song --- include/linux/vmstat.h | 17 ++++++++++------- mm/vmstat.c | 21 ++++++++++----------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index 322dcbfcc933..fd1a3d5d4926 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -197,18 +197,26 @@ static inline unsigned long global_node_page_state_pages(enum node_stat_item item) { long x = atomic_long_read(&vm_node_stat[item]); + #ifdef CONFIG_SMP if (x < 0) x = 0; #endif + if (vmstat_item_in_bytes(item)) + x >>= PAGE_SHIFT; return x; } static inline unsigned long global_node_page_state(enum node_stat_item item) { - VM_WARN_ON_ONCE(vmstat_item_in_bytes(item)); + long x = atomic_long_read(&vm_node_stat[item]); - return global_node_page_state_pages(item); + VM_WARN_ON_ONCE(vmstat_item_in_bytes(item)); +#ifdef CONFIG_SMP + if (x < 0) + x = 0; +#endif + return x; } static inline unsigned long zone_page_state(struct zone *zone, @@ -312,11 +320,6 @@ static inline void __mod_zone_page_state(struct zone *zone, static inline void __mod_node_page_state(struct pglist_data *pgdat, enum node_stat_item item, int delta) { - if (vmstat_item_in_bytes(item)) { - VM_WARN_ON_ONCE(delta & (PAGE_SIZE - 1)); - delta >>= PAGE_SHIFT; - } - node_page_state_add(delta, pgdat, item); } diff --git a/mm/vmstat.c b/mm/vmstat.c index 8d77ee426e22..7fb0c7cb9516 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -345,11 +345,6 @@ void __mod_node_page_state(struct pglist_data *pgdat, enum node_stat_item item, long x; long t; - if (vmstat_item_in_bytes(item)) { - VM_WARN_ON_ONCE(delta & (PAGE_SIZE - 1)); - delta >>= PAGE_SHIFT; - } - x = delta + __this_cpu_read(*p); t = __this_cpu_read(pcp->stat_threshold); @@ -554,11 +549,6 @@ static inline void mod_node_state(struct pglist_data *pgdat, s8 __percpu *p = pcp->vm_node_stat_diff + item; long o, n, t, z; - if (vmstat_item_in_bytes(item)) { - VM_WARN_ON_ONCE(delta & (PAGE_SIZE - 1)); - delta >>= PAGE_SHIFT; - } - do { z = 0; /* overflow to node counters */ @@ -1012,19 +1002,28 @@ unsigned long node_page_state_pages(struct pglist_data *pgdat, enum node_stat_item item) { long x = atomic_long_read(&pgdat->vm_stat[item]); + #ifdef CONFIG_SMP if (x < 0) x = 0; #endif + if (vmstat_item_in_bytes(item)) + x >>= PAGE_SHIFT; return x; } unsigned long node_page_state(struct pglist_data *pgdat, enum node_stat_item item) { + long x = atomic_long_read(&pgdat->vm_stat[item]); + VM_WARN_ON_ONCE(vmstat_item_in_bytes(item)); - return node_page_state_pages(pgdat, item); +#ifdef CONFIG_SMP + if (x < 0) + x = 0; +#endif + return x; } #endif -- 2.11.0