From: Mel Gorman <mgorman@techsingularity.net>
To: Vasily Averin <vvs@virtuozzo.com>
Cc: Michal Hocko <mhocko@suse.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Vladimir Davydov <vdavydov.dev@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Cgroups <cgroups@vger.kernel.org>, Linux MM <linux-mm@kvack.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
kernel@openvz.org, Mel Gorman <mgorman@suse.de>,
Uladzislau Rezki <urezki@gmail.com>
Subject: Re: memcg memory accounting in vmalloc is broken
Date: Thu, 7 Oct 2021 11:20:44 +0100 [thread overview]
Message-ID: <20211007102044.GR3959@techsingularity.net> (raw)
In-Reply-To: <953ef8e2-1221-a12c-8f71-e34e477a52e8@virtuozzo.com>
On Thu, Oct 07, 2021 at 11:50:44AM +0300, 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.
Thanks Vasily.
This papers over the problem but it could certainly be optimized. At
minimum;
1. Test (memcg_kmem_enabled() && (gfp & __GFP_ACCOUNT)) in the
function preamble and store the result in a bool
2. Avoid the temptation to batch the accounting because if the
accounting fails, there is no information on how many pages could be
allocated before the limits were hit. I guess you could pre-charge the
pages and uncharging the number of pages that failed to be allocated
but it should be a separate patch.
3. If an allocation fails due to memcg accounting, break
out of the loop because all remaining bulk allocations are
also likely to fail.
As it's not vmalloc's fault, I would suggest the patch
have
Fixes: 387ba26fb1cb ("mm/page_alloc: add a bulk page allocator")
and
Cc: <stable@vger.kernel.org>
Note the Cc should just be in the patch and not mailed directly to
stable@ as it'll simply trigger a form letter about the patch having to
be merged to mainline first.
--
Mel Gorman
SUSE Labs
next prev parent reply other threads:[~2021-10-07 10:21 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-07 8:04 memcg memory accounting in vmalloc is broken Vasily Averin
2021-10-07 8:04 ` Vasily Averin
2021-10-07 8:13 ` Michal Hocko
2021-10-07 8:13 ` Michal Hocko
2021-10-07 8:16 ` Michal Hocko
2021-10-07 8:16 ` Michal Hocko
2021-10-07 8:50 ` Vasily Averin
2021-10-07 8:50 ` Vasily Averin
2021-10-07 10:08 ` Michal Hocko
2021-10-07 10:08 ` Michal Hocko
2021-10-07 10:20 ` Mel Gorman [this message]
2021-10-07 14:02 ` Vlastimil Babka
2021-10-07 14:02 ` Vlastimil Babka
2021-10-07 14:00 ` Vlastimil Babka
2021-10-07 14:00 ` Vlastimil Babka
2021-10-07 14:09 ` Michal Hocko
2021-10-07 14:09 ` Michal Hocko
2021-10-07 19:33 ` Vasily Averin
2021-10-07 19:33 ` Vasily Averin
2021-10-08 9:23 ` [PATCH memcg] memcg: enable memory accounting in __alloc_pages_bulk Vasily Averin
2021-10-08 9:23 ` Vasily Averin
2021-10-08 17:35 ` Shakeel Butt
2021-10-08 17:35 ` Shakeel Butt
2021-10-12 10:18 ` [PATCH mm v2] " Vasily Averin
2021-10-12 10:18 ` Vasily Averin
2021-10-12 13:10 ` Mel Gorman
2021-10-12 13:10 ` Mel Gorman
2021-10-12 13:40 ` Vasily Averin
2021-10-12 13:40 ` Vasily Averin
2021-10-12 14:58 ` [PATCH mm v3] " Vasily Averin
2021-10-12 14:58 ` Vasily Averin
2021-10-12 15:19 ` Shakeel Butt
2021-10-12 15:19 ` Shakeel Butt
2021-10-12 15:20 ` Mel Gorman
2021-10-12 15:20 ` Mel Gorman
2021-10-12 15:36 ` Michal Hocko
2021-10-12 15:36 ` Michal Hocko
2021-10-12 16:08 ` Shakeel Butt
2021-10-12 16:08 ` Shakeel Butt
2021-10-12 18:24 ` Michal Hocko
2021-10-12 18:24 ` Michal Hocko
2021-10-13 16:41 ` Shakeel Butt
2021-10-13 16:41 ` Shakeel Butt
2021-10-13 17:16 ` Michal Hocko
2021-10-13 17:16 ` Michal Hocko
2021-10-13 17:30 ` Shakeel Butt
2021-10-13 17:30 ` Shakeel Butt
2021-10-12 18:45 ` Vasily Averin
2021-10-12 18:45 ` Vasily Averin
2021-10-14 8:02 ` [PATCH mm v5] " Vasily Averin
2021-10-14 8:02 ` Vasily Averin
2021-10-15 21:34 ` Andrew Morton
2021-10-15 21:34 ` Andrew Morton
2021-10-16 6:04 ` Vasily Averin
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=20211007102044.GR3959@techsingularity.net \
--to=mgorman@techsingularity.net \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kernel@openvz.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=mhocko@suse.com \
--cc=urezki@gmail.com \
--cc=vdavydov.dev@gmail.com \
--cc=vvs@virtuozzo.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.