[lc-checkins] CVS: linux/mm filemap.c,1.27,1.28 memory.c,1.29,1.30 page_alloc.c,1.18,1.19 swap_state
Status: Beta
Brought to you by:
nitin_sf
|
From: Rodrigo S. de C. <rc...@us...> - 2002-06-11 13:21:02
|
Update of /cvsroot/linuxcompressed/linux/mm
In directory usw-pr-cvs1:/tmp/cvs-serv3905/mm
Modified Files:
filemap.c memory.c page_alloc.c swap_state.c swapfile.c
vmscan.c
Log Message:
- Now compress_*_page() and shrink_cache() take into account the
return value of compress_page() and don't loop in shrink_cache() if
not needed.
- Support for storing page with buffers in compressed cache. These
pages are not compressed, only referenced by a compressed cache entry
in order to make the space reserved for compressed cache useful for
these kind of pages. The main consequence is that we avoid syncing
those buffers to disk in case of memory pressure on the uncompressed
cache.
- For this buffer support, there's a new page flag used by our
code. It's called PG_mapped_comp_cache, which means that a certain
page is part of page cache, but is also mapped by compressed
cache. The old PG_comp_cache flag means that the page has a fragment
in compressed cache. The difference is subtle.
- The buffer support is based on two main functions. The first one,
comp_cache_try_to_release(), is a wrapper for try_to_release()
function. In some cases, we won't call the try_to_release() and will
store the page in compressed cache, returning the page reserved for
compressed cache (if any) to the caller (shrink_cache()) to be freed.
- The second fundamental function is steal_page_from_comp_cache(),
which will remove a PageMappedCompCache from compressed cache,
ocasionally replacing this page (which was used by compressed cache)
with a new one. That sort of thing is needed when mapping this page
back to a pte or for any reference that is made to this particular
page. Actually, all reference to a PageMappedCompCache page will
remove it from compressed cache (will "steal" it).
- Another way out for this kind of page will be writeout_fragments(),
which will sync the page buffers, removing from page cache (or swap
cache), and keep using this page just freed for the compressed cache.
- New info in /proc/comp_cache_hist. Now /proc/comp_cache_hist shows
data about how many compressed cache entries whose pages have buffers
and also compressed cache entries without a reserved page (which will
happen often with buffer support, since the buffer support may "steal"
the page from compressed cache).
Index: filemap.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/filemap.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -r1.27 -r1.28
*** filemap.c 31 May 2002 16:48:53 -0000 1.27
--- filemap.c 11 Jun 2002 13:20:49 -0000 1.28
***************
*** 163,168 ****
mark_inode_dirty_pages(mapping->host);
#ifdef CONFIG_COMP_CACHE
! if (PageTestandClearCompCache(page))
! invalidate_comp_cache(mapping, page->index);
#endif
}
--- 163,172 ----
mark_inode_dirty_pages(mapping->host);
#ifdef CONFIG_COMP_CACHE
! if (PageTestandClearCompCache(page)) {
! if (PageMappedCompCache(page))
! steal_page_from_comp_cache(page, NULL);
! else
! invalidate_comp_cache(mapping, page->index);
! }
#endif
}
***************
*** 248,251 ****
--- 252,263 ----
/*
+ * Let's steal the page from comp cache to be safely removed
+ * from page cache below. Actually, this page will also be
+ * used by compressed cache, that's why it's passed as second
+ * parameter to the function
+ */
+ steal_page_from_comp_cache(page, page);
+
+ /*
* We remove the page from the page cache _after_ we have
* destroyed all buffer-cache references to it. Otherwise some
***************
*** 985,988 ****
--- 997,1001 ----
if (page) {
page_cache_get(page);
+ steal_page_from_comp_cache(page, NULL);
if (TryLockPage(page)) {
spin_unlock(&pagecache_lock);
***************
*** 1074,1079 ****
lru_cache_add(page);
#ifdef CONFIG_COMP_PAGE_CACHE
! if (!read_comp_cache(mapping, index, page))
! LockPage(page);
#endif
}
--- 1087,1094 ----
lru_cache_add(page);
#ifdef CONFIG_COMP_PAGE_CACHE
! if (!read_comp_cache(mapping, index, page)) {
! if (TryLockPage(page))
! BUG();
! }
#endif
}
***************
*** 1491,1494 ****
--- 1506,1511 ----
found_page:
page_cache_get(page);
+ steal_page_from_comp_cache(page, NULL);
+
spin_unlock(&pagecache_lock);
***************
*** 2040,2043 ****
--- 2057,2061 ----
if (!page)
goto no_cached_page;
+ steal_page_from_comp_cache(page, NULL);
/*
***************
*** 2926,2929 ****
--- 2944,2948 ----
if (cached_page)
page_cache_release(cached_page);
+ steal_page_from_comp_cache(page, NULL);
#ifdef CONFIG_COMP_PAGE_CACHE
if (page)
Index: memory.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/memory.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -r1.29 -r1.30
*** memory.c 21 May 2002 18:49:06 -0000 1.29
--- memory.c 11 Jun 2002 13:20:49 -0000 1.30
***************
*** 1110,1114 ****
/* Ok, do the async read-ahead now */
new_page = read_swap_cache_async(SWP_ENTRY(SWP_TYPE(entry), offset));
-
if (!new_page)
break;
--- 1110,1113 ----
***************
*** 1133,1137 ****
spin_unlock(&mm->page_table_lock);
page = lookup_swap_cache(entry);
-
if (!page) {
comp_cache_fragment_t * fragment;
--- 1132,1135 ----
***************
*** 1157,1161 ****
mark_page_accessed(page);
!
lock_page(page);
--- 1155,1159 ----
mark_page_accessed(page);
!
lock_page(page);
Index: page_alloc.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/page_alloc.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -r1.18 -r1.19
*** page_alloc.c 28 May 2002 19:16:14 -0000 1.18
--- page_alloc.c 11 Jun 2002 13:20:49 -0000 1.19
***************
*** 86,89 ****
--- 86,91 ----
if (PageSwapCache(page))
BUG();
+ if (PageMappedCompCache(page))
+ BUG();
if (PageLocked(page))
BUG();
***************
*** 93,97 ****
BUG();
page->flags &= ~((1<<PG_referenced) | (1<<PG_dirty) | (1<<PG_comp_cache));
!
if (current->flags & PF_FREE_PAGES)
goto local_freelist;
--- 95,99 ----
BUG();
page->flags &= ~((1<<PG_referenced) | (1<<PG_dirty) | (1<<PG_comp_cache));
!
if (current->flags & PF_FREE_PAGES)
goto local_freelist;
Index: swap_state.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/swap_state.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -r1.27 -r1.28
*** swap_state.c 28 Apr 2002 20:51:34 -0000 1.27
--- swap_state.c 11 Jun 2002 13:20:49 -0000 1.28
***************
*** 134,138 ****
__delete_from_swap_cache(page);
spin_unlock(&pagecache_lock);
!
swap_free(entry);
page_cache_release(page);
--- 134,138 ----
__delete_from_swap_cache(page);
spin_unlock(&pagecache_lock);
!
swap_free(entry);
page_cache_release(page);
***************
*** 179,184 ****
*/
INC_CACHE_INFO(find_total);
! if (found)
INC_CACHE_INFO(find_success);
return found;
}
--- 179,186 ----
*/
INC_CACHE_INFO(find_total);
! if (found) {
INC_CACHE_INFO(find_success);
+ steal_page_from_comp_cache(found, NULL);
+ }
return found;
}
***************
*** 203,208 ****
*/
found_page = find_get_page(&swapper_space, entry.val);
! if (found_page)
break;
/*
--- 205,212 ----
*/
found_page = find_get_page(&swapper_space, entry.val);
! if (found_page) {
! steal_page_from_comp_cache(found_page, new_page);
break;
+ }
/*
Index: swapfile.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/swapfile.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -r1.29 -r1.30
*** swapfile.c 12 Mar 2002 17:54:19 -0000 1.29
--- swapfile.c 11 Jun 2002 13:20:49 -0000 1.30
***************
*** 361,365 ****
page_cache_release(page);
}
!
return retval;
}
--- 361,365 ----
page_cache_release(page);
}
!
return retval;
}
***************
*** 384,387 ****
--- 384,388 ----
/* Only cache user (+us), or swap space full? Free it! */
if (page_count(page) - !!page->buffers == 2 || vm_swap_full()) {
+ steal_page_from_comp_cache(page, NULL);
delete_from_swap_cache(page);
SetPageDirty(page);
Index: vmscan.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/vmscan.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -r1.33 -r1.34
*** vmscan.c 8 May 2002 20:24:36 -0000 1.33
--- vmscan.c 11 Jun 2002 13:20:49 -0000 1.34
***************
*** 411,418 ****
writepage = page->mapping->a_ops->writepage;
#ifdef CONFIG_COMP_CACHE
! if (writepage) {
#else
! if ((gfp_mask & __GFP_FS) && writepage) {
#endif
ClearPageDirty(page);
SetPageLaunder(page);
--- 411,419 ----
writepage = page->mapping->a_ops->writepage;
#ifdef CONFIG_COMP_CACHE
! if (writepage)
#else
! if ((gfp_mask & __GFP_FS) && writepage)
#endif
+ {
ClearPageDirty(page);
SetPageLaunder(page);
***************
*** 423,429 ****
page_cache_release(page);
!
spin_lock(&pagemap_lru_lock);
! continue;
}
}
--- 424,438 ----
page_cache_release(page);
!
spin_lock(&pagemap_lru_lock);
!
! /***
! * if we could compress, it means that
! * the page has neither been mapped
! * back to any process nor freed, so
! * we can go on freeing it here
! */
! if (!PageCompCache(page))
! continue;
}
}
***************
*** 440,444 ****
page_cache_get(page);
! if (try_to_release_page(page, gfp_mask)) {
if (!page->mapping) {
/*
--- 449,453 ----
page_cache_get(page);
! if (comp_cache_try_to_release_page(&page, gfp_mask)) {
if (!page->mapping) {
/*
***************
*** 472,476 ****
UnlockPage(page);
page_cache_release(page);
!
spin_lock(&pagemap_lru_lock);
continue;
--- 481,485 ----
UnlockPage(page);
page_cache_release(page);
!
spin_lock(&pagemap_lru_lock);
continue;
***************
*** 483,487 ****
* this is the non-racy check for busy page.
*/
! if (!page->mapping || !is_page_cache_freeable(page)) {
spin_unlock(&pagecache_lock);
UnlockPage(page);
--- 492,496 ----
* this is the non-racy check for busy page.
*/
! if (!page->mapping || !is_page_cache_freeable(page) || PageMappedCompCache(page)) {
spin_unlock(&pagecache_lock);
UnlockPage(page);
***************
*** 509,516 ****
}
! /* compress it if it's a clean page that has not been
! * compressed in a previous iteration */
! if (compress_clean_page(page, gfp_mask))
! continue;
/* point of no return */
--- 518,539 ----
}
! /***
! * compress the page if it's a clean page that has not
! * been compressed in a previous iteration
! */
! if (!PageCompCache(page)) {
! page_cache_get(page);
! spin_unlock(&pagemap_lru_lock);
!
! if (!compress_clean_page(page, gfp_mask)) {
! UnlockPage(page);
! page_cache_release(page);
! spin_lock(&pagemap_lru_lock);
! continue;
! }
!
! page_cache_release(page);
! spin_lock(&pagemap_lru_lock);
! }
/* point of no return */
|