Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4102453ybl; Mon, 3 Feb 2020 12:37:28 -0800 (PST) X-Google-Smtp-Source: APXvYqySOOG6rYU0eDWh9MeICibx6M09oIlDQfpEQBgnN6oaO79qnBmWNAqH8FsJwS0NPVzBPRRe X-Received: by 2002:a9d:7e90:: with SMTP id m16mr12709296otp.227.1580762247874; Mon, 03 Feb 2020 12:37:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580762247; cv=none; d=google.com; s=arc-20160816; b=DBXqNDG/uRzrwa0k9qqbUIubkv/qOlCqYqqczJxnfQVyAIHHkWRQIROxV/oadM2Tr4 gFj1mMIydRumSH9hAV5FVvJGxGp+rhbCT2nisKP4rqM3jxry33U4/E6Vmfh3Ce6g/hdo s91VwY8wh+HLvKcjAw4af8uogIrmNYCoW8QVkzgSKiprb892nRtmfcuZICAwvpM617fC BrY5U4IcWpe8ngemKDskAZplkD1Zu0rvHZLGRhq8eDwwPP2Ik3oy+4QVKUGrWE9fIdnv kTLiFXrhCx/C4mrNFlL6LwppUlEcDs4csnm5zbWyo0hiJ6vnOwOKWdlFXOEX+k6fenle 472Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=vD4OaD6/Gu08Tv/eWLm2QG4l2LOcwWo02bsHVNhYVEQ=; b=l7IK0hKpZN69SIjXYBVfIqKh5r6Cs7teSgIB83EKO6w9HxFXzVUgWIu+UT+4n7BugO 7YDIcpnVWsnNKtmubxX7NLnxTT3BBZ041W+5wKURfvcg+5xNR3Rasy7TQ3yHbPXTOblI ds6FM/g2BNSifqwaytQbRiOqItKfLkPHNcNzvSL50D5COYq1OQczNR+npkWGO3d0iUuN C/hbhwvMrlYiUjw7FnH71JRSFmwZIWv1Et3bG8rTTMlDLOl/cgtRa35oT3XTrpM6uzaP +l0EpqNLN1i4vzUycugSTZq8w/co7nuPzSbj5pIwrDAkthRleq/frqVtZl3/x5NmQC5r 0m6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=W3DY1kzj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f187si9355727oia.218.2020.02.03.12.37.15; Mon, 03 Feb 2020 12:37:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=W3DY1kzj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727119AbgBCUex (ORCPT + 99 others); Mon, 3 Feb 2020 15:34:53 -0500 Received: from mail-qk1-f195.google.com ([209.85.222.195]:36316 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726187AbgBCUex (ORCPT ); Mon, 3 Feb 2020 15:34:53 -0500 Received: by mail-qk1-f195.google.com with SMTP id w25so15654991qki.3 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=B5uzzlxwnjLBikrRGxVwRW20/zstl6kZZd1DXn0zGwlPDWhFKJXfQnKqIaZrwAGpYn pDTVs0rVFZumEH7zyjZ7pdjKcLxeNiRTgdqde/5TZ+vOmegWjIw8lwQcKUvM687ZCACs 3UXtftKbB6JhqYMwAu/TV8iFsf0LufZTw5AmwDoj+ZhJzX2bwmumbNiFscZEMn9DufDI XYF+JLxMWunJ79ZlgOYuBijKkLZybm7t5cwCl1aI+pOmQZkWfDusOi7+WRvthLnPPbFS 6HtIJeQyILpREKmb9abnHW6geZGtLHUaHAAWqASNzGhrORYdsyTe1mKigoJuOlhtdHKx +mog== X-Gm-Message-State: APjAAAVltKuUYNh6zRtWhnQn9AArkPr0r2AAmeYVEPL3ty6gIt+d5YrX msz/GaBrdATX9S7IQT80Yg27vA== 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.