On Tue, 2006-02-21 at 13:21 +1100, David Gibson wrote: > The patch below is a draft attempt to address this problem, by > strictly reserving a number of physical hugepages for hugepages inodes > which have been mapped, but not instatiated. MAP_SHARED mappings are > thus "safe" - they will fail on mmap(), not later with a SIGBUS. > MAP_PRIVATE mappings can still SIGBUS. ... > + read_lock_irq(&inode->i_mapping->tree_lock); > + for (pg = inode->i_blocks; pg < npages; pg++) { > + page = radix_tree_lookup(&mapping->page_tree, pg); > + if (! page) > + change_in_reserve++; > + } > + > + for (pg = npages; pg < inode->i_blocks; pg++) { > + page = radix_tree_lookup(&mapping->page_tree, pg); > + if (! page) > + change_in_reserve--; > + } > + spin_lock(&hugetlb_lock); I'm a bit confused by this. The for loops goes through and looks for pages that have indexes greater than the current i_blocks, but less than the number of pages requested by this reservation. With demand faulting, can there be holes in the file? Will this code account for them? I think this would also be a bit more clear if the two for loops were a bit more explicit in what they are doing. The first is growing the reservation when "npages > inode->i_blocks" and the second is shrinking the reservation when "npages < inode->i_blocks", right? Is this completely clear from the code? ;) Also, since the operation you are performing is actually counting pages in the radix tree at certain indexes, would it be sane to have a patch such as the (completely untested) attached one to do just that, but in the radix code? -- Dave