Re: [PATCH v2 1/2] hugetlb: memcg: account hugetlb-backed memory in memory controller

Michal Hocko
2023-10-02T15:08:40Z

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?

With the later point I meant to say that the memcg OOM killer will not
communicate the hugetlb request failure so the usual SIGBUS will be
returned to the userspace. I can imagine a SIGBUS handler could check
hugetlb availability to retry or something similar.
--
Michal Hocko
SUSE Labs