Messages in this thread | | | Date | Wed, 17 Nov 1999 11:56:47 -0500 (EST) | From | Chuck Lever <> | Subject | Re: [RFC]: madvise(2) and mincore(2) in 2.3.26 |
| |
On 17 Nov 1999, Andi Kleen wrote: > cel@monkey.org (Chuck Lever) writes: > > Hallo Chuck, > > > + */ > > +static long madvise_dontneed(struct vm_area_struct * vma, > > + unsigned long start, unsigned long end) > > +{ > > + struct inode * inode = vma->vm_file->f_dentry->d_inode; > > + struct page * page, **hash; > > + > > + start = ((start - vma->vm_start) >> PAGE_CACHE_SHIFT) + vma->vm_pgoff; > > + end = ((end - vma->vm_start) >> PAGE_CACHE_SHIFT) + vma->vm_pgoff; > > + > > + while (start < end) { > > + hash = page_hash(&inode->i_data, start); > > + > > + spin_lock(&pagecache_lock); > > + page = __find_page_nolock(&inode->i_data, start, > > + *hash); > > + if (page) > > + clear_bit(PG_referenced, &page->flags); > > + spin_unlock(&pagecache_lock); > > > What happens when some other thread/process has set the referenced bit? > shrink_mmap() could throw the data way. > I think you need at least check for shared pages here, and make it a nop > for this case.
agreed, and i'll also take a look at try_to_swap_out as mikulas suggested. i was thinking that this implementation would only boost the page's reclamation priority. shrink_mmap would simply put the page on it's reclamation LRU a little earlier than usual, and the actual work of reclaiming the page would happen later iff the system is low on memory -- but perhaps that's too simple?
> Also is mincore really useful? Either you have the memory locked and > then then you know that it is in core, or you haven't, then everything > is possible. I cannot imagine a useful application for it.
vivek pai suggested mincore might be useful for applications that manage their own user-space cache. it's easy enough to implement, and might make it easier to port applications that depend on it to Linux.
- Chuck Lever -- corporate: <chuckl@netscape.com> personal: <chucklever@netscape.net> or <cel@monkey.org>
The Linux Scalability project: http://www.citi.umich.edu/projects/linux-scalability/
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |