From: Johannes Weiner <hannes@cmpxchg.org>
To: Michal Hocko <mhocko@suse.com>
Cc: Nhat Pham <nphamcs@gmail.com>,
akpm@linux-foundation.org, riel@surriel.com,
roman.gushchin@linux.dev, shakeelb@google.com,
muchun.song@linux.dev, tj@kernel.org, lizefan.x@bytedance.com,
shuah@kernel.org, mike.kravetz@oracle.com, yosryahmed@google.com,
linux-mm@kvack.org, kernel-team@meta.com,
linux-kernel@vger.kernel.org, cgroups@vger.kernel.org
Subject: Re: [PATCH v2 1/2] hugetlb: memcg: account hugetlb-backed memory in memory controller
Date: Mon, 2 Oct 2023 11:25:55 -0400 [thread overview]
Message-ID: <20231002152555.GA5054@cmpxchg.org> (raw)
In-Reply-To: <ZRrc8hv4t740MZar@dhcp22.suse.cz>
On Mon, Oct 02, 2023 at 05:08:34PM +0200, Michal Hocko wrote:
> On Mon 02-10-23 10:50:26, Johannes Weiner wrote:
> > On Mon, Oct 02, 2023 at 03:43:19PM +0200, Michal Hocko wrote:
> > > On Wed 27-09-23 17:57:22, Nhat Pham wrote:
> [...]
> > > - memcg limit reclaim doesn't assist hugetlb pages allocation when
> > > hugetlb overcommit is configured (i.e. pages are not consumed from the
> > > pool) which means that the page allocation might disrupt workloads
> > > from other memcgs.
> > > - failure to charge a hugetlb page results in SIGBUS rather
> > > than memcg oom killer. That could be the case even if the
> > > hugetlb pool still has pages available and there is
> > > reclaimable memory in the memcg.
> >
> > Are these actually true? AFAICS, regardless of whether the page comes
> > from the pool or the buddy allocator, the memcg code will go through
> > the regular charge path, attempt reclaim, and OOM if that fails.
>
> OK, I should have been more explicit. Let me expand. Charges are
> accounted only _after_ the actual allocation is done. So the actual
> allocation is not constrained by the memcg context. It might reclaim
> from the memcg at that time but the disruption could have already
> happened. Not really any different from regular memory allocation
> attempt but much more visible with GB pages and one could reasonably
> expect that memcg should stop such a GB allocation if the local reclaim
> would be hopeless to free up enough from its own consumption.
>
> Makes more sense?
Yes, that makes sense.
This should be fairly easy to address by having hugetlb do the split
transaction that charge_memcg() does in one go, similar to what we do
for the hugetlb controller as well. IOW,
alloc_hugetlb_folio()
{
if (mem_cgroup_hugetlb_try_charge())
return ERR_PTR(-ENOMEM);
folio = dequeue();
if (!folio) {
folio = alloc_buddy();
if (!folio)
goto uncharge;
}
mem_cgroup_hugetlb_commit_charge();
}
next prev parent reply other threads:[~2023-10-02 15:26 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-28 0:57 [PATCH v2 0/2] hugetlb memcg accounting Nhat Pham
2023-09-28 0:57 ` [PATCH v2 1/2] hugetlb: memcg: account hugetlb-backed memory in memory controller Nhat Pham
2023-09-28 22:59 ` Frank van der Linden
2023-09-29 0:33 ` Nhat Pham
2023-09-29 0:38 ` Yosry Ahmed
2023-09-29 0:58 ` Nhat Pham
2023-09-29 1:07 ` Nhat Pham
2023-09-29 1:18 ` Yosry Ahmed
2023-09-29 1:25 ` Nhat Pham
2023-09-29 15:08 ` Johannes Weiner
2023-09-29 15:11 ` Yosry Ahmed
2023-09-29 17:42 ` Johannes Weiner
2023-09-29 17:48 ` Nhat Pham
2023-09-29 18:07 ` Frank van der Linden
2023-10-02 12:18 ` Michal Hocko
2023-09-29 18:17 ` [PATCH v2 1/2] hugetlb: memcg: account hugetlb-backed memory in memory controller (fix) Nhat Pham
2023-09-29 18:19 ` Nhat Pham
2023-10-02 13:43 ` [PATCH v2 1/2] hugetlb: memcg: account hugetlb-backed memory in memory controller Michal Hocko
2023-10-02 14:50 ` Johannes Weiner
2023-10-02 15:08 ` Michal Hocko
2023-10-02 15:25 ` Johannes Weiner [this message]
2023-10-02 17:32 ` Nhat Pham
2023-10-03 9:17 ` Michal Hocko
2023-10-02 16:21 ` Johannes Weiner
2023-10-02 17:28 ` Nhat Pham
2023-09-28 0:57 ` [PATCH v2 2/2] selftests: add a selftest to verify hugetlb usage in memcg Nhat Pham
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=20231002152555.GA5054@cmpxchg.org \
--to=hannes@cmpxchg.org \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lizefan.x@bytedance.com \
--cc=mhocko@suse.com \
--cc=mike.kravetz@oracle.com \
--cc=muchun.song@linux.dev \
--cc=nphamcs@gmail.com \
--cc=riel@surriel.com \
--cc=roman.gushchin@linux.dev \
--cc=shakeelb@google.com \
--cc=shuah@kernel.org \
--cc=tj@kernel.org \
--cc=yosryahmed@google.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.