[lc-checkins] CVS: linux/mm/comp_cache aux.c,1.38,1.39 free.c,1.36,1.37 main.c,1.55,1.56 proc.c,1.20
Status: Beta
Brought to you by:
nitin_sf
From: Rodrigo S. de C. <rc...@us...> - 2002-07-16 21:58:11
|
Update of /cvsroot/linuxcompressed/linux/mm/comp_cache In directory usw-pr-cvs1:/tmp/cvs-serv2686/mm/comp_cache Modified Files: aux.c free.c main.c proc.c swapout.c Log Message: Bug fixes o Fixed bug in compact_fragments() which could corrupt the fragments list of a comp cache and also corrupt the comp page data when compacting fragments. Critical bug. Cleanups o Cleanup in comp_cache_free_locked() code o Removed alloc parameter from get_comp_cache_page() (not any longer used) Other o /proc/comp_cache_hist shows up to 6 fragments in a comp page Index: aux.c =================================================================== RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/aux.c,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -r1.38 -r1.39 *** aux.c 16 Jul 2002 18:41:55 -0000 1.38 --- aux.c 16 Jul 2002 21:58:08 -0000 1.39 *************** *** 2,6 **** * linux/mm/comp_cache/aux.c * ! * Time-stamp: <2002-07-16 14:53:55 rcastro> * * Linux Virtual Memory Compressed Cache --- 2,6 ---- * linux/mm/comp_cache/aux.c * ! * Time-stamp: <2002-07-16 16:33:09 rcastro> * * Linux Virtual Memory Compressed Cache *************** *** 232,237 **** break; default: ! if (total_fragments > 4) ! num_fragments[5]++; else num_fragments[total_fragments]++; --- 232,237 ---- break; default: ! if (total_fragments > 6) ! num_fragments[7]++; else num_fragments[total_fragments]++; Index: free.c =================================================================== RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/free.c,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -r1.36 -r1.37 *** free.c 16 Jul 2002 18:41:55 -0000 1.36 --- free.c 16 Jul 2002 21:58:08 -0000 1.37 *************** *** 2,6 **** * linux/mm/comp_cache/free.c * ! * Time-stamp: <2002-07-16 14:31:04 rcastro> * * Linux Virtual Memory Compressed Cache --- 2,6 ---- * linux/mm/comp_cache/free.c * ! * Time-stamp: <2002-07-16 18:35:21 rcastro> * * Linux Virtual Memory Compressed Cache *************** *** 75,84 **** num_fragments--; comp_cache_free_space += fragment->compressed_size; - - /*** - * Add the fragment compressed size only to total_free_space - * field since fragments that will be standing to be merged - * cannot be added to free_space field at this moment - */ fragment->comp_page->total_free_space += fragment->compressed_size; } --- 75,78 ---- *************** *** 94,98 **** /* remove all the freed fragments */ ! for_each_fragment(fragment_lh, comp_page) { fragment = list_entry(fragment_lh, struct comp_cache_fragment, list); --- 88,92 ---- /* remove all the freed fragments */ ! for_each_fragment_safe(fragment_lh, tmp_lh, comp_page) { fragment = list_entry(fragment_lh, struct comp_cache_fragment, list); *************** *** 139,142 **** --- 133,140 ---- list_add(fragment_lh, &(comp_page->fragments)); } + + + if (comp_page->free_space != comp_page->total_free_space) + BUG(); } *************** *** 166,174 **** previous_fragment = list_entry(fragment->list.prev, struct comp_cache_fragment, list); /* simple case - no free space * 1 - one not compressed page * 2 - sum of all fragments = COMP_PAGE_SIZE */ if (!comp_page->free_space) { - remove_fragment_from_comp_cache(fragment); comp_page->free_offset = fragment->offset; goto remove; --- 164,173 ---- previous_fragment = list_entry(fragment->list.prev, struct comp_cache_fragment, list); + remove_fragment_from_comp_cache(fragment); + /* simple case - no free space * 1 - one not compressed page * 2 - sum of all fragments = COMP_PAGE_SIZE */ if (!comp_page->free_space) { comp_page->free_offset = fragment->offset; goto remove; *************** *** 177,182 **** /* this fragment has the free space as its left neighbour */ if (comp_page->free_offset + comp_page->free_space == fragment->offset) { - remove_fragment_from_comp_cache(fragment); - merge_right_neighbour(fragment, next_fragment); goto remove; --- 176,179 ---- *************** *** 185,190 **** /* this fragment has the free space as its right neighbour */ if (fragment->offset + fragment->compressed_size == comp_page->free_offset) { - remove_fragment_from_comp_cache(fragment); - merge_left_neighbour(fragment, previous_fragment); comp_page->free_offset = fragment->offset; --- 182,185 ---- *************** *** 193,198 **** /* we have used fragment(s) between the free space and the one we want to free */ - remove_fragment_from_comp_cache(fragment); - if (CompFragmentTestandSetFreed(fragment)) BUG(); --- 188,191 ---- Index: main.c =================================================================== RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/main.c,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -r1.55 -r1.56 *** main.c 16 Jul 2002 18:41:55 -0000 1.55 --- main.c 16 Jul 2002 21:58:08 -0000 1.56 *************** *** 2,6 **** * linux/mm/comp_cache/main.c * ! * Time-stamp: <2002-07-16 14:55:38 rcastro> * * Linux Virtual Memory Compressed Cache --- 2,6 ---- * linux/mm/comp_cache/main.c * ! * Time-stamp: <2002-07-16 16:35:35 rcastro> * * Linux Virtual Memory Compressed Cache *************** *** 47,51 **** extern unsigned long num_physpages; ! extern struct comp_cache_page * get_comp_cache_page(struct page *, unsigned short, struct comp_cache_fragment **, int, unsigned int, int); inline void --- 47,51 ---- extern unsigned long num_physpages; ! extern struct comp_cache_page * get_comp_cache_page(struct page *, unsigned short, struct comp_cache_fragment **, unsigned int, int); inline void *************** *** 120,124 **** comp_size = compress(current_compressed_page = page, buffer_compressed = (unsigned long *) &buffer_compressed1, &algorithm, dirty); ! comp_page = get_comp_cache_page(page, comp_size, &fragment, 1, gfp_mask, priority); /* if comp_page == NULL, get_comp_cache_page() gave up --- 120,124 ---- comp_size = compress(current_compressed_page = page, buffer_compressed = (unsigned long *) &buffer_compressed1, &algorithm, dirty); ! comp_page = get_comp_cache_page(page, comp_size, &fragment, gfp_mask, priority); /* if comp_page == NULL, get_comp_cache_page() gave up Index: proc.c =================================================================== RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/proc.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -r1.20 -r1.21 *** proc.c 16 Jul 2002 18:41:55 -0000 1.20 --- proc.c 16 Jul 2002 21:58:08 -0000 1.21 *************** *** 2,6 **** * linux/mm/comp_cache/proc.c * ! * Time-stamp: <2002-07-16 14:55:14 rcastro> * * Linux Virtual Memory Compressed Cache --- 2,6 ---- * linux/mm/comp_cache/proc.c * ! * Time-stamp: <2002-07-16 16:32:43 rcastro> * * Linux Virtual Memory Compressed Cache *************** *** 398,403 **** #define HIST_PRINTK \ num_fragments[0], num_fragments[1], num_fragments[2], num_fragments[3], \ ! num_fragments[4], num_fragments[5] ! #define HIST_COUNT 6 int --- 398,403 ---- #define HIST_PRINTK \ num_fragments[0], num_fragments[1], num_fragments[2], num_fragments[3], \ ! num_fragments[4], num_fragments[5], num_fragments[6], num_fragments[7] ! #define HIST_COUNT 8 int *************** *** 416,420 **** length = sprintf(page, "compressed cache - free space histogram (free space x number of fragments)\n" ! " total 0f 1f 2f 3f 4f more\n"); memset((void *) num_fragments, 0, HIST_COUNT * sizeof(unsigned long)); --- 416,420 ---- length = sprintf(page, "compressed cache - free space histogram (free space x number of fragments)\n" ! " total 0f 1f 2f 3f 4f 5f 6f more\n"); memset((void *) num_fragments, 0, HIST_COUNT * sizeof(unsigned long)); *************** *** 422,426 **** total1 = free_space_count(0, num_fragments); length += sprintf(page + length, ! " %4d: %7lu %5lu %5lu %5lu %5lu %5lu %5lu\n", 0, total1, --- 422,426 ---- total1 = free_space_count(0, num_fragments); length += sprintf(page + length, ! " %4d: %7lu %5lu %5lu %5lu %5lu %5lu %5lu %5lu %5lu\n", 0, total1, *************** *** 435,439 **** length += sprintf(page + length, ! "%4d - %4d: %7lu %5lu %5lu %5lu %5lu %5lu %5lu\n", (i-1)*free_space_interval+1, (i+1)*free_space_interval<COMP_PAGE_SIZE?(i+1)*free_space_interval:(int)COMP_PAGE_SIZE, total1 + total2, HIST_PRINTK); --- 435,439 ---- length += sprintf(page + length, ! "%4d - %4d: %7lu %5lu %5lu %5lu %5lu %5lu %5lu %5lu %5lu\n", (i-1)*free_space_interval+1, (i+1)*free_space_interval<COMP_PAGE_SIZE?(i+1)*free_space_interval:(int)COMP_PAGE_SIZE, total1 + total2, HIST_PRINTK); Index: swapout.c =================================================================== RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/swapout.c,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -r1.60 -r1.61 *** swapout.c 16 Jul 2002 18:41:55 -0000 1.60 --- swapout.c 16 Jul 2002 21:58:08 -0000 1.61 *************** *** 2,6 **** * /mm/comp_cache/swapout.c * ! * Time-stamp: <2002-07-16 14:56:05 rcastro> * * Linux Virtual Memory Compressed Cache --- 2,6 ---- * /mm/comp_cache/swapout.c * ! * Time-stamp: <2002-07-16 16:35:08 rcastro> * * Linux Virtual Memory Compressed Cache *************** *** 341,348 **** * @compressed_size: size of swap cache page in compressed state * - * @alloc: do we allocate in case the comp_page->page == NULL? Usually - * yes, but in case we are going to store a page from page cache with - * buffers, that's not needed. - * * @fragment: variable that will store the fragment to store the * compressed data --- 341,344 ---- *************** *** 350,354 **** * @gfp_mask: we need to know if we can perform IO */ struct comp_cache_page * ! get_comp_cache_page(struct page * page, unsigned short compressed_size, struct comp_cache_fragment ** fragment_out, int alloc, unsigned int gfp_mask, int priority) { struct comp_cache_page * comp_page = NULL, ** hash_table; --- 346,350 ---- * @gfp_mask: we need to know if we can perform IO */ struct comp_cache_page * ! get_comp_cache_page(struct page * page, unsigned short compressed_size, struct comp_cache_fragment ** fragment_out, unsigned int gfp_mask, int priority) { struct comp_cache_page * comp_page = NULL, ** hash_table; *************** *** 384,392 **** if (comp_page->free_space != COMP_PAGE_SIZE) BUG(); ! if (alloc) ! goto alloc_new_page; ! ! remove_comp_page_from_hash_table(comp_page); ! goto check_references; } --- 380,384 ---- if (comp_page->free_space != COMP_PAGE_SIZE) BUG(); ! goto alloc_new_page; } |