Thread: [lc-checkins] CVS: linux/mm/comp_cache aux.c,1.29,1.30 free.c,1.30,1.31 main.c,1.43,1.44 proc.c,1.14
Status: Beta
Brought to you by:
nitin_sf
|
From: Rodrigo S. de C. <rc...@us...> - 2002-06-13 20:18:39
|
Update of /cvsroot/linuxcompressed/linux/mm/comp_cache
In directory usw-pr-cvs1:/tmp/cvs-serv8112/mm/comp_cache
Modified Files:
aux.c free.c main.c proc.c swapin.c swapout.c
Log Message:
- read_comp_cache() has an "access" parameter to know if it should
account that access or not. If it is to account it, it will move the
fragment to the back of LRU list. That implied that we had to add some
parameters to some functions in filemap.c. It's there for testing
purposes and might be removed.
- account all PageMappedCompCache pages and not only page->buffers in
buffers column in /proc/comp_cache_hist
- added code that will enable to store all page cache pages without
compressing them. It's disable by an "#if 0".
- added code that will remove the fragment from compressed cache
whenever accessed. Disable by an "#if 0" too.
- tried to make a more robust writeout system using priority idea
present in vmscan.c. Now we are not supposed to panic because we
couldn't free a swap buffer page.
- fixed a potential bug when trying to free buffers in
writeout_fragments(). The fragment wasn't removed from lru queue
before being submitted to IO.
- added code that will support write out of all fragments in a certain
page. Also disabled by an "#if 0".
Index: aux.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/aux.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -r1.29 -r1.30
*** aux.c 11 Jun 2002 13:20:49 -0000 1.29
--- aux.c 13 Jun 2002 20:18:32 -0000 1.30
***************
*** 2,6 ****
* linux/mm/comp_cache/aux.c
*
! * Time-stamp: <2002-06-10 15:04:55 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/aux.c
*
! * Time-stamp: <2002-06-13 17:15:16 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 206,210 ****
#if 0
if (comp_page->page) {
! if (comp_page->page->buffers) {
if (index != 0 && index != free_space_hash_size - 1)
BUG();
--- 206,210 ----
#if 0
if (comp_page->page) {
! if (PageMappedCompCache(comp_page->page)) {
if (index != 0 && index != free_space_hash_size - 1)
BUG();
***************
*** 234,238 ****
break;
case 1:
! if (comp_page->page && comp_page->page->buffers)
num_fragments[5]++;
num_fragments[1]++;
--- 234,238 ----
break;
case 1:
! if (comp_page->page && PageMappedCompCache(comp_page->page))
num_fragments[5]++;
num_fragments[1]++;
***************
*** 305,308 ****
--- 305,327 ----
return comp_page;
+ }
+
+ inline void
+ add_fragment_to_lru_queue_tail(comp_cache_fragment_t * fragment) {
+ swp_entry_t entry;
+
+ if (!fragment)
+ BUG();
+
+ if (!PageSwapCache(fragment))
+ goto add;
+
+ entry.val = fragment->index;
+
+ if (vswap_address(entry))
+ return;
+
+ add:
+ list_add_tail(&(fragment->lru_queue), &lru_queue);
}
Index: free.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/free.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -r1.30 -r1.31
*** free.c 11 Jun 2002 13:20:49 -0000 1.30
--- free.c 13 Jun 2002 20:18:32 -0000 1.31
***************
*** 2,6 ****
* linux/mm/comp_cache/free.c
*
! * Time-stamp: <2002-06-10 13:42:06 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/free.c
*
! * Time-stamp: <2002-06-13 10:37:11 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 73,76 ****
--- 73,77 ----
if (PageSwapCache(fragment))
num_swapper_fragments--;
+ num_fragments--;
comp_cache_free_space += fragment->compressed_size;
}
Index: main.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/main.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -C2 -r1.43 -r1.44
*** main.c 11 Jun 2002 13:20:50 -0000 1.43
--- main.c 13 Jun 2002 20:18:33 -0000 1.44
***************
*** 2,6 ****
* linux/mm/comp_cache/main.c
*
! * Time-stamp: <2002-06-10 15:15:24 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/main.c
*
! * Time-stamp: <2002-06-13 17:08:28 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 22,25 ****
--- 22,26 ----
unsigned long num_comp_pages = 0;
unsigned long num_swapper_fragments = 0;
+ unsigned long num_fragments = 0;
unsigned long init_num_comp_pages = 0;
Index: proc.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/proc.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -r1.14 -r1.15
*** proc.c 11 Jun 2002 13:20:50 -0000 1.14
--- proc.c 13 Jun 2002 20:18:33 -0000 1.15
***************
*** 2,6 ****
* linux/mm/comp_cache/proc.c
*
! * Time-stamp: <2002-06-10 14:46:20 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/proc.c
*
! * Time-stamp: <2002-06-13 17:04:41 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 206,209 ****
--- 206,219 ----
stats_page_t comp_page_stats;
void * from = page_address(page);
+
+ #if 0
+ /* That's a testing police to compress only swap cache
+ * pages. All other pages from page cache will be stored
+ * without compression in compressed cache. */
+ if (!PageSwapCache(page)) {
+ *algorithm = current_algorithm;
+ return PAGE_SIZE;
+ }
+ #endif
START_ZEN_TIME(comp_page_stats.myTimer);
Index: swapin.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/swapin.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -r1.38 -r1.39
*** swapin.c 11 Jun 2002 13:20:50 -0000 1.38
--- swapin.c 13 Jun 2002 20:18:34 -0000 1.39
***************
*** 2,6 ****
* linux/mm/comp_cache/swapin.c
*
! * Time-stamp: <2002-06-10 18:05:50 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/swapin.c
*
! * Time-stamp: <2002-06-12 17:05:28 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 86,91 ****
}
! inline int
! read_comp_cache(struct address_space *mapping, unsigned long offset, struct page * page)
{
comp_cache_fragment_t * fragment;
--- 86,91 ----
}
! int
! read_comp_cache(struct address_space *mapping, unsigned long offset, struct page * page, int access)
{
comp_cache_fragment_t * fragment;
***************
*** 111,118 ****
/* move the fragment to the back of the lru list */
! remove_fragment_from_lru_queue(fragment);
! add_fragment_to_lru_queue(fragment);
decompress_fragment(fragment, page);
/* update fault in stats */
--- 111,129 ----
/* move the fragment to the back of the lru list */
! if (access) {
! remove_fragment_from_lru_queue(fragment);
! add_fragment_to_lru_queue(fragment);
! }
decompress_fragment(fragment, page);
+
+ #if 0
+ PageClearCompCache(page);
+
+ if (CompFragmentTestandClearDirty(fragment))
+ __set_page_dirty(page);
+
+ comp_cache_free_locked(fragment);
+ #endif
/* update fault in stats */
Index: swapout.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/swapout.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -C2 -r1.48 -r1.49
*** swapout.c 11 Jun 2002 13:20:50 -0000 1.48
--- swapout.c 13 Jun 2002 20:18:34 -0000 1.49
***************
*** 2,6 ****
* /mm/comp_cache/swapout.c
*
! * Time-stamp: <2002-06-10 15:27:56 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* /mm/comp_cache/swapout.c
*
! * Time-stamp: <2002-06-13 17:02:45 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 24,28 ****
static int
! refill_swp_buffer(unsigned int gfp_mask, int num_pages)
{
struct list_head * swp_buffer_lh;
--- 24,28 ----
static int
! refill_swp_buffer(unsigned int gfp_mask, int num_pages, int priority)
{
struct list_head * swp_buffer_lh;
***************
*** 34,38 ****
gfp_mask_buffer = gfp_mask & ~__GFP_IO;
! maxscan = max(NUM_SWP_BUFFERS >> 2, (int) (num_pages * 1.5));
wait = 0;
--- 34,38 ----
gfp_mask_buffer = gfp_mask & ~__GFP_IO;
! maxscan = max(NUM_SWP_BUFFERS/priority, (int) (num_pages * 1.5));
wait = 0;
***************
*** 103,107 ****
if (!wait && num_pages > 0) {
wait = 1;
! maxscan = max(NUM_SWP_BUFFERS >> 4, (int) (num_pages * 1.5));
gfp_mask_buffer = gfp_mask;
run_task_queue(&tq_disk);
--- 103,107 ----
if (!wait && num_pages > 0) {
wait = 1;
! maxscan = max(NUM_SWP_BUFFERS >> 4, (int) (num_pages * 4));
gfp_mask_buffer = gfp_mask;
run_task_queue(&tq_disk);
***************
*** 128,131 ****
--- 128,132 ----
struct list_head * swp_buffer_lh;
struct swp_buffer * swp_buffer;
+ int priority = 6;
if (!fragment)
***************
*** 137,141 ****
goto get_a_page;
! if (!refill_swp_buffer(gfp_mask, 1))
panic("couldn't free a swap buffer\n");
--- 138,145 ----
goto get_a_page;
! while (list_empty(&swp_free_buffer_head) && priority)
! refill_swp_buffer(gfp_mask, 1, priority--);
!
! if (list_empty(&swp_free_buffer_head))
panic("couldn't free a swap buffer\n");
***************
*** 204,211 ****
* we have a comp_page where we can store the new page */
static void
! writeout_fragments(unsigned int gfp_mask) {
int (*writepage)(struct page *);
! struct list_head * fragment_lh, * next_fragment;
! int maxscan, swap_cache_page;
comp_cache_fragment_t * fragment;
struct swp_buffer * swp_buffer;
--- 208,215 ----
* we have a comp_page where we can store the new page */
static void
! writeout_fragments(unsigned int gfp_mask, int priority) {
int (*writepage)(struct page *);
! struct list_head * fragment_lh, * tmp_lh;
! int maxscan, nrpages, swap_cache_page;
comp_cache_fragment_t * fragment;
struct swp_buffer * swp_buffer;
***************
*** 213,220 ****
swp_entry_t entry;
! maxscan = SWAP_CLUSTER_MAX;
!
! next_fragment = &lru_queue;
!
while (!list_empty(&lru_queue) && maxscan--) {
if (unlikely(current->need_resched)) {
--- 217,223 ----
swp_entry_t entry;
! maxscan = num_fragments/priority;
! nrpages = SWAP_CLUSTER_MAX;
!
while (!list_empty(&lru_queue) && maxscan--) {
if (unlikely(current->need_resched)) {
***************
*** 232,240 ****
/* page locked */
! if (TryLockPage(page))
! continue;
/* page which has/had buffer? */
if (PageMappedCompCache(page)) {
page_cache_get(page);
CompFragmentSetIO(fragment);
--- 235,245 ----
/* page locked */
! if (TryLockPage(page)) {
! continue;
! }
/* page which has/had buffer? */
if (PageMappedCompCache(page)) {
+ list_del(fragment_lh);
page_cache_get(page);
CompFragmentSetIO(fragment);
***************
*** 243,246 ****
--- 248,252 ----
page_cache_release(page);
CompFragmentClearIO(fragment);
+ list_add(fragment_lh, &lru_queue);
continue;
}
***************
*** 265,269 ****
if (PageDirty(page))
BUG();
! continue;
}
--- 271,278 ----
if (PageDirty(page))
BUG();
!
! if (--nrpages)
! continue;
! break;
}
***************
*** 272,276 ****
comp_cache_free_locked(fragment);
UnlockPage(page);
! continue;
}
--- 281,288 ----
comp_cache_free_locked(fragment);
UnlockPage(page);
!
! if (--nrpages)
! continue;
! break;
}
***************
*** 297,300 ****
--- 309,328 ----
CompFragmentClearDirty(fragment);
+ #if 0
+ /* That will move all the fragments in this comp page
+ * to the beginning of lru queue to be swapped out as
+ * soon as possible. This police may improve comp
+ * pages usage (fragment distribution). */
+ for_each_fragment(tmp_lh, fragment->comp_page) {
+ if (tmp_lh != fragment_lh) {
+ comp_cache_fragment_t * tmp = list_entry(tmp_lh, comp_cache_fragment_t, list);
+ if (!list_empty(&(tmp->lru_queue))) {
+ remove_fragment_from_lru_queue(tmp);
+ add_fragment_to_lru_queue_tail(tmp);
+ }
+ }
+ }
+ #endif
+
UnlockPage(page);
***************
*** 323,326 ****
--- 351,358 ----
if (swap_cache_page)
swap_free(entry);
+
+ if (!swp_buffer || --nrpages)
+ continue;
+ break;
}
}
***************
*** 359,363 ****
struct page * new_page;
unsigned short aux_comp_size;
! int maxscan, maxtry;
if (!page)
--- 391,395 ----
struct page * new_page;
unsigned short aux_comp_size;
! int maxscan, maxtry, priority = 6;
if (!page)
***************
*** 372,376 ****
page_cache_get(page);
! while (maxtry--) {
aux_comp_size = compressed_size;
maxscan = num_comp_pages >> 3;
--- 404,408 ----
page_cache_get(page);
! while (maxtry-- && priority) {
aux_comp_size = compressed_size;
maxscan = num_comp_pages >> 3;
***************
*** 418,423 ****
UnlockPage(page);
! if (!refill_swp_buffer(gfp_mask, SWAP_CLUSTER_MAX >> 2))
! writeout_fragments(gfp_mask);
if (TryLockPage(page)) {
--- 450,455 ----
UnlockPage(page);
! if (!refill_swp_buffer(gfp_mask, SWAP_CLUSTER_MAX >> 2, priority))
! writeout_fragments(gfp_mask, priority--);
if (TryLockPage(page)) {
***************
*** 558,562 ****
if (PageSwapCache(page))
num_swapper_fragments++;
!
add_fragment_to_hash_table(fragment);
add_fragment_to_lru_queue(fragment);
--- 590,595 ----
if (PageSwapCache(page))
num_swapper_fragments++;
! num_fragments++;
!
add_fragment_to_hash_table(fragment);
add_fragment_to_lru_queue(fragment);
|