Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2862415pxu; Mon, 7 Dec 2020 18:50:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJyMJRE/wEbry0WPL9G5pMMtW3VVrCu/7vAbkSPAjxbRf/+WfRs1XYpUlFCAntMV96YRqsYG X-Received: by 2002:a50:e688:: with SMTP id z8mr23229375edm.129.1607395799905; Mon, 07 Dec 2020 18:49:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607395799; cv=none; d=google.com; s=arc-20160816; b=Jmac6ti9WL0Qt8Jp5crV3htCJREv3Yw25tDgYlCUGksBrm0ObYLWdyZ4cIVxapgTVE V/yrZCN02AjEWD7Tg1yFU+NrwEvMW+0hmec+o0gu/gYtDYul3ZhBpJdK5DG5S5U29hgD AX7IyvxSNNLsUN06+am4mOcF0KDaGaWNXl1NfH5QmvX8tf3t8JmNjx5y2awpPp5LlXQd oO5pUxEsQsJg6x4qCNRB+upOIrtyT9VSLxi2iLgKY7ARWjWCDRyxdoNapt5d8VBMMyh7 Xm/W+HgsjL/o4tieqg/2GrHPStor3lT7wOmN/XkZfulYAhqRvZywETRPdfAlQrvPbPKv fhpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=bd4Hsr49ZJKHJxsRFcOWYguXCX0y9MtXs3EZNlzxdm4=; b=zjT8a3BryQ+tqf6juMf3Yj8C5589HjyQ0YPbafcrCa6clUrVXltywDKduwSfYasYVA rWTbW6amL6HG/TIbgIP6POZ59bGzsAUAbDbegKFTmk8ntk6JbwES1A/wIZwQu52kHqkV zNuTLIkzod/RqhmOs119z0bXNMwFtJR4opiKGI0yQ1DfH8HLcnH/3EMPdWEOkv66Fwjp FZnhGd/aic3ZDbeC1fL8toEfDaWAS83ro/aNNTY/Wt5bkMzmcCTosFK+bDMR+pkvOOBQ 8as1zOqE09MW+XlyNrb4HIMlXuTJ41JPFK7Hg/g120/um2bj+8R1QKSklZt+Pv+vFuua e12Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=OXUXdThR; 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 v1si7306558ejf.162.2020.12.07.18.49.36; Mon, 07 Dec 2020 18:49:59 -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=OXUXdThR; 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 S1728135AbgLHCpf (ORCPT + 99 others); Mon, 7 Dec 2020 21:45:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727554AbgLHCpe (ORCPT ); Mon, 7 Dec 2020 21:45:34 -0500 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD57AC061749 for ; Mon, 7 Dec 2020 18:44:54 -0800 (PST) Received: by mail-pf1-x443.google.com with SMTP id t7so12430381pfh.7 for ; Mon, 07 Dec 2020 18:44:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bd4Hsr49ZJKHJxsRFcOWYguXCX0y9MtXs3EZNlzxdm4=; b=OXUXdThRs0qPdY6KEOM/aFVNwkZvW9d+93Pe+/JG6Te3MYtWs1tQ8wuA4565rISPTo IpMNiPjxjuwB4Z1DOxGmFYQI273fJ2EH4+DDBMSTVGeK+VSYmFHrt4pz5PodmjMHZbS3 oOOaWCeFh0oO+6FfRMD5IoRVV3WldU8+EEXkoj4pqNIEDdfBsAi0c1pT5GRdvfd6/zC/ zjZXFVFezJLBqBBA4qo2Y2R1A5YNenWVtVibEMpCLi7QwRVy4hmCYGFDAL+y1vOIaQj0 d0aI8xhqAnUttrYq9uvO2OWgwb1mbYo4zJt//eX1Psn46BEDnZ/VJNUmiOoqb/R1a5OU lPIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bd4Hsr49ZJKHJxsRFcOWYguXCX0y9MtXs3EZNlzxdm4=; b=mwJyynL4IIzD0HROzepmUh2vIoyo0L/F4kLAdqib+yeqVorBl4rI4/gQIux96FQvQl OiPxuXMnSssANexQdzeIMZJJ7+/AHSutsEodC37W++7d0MNfePzUy87+ZRPOLq07tsIN BnUg0kfKHB4rKD8ubGyazTPvI2btHGhInpeTyQj9EIgUCTz9i5kYgUhaskZqa5RENEr+ 3WCklQOtAkxg8VkC7zjYgXANfSYo6LKqihlDMgCpcwyJe/Yq2Spp8E9iQaF+r6sPeFww MvAWy58jZHtmffhR/hDR71ZbmPBRUtZKRRuFRIgVptlZ1v4sg8HFZmihOLl97+25sChh E6Bg== X-Gm-Message-State: AOAM531dp9pBJO+/1IwB6dJMEiPXdV5CeObcT0+B5dLUBFkHED94FbNE 3VbBuzY3DFGkZ7dVsMV5lnRMu/X7VySIe8yb875W7w== X-Received: by 2002:a63:cd14:: with SMTP id i20mr16192071pgg.31.1607395494294; Mon, 07 Dec 2020 18:44:54 -0800 (PST) MIME-Version: 1.0 References: <20201206101451.14706-1-songmuchun@bytedance.com> <20201206101451.14706-10-songmuchun@bytedance.com> <20201207194622.GA2238414@carbon.dhcp.thefacebook.com> In-Reply-To: <20201207194622.GA2238414@carbon.dhcp.thefacebook.com> From: Muchun Song Date: Tue, 8 Dec 2020 10:44:18 +0800 Message-ID: Subject: Re: [External] Re: [RESEND PATCH v2 09/12] mm: memcontrol: convert vmstat slab counters to bytes To: Roman Gushchin Cc: Greg KH , rafael@kernel.org, Alexey Dobriyan , Andrew Morton , Johannes Weiner , Michal Hocko , Vladimir Davydov , Hugh Dickins , Will Deacon , Mike Rapoport , Thomas Gleixner , esyr@redhat.com, peterx@redhat.com, krisman@collabora.com, Suren Baghdasaryan , avagin@openvz.org, Marco Elver , Randy Dunlap , Joonsoo Kim , LKML , linux-fsdevel , Linux Memory Management List , Cgroups Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 8, 2020 at 3:46 AM Roman Gushchin wrote: > > On Sun, Dec 06, 2020 at 06:14:48PM +0800, Muchun Song wrote: > > 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. > > There is a reason for this weird scheme: > percpu caches (see struct per_cpu_nodestat) are s8, so counting in bytes > will lead to overfills. Switching to s32 can lead to an increase in > the cache thrashing, especially on small machines. Thanks Roman. I see now. > > > > > 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 > > -- Yours, Muchun