Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1209929pxb; Thu, 7 Oct 2021 03:11:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyz503WDhc2A5nmk4i53C4PZZkpvkCTiTe4a9svxrtK+Z+qFPsixIsW2H4vRRr7RCJfixIZ X-Received: by 2002:a17:906:640f:: with SMTP id d15mr4514961ejm.419.1633601495762; Thu, 07 Oct 2021 03:11:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633601495; cv=none; d=google.com; s=arc-20160816; b=lijyXgjhK6c5yxkrgWKQ12HdvuOrxjO2aLYsKYMEtUy8euwlnSQXOHkXLdZUv1FKOJ pTqkvhmmBC/bsiyIsa0L2FmxNHXXzNHm9J7zYgr8TsvdTS6nRYT0gHKSo5OgmAVK1+yG CZe0GrUzsO3RLi+A0cpJBxKc04yNBUuSYixzzrUy8dyjo3/OY6Eakkf0c+ksgovbpumY htLaXCYXHPxMltERxfKvbqvoLHuoRlFuM0ZQSa5OuKMNBaF35GcQBSMgPPhpastlyvD4 3j5s/Z8QsRi92hCNZFM+hBITgFwgz5i+gpef1yxHEZW/kbrzkcKLN/ancmlnlRmez5LK nCDA== 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=3G2bH2N+XRfVhANdLLTSFVWFnNxjpsfsI2fUkInvKBw=; b=l2hFscrOyZ/Sw0tXlzbQZqN2rJqYtnHSW+PVxF4+6nErlzb4yPUd0cYysDfKjU5aXJ V+ZhAZG8kL46wzLfiEb+ATdjQ27nJAqpKb7JluRHkHti2mUkUiW8VHeCDJGINN1CTWEV AqPawlACNDyJ+Ri0MOi6Z1SsI2+L38fbvNFisz1626bTZdAr9WvP3KijAzA7k1grrUli lFw2UpSb/jyXoEjKjleDZNNZ7WvMPI9dISPu7+/ZfoLtQCPKoe/44A2ZxWSrDv0C8K+s Jc+F5dQwTWI/OdylNzWWN7t0WIiJkTTK2l5528VnZeyZOVkB7WR7RvhutXVOIG7hqUT8 SJNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=CrOdU3gG; 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 w19si6654721edc.402.2021.10.07.03.11.05; Thu, 07 Oct 2021 03:11:35 -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=CrOdU3gG; 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 S240631AbhJGKKd (ORCPT + 99 others); Thu, 7 Oct 2021 06:10:33 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:50112 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240743AbhJGKKc (ORCPT ); Thu, 7 Oct 2021 06:10:32 -0400 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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