public inbox for cgroups@vger.kernel.org
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko-IBi9RG/b67k@public.gmane.org>
To: Vasily Averin <vvs-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org>
Cc: Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>,
	Vladimir Davydov
	<vdavydov.dev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Andrew Morton
	<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
	Cgroups <cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Linux MM <linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org>,
	"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	kernel-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org,
	Mel Gorman <mgorman-l3A5Bk7waGM@public.gmane.org>,
	Uladzislau Rezki <urezki-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: Re: memcg memory accounting in vmalloc is broken
Date: Thu, 7 Oct 2021 12:08:37 +0200	[thread overview]
Message-ID: <YV7HJd4r8tcLUpTB@dhcp22.suse.cz> (raw)
In-Reply-To: <953ef8e2-1221-a12c-8f71-e34e477a52e8-5HdwGun5lf+gSpxsJD1C4w@public.gmane.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

  parent reply	other threads:[~2021-10-07 10:08 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-07  8:04 memcg memory accounting in vmalloc is broken Vasily Averin
     [not found] ` <b3c232ff-d9dc-4304-629f-22cc95df1e2e-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org>
2021-10-07  8:13   ` Michal Hocko
     [not found]     ` <YV6sIz5UjfbhRyHN-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2021-10-07  8:16       ` Michal Hocko
     [not found]         ` <YV6s+ze8LzuxfvOM-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2021-10-07  8:50           ` Vasily Averin
     [not found]             ` <953ef8e2-1221-a12c-8f71-e34e477a52e8-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org>
2021-10-07 10:08               ` Michal Hocko [this message]
2021-10-07 14:00               ` Vlastimil Babka
     [not found]                 ` <0668b6d8-6f8c-07c7-75e0-5448ea87cb54-AlSwsSmVLrQ@public.gmane.org>
2021-10-07 14:09                   ` Michal Hocko
2021-10-07 19:33               ` Vasily Averin
     [not found]                 ` <6411d3f7-b3a4-23a8-14fc-fcf6b9c5b73a-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org>
2021-10-08  9:23                   ` [PATCH memcg] memcg: enable memory accounting in __alloc_pages_bulk Vasily Averin
     [not found]                     ` <bf3b1364-2c48-533f-9dae-22470074a037-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org>
2021-10-08 17:35                       ` Shakeel Butt
     [not found]                         ` <CALvZod7_fhgV39HXmmMApubW-39CjJ5t+WjmkyA_DNGF7b5O+w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-10-12 10:18                           ` [PATCH mm v2] " Vasily Averin
     [not found]                             ` <2410e99a-087c-3f89-9bdf-b62a7d5df725-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org>
2021-10-12 13:10                               ` Mel Gorman
     [not found]                                 ` <20211012131019.GV3959-3eNAlZScCAx27rWaFMvyedHuzzzSOjJt@public.gmane.org>
2021-10-12 13:40                                   ` Vasily Averin
     [not found]                                     ` <0baa2b26-a41b-acab-b75d-72ec241f5151-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org>
2021-10-12 14:58                                       ` [PATCH mm v3] " Vasily Averin
     [not found]                                         ` <60df0efd-f458-a13c-7c89-749bdab21d1d-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org>
2021-10-12 15:19                                           ` Shakeel Butt
2021-10-12 15:20                                           ` Mel Gorman
2021-10-12 15:36                                           ` Michal Hocko
     [not found]                                             ` <YWWrai/ChIgycgCo-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2021-10-12 16:08                                               ` Shakeel Butt
     [not found]                                                 ` <CALvZod7LpEY98r=pD-k=WbOT-z=Ux16Mfmv3s7PDtJg6=ZStgw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-10-12 18:24                                                   ` Michal Hocko
     [not found]                                                     ` <YWXS09ZBhZSy6FQQ-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2021-10-13 16:41                                                       ` Shakeel Butt
     [not found]                                                         ` <CALvZod6K6UXxDrkHp=mVDV7O-fAtmRkgMDngPazBhcyDUNxy_Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-10-13 17:16                                                           ` Michal Hocko
     [not found]                                                             ` <YWcUbXfBsbNzYIad-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2021-10-13 17:30                                                               ` Shakeel Butt
2021-10-12 18:45                                               ` Vasily Averin
2021-10-14  8:02                                       ` [PATCH mm v5] " Vasily Averin
     [not found]                                         ` <65c1afaf-7947-ce28-55b7-06bde7aeb278-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org>
2021-10-15 21:34                                           ` Andrew Morton
2021-10-16  6:04                                             ` Vasily Averin
2021-10-07 10:20             ` memcg memory accounting in vmalloc is broken Mel Gorman
     [not found]               ` <20211007102044.GR3959-3eNAlZScCAx27rWaFMvyedHuzzzSOjJt@public.gmane.org>
2021-10-07 14:02                 ` Vlastimil Babka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YV7HJd4r8tcLUpTB@dhcp22.suse.cz \
    --to=mhocko-ibi9rg/b67k@public.gmane.org \
    --cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org \
    --cc=kernel-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org \
    --cc=mgorman-l3A5Bk7waGM@public.gmane.org \
    --cc=urezki-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=vdavydov.dev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=vvs-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox