Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp903520ybk; Fri, 15 May 2020 17:16:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhF4vQP4JW30FzDHVc64DhE4hpfkkotmkEpN7MVab+K5cofnlfWF8x9mvmwyDe7zXxOCxh X-Received: by 2002:a17:906:944e:: with SMTP id z14mr5613812ejx.86.1589588191315; Fri, 15 May 2020 17:16:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589588191; cv=none; d=google.com; s=arc-20160816; b=i89Z5uCMnHYezImD92RWYutqNeuShXDsLIOXnLsknNhQQEMFnNAcyPHEZ10fMgw2cH R5umVh+kIHw6zOl4pRejfpG+t5vPjobwpgW774kvcJptLL7yPzLKTbUOD6JEdnZPuU4L nRRrZjle5v0nYrKPSXkMIcojMncMPzJfC3AwcRdqdyDf6kNF7ZH2o+J7ojJMKIufN32F DIdgQ1k1Ooijprqep+k4PNpNu6rdUFwbS+Ud+8RaPvfES1FIMdXUQuxjsGaghss+l+SK IcBf9ag83qtbcZ6NS3qbfIU+4zqr1fokjbBuor6ESPqtkGBvsEdliZST/dxNwuL5H9Q7 Bccw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=QTdULXcDq8mWIqVt/vb5iveO+2D6SqGvUKrtXPTBlEY=; b=NeFAizsHVLS68/xjtYNwIWpeLwvDyWg5chRc39/mlgQnjkLgdOjILX99KNmlCcTe4s 4yCrPlYnMjodcUDZg1ZkrsbSFYQxU3TtLGh6KFOrfdUTUA+YjGoAEh9lsQKiGAo1CHbf 1aEARM1JYCzZXE5TvAL7OoSkMAu4KgduYFn6QYwRO9Ae8V7+0ifX4+8c2c5N+ZFrX/x3 5mHf5oTR1o4caVFtataD8qcbvG7k1yO9arLAvr3ObkcOn6W1p+vxFST9vBnqhZzkHyRc dGiawPKBq+mgPW84QygAVKhTRHwtRKgIAaCON3XMbiSvjiVZiea0obDGSg7FaTMSWWG1 k/LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=khnNG9Gz; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f26si2379946ejb.74.2020.05.15.17.16.08; Fri, 15 May 2020 17:16:31 -0700 (PDT) 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=@google.com header.s=20161025 header.b=khnNG9Gz; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727854AbgEPAN0 (ORCPT + 99 others); Fri, 15 May 2020 20:13:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726541AbgEPAN0 (ORCPT ); Fri, 15 May 2020 20:13:26 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 949D4C061A0C for ; Fri, 15 May 2020 17:13:25 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id j3so4044071ljg.8 for ; Fri, 15 May 2020 17:13:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=QTdULXcDq8mWIqVt/vb5iveO+2D6SqGvUKrtXPTBlEY=; b=khnNG9GzJUWCDxebtBF/4SavVHZ5K1XVmzcmgB8knXpmAzpoznXX+GI9LUIEsyDAcp GUkYxYruKzYaE5t9D9vzn9Z7zJ7WMbaTwiH7VLJ9NQc8HeZWG7+fDpWgURK/eWD/DH4O ejsL7skauXPqicLPunbijV2jvsyfstyagkjzmcTAr/665lf8yhJBCrE07ofIUASR7iA2 BOkXaXCY41lrexJKBFg1zxnhmDIfyPzIKpXlLzSFJ/VPZ51QjyNaGayYpEKSTbDZlDkb FFO1Lh0zAS2dlKKwpAwHMOdvzL+cLdkPzJCUogXkEGptCbxijQgqiaBsvY72KFyF0FX2 1ZJw== 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=QTdULXcDq8mWIqVt/vb5iveO+2D6SqGvUKrtXPTBlEY=; b=bc39K+KTitHAoYyOzs5vpKcNCJcTC825LMYU0n8IqquSPpOi15zsqf81C0S7Z3bptw zAVAPjFwyCXO34Ep2lgXeTF/eVmg18mVziqyVmwdNsk5U+xI/tOW4s23eoIhi4XlG+9b poTnbEGx449pmJl7wdX5Asu9QqckOtGAVUNpuD2f/qAajOiy7w6IYbPDQHqFLVIR6A+t mHNAWgknTuFipON2SUbkh8fbhz4dBlNcCl4ri3URiifh2vWMCjgkhBJNddXcJ2YwyVyw J8+EamVMB6iIra6KM+0JuDwCq0YJ5zCvq1wlhMBQcxJy21rT8+xBEUm4d5p2xouxgeO0 XjZA== X-Gm-Message-State: AOAM5335uWwxKGYlCb/g/u5sWTgQrzSo3cIQbQprgL99BxMtDTyP4LzF hu2otWfZdYeWPqZGp5NWq8M6WUCtJsE8zC0hyltuvA== X-Received: by 2002:a2e:9795:: with SMTP id y21mr3714912lji.115.1589588003829; Fri, 15 May 2020 17:13:23 -0700 (PDT) MIME-Version: 1.0 References: <20200508170630.94406-1-shakeelb@google.com> <20200508214405.GA226164@cmpxchg.org> <20200515082955.GJ29153@dhcp22.suse.cz> <20200515132421.GC591266@cmpxchg.org> <20200515150026.GA94522@carbon.DHCP.thefacebook.com> <20200515180906.GA630613@cmpxchg.org> In-Reply-To: <20200515180906.GA630613@cmpxchg.org> From: Shakeel Butt Date: Fri, 15 May 2020 17:13:12 -0700 Message-ID: Subject: Re: [PATCH] memcg: expose root cgroup's memory.stat To: Johannes Weiner Cc: Roman Gushchin , Michal Hocko , Mel Gorman , Andrew Morton , Yafang Shao , Linux MM , Cgroups , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 15, 2020 at 11:09 AM Johannes Weiner wrote: > > On Fri, May 15, 2020 at 10:49:22AM -0700, Shakeel Butt wrote: > > On Fri, May 15, 2020 at 8:00 AM Roman Gushchin wrote: > > > On Fri, May 15, 2020 at 06:44:44AM -0700, Shakeel Butt wrote: > > > > On Fri, May 15, 2020 at 6:24 AM Johannes Weiner wrote: > > > > > You're right. It should only bypass the page_counter, but still set > > > > > page->mem_cgroup = root_mem_cgroup, just like user pages. > > > > > > What about kernel threads? We consider them belonging to the root memory > > > cgroup. Should their memory consumption being considered in root-level stats? > > > > > > I'm not sure we really want it, but I guess we need to document how > > > kernel threads are handled. > > > > What will be the cons of updating root-level stats for kthreads? > > Should kernel threads be doing GFP_ACCOUNT allocations without > memalloc_use_memcg()? GFP_ACCOUNT implies that the memory consumption > can be significant and should be attributed to userspace activity. > > If the kernel thread has no userspace entity to blame, it seems to > imply the same thing as a !GFP_ACCOUNT allocation: shared public > infrastructure, not interesting to account to any specific cgroup. > > I'm not sure if we have such allocations right now. But IMO we should > not account anything from kthreads, or interrupts for that matter, > /unless/ there is a specific active_memcg that was set by the kthread > or the interrupt. I totally agree with you but I think your response is about memory charging in IRQ/kthread context, a topic of a parallel patch from Zefan Li at [1]. Here we are discussing stats update for kthreads e.g. should we update root memcg's MEMCG_KERNEL_STACK_KB stat when we allocate stack for kernel threads? [1] http://lkml.kernel.org/r/3a721f62-5a66-8bc5-247b-5c8b7c51c555@huawei.com