Re: [PATCH RFC 5/9] x86, mm: Use cache of page tables

From: Shakeel Butt
Date: Thu May 06 2021 - 14:24:36 EST


On Tue, May 4, 2021 at 5:36 PM Rick Edgecombe
<rick.p.edgecombe@xxxxxxxxx> wrote:
>
[...]
> +#ifdef CONFIG_PKS_PG_TABLES
> +struct page *alloc_table(gfp_t gfp)
> +{
> + struct page *table;
> +
> + if (!pks_page_en)
> + return alloc_page(gfp);
> +
> + table = get_grouped_page(numa_node_id(), &gpc_pks);
> + if (!table)
> + return NULL;
> +
> + if (gfp & __GFP_ZERO)
> + memset(page_address(table), 0, PAGE_SIZE);
> +
> + if (memcg_kmem_enabled() &&
> + gfp & __GFP_ACCOUNT &&
> + !__memcg_kmem_charge_page(table, gfp, 0)) {
> + free_table(table);
> + table = NULL;
> + }
> +
> + VM_BUG_ON_PAGE(*(unsigned long *)&table->ptl, table);

table can be NULL due to charge failure.