Re: [patch V163 37/51] x86/events/intel/ds: Map debug buffers in fixmap
From: Peter Zijlstra
Date: Mon Dec 18 2017 - 08:19:25 EST
On Mon, Dec 18, 2017 at 12:42:52PM +0100, Thomas Gleixner wrote:
> +static u64 ds_update_fixmap(int idx, void *addr, size_t size, pgprot_t prot)
> {
> + phys_addr_t pa, va;
> + size_t msz = 0;
> +
> + va = __fix_to_virt(idx);
> + pa = virt_to_phys(addr);
> + for (; msz < size; idx--, msz += PAGE_SIZE, pa += PAGE_SIZE)
> + __set_fixmap(idx, pa, prot);
> + return va;
> +}
> +
> +static void *dsalloc_pages(size_t size, gfp_t flags, int cpu)
> +{
> + unsigned int order = get_order(size);
> int node = cpu_to_node(cpu);
> + struct page *page;
> +
> + page = __alloc_pages_node(node, flags | __GFP_ZERO, order);
> + return page ? page_address(page) : NULL;
> +}
> +
> +static void dsfree_pages(const void *buffer, size_t size)
> +{
> + if (buffer)
> + free_pages((unsigned long)buffer, get_order(size));
> +}
Note to self: since we're now using a virtual mapping for this stuff, we
can avoid the high order page allocs.