From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4B09C4361B for ; Tue, 8 Dec 2020 02:44:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2CB7123976 for ; Tue, 8 Dec 2020 02:44:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2CB7123976 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A9B838D0008; Mon, 7 Dec 2020 21:44:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A72118D0001; Mon, 7 Dec 2020 21:44:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 987E78D0008; Mon, 7 Dec 2020 21:44:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0153.hostedemail.com [216.40.44.153]) by kanga.kvack.org (Postfix) with ESMTP id 8295C8D0001 for ; Mon, 7 Dec 2020 21:44:56 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 51C228249980 for ; Tue, 8 Dec 2020 02:44:56 +0000 (UTC) X-FDA: 77568572592.04.net47_5e002c7273e3 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 366428008B03 for ; Tue, 8 Dec 2020 02:44:56 +0000 (UTC) X-HE-Tag: net47_5e002c7273e3 X-Filterd-Recvd-Size: 7795 Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Tue, 8 Dec 2020 02:44:55 +0000 (UTC) Received: by mail-pg1-f196.google.com with SMTP id w16so10834006pga.9 for ; Mon, 07 Dec 2020 18:44:55 -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=D7jLKiDQHE1+0bZ9cLhy2eju3E/GAyr8zCXMN8i38GOi2UWeMMCuHGAzd1TMvWoQb0 Rzj/+AV2yo/V775JYTea8xEgOoRFGbJzJzB3xxOLHw+Z1cNEfhh8/Z1hR/JW4/tmNiEK AS1EnG2EiKdnGLmNY4lDEH6rZw0R/57I4Tx9xzfBykjnSsoP4VjZGfIMPGL2yXAhmkQc 73qn1znQ4MnHagKCjodrBOxNMub53CZhmoBsH5iubycpzAlO2ZwhdtrbL9Sp5H/gMjD2 yr5sUHSbwbZEL5Wgbi/lDthFmGBkhR8X5JCWgA5NOdza2ixxLLfWM9lYwjmqbsYl+GQv aFeA== X-Gm-Message-State: AOAM530EQdepp/cm5PoSeR5JnK5/lxuBS8eeb2+XkZnXKcAIJ8LzMhso YfPyH2EPIF4hpzHcdXFolcrwCTMyAmOlyoFFqxlh5Q== X-Google-Smtp-Source: ABdhPJwqa+f1tyVp/LuQ33qHv6ozHYyyImMS8P4cYyJzsunu1zEoxxRxqEUkdKpgtpj01JOEb8oDa1RkcwItsk3p3Fo= 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" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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