Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3661335pxb; Wed, 13 Oct 2021 10:18:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvG4Goc4R9wZzb6qMJ2XecgcLCgexFfACWSHTEYWjPOWID4xabmj8bwEigw19D5Nxwoptu X-Received: by 2002:a50:d88b:: with SMTP id p11mr859592edj.287.1634145536922; Wed, 13 Oct 2021 10:18:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634145536; cv=none; d=google.com; s=arc-20160816; b=HGdM0cwnVgb4ur91J7uO4nlFRA58inrDUBQ2p+CiWHf5kcWkYcpDamzUFPPnA3G5Ku ueYumhu8A5+Bn5kg3xC/4N9FkQjOUqZHOfrHtB0xpaC1HqcMqoIbXn0IwNAtuoT9LYJ2 uNPVQA89G1tPBhs7I7SPPF1pgB8QLLnhREYht7o6m4ObDBF2YZ+5ulTX6A6kJ9gjb48D S2ung+WBOLtlBPbSzfPeIzj7kV3HKERxbZDZaA7Xc2QclqbwFDjCt9f9aGBMO17M8OXs NsdsHzSmpzxw6ViGr/1m8svpfgBVu6JotR/nbw+qzPHNtlN4q0VV2A3dqwc3sBN/Endz 32lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=b/zEsRXmAZrCKtzPcm6tYZaLnIWbf4/HEIHx/3hXRrA=; b=xXo/ttEs0FHnyVX49QJTpL0/nJ6wuo/KOmJttkorrrCFQi7oOtpyc36bxckVmD6uy/ 27DmlEgCL9+bieMc9xdWhjAp5Y28lZArEmWHBUrxoG2LaEsqC/WX8JI7Ztm0648ktPP3 0lAuhSabMjL/hgJeeyYGWwdvoapGUNfdAinbkmKlcSjSmxoKGICclhfzl51FuR0WMsRx PAXFmEfTdtzdbLaLl2yTEbH5S15AB8o+hoDVFGZP6eqlzIURRVihQzVWjs7S+Za8ARTm 7YGD92dw1HOKinaFeWEGelHe6fkqFf34cimE9KF7sFmjeAybd/VoGnILTwUGVD2iEm+U g9Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=CiciIxvn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e1si30702edl.569.2021.10.13.10.18.32; Wed, 13 Oct 2021 10:18:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=CiciIxvn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229915AbhJMRSi (ORCPT + 99 others); Wed, 13 Oct 2021 13:18:38 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:43876 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234083AbhJMRSg (ORCPT ); Wed, 13 Oct 2021 13:18:36 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 0D37A21A1E; Wed, 13 Oct 2021 17:16:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1634145391; 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=b/zEsRXmAZrCKtzPcm6tYZaLnIWbf4/HEIHx/3hXRrA=; b=CiciIxvn36QlEyV9EzgU3lo8Sh9+Q+9OSO4PP9EFH7QREFnrsp5lIFmdQgR+6SbdFsawxz JcouaancYdkpi34W539NgTOqpe6RDOJpphs60LND9NNE5O9AfM55yFHBis1V3N/KT2HyvE KnjD8z1Menw7asLknSWNkTZYeQ3hbGw= 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 26179A3B8F; Wed, 13 Oct 2021 17:16:30 +0000 (UTC) Date: Wed, 13 Oct 2021 19:16:29 +0200 From: Michal Hocko To: Shakeel Butt Cc: Vasily Averin , Johannes Weiner , Vladimir Davydov , Andrew Morton , Mel Gorman , Roman Gushchin , Uladzislau Rezki , Vlastimil Babka , Cgroups , Linux MM , LKML , kernel@openvz.org Subject: Re: [PATCH mm v3] memcg: enable memory accounting in __alloc_pages_bulk Message-ID: References: <0baa2b26-a41b-acab-b75d-72ec241f5151@virtuozzo.com> <60df0efd-f458-a13c-7c89-749bdab21d1d@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 13-10-21 09:41:15, Shakeel Butt wrote: > On Tue, Oct 12, 2021 at 11:24 AM Michal Hocko wrote: > > > > On Tue 12-10-21 09:08:38, Shakeel Butt wrote: > > > On Tue, Oct 12, 2021 at 8:36 AM Michal Hocko wrote: > > > > > > > > On Tue 12-10-21 17:58:21, Vasily Averin wrote: > > > > > Enable memory accounting for bulk page allocator. > > > > > > > > ENOCHANGELOG > > > > > > > > And I have to say I am not very happy about the solution. It adds a very > > > > tricky code where it splits different charging steps apart. > > > > > > > > Would it be just too inefficient to charge page-by-page once all pages > > > > are already taken away from the pcp lists? This bulk should be small so > > > > this shouldn't really cause massive problems. I mean something like > > > > > > > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > > > index b37435c274cf..8bcd69195ef5 100644 > > > > --- a/mm/page_alloc.c > > > > +++ b/mm/page_alloc.c > > > > @@ -5308,6 +5308,10 @@ unsigned long __alloc_pages_bulk(gfp_t gfp, int preferred_nid, > > > > > > > > local_unlock_irqrestore(&pagesets.lock, flags); > > > > > > > > + if (memcg_kmem_enabled() && (gfp & __GFP_ACCOUNT)) { > > > > + /* charge pages here */ > > > > + } > > > > > > It is not that simple because __alloc_pages_bulk only allocate pages > > > for empty slots in the page_array provided by the caller. > > > > > > The failure handling for post charging would be more complicated. > > > > If this is really that complicated (I haven't tried) then it would be > > much more simple to completely skip the bulk allocator for __GFP_ACCOUNT > > rather than add a tricky code. The bulk allocator is meant to be used > > for ultra hot paths and memcg charging along with the reclaim doesn't > > really fit into that model anyway. Or are there any actual users who > > really need bulk allocator optimization and also need memcg accounting? > > Bulk allocator is being used for vmalloc and we have several > kvmalloc() with __GFP_ACCOUNT allocations. Do we really need to use bulk allocator for these allocations? Bulk allocator is an bypass of the page allocator for performance reason and I can see why that can be useful but considering that the charging path can imply some heavy lifting is all the code churn to make bulk allocator memcg aware really worth it? Why cannot we simply skip over bulk allocator for __GFP_ACCOUNT. That would be a trivial fix. -- Michal Hocko SUSE Labs