Thread: [lc-checkins] CVS: linux/mm/comp_cache aux.c,1.8,1.9 main.c,1.14,1.15 swapin.c,1.11,1.12 swapout.c,1
Status: Beta
Brought to you by:
nitin_sf
From: Rodrigo S. de C. <rc...@us...> - 2002-01-04 22:24:10
|
Update of /cvsroot/linuxcompressed/linux/mm/comp_cache In directory usw-pr-cvs1:/tmp/cvs-serv25332/mm/comp_cache Modified Files: aux.c main.c swapin.c swapout.c Log Message: Some changes regarding code optimization. These modifications have improved a lot some tests (fillmem) we performed to test our current code. - hash function changed to be arch-independent (by using SWP_OFFSET) and also has been improved (shifting one position to the left). - hash table size is in function of COMP_CACHE_CACHE_SIZE. It was set to a static value and that hurts performance pretty badly for bigger sizes of compressed cache. This change breaks the kernel parameter compsize=, but I don't know if it's worth to add a variable to hold the hash table size since the macro that uses this value (fragment_hashfn) is called many times. - now the option in kernel config menu warns about the need of having a maximum size of compressed cache as a power of two number for this hash table size. If it's not a power of two, it breaks the hash function and the performance drops heavily. To solve this problem, we could add a variable that would be set to a reasonable value (a power of two) and in function of the maximum size of the compressed cache, but there's the problem explained above. - swap_out_fragments() never sleeps to lock a page. If it couldn't be locked at once, move it to the end of the LRU list and tries to lock the next. - removed checksum from the comp_cache_fragment_t and checksum computation from get_comp_cache_page() and decompress_page(). It added a huge overhead in our tests. Index: aux.c =================================================================== RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/aux.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** aux.c 2001/12/20 13:24:32 1.8 --- aux.c 2002/01/04 22:24:07 1.9 *************** *** 2,6 **** * linux/mm/comp_cache/aux.c * ! * Time-stamp: <2001-12-20 10:33:21 rcastro> * * Linux Virtual Memory Compressed Cache --- 2,6 ---- * linux/mm/comp_cache/aux.c * ! * Time-stamp: <2002-01-04 19:10:26 rcastro> * * Linux Virtual Memory Compressed Cache *************** *** 14,18 **** #include <linux/init.h> ! comp_cache_fragment_t * fragment_hash[HTABLE_SIZE]; /* computes (unsigned long long x) / (unsigned long long y) */ --- 14,18 ---- #include <linux/init.h> ! comp_cache_fragment_t * fragment_hash[FRAGMENT_HASH_SIZE]; /* computes (unsigned long long x) / (unsigned long long y) */ *************** *** 62,67 **** add_fragment_to_hash_table(comp_cache_fragment_t * new_fragment) { comp_cache_fragment_t ** fragment; ! fragment = &fragment_hash[hashfn(new_fragment->index)]; if ((new_fragment->next_hash = *fragment)) --- 62,70 ---- add_fragment_to_hash_table(comp_cache_fragment_t * new_fragment) { comp_cache_fragment_t ** fragment; + swp_entry_t entry; + + entry = (swp_entry_t) { new_fragment->index }; ! fragment = &fragment_hash[fragment_hashfn(entry)]; if ((new_fragment->next_hash = *fragment)) *************** *** 120,124 **** *fragment_out = NULL; ! for (fragment = fragment_hash[hashfn(entry.val)]; fragment != NULL; fragment = fragment->next_hash) { if (fragment->index == entry.val && !CompFragmentFreed(fragment)) { *fragment_out = fragment; --- 123,127 ---- *fragment_out = NULL; ! for (fragment = fragment_hash[fragment_hashfn(entry)]; fragment != NULL; fragment = fragment->next_hash) { if (fragment->index == entry.val && !CompFragmentFreed(fragment)) { *fragment_out = fragment; *************** *** 372,376 **** /* inits fragment hash table */ ! for (i = 0; i < HTABLE_SIZE; i++) fragment_hash[i] = NULL; } --- 375,379 ---- /* inits fragment hash table */ ! for (i = 0; i < FRAGMENT_HASH_SIZE; i++) fragment_hash[i] = NULL; } Index: main.c =================================================================== RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/main.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** main.c 2002/01/02 16:59:05 1.14 --- main.c 2002/01/04 22:24:07 1.15 *************** *** 2,6 **** * linux/mm/comp_cache/main.c * ! * Time-stamp: <2002-01-02 10:33:08 rcastro> * * Linux Virtual Memory Compressed Cache --- 2,6 ---- * linux/mm/comp_cache/main.c * ! * Time-stamp: <2002-01-04 11:44:44 rcastro> * * Linux Virtual Memory Compressed Cache *************** *** 100,104 **** } - fragment->checksum = csum_partial(page_address(swap_cache_page), PAGE_SIZE, 0); set_fragment_algorithm(fragment, algorithm); --- 100,103 ---- Index: swapin.c =================================================================== RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/swapin.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** swapin.c 2002/01/02 16:59:06 1.11 --- swapin.c 2002/01/04 22:24:07 1.12 *************** *** 2,6 **** * linux/mm/comp_cache/swapin.c * ! * Time-stamp: <2001-12-31 12:39:11 rcastro> * * Linux Virtual Memory Compressed Cache --- 2,6 ---- * linux/mm/comp_cache/swapin.c * ! * Time-stamp: <2002-01-04 11:44:53 rcastro> * * Linux Virtual Memory Compressed Cache *************** *** 40,46 **** decompress(fragment_algorithm(fragment), page_address(comp_page->page) + fragment->offset, page_address(uncompressed_page)); - if (fragment->checksum != csum_partial(page_address(uncompressed_page), PAGE_SIZE, 0)) - BUG(); - return; --- 40,43 ---- Index: swapout.c =================================================================== RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/swapout.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** swapout.c 2002/01/02 16:59:06 1.13 --- swapout.c 2002/01/04 22:24:07 1.14 *************** *** 2,6 **** * linux/mm/comp_cache/swapout.c * ! * Time-stamp: <2002-01-02 12:06:04 rcastro> * * Linux Virtual Memory Compressed Cache --- 2,6 ---- * linux/mm/comp_cache/swapout.c * ! * Time-stamp: <2002-01-03 17:24:51 rcastro> * * Linux Virtual Memory Compressed Cache *************** *** 146,150 **** swap_out_fragments(void) { struct list_head * fragment_lh, * next_fragment; ! int maxscan, not_found; comp_cache_fragment_t * fragment, * aux_fragment; comp_cache_t * comp_page = NULL; --- 146,150 ---- swap_out_fragments(void) { struct list_head * fragment_lh, * next_fragment; ! int maxscan; comp_cache_fragment_t * fragment, * aux_fragment; comp_cache_t * comp_page = NULL; *************** *** 157,162 **** next_fragment = &lru_queue; ! while (!list_empty(&lru_queue) && maxscan--) { ! fragment = list_entry(lru_queue.next, comp_cache_fragment_t, lru_queue); entry.val = fragment->index; --- 157,162 ---- next_fragment = &lru_queue; ! while (!list_empty(&lru_queue) && maxscan--) { ! fragment = list_entry(fragment_lh = lru_queue.next, comp_cache_fragment_t, lru_queue); entry.val = fragment->index; *************** *** 172,175 **** --- 172,176 ---- comp_cache_free(fragment); page_cache_release(page); + maxscan++; continue; } *************** *** 186,209 **** swap_duplicate(entry); ! lock_page(page); ! ! /* the fragment might have been freed while we slept ! * for the lock above */ ! not_found = 1; ! for_each_fragment(fragment_lh, comp_page) ! if (list_entry(fragment_lh, comp_cache_fragment_t, list) == fragment) ! not_found = 0; ! ! /* if the fragment have been freed, forget it (even it ! * has been reallocated to the same comp page, the ! * fragment->index will be different because we hold a ! * reference on the swp_entry */ ! if (not_found || fragment->index != entry.val) { ! next_fragment = &lru_queue; ! maxscan = 10; ! UnlockPage(page); goto freed; } ! swp_buffer = find_free_swp_buffer(); buffer_page = swp_buffer->comp_page->page; --- 187,198 ---- swap_duplicate(entry); ! /* page locked? move it to the back of the list */ ! if (TryLockPage(page)) { ! list_del(fragment_lh); ! list_add_tail(fragment_lh, &lru_queue); ! maxscan++; goto freed; } ! swp_buffer = find_free_swp_buffer(); buffer_page = swp_buffer->comp_page->page; *************** *** 213,217 **** /* race: this is not supposed to happen unless we ! * sleep to lock the page in find_free_swp_buffer */ if (CompFragmentFreed(fragment)) { free_swp_buffer(swp_buffer); --- 202,206 ---- /* race: this is not supposed to happen unless we ! * sleep to lock the page in find_free_swp_buffer() */ if (CompFragmentFreed(fragment)) { free_swp_buffer(swp_buffer); |