Re: [patch 1/1] alloc_pages(): permit get_zeroed_page(GFP_ATOMIC) from interrupt context

Christoph Lameter
2007-08-27T21:20:57Z

On Mon, 27 Aug 2007, Andrew Morton wrote:

> __GFP_HIGHMEM is not set.
>
> : /*
> : * clear_highpage() will use KM_USER0, so it's a bug to use __GFP_ZERO
> : * and __GFP_HIGHMEM from hard or soft interrupt context.
> : */
> : VM_BUG_ON((gfp_flags & __GFP_HIGHMEM) && in_interrupt());
>
> __GFP_HIGHMEM is not set
>
> : for (i = 0; i < (1 << order); i++)
> : clear_highpage(page + i);
>
> kmap_atomic() goes boom.

So the page is not a highmem page. kmap does:

void *kmap(struct page *page)
{
might_sleep();
if (!PageHighMem(page))
return page_address(page);
return kmap_high(page);
}

-> kmap is fine.

kmap_atomic() does:

void *kmap_atomic_prot(struct page *page, enum km_type type, pgprot_t prot)
{
enum fixed_addresses idx;
unsigned long vaddr;

/* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
pagefault_disable();

idx = type + KM_TYPE_NR*smp_processor_id();
BUG_ON(!pte_none(*(kmap_pte-idx)));

if (!PageHighMem(page))
return page_address(page);

vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
set_pte(kmap_pte-idx, mk_pte(page, prot));
arch_flush_lazy_mmu_mode();

return (void*) vaddr;
}

Move the check for highmem to the beginning of the function? Why
should kmap_atomic fail for a non highmem page?