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 11498C433F5 for ; Mon, 27 Dec 2021 10:48:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 24D6E6B0071; Mon, 27 Dec 2021 05:48:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1FCCC6B0072; Mon, 27 Dec 2021 05:48:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 113016B0073; Mon, 27 Dec 2021 05:48:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0071.hostedemail.com [216.40.44.71]) by kanga.kvack.org (Postfix) with ESMTP id 072666B0071 for ; Mon, 27 Dec 2021 05:48:41 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 9A1D189128 for ; Mon, 27 Dec 2021 10:48:39 +0000 (UTC) X-FDA: 78963250758.30.8FC3115 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf08.hostedemail.com (Postfix) with ESMTP id E97DD16000C for ; Mon, 27 Dec 2021 10:48:29 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id D5D39210F0; Mon, 27 Dec 2021 10:48:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1640602117; 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=2Rvd63Dmd2SDNoBxHdD3p9t0LUSl3An6PqLQ93ELpwE=; b=DvOn88a8sFAxHav9YVpiBmGnO9MSGXNH2RgFIzrf9uYiq5kF/qqZLmaDWjhTQbro47iJDH vLz7INpg2b8LF02Px27OnfjzjLa3Mm3ZP+OdThg2VIjjsY3kdtdLraoqD4uRBX28uB8Ne1 BZcWBJcpcrDsLUWCf4yMpGADTKqCI6k= 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 46987A3B81; Mon, 27 Dec 2021 10:48:37 +0000 (UTC) Date: Mon, 27 Dec 2021 11:48:35 +0100 From: Michal Hocko To: Shakeel Butt Cc: Johannes Weiner , Roman Gushchin , Muchun Song , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org 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: <20211222052457.1960701-1-shakeelb@google.com> X-Rspamd-Queue-Id: E97DD16000C X-Stat-Signature: z37wtq93haoqh9ck4zkyfi11q58r8ghh Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=DvOn88a8; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf08.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com X-Rspamd-Server: rspam11 X-HE-Tag: 1640602109-341445 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 21-12-21 21:24:57, Shakeel Butt wrote: > The kvmalloc* allocation functions can fallback to vmalloc allocations > and more often on long running machines. In addition the kernel does > have __GFP_ACCOUNT kvmalloc* calls. So, often on long running machines, > the memory.stat does not tell the complete picture which type of memory > is charged to the memcg. So add a per-memcg vmalloc stat. > > Signed-off-by: Shakeel Butt The counter is useful IMHO. I just have one implementation specific question. [...] > @@ -2626,6 +2627,9 @@ static void __vunmap(const void *addr, int deallocate_pages) > unsigned int page_order = vm_area_page_order(area); > int i; > > + mod_memcg_page_state(area->pages[0], MEMCG_VMALLOC, > + -(int)area->nr_pages); > + > for (i = 0; i < area->nr_pages; i += 1U << page_order) { > struct page *page = area->pages[i]; > > @@ -2964,6 +2968,7 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, > page_order, nr_small_pages, area->pages); > > 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? A clarification comment would be really handy. -- Michal Hocko SUSE Labs