Re: [PATCH v11 3/9] hugetlb_cgroup: add reservation accounting for private mappings

From: Mike Kravetz
Date: Wed Feb 05 2020 - 18:27:09 EST


On 2/3/20 3:22 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@xxxxxxxxxx>
> Reviewed-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx>
> Acked-by: David Rientjes <rientjes@xxxxxxxxxx>
>
> ---
>
> Changes in v11:
> - Refactored hugetlb_cgroup_uncharge_conuter a bit to eliminate
> unnecessary #ifdefs.
> - Added resv_map_set_hugetlb_cgroup_uncharge_info() to eliminate #ifdefs
> in the middle of hugetlb logic.

Thanks.
Code looks better without the #ifdefs.
You can keep my Reviewed-by:

--
Mike Kravetz