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=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 106B4C3524D for ; Mon, 3 Feb 2020 20:34:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B5EA420CC7 for ; Mon, 3 Feb 2020 20:34:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20150623.gappssmtp.com header.i=@cmpxchg-org.20150623.gappssmtp.com header.b="W3DY1kzj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B5EA420CC7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5D0286B0005; Mon, 3 Feb 2020 15:34:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 582496B0006; Mon, 3 Feb 2020 15:34:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 497B36B0007; Mon, 3 Feb 2020 15:34:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0235.hostedemail.com [216.40.44.235]) by kanga.kvack.org (Postfix) with ESMTP id 336546B0005 for ; Mon, 3 Feb 2020 15:34:54 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id C6B19180AD804 for ; Mon, 3 Feb 2020 20:34:53 +0000 (UTC) X-FDA: 76449969666.22.fifth69_d8a49cdcae4b X-HE-Tag: fifth69_d8a49cdcae4b X-Filterd-Recvd-Size: 6206 Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Mon, 3 Feb 2020 20:34:52 +0000 (UTC) Received: by mail-qk1-f195.google.com with SMTP id k6so15636761qki.5 for ; Mon, 03 Feb 2020 12:34:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=vD4OaD6/Gu08Tv/eWLm2QG4l2LOcwWo02bsHVNhYVEQ=; b=W3DY1kzjGYRaQaDtq2ZYG1aZxLOR7ajyPdRtTamhizsDcB/cyjSjh5XRHFBA9iCHva fsxvDp7ShuBRZnOMZmW7pA3Y5guojMO9S+oOh11qPvpAoNYgygM9Coy+EtHWbt+dzAxz nymZW8joGe5Vj+WBlgcaHsMAM3enIIe825VxnEbtQcRXW5EVouOS4Qr4JOmbkQlV60RE Br79AFZv5RgJC6JbD/B1lTVtsi/z9nsg6M9x3CPYeB2mwcg3SXWlu6HTlkzAZFx1wQOY Qn8N0UCnOV3TeAMhET8najN9YueeVvnODYE1eWTz0KE1YdNHZIQPInFc2jjtl5XmQBl3 CHGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=vD4OaD6/Gu08Tv/eWLm2QG4l2LOcwWo02bsHVNhYVEQ=; b=i28CcI6Nkr80gGqqPEcgu0JNeGqmhx3U1Vz3XOwPwPXF6gjw3/15H/A0qvB9Nzd4hO gqHmx06XsmRFRFFLCPLMh5DO5YafGj8jIlPBwDfQD+aA/zVTFrm/9dZFVa4TM/mNFmiy Tm7GgIdPtr8kpNGBJ4jrUFtKOwpf1dq9tL0kSBAlaGQHGKQppyoL8OZdesoAiA5zi+fl tjryB0/yXkVc4xTiUarjPQQZ7rv+DUZi1i+Klvh5z6097qigE1mfoJyew6JicRj1na1k pKoGgpijc29zPrfOMH/tM4rq8Zz6l4qwg99VQormyNqywbVYrktnM9xB66cjjtkonYBu XfXw== X-Gm-Message-State: APjAAAUQAwbPynl8WNISB4coRhUCMsDauqJFZ0ThKAAfPmm3XeOvzEp0 pDWLbUW6ijSRkXIUdEiaGc122g== X-Google-Smtp-Source: APXvYqzyJpvTPAQNuO333DHFMTSybUxePPApluL4ereGDZzQa5rPBTdzb1jyqc/jIvL27oY7+5IubA== X-Received: by 2002:a05:620a:909:: with SMTP id v9mr12691741qkv.138.1580762092138; Mon, 03 Feb 2020 12:34:52 -0800 (PST) Received: from localhost ([2620:10d:c091:500::2:6320]) by smtp.gmail.com with ESMTPSA id v4sm9703099qkj.64.2020.02.03.12.34.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 12:34:51 -0800 (PST) Date: Mon, 3 Feb 2020 15:34:50 -0500 From: Johannes Weiner To: Roman Gushchin Cc: linux-mm@kvack.org, Andrew Morton , Michal Hocko , Shakeel Butt , Vladimir Davydov , linux-kernel@vger.kernel.org, kernel-team@fb.com, Bharata B Rao , Yafang Shao Subject: Re: [PATCH v2 12/28] mm: vmstat: use s32 for vm_node_stat_diff in struct per_cpu_nodestat Message-ID: <20200203203450.GA6380@cmpxchg.org> References: <20200127173453.2089565-1-guro@fb.com> <20200127173453.2089565-13-guro@fb.com> <20200203175818.GF1697@cmpxchg.org> <20200203182506.GA3700@xps.dhcp.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200203182506.GA3700@xps.dhcp.thefacebook.com> 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 Mon, Feb 03, 2020 at 10:25:06AM -0800, Roman Gushchin wrote: > On Mon, Feb 03, 2020 at 12:58:18PM -0500, Johannes Weiner wrote: > > On Mon, Jan 27, 2020 at 09:34:37AM -0800, Roman Gushchin wrote: > > > Currently s8 type is used for per-cpu caching of per-node statistics. > > > It works fine because the overfill threshold can't exceed 125. > > > > > > But if some counters are in bytes (and the next commit in the series > > > will convert slab counters to bytes), it's not gonna work: > > > value in bytes can easily exceed s8 without exceeding the threshold > > > converted to bytes. So to avoid overfilling per-cpu caches and breaking > > > vmstats correctness, let's use s32 instead. > > > > > > This doesn't affect per-zone statistics. There are no plans to use > > > zone-level byte-sized counters, so no reasons to change anything. > > > > Wait, is this still necessary? AFAIU, the node counters will account > > full slab pages, including free space, and only the memcg counters > > that track actual objects will be in bytes. > > > > Can you please elaborate? > > It's weird to have a counter with the same name (e.g. NR_SLAB_RECLAIMABLE_B) > being in different units depending on the accounting scope. > So I do convert all slab counters: global, per-lruvec, > and per-memcg to bytes. Since the node counters tracks allocated slab pages and the memcg counter tracks allocated objects, arguably they shouldn't use the same name anyway. > Alternatively I can fork them, e.g. introduce per-memcg or per-lruvec > NR_SLAB_RECLAIMABLE_OBJ > NR_SLAB_UNRECLAIMABLE_OBJ Can we alias them and reuse their slots? /* Reuse the node slab page counters item for charged objects */ MEMCG_SLAB_RECLAIMABLE = NR_SLAB_RECLAIMABLE, MEMCG_SLAB_UNRECLAIMABLE = NR_SLAB_UNRECLAIMABLE, > and keep global counters untouched. If going this way, I'd prefer to make > them per-memcg, because it will simplify things on charging paths: > now we do get task->mem_cgroup->obj_cgroup in the pre_alloc_hook(), > and then obj_cgroup->mem_cgroup in the post_alloc_hook() just to > bump per-lruvec counters. I don't quite follow. Don't you still have to update the global counters? > Btw, I wonder if we really need per-lruvec counters at all (at least > being enabled by default). For the significant amount of users who > have a single-node machine it doesn't bring anything except performance > overhead. Yeah, for single-node systems we should be able to redirect everything to the memcg counters, without allocating and tracking lruvec copies. > For those who have multiple nodes (and most likely many many > memory cgroups) it provides way too many data except for debugging > some weird mm issues. > I guess in the absolute majority of cases having global per-node + per-memcg > counters will be enough. Hm? Reclaim uses the lruvec counters.