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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C3CAC433F5 for ; Thu, 7 Oct 2021 10:08:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C77E561108 for ; Thu, 7 Oct 2021 10:08:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C77E561108 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 634D06B0073; Thu, 7 Oct 2021 06:08:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E4B76B0074; Thu, 7 Oct 2021 06:08:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4ABCB6B0075; Thu, 7 Oct 2021 06:08:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0030.hostedemail.com [216.40.44.30]) by kanga.kvack.org (Postfix) with ESMTP id 3D4566B0073 for ; Thu, 7 Oct 2021 06:08:39 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id F3F6B8249980 for ; Thu, 7 Oct 2021 10:08:38 +0000 (UTC) X-FDA: 78669217158.05.3D2AA98 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf26.hostedemail.com (Postfix) with ESMTP id 9D455200B3B7 for ; Thu, 7 Oct 2021 10:08:38 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id B164F2008A; Thu, 7 Oct 2021 10:08:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1633601317; 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=3G2bH2N+XRfVhANdLLTSFVWFnNxjpsfsI2fUkInvKBw=; b=CrOdU3gG8cpo5xfQ58KOOUZT6kC73I9ccroWpXYuSA6z+sweBO4lrYQxoIsSO2TyxFIEw1 cjAbmHhbHtkp7rL3do7yvOGj5K6kLMlPrV3+hVLoic9kE5SMz2xCgB1yWXCX3UU+75Z3s4 mAW/5FOlrRoe7eDO5ITZY9ScswmKMBc= 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 7FA75A3B87; Thu, 7 Oct 2021 10:08:37 +0000 (UTC) Date: Thu, 7 Oct 2021 12:08:37 +0200 From: Michal Hocko To: Vasily Averin Cc: Johannes Weiner , Vladimir Davydov , Andrew Morton , Cgroups , Linux MM , "linux-kernel@vger.kernel.org" , kernel@openvz.org, Mel Gorman , Uladzislau Rezki Subject: Re: memcg memory accounting in vmalloc is broken Message-ID: References: <953ef8e2-1221-a12c-8f71-e34e477a52e8@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <953ef8e2-1221-a12c-8f71-e34e477a52e8@virtuozzo.com> X-Rspamd-Queue-Id: 9D455200B3B7 X-Stat-Signature: gp9ehya8nicb7frkwwnekrs5bfmt7t9b Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=CrOdU3gG; spf=pass (imf26.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com X-Rspamd-Server: rspam06 X-HE-Tag: 1633601318-631817 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 07-10-21 11:50:44, Vasily Averin wrote: > On 10/7/21 11:16 AM, Michal Hocko wrote: > > Cc Mel and Uladzislau > > > > On Thu 07-10-21 10:13:23, Michal Hocko wrote: > >> On Thu 07-10-21 11:04:40, Vasily Averin wrote: > >>> vmalloc was switched to __alloc_pages_bulk but it does not account the memory to memcg. > >>> > >>> Is it known issue perhaps? > >> > >> No, I think this was just overlooked. Definitely doesn't look > >> intentional to me. > > I use following patch as a quick fix, > it helps though it is far from ideal and can be optimized. > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index b37435c274cf..e6abe2cac159 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -5290,6 +5290,12 @@ unsigned long __alloc_pages_bulk(gfp_t gfp, int preferred_nid, > > page = __rmqueue_pcplist(zone, 0, ac.migratetype, alloc_flags, > pcp, pcp_list); > + > + if (memcg_kmem_enabled() && (gfp & __GFP_ACCOUNT) && page && > + unlikely(__memcg_kmem_charge_page(page, gfp, 0) != 0)) { > + __free_pages(page, 0); > + page = NULL; > + } > if (unlikely(!page)) { > /* Try and get at least one page */ > if (!nr_populated) > -- > 2.31.1 Yes, this makes sense to me. -- Michal Hocko SUSE Labs