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 31CB0C27C50 for ; Fri, 31 May 2024 22:51:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C61576B00A0; Fri, 31 May 2024 18:51:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C10F86B00A2; Fri, 31 May 2024 18:51:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AB2136B00A3; Fri, 31 May 2024 18:51:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 89AB26B00A0 for ; Fri, 31 May 2024 18:51:39 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 1144C805F6 for ; Fri, 31 May 2024 22:51:39 +0000 (UTC) X-FDA: 82180189518.06.ED67D31 Received: from out-174.mta1.migadu.com (out-174.mta1.migadu.com [95.215.58.174]) by imf23.hostedemail.com (Postfix) with ESMTP id 8829814000E for ; Fri, 31 May 2024 22:51:36 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=MZy9Bep6; spf=pass (imf23.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.174 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717195896; a=rsa-sha256; cv=none; b=QuIVmNOuUG1XkGqA2Uh5vKb6laCyDhF4/xc0jyHa2gwRIq9tAkihosSyUF9vn4CUx59FkQ ZL6+cHAg9uHOm6NRLj7IZxXDpAQx01HMyT6Gdqa3+bCSOt1RHcLjPDfdEdk+jUWKH7KP3g VCW9FXXSjtvoAaQLBqWpX11Ffa+vAJg= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=MZy9Bep6; spf=pass (imf23.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.174 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717195896; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=yvNYXDzk//IU7YejWZtIAkTEAkRe2EZsR+gbKgk03H0=; b=lB77kqbjepAtn1oeZRI1oiftnSCe2ffP1H+NeEVnJP8oMLUR32uFcfdf3t922G1FP5t4yX iepg4WXHz0UnzbuLyDO6R2Eu9wvtL4hKs4NJnQVlb/SHtjGzR/w81e+kAnfDDmghmCmf3z C9HutRe+MKWlB9nvbZNj9pyLWQ1/X18= X-Envelope-To: willy@infradead.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1717195894; 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: in-reply-to:in-reply-to:references:references; bh=yvNYXDzk//IU7YejWZtIAkTEAkRe2EZsR+gbKgk03H0=; b=MZy9Bep6QM2jJVR5AyZVt7Dox3dmsj0RxbqGiKQjDbX7GD5amZx9zoykD/CdatCNuaZx+K Ecwezjdcst347tKHqiiWbq1qSTBHRRpN2tgbPAusMs1NHctLc5/9AB3BTvxqm/U79ltEF/ Y+pkNIcepkaU5VvTyH43TWT9O19vMl0= X-Envelope-To: wangkefeng.wang@huawei.com X-Envelope-To: akpm@linux-foundation.org X-Envelope-To: hannes@cmpxchg.org X-Envelope-To: mhocko@kernel.org X-Envelope-To: roman.gushchin@linux.dev X-Envelope-To: muchun.song@linux.dev X-Envelope-To: linux-mm@kvack.org X-Envelope-To: cgroups@vger.kernel.org X-Envelope-To: urezki@gmail.com X-Envelope-To: hch@infradead.org X-Envelope-To: lstoakes@gmail.com Date: Fri, 31 May 2024 15:51:28 -0700 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Matthew Wilcox Cc: Kefeng Wang , Andrew Morton , Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song , linux-mm@kvack.org, cgroups@vger.kernel.org, Uladzislau Rezki , Christoph Hellwig , Lorenzo Stoakes Subject: Re: [PATCH] mm: memcontrol: remove page_memcg() Message-ID: References: <20240521131556.142176-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 8829814000E X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: x5f4kghod8nbain4wnanmdr55sx3iab9 X-HE-Tag: 1717195896-521840 X-HE-Meta: U2FsdGVkX1+jGyd45QdeAyLYoMw7I6lGXBEgrIPSrJyrFW4YDsqVzJ8YUbctv2i4uFvV57zbnqbiaflmF0YtE2t3NGWZPm8+yVtiRRYCJ3v+Zbvy91caujk+uT3CI/CP9xE3+lXqwvodGEmSfRwJJnIlhNREWqODgAVyekwNFjpwJCQWGwzdTgEe4AtW/krd+TqEGNPV1k6h49Mtj3uG3bsFzfH/2qANAJ8oE7zYOqmuNa7Mj5VkRoEiLGVrKyFPXSq8fufLKR1xanuI3lMrPYeq+B/Oc20XprVUcCCvV4N1DnYlCNDEYR69ocUObwdObwmypGYK/ctav8kjn7tjvFra4A5q0TyY1F8ppRlq/B3ruaJ1UK4VQJi/BqLIenAHnduXPwDXQMCaxCAfsQgzvTou1ace3H+7NRGRgW5ZIaXYwK3oR96nz1xELLIDCtTCrMVN2ODmrJxoWTcr3uYUw/BetRAf/5mqXphI5iyqHz1I6l7HcmjKX7Fskp7JH6uZD2mnASYkAW0u1/HM+5Wt5UH52/hBGjWsa5IlYXT/+X+e7UIPlbaeW0cgG0HxDQsPO8FCZj4xoFm7MXJ6zcj4f3FyK8UNR4dANy85msldhQFHvUUduyg1qu0QNk4DRKYwTV2zkdfllQDeMza9ZCV3VOMmO6loGELTrkRUGkHPk1JohrFZ9IgXadJWVoUZvn0z0OJfqbVR41rjdRDh0XQbaXtRie61WqTBjAYqApqXdhhvfQsznslVFshoZcJjQtP/yy7e761Vn228pjQ9IL/co00/5E8IQRiMAZeIlWzPK+QOsk44gZEwZ6utKn/WWB4lAw+fW9NROigWy3Sv/PtmaMNtskzhRh1eIJuK7WCCx6VOP0zeGWx+lOlchTcix7MvmOA8apmKqot4zcx8G3J7m/K8qt2/Y1o/urWSD549zu/SJDX3EXEBRoMiZ7jSDw5+4yYyGpS9Z87zeXSDGCu I0hjEYh3 b8y3hSJrYIK+N/t3iAqnCtDvrZP4A6+vdE4h1XzyFpn0a8dJa0X9tgigbCSWdgaEEDk5MLdlm/1dhUWnvPuy3FmqzQfTuI4vGrG57IawCv0aH5W639o5S2Qv//+CRM3wPkrqUi7pINU3AJ/o= 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, May 23, 2024 at 05:34:27PM GMT, Matthew Wilcox wrote: > On Thu, May 23, 2024 at 08:41:25AM -0700, Shakeel Butt wrote: > > On Thu, May 23, 2024 at 02:31:05PM +0100, Matthew Wilcox wrote: > > > On Tue, May 21, 2024 at 12:29:39PM -0700, Shakeel Butt wrote: > > > > On Tue, May 21, 2024 at 03:44:21PM +0100, Matthew Wilcox wrote: > > > > > The memcg should not be attached to the individual pages that make up a > > > > > vmalloc allocation. Rather, it should be managed by the vmalloc > > > > > allocation itself. I don't have the knowledge to poke around inside > > > > > vmalloc right now, but maybe somebody else could take that on. > > > > > > > > Are you concerned about accessing just memcg or any field of the > > > > sub-page? There are drivers accessing fields of pages allocated through > > > > vmalloc. Some details at 3b8000ae185c ("mm/vmalloc: huge vmalloc backing > > > > pages should be split rather than compound"). > > > > > > Thanks for the pointer, and fb_deferred_io_fault() is already on my > > > hitlist for abusing struct page. > > > > > > My primary concern is that we should track the entire allocation as a > > > single object rather than tracking each page individually. That means > > > assigning the vmalloc allocation to a memcg rather than assigning each > > > page to a memcg. It's a lot less overhead to increment the counter once > > > per allocation rather than once per page in the allocation! > > > > > > But secondarily, yes, pages allocated by vmalloc probably don't need > > > any per-page state, other than tracking the vmalloc allocation they're > > > assigned to. We'll see how that theory turns out. > > > > I think the tricky part would be vmalloc having pages spanning multiple > > nodes which is not an issue for MEMCG_VMALLOC stat but the vmap based > > kernel stack (CONFIG_VMAP_STACK) metric NR_KERNEL_STACK_KB cares about > > that information. > > Yes, we'll have to handle mod_lruvec_page_state() differently since that > stat is tracked per node. Or we could stop tracking that stat per node. > Is it useful to track it per node? Why is it useful to track kernel > stacks per node, but not track vmalloc allocations per node? This is a good question and other than that there are user visible APIs (per numa meminfo & memory.numa_stat), I don't have a good answer.