Re: [PATCH v10 3/8] hugetlb_cgroup: add reservation accounting for private mappings

Mike Kravetz
2020-01-17T22:58:14Z

On 1/14/20 5:26 PM, Mina Almasry wrote:
> Normally the pointer to the cgroup to uncharge hangs off the struct
> page, and gets queried when it's time to free the page. With
> hugetlb_cgroup reservations, this is not possible. Because it's possible
> for a page to be reserved by one task and actually faulted in by another
> task.
>
> The best place to put the hugetlb_cgroup pointer to uncharge for
> reservations is in the resv_map. But, because the resv_map has different
> semantics for private and shared mappings, the code patch to
> charge/uncharge shared and private mappings is different. This patch
> implements charging and uncharging for private mappings.
>
> For private mappings, the counter to uncharge is in
> resv_map->reservation_counter. On initializing the resv_map this is set
> to NULL. On reservation of a region in private mapping, the tasks
> hugetlb_cgroup is charged and the hugetlb_cgroup is placed is
> resv_map->reservation_counter.
>
> On hugetlb_vm_op_close, we uncharge resv_map->reservation_counter.
>
> Signed-off-by: Mina Almasry <almasrymina@google.com>

Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>

--
Mike Kravetz