Re: Implementing fault handler

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




2009/5/18 Peter Teoh <htmldeveloper@xxxxxxxxx>
sorry...my bad....u are indeed using GFP_KERNEL for __get_free_pages().

let me make another guess....since u use VMA operation to implement
the mmapping, did u clear up the (unmap) the VMA before free-ing the
pages?
 
The userspace code does the following:

void *p = mmap(0, size / 2, PROT_READ | PROT_WRITE, MAP_SHARED, fd, addr + size / 2);
if (p != MAP_FAILED) {
p[0] = 0x11223344;
munmap(p, size / 2);
} else {
perror("mmap");
}

So shouldn't take take care of clearing the vma?

Anyway, I did some grepping with kernel sources, and found the following in drivers/video/vermillion/vermillion.c:

/*
 * It seems like __get_free_pages only ups the usage count
 * of the first page. This doesn't work with fault mapping, so
 * up the usage count once more (XXX: should use split_page or
 * compound page).
 */

memset((void *)va->logical, 0x00, va->size);
for (i = va->logical; i < va->logical + va->size; i += PAGE_SIZE) {
get_page(virt_to_page(i));
}
 
I changed my own code to do the get_page() calls after allocating the memory and it seems to work with that. (Also need to decrease usage count before freeing pages.)

this is because kernel will go through the entire chain list of VMA to
free it.....and necessarily...it always assum that VMA's memory comes
from HIGH mem - which is why u have no problem when vmalloc() is used.

(ie, u have violated one of the rule - never never used lowmem for
userspace operation....but it's another big story altogether.....).
u are lucky they did not check everywhere in kernel source
(performance reason)....

I'm not sure I understand. Basically I'm using LDD3 as reference, it has the scullp example where they implement mmap by nopage method. Isn't fault method more or less the same operation, only more generalized?

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux