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 37005ECAAD8 for ; Tue, 30 Aug 2022 07:07:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BD2E76B0073; Tue, 30 Aug 2022 03:07:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B836E940008; Tue, 30 Aug 2022 03:07:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A4A27940007; Tue, 30 Aug 2022 03:07:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 95FB86B0073 for ; Tue, 30 Aug 2022 03:07:11 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6F20980F1F for ; Tue, 30 Aug 2022 07:07:11 +0000 (UTC) X-FDA: 79855377462.07.339583C Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by imf19.hostedemail.com (Postfix) with ESMTP id 108D91A001F for ; Tue, 30 Aug 2022 07:07:10 +0000 (UTC) Received: by mail-pf1-f178.google.com with SMTP id 72so10464059pfx.9 for ; Tue, 30 Aug 2022 00:07:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc; bh=I6h+p+HXVP3mSqfdvkmPovmRewn0b+siAgR4AO+P2BE=; b=Y3eReunSE2Y54gGd+4yIdZ0icTwQ5EJ/3dWQgm/g6JFNU/y72JrhdvOTk32zvNxcFd YqToO/fmRoRruDY85/WP3/6GEu6ZpU2qXYmfCRhJ6P0l/AXwXBzZMibHdBySun+aifOz aGGehvk94R59ZeGRUPSTvaIo/lDczky3Ea3QpAGWmTR4/MZ8OUVBlt8DkqecYft03QyL /HmLgCE5weDZbiSxff706yg9YZD5GnG4RKMF/aJ7Cs29cmE1xOPJqF9zPtOPNi4mS2e2 9cN7/wjPKiXLFdIclE3ZEFWNp8kYcQjof69Pir0esfprnaTn5AATb0v5m5OKafI8+XhS 8f9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc; bh=I6h+p+HXVP3mSqfdvkmPovmRewn0b+siAgR4AO+P2BE=; b=emwFO0LRmKeR+fcsGRIOXFYlgg8DWxV2WOw3UtBNa0OeaDOj1TVyWtTAmIrMWRz382 HwlFzU4TIVfiVDVbK2pX5T0cj/rGSBK/I7IzkEfIWAETQ7h690hymUCp51qSTSbZjnD/ uUyQVtNhKVy/qKQpGq0s+qY3/Cm8IU5vW3hHgaQ01ktviLQkoGvLYRjiakqSTF9w4WCA /2TCeLTs9DLSXQKAZAQpnVHBIJNyBBC05x/vBY13xrQm+zCIu0YoKVFFp2A/Ib+jYTGv DeTbYjhRfOUOrPSrcWlflUqvI0EZTQ55tPd9MLQmGTBzewiBcnobB1Ybbpf/y6STh937 9Zlg== X-Gm-Message-State: ACgBeo3zomSWkrWgEI/h1X/41RJHUqZfvRCa//cSYcgIg85x+fEqRm2B xtVKRd6i+rWchhdwymvq9rFSIm2vCJkkcu7oieU= X-Google-Smtp-Source: AA6agR58zClFWgeDJ0kAO0l5oaczNFAetdbjSu3zeENeI/vImtl4fx37vRtls8nsHMSAEjMRc8IZTGBuH26A/8CRR4k= X-Received: by 2002:a63:4a4b:0:b0:427:d453:78b6 with SMTP id j11-20020a634a4b000000b00427d45378b6mr17212423pgl.318.1661843230041; Tue, 30 Aug 2022 00:07:10 -0700 (PDT) MIME-Version: 1.0 References: <20220830055949.12640-1-ryncsn@gmail.com> <20220830055949.12640-2-ryncsn@gmail.com> In-Reply-To: From: Kairui Song Date: Tue, 30 Aug 2022 15:06:57 +0800 Message-ID: Subject: Re: [PATCH 1/2] mm: memcontrol: remove mem_cgroup_kmem_disabled To: Michal Hocko Cc: cgroups@vger.kernel.org, linux-mm@kvack.org, Johannes Weiner , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661843231; a=rsa-sha256; cv=none; b=cAa5SiqCWdAnUyHqK9vYfKFtb9fgZOZm5TnlwcM51WIarxGPhdIg7Jvrgc1frRHcY+tmCq hMM/35WYCj+RT0S4g9O4SRsKeRKXR08AKRPCxvOlOw6No0jhwfuubYl00DSg+iwKo/liQn QGhHr2VLzbZ3sixVPH6YFZMt/kJHT9c= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Y3eReunS; spf=pass (imf19.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661843231; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=I6h+p+HXVP3mSqfdvkmPovmRewn0b+siAgR4AO+P2BE=; b=Mplvvg7/uoTaP4PduSAb9boyGUC2dnStxibUhWvKwlrsB8YYGpkUHa207+JaI/F9GYvyGI uZJJ5acSTRFzr/3VeSjA9o1bhEggVdljsGP7kSHakYoL4UYmwx34Q6Vuha/yduy7amrdcG UbdJRODbF/nUfeP8UwYnzfDl1C7Umhc= Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Y3eReunS; spf=pass (imf19.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam05 X-Stat-Signature: tyhojxzfn3rxm3a51f5r43x1jz8eknxg X-Rspamd-Queue-Id: 108D91A001F X-Rspam-User: X-HE-Tag: 1661843230-247890 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: Michal Hocko =E4=BA=8E2022=E5=B9=B48=E6=9C=8830=E6=97=A5= =E5=91=A8=E4=BA=8C 14:45=E5=86=99=E9=81=93=EF=BC=9A > > On Tue 30-08-22 13:59:48, Kairui Song wrote: > > From: Kairui Song > > > > There are currently two helpers for checking if cgroup kmem > > accounting is enabled: > > > > - mem_cgroup_kmem_disabled > > - memcg_kmem_enabled > > Yes, this is a bit confusing indeed! > > > mem_cgroup_kmem_disabled is a simple helper that returns true if > > cgroup.memory=3Dnokmem is specified, otherwise returns false. > > > > memcg_kmem_enabled is a bit different, it returns true if > > cgroup.memory=3Dnokmem is not specified and there is at least one > > non-root cgroup ever created. And once there is any non-root memcg > > created, it won't go back to return false again. > > > > This may help improve performance for some corner use cases where > > the user enables memory cgroup and kmem accounting globally but never > > create any cgroup. > > > > Considering that corner case is rare, especially nowadays cgroup is > > widely used as a standard way to organize services. > > Is it really that rare? Most configurations would use a default setup, so > both MEMCG enabled and without nokmem on cmd line yet the memory > controller is not enabled in their setups. Actually I don't have too much confidence saying that as well... but AFAIK, almost all distros will create a few sub cgroup on boot by the init (eg. openrc, finit, systemd). Maybe it's not that rare indeed. > > > And the "once > > enabled never disable" behavior is kind of strange. This commit simplif= ies > > the behavior of memcg_kmem_enabled, making it simply the opposite of > > mem_cgroup_kmem_disabled, always true if cgroup.memory=3Dnokmem is > > not specified. So mem_cgroup_kmem_disabled can be dropped. > > > > This simplifies the code, and besides, memcg_kmem_enabled makes use > > of static key so it has a lower overhead. > > I agree that this is slightly confusing and undocumented. The first step > would be finding out why we need both outside of the memcg proper. > > E.g. it doesn't make much sense to me that count_objcg_event uses the > command line variant when it should be using the dynamic (and more > optimized no branch) variant. > > On the other hand pcpu_alloc_chunk seems to be different because it can > be called before the controller is enabled but maybe we do not need to > waste memory before that? Similarly new_kmalloc_cache. I suspect these > are mostly to simplify the code and reduce special casing. Yes, that's very insightful, let me tidy up the code and logic behind and send a V2 later.