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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D9B4C433F5 for ; Tue, 1 Feb 2022 20:26:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D32656B0089; Tue, 1 Feb 2022 15:26:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CE1826B010B; Tue, 1 Feb 2022 15:26:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B81EF6B015D; Tue, 1 Feb 2022 15:26:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0248.hostedemail.com [216.40.44.248]) by kanga.kvack.org (Postfix) with ESMTP id A5F636B0089 for ; Tue, 1 Feb 2022 15:26:24 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 6545D87705 for ; Tue, 1 Feb 2022 20:26:24 +0000 (UTC) X-FDA: 79095343488.29.44F401A Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) by imf13.hostedemail.com (Postfix) with ESMTP id 1A5A120009 for ; Tue, 1 Feb 2022 20:26:23 +0000 (UTC) Received: by mail-lf1-f50.google.com with SMTP id x23so36400674lfc.0 for ; Tue, 01 Feb 2022 12:26:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ltsemEE7HoLIKHkXcNlB0CpyePLR2S+8XYoTKvHdxwY=; b=ILkxG8/cjLZ6qIh6DnpralN/7qPYJkgLY+jsRisfd/5RIxS+tiPGowEFvFcFCmoom2 rOFOao7QsK1hqJb/iBbG5OlCnuwCLIOXNte8Uzmfp4w1C5NiHSQj18qKISohu3dzkpgG zFyaeh67n/77ciUQerZgJrjWe4ZAC/VOSE8tHPji7NH4YcGU9yMg6fMbgjT2T7l8JIwH XNdimVFcCkjEYZcw2BWwPWhbBAeOUju8ARI30snW8sNsQOH0uHWWDwwtbTZ8TvlLOp+a Z9FoLYNJfFXuRGf4TR5GhbG7zriw5+Ioi3cmcZjVwQzAFsEpYEJI/8bCmnL0p4vVc6JV K7pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ltsemEE7HoLIKHkXcNlB0CpyePLR2S+8XYoTKvHdxwY=; b=6MNW6a5carPNdn1vHKfDd+mHwVGfb7mgcW/38S2Vp0uYnEhagVB2WK3Qe4n/w2M8R7 UC3oZ99rvArANW2qbwjyBw6GzO6qRvMXPacbemNGuQYFgurOWF9+QVIZCpL+Eo5G2sVi XpjcbgL829wzYLN/0f0G7IQ7OtLsVdFmX2TvUQrHfR2WYSuOPfuTcS2mJ5RDKqkP8RNL U/wymZCgYBgwCYQt0qa2bCNEW0kYBflO47qKGlGvn+TAzBXWi+HS8VIcxVP4+yu1c+8x 8xwUK0QEHnHcCWutDlmGBPnV9tY6bhDGC9oPAv88G8gznfml4cmAt6LMtlNtxEsq92U/ Xpjg== X-Gm-Message-State: AOAM533ZqtYFgpOnGjaFO+SrR+OHbtkw7D6z/xl8wnGynrxNFiJqtZT3 gGjVpoQeHpyKSN64G2ojDBQlMSGdw0g0x8XGGbMWJw== X-Google-Smtp-Source: ABdhPJw22635Ta+Khv9rQ+AvtU1mFH5u0oayx/EL5nr72sUDUyiFwIzrAqFLdDvtpHDR9Iedp4BlfRx3TN537PHx6bM= X-Received: by 2002:ac2:43ad:: with SMTP id t13mr20760851lfl.8.1643747181742; Tue, 01 Feb 2022 12:26:21 -0800 (PST) MIME-Version: 1.0 References: <20220201200823.3283171-1-yosryahmed@google.com> In-Reply-To: <20220201200823.3283171-1-yosryahmed@google.com> From: Shakeel Butt Date: Tue, 1 Feb 2022 12:26:10 -0800 Message-ID: Subject: Re: [PATCH] memcg: add per-memcg total kernel memory stat To: Yosry Ahmed Cc: Andrew Morton , Johannes Weiner , Michal Hocko , Muchun Song , LKML , Linux MM Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 1A5A120009 X-Stat-Signature: n45o6ad13r756j69aegc4sspe1cgpmm4 Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="ILkxG8/c"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf13.hostedemail.com: domain of shakeelb@google.com designates 209.85.167.50 as permitted sender) smtp.mailfrom=shakeelb@google.com X-Rspam-User: nil X-HE-Tag: 1643747183-98495 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, Feb 1, 2022 at 12:08 PM Yosry Ahmed wrote: > > Currently memcg stats show several types of kernel memory: > kernel stack, page tables, sock, vmalloc, and slab. > However, there are other allocations with __GFP_ACCOUNT > (or supersets such as GFP_KERNEL_ACCOUNT) that are not accounted > in any of those stats, a few examples are: > - various kvm allocations (e.g. allocated pages to create vcpus) > - io_uring > - tmp_page in pipes during pipe_write() > - bpf ringbuffers > - unix sockets > > Keeping track of the total kernel memory is essential for the ease of > migration from cgroup v1 to v2 as there are large discrepancies between > v1's kmem.usage_in_bytes and the sum of the available kernel memory stats > in v2. Adding separate memcg stats for all __GFP_ACCOUNT kernel > allocations is an impractical maintenance burden as there a lot of those > all over the kernel code, with more use cases likely to show up in the > future. > > Therefore, add a "kernel" memcg stat that is analogous to kmem > page counter, with added benefits such as using rstat infrastructure > which aggregates stats more efficiently. Additionally, this provides a > lighter alternative in case the legacy kmem is deprecated in the future > > Signed-off-by: Yosry Ahmed Thanks Yosry. Just to emphasize further, in our gradual migration to v2 (exposing v2 interfaces in v1 and removing v1-only interfaces), the difference between kernel memory from v1 and v2 is very prominent for some workloads. This patch will definitely ease the v2 migration. Acked-by: Shakeel Butt