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 B8875C433FE for ; Mon, 3 Jan 2022 11:58:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 133086B0072; Mon, 3 Jan 2022 06:58:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0E31F6B0073; Mon, 3 Jan 2022 06:58:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F3B286B0074; Mon, 3 Jan 2022 06:58:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0159.hostedemail.com [216.40.44.159]) by kanga.kvack.org (Postfix) with ESMTP id E6C9C6B0072 for ; Mon, 3 Jan 2022 06:58:24 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 99BD0181843F3 for ; Mon, 3 Jan 2022 11:58:24 +0000 (UTC) X-FDA: 78988828128.06.EAB5486 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf05.hostedemail.com (Postfix) with ESMTP id 1A16710000E for ; Mon, 3 Jan 2022 11:58:23 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id A1DE91F38A; Mon, 3 Jan 2022 11:58:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641211102; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YZ7mq25SiE5S03nlCAmxhvLOytwyCBcGbYZinRze5bo=; b=tbn/jgA+JlfeERiquz3joiGXXpA6BzeN8LLT3j8QbnzVMvlPUUbG5mqpfUNXix06Mi19Sw 6VIQZEf6J2ZVz1NguyRuGVWTk5IWaLy0ayufISQnSu/xflu571srH4E+x2uQtO29OJ3Aag J7ugDpgVy/kCD22KLt+6sDe9GCaSXe0= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 179BAA3B83; Mon, 3 Jan 2022 11:58:22 +0000 (UTC) Date: Mon, 3 Jan 2022 12:58:21 +0100 From: Michal Hocko To: Shakeel Butt Cc: Johannes Weiner , Roman Gushchin , Muchun Song , Andrew Morton , Linux MM , LKML Subject: Re: [PATCH v2] memcg: add per-memcg vmalloc stat Message-ID: References: <20211222052457.1960701-1-shakeelb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 1A16710000E X-Stat-Signature: zeqomfkc5ktmmgzg5fdbz7dzbcjcp46a Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b="tbn/jgA+"; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf05.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com X-HE-Tag: 1641211103-698173 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 Thu 30-12-21 11:06:14, Shakeel Butt wrote: > Hi Michal, > > On Mon, Dec 27, 2021 at 2:48 AM Michal Hocko wrote: > > > [...] > > > atomic_long_add(area->nr_pages, &nr_vmalloc_pages); > > > + mod_memcg_page_state(area->pages[0], MEMCG_VMALLOC, area->nr_pages); > > > > > > /* > > > * If not enough pages were obtained to accomplish an > > > > Is it safe to assume that the whole area is always charged to the same > > memcg? I am not really deeply familiar with vmalloc internals but is it > > possible that an area could get resized/partially reused with a > > different charging context? > > From what I understand, vmalloc areas are not resized or partially > reused at the moment. There is some ongoing discussion on caching it > but caching would also require updating the accounting part as well. OK. > Regarding the whole area charged to the same memcg, the only way it > may get charged to different memcgs is if the process in which the > allocations are happening is migrated to a different memcg. We can > resolve this by traversing the pages in area->pages array (and use > lruvec based stats instead). I haven't even thought of a task migration. I expect that this is not a very likely scenario but it would lead to weird numbers and I guess we would like to prevent from that. A loop over all pages in the area and accounting them each separately should be good enough to cover that as well as the existing problem that has already been observed by syzbot. > I did contemplate on making this a lruvec stat but decided to start > simple and if we ever need per-node stat then we can easily move to > lruvec based stats. Let me know what you think. I am not really sure here. For now I would go with page by page stats gathering. Thanks! -- Michal Hocko SUSE Labs