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 CE47EC3DA49 for ; Fri, 26 Jul 2024 15:48:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 640706B008C; Fri, 26 Jul 2024 11:48:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F03B6B009E; Fri, 26 Jul 2024 11:48:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4DF0E6B00A4; Fri, 26 Jul 2024 11:48:40 -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 27A766B008C for ; Fri, 26 Jul 2024 11:48:40 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 9F4D6A3FC2 for ; Fri, 26 Jul 2024 15:48:39 +0000 (UTC) X-FDA: 82382336358.20.5B733C0 Received: from out-183.mta0.migadu.com (out-183.mta0.migadu.com [91.218.175.183]) by imf05.hostedemail.com (Postfix) with ESMTP id A3CA410001D for ; Fri, 26 Jul 2024 15:48:37 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=wifk2Ggx; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf05.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.183 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722008877; a=rsa-sha256; cv=none; b=UByO1lQjLsH5rSWiRicWpGsp3tRnNWVMqlcLvFTtDMlcO9VybzhFn27xK0S3WY/ZuMkLcT EQUNKlvwjFCpMmIRYcVURauYAFXpr6mhNqzJTMAugk86UVN1iLFwiUgj/0eaIILNBzSMtK IyBW0jafaRtmt/9rSC9mFjpWPsvMV9M= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=wifk2Ggx; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf05.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.183 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722008877; 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=xAiY6xy1vYp9Vc1+qLGpcdiwV7rz8YuP3/AppObKDGI=; b=gvFNIbPh/CKtSWp8eq1vclEEHgzAOMMNfcxucW5UReWXFgiuWn8vwhGQ5qB6whOgObuUqa KVZC8RBD2RFDkvxlg0gdbctEeIReIoHeHKWkRaNlKckcuH21Yx9esV+tDAufNvidDXnjD+ jY2QY2sXkQSnwYxZNcWtfR0DKfA+MYs= Date: Fri, 26 Jul 2024 08:48:27 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1722008915; h=from:from: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; bh=xAiY6xy1vYp9Vc1+qLGpcdiwV7rz8YuP3/AppObKDGI=; b=wifk2GgxWaDid6XNGUsTYPZa1z6WURX6tZpEpkZzaULvdWVlNffUIfuvnz0gb0NTdb9DAz +oTxgqp5oP2J/sfKsBMnIYBDV/ARnzywPd4o1z8DnskdBrz9PvpXHQQ+iUIoicY3wgZlbP U5zLMIKIIwktVO1i09fXxkdHIFywSjI= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Yosry Ahmed Cc: Andrew Morton , Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song , Greg Thelen , Facebook Kernel Team , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH] memcg: expose children memory usage for root Message-ID: References: <20240722225306.1494878-1-shakeel.butt@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: A3CA410001D X-Stat-Signature: kdqzghfde9qbudter6xp4fhwr1dxxsgd X-Rspam-User: X-HE-Tag: 1722008917-44134 X-HE-Meta: U2FsdGVkX1+jjTC3kMo/lmRWiQus0186DX81LToE3GxzNPjnxoZtvlAwt8O71OfAS/ZWOwTlH0+OGD96X0I9X+5fx8VEEqsksqAbar7epq+8betVsdJVj/fCMMpznxKaMENdB51bG7WbQBW6KnjtliY4gOG+PDOOysZpJxWLKgTX0OJGPlLQ1Q/nAlsZS/WA8q/WTBOX7p0zMFYS7d7ZJv416PvZD+lbZEbjguEGAc88fRty7e0fcY4O8qFvVhCJlg4n9BVL0Mwie9UeB3foEwLINpV9/csNJR4vz0M1hftRpPhavXGgQbanZpMyomIWfpk32Rc9MyJTDHjJLH8YPsDTZLuAf1FO/+M+U/NviruI+FcO1TdA6b2ZOb7imX+Mup35gEojY2MEjPvyvhstdDEQRkeQ3C7AdBbUeE2SasS87Zz2UgaprzAarobCFgZ//xgooDW1VYVdZ1s3fJjEFRNlSMDeiS8vc/eYMASl9nihcitQvhen1wNbFWCI3IrDacU7mK+F9Pds7C+txMMMU/jG4gNmUDqltVvY6H7gPJs1gPGWBgzv0xkclw2AaVQ3M/Ab0quYIM8ntQlHDfuU0/7xVRZIjOKXB1hcvhmIJUq5qvD2zXulKx20gEU7JB8iTTe2luxErnA/q0HuTNM5T8Ut/y4REWarhdAGRh1q1+82PzDwG+DsHNaH2F4s0cAfmjMkdINHV1ZXBo6I1fDOLeVicOr38IzREMmhBjdSdwEXFkQwTv89yo9YG9HGJ1M4/Ilc7T6DX2XSdZTFtzhf8TAjOpYwxAcc7XcE+GAhC0xkgO3mjZSHnWcQj6xgrJJhPrKyUk8TrsdGON2XC0OFyF11qXx/6WuyuUuNVCCfhPdn6+WCGTQHyuq2mDg46ghbNRsDlYoQe9aLWMdZFskTqPWskqz4CXuAyd6njT2sRXPoyZK9vzkDpduBzwky/XUyYzPQhEmGZBoKohpev9H 7QBjx5JY ui7SKkpxciOVN7gTz2/lM3RMAkSvYgmhLd/yZ1s61yCszRgQRT6vvFgjOx+0cb2YuVNFtjS9Hsq5h305eqemh11UqL5daISXRH9L5P/irKDVyhvNtcGEkP4VhSO+3CfTjSNhUvX+6gUkb2LU= 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: List-Subscribe: List-Unsubscribe: On Thu, Jul 25, 2024 at 04:20:45PM GMT, Yosry Ahmed wrote: > On Mon, Jul 22, 2024 at 3:53 PM Shakeel Butt wrote: > > > > Linux kernel does not expose memory.current on the root memcg and there > > are applications which have to traverse all the top level memcgs to > > calculate the total memory charged in the system. This is more expensive > > (directory traversal and multiple open and reads) and is racy on a busy > > machine. As the kernel already have the needed information i.e. root's > > memory.current, why not expose that? > > > > However root's memory.current will have a different semantics than the > > non-root's memory.current as the kernel skips the charging for root, so > > maybe it is better to have a different named interface for the root. > > Something like memory.children_usage only for root memcg. > > > > Now there is still a question that why the kernel does not expose > > memory.current for the root. The historical reason was that the memcg > > charging was expensice and to provide the users to bypass the memcg > > charging by letting them run in the root. However do we still want to > > have this exception today? What is stopping us to start charging the > > root memcg as well. Of course the root will not have limits but the > > allocations will go through memcg charging and then the memory.current > > of root and non-root will have the same semantics. > > > > This is an RFC to start a discussion on memcg charging for root. > > I vaguely remember when running some netperf tests (tcp_rr?) in a > cgroup that the performance decreases considerably with every level > down the hierarchy. I am assuming that charging was a part of the > reason. If that's the case, charging the root will be similar to > moving all workloads one level down the hierarchy in terms of charging > overhead. No, the workloads running in non-root memcgs will not see any difference. Only the workloads running in root will see charging overhead.