[lc-checkins] CVS: linux/mm/comp_cache adaptivity.c,1.27,1.28 main.c,1.46,1.47 swapin.c,1.40,1.41
Status: Beta
Brought to you by:
nitin_sf
|
From: Rodrigo S. de C. <rc...@us...> - 2002-06-20 14:28:53
|
Update of /cvsroot/linuxcompressed/linux/mm/comp_cache
In directory usw-pr-cvs1:/tmp/cvs-serv24634/mm/comp_cache
Modified Files:
adaptivity.c main.c swapin.c
Log Message:
Cleanup
o Removed adapt_comp_cache() and all CONFIG_COMP_ADAPTIVITY related stuff.
That will be replaced by growing/shrinking by demand at the moment.
Index: adaptivity.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/adaptivity.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -r1.27 -r1.28
*** adaptivity.c 20 Jun 2002 12:33:58 -0000 1.27
--- adaptivity.c 20 Jun 2002 14:28:49 -0000 1.28
***************
*** 2,6 ****
* linux/mm/comp_cache/adaptivity.c
*
! * Time-stamp: <2002-06-20 08:57:04 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/adaptivity.c
*
! * Time-stamp: <2002-06-20 10:59:52 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 18,168 ****
static int fragment_failed_alloc = 0, vswap_failed_alloc = 0;
- struct preset_comp_cache * preset_comp_cache;
- int nr_preset_sizes, current_preset_size;
-
- static double time_comp = 0.3, time_decomp = 0.2, time_disk_read = 5;
- int latest_uncomp_misses[10], latest_miss;
-
- #define comp_cache_total_space (preset_comp_cache[i].size * PAGE_SIZE)
-
extern void comp_cache_fix_watermarks(int);
-
- /***
- * adapt_comp_cache(void) - adapt compressed cache to the recent
- * behaviour, resizing it if we would have better performance with
- * another size.
- *
- * TODO
- * - make compressed_ratio variable show the actual ratio
- * - collect faults by lru region
- * - account the number of swap cache pages in active and inactive lists?
- */
- void
- adapt_comp_cache(void) {
- static int nr = 0;
- int i, best_size, nr_uncomp_misses, uncomp_size, delta_disk_reads, compress_ratio = 2;
-
- if (++nr % 100)
- return;
-
- /* decay miss information */
- i = (latest_miss + 1) % 10;
- while (i != latest_miss) {
- latest_uncomp_misses[i] = 0.8 * latest_uncomp_misses[i];
- i = (i + 1) % 10;
- }
- latest_uncomp_misses[latest_miss] = nr_compressed_cache_misses + nr_swap_misses;
-
- for (nr_uncomp_misses = 0, i = 0; i < 10; i++)
- nr_uncomp_misses += latest_uncomp_misses[i];
-
- latest_miss = (latest_miss + 1) % 10;
-
- if (!nr_uncomp_misses)
- return;
-
- printk("nr_uncomp_misses %d\n", nr_uncomp_misses);
- printk("free space %ld\n", (comp_cache_free_space * 100)/(num_comp_pages * PAGE_SIZE));
-
- /* compute costs and benefits - smaller sizes*/
- best_size = current_preset_size;
- for (i = current_preset_size; i >= 0; i--) {
- double cost, benefit;
- int comp_size, delta_real_size;
-
- comp_size = preset_comp_cache[i].size;
- uncomp_size = num_physpages - comp_size;
-
- delta_real_size = (comp_cache_total_space/compress_ratio);
- printk("size %d real size %d used space %ld\n", preset_comp_cache[i].size, delta_real_size, comp_cache_used_space);
-
- if (comp_cache_used_space < delta_real_size)
- delta_disk_reads = 0;
- else {
- if (comp_cache_used_space > preset_comp_cache[i].size * PAGE_SIZE) {
- delta_disk_reads = ((float) comp_size)/preset_comp_cache[current_preset_size].size * nr_compressed_cache_misses;
- //printk("disk reads 1 %d\n", delta_disk_reads);
- }
- else {
- delta_disk_reads = ((comp_cache_used_space - delta_real_size) * nr_compressed_cache_misses)/comp_cache_used_space;
- //printk("disk reads 2 %d\n", delta_disk_reads);
- }
- }
-
- cost = (nr_uncomp_misses * comp_size)/preset_comp_cache[current_preset_size].size;
- printk("cost %d\n", (int) cost);
- cost *= (time_comp + time_decomp);
- benefit = delta_disk_reads * (time_disk_read);
- printk("cost %d benefit %d\n", (int) cost, (int) benefit);
-
- preset_comp_cache[i].profit = cost - benefit;
-
- if (preset_comp_cache[i].profit < preset_comp_cache[best_size].profit)
- best_size = i;
-
- printk("profit %d -> %d (smaller)\n", i, preset_comp_cache[i].profit);
- }
-
- if (comp_cache_free_space > 0.30 * num_comp_pages * PAGE_SIZE)
- goto out;
-
- /* compute costs and benefits - larger sizes*/
- for (i = current_preset_size + 1; i < nr_preset_sizes; i++) {
- double cost, benefit;
- int comp_size, diff_new_real_old_uncomp, incr_comp_size, scale = 0;
-
- comp_size = preset_comp_cache[i].size;
- uncomp_size = num_physpages - comp_size;
-
- /* new real memory size in function of the new compressed cache size */
- diff_new_real_old_uncomp = uncomp_size + comp_size/compress_ratio;
- /* minus the current uncompressed cache */
- diff_new_real_old_uncomp -= (num_physpages - preset_comp_cache[current_preset_size].size);
-
- /* unlikely */
- if (diff_new_real_old_uncomp > 0) {
- printk("1st case\n");
- scale = 1;
- }
-
- /* we can fill up the new comp cache space */
- incr_comp_size = preset_comp_cache[i].size - preset_comp_cache[current_preset_size].size;
- if (swapper_space.nrpages/compress_ratio > incr_comp_size) {
- printk("fill up\n");
- scale = 1;
- }
-
- printk("nr_compressed_cache_misses %d\n", nr_compressed_cache_misses);
-
- if (scale)
- delta_disk_reads = (1 - ((float) diff_new_real_old_uncomp/preset_comp_cache[current_preset_size].size)) * nr_compressed_cache_misses;
- else {
- delta_disk_reads = nr_compressed_cache_misses;
- delta_disk_reads += ((((float) swapper_space.nrpages)/compress_ratio - (incr_comp_size + diff_new_real_old_uncomp)) * nr_compressed_cache_misses)/preset_comp_cache[current_preset_size].size;
- printk("delta_disk_reads %d\n", delta_disk_reads);
- }
-
- cost = nr_uncomp_misses * ((float) preset_comp_cache[i].size/preset_comp_cache[current_preset_size].size);
- cost *= (time_comp + time_decomp);
- benefit = delta_disk_reads * (time_disk_read);
- printk("cost %d benefit %d\n", (int) cost, (int) benefit);
-
- preset_comp_cache[i].profit = cost - benefit;
-
- printk("profit %d -> %d (bigger)\n", i, preset_comp_cache[i].profit);
-
- if (preset_comp_cache[i].profit < preset_comp_cache[best_size].profit)
- best_size = i;
- }
-
-
- out:
- new_num_comp_pages = preset_comp_cache[best_size].size;
- current_preset_size = best_size;
- printk("best size %d\n", best_size);
-
- /* reset stats */
- nr_compressed_cache_misses = nr_swap_misses = 0;
- }
void
--- 18,22 ----
Index: main.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/main.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -r1.46 -r1.47
*** main.c 19 Jun 2002 12:18:44 -0000 1.46
--- main.c 20 Jun 2002 14:28:49 -0000 1.47
***************
*** 2,6 ****
* linux/mm/comp_cache/main.c
*
! * Time-stamp: <2002-06-19 08:46:38 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/main.c
*
! * Time-stamp: <2002-06-20 11:01:24 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 39,45 ****
kmem_cache_t * fragment_cachep;
- int nr_swap_misses;
- int nr_compressed_cache_misses;
-
extern unsigned long num_physpages;
--- 39,42 ----
***************
*** 114,121 ****
}
- #ifdef CONFIG_COMP_ADAPTIVITY
- adapt_comp_cache();
- #endif
-
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, dirty, 1, gfp_mask);
--- 111,114 ----
***************
*** 295,330 ****
min_num_comp_pages = num_physpages * 0.05;
- #ifndef CONFIG_COMP_ADAPTIVITY
if (!init_num_comp_pages || init_num_comp_pages < min_num_comp_pages || init_num_comp_pages > max_num_comp_pages)
- #endif
init_num_comp_pages = min_num_comp_pages;
new_num_comp_pages = num_comp_pages = init_num_comp_pages;
printk("Compressed Cache: %s\n", COMP_CACHE_VERSION);
-
- /* adaptivity */
- nr_swap_misses = 0;
- nr_compressed_cache_misses = 0;
-
- nr_preset_sizes = 4;
- preset_comp_cache = (struct preset_comp_cache *) kmalloc(nr_preset_sizes * sizeof(*preset_comp_cache), GFP_ATOMIC);
-
- #ifdef CONFIG_COMP_ADAPTIVITY
- printk("Compressed Cache: adaptivity\n");
- preset_comp_cache[0].size = num_physpages * 0.05;
- preset_comp_cache[1].size = num_physpages * 0.23;
- preset_comp_cache[2].size = num_physpages * 0.37;
- preset_comp_cache[3].size = num_physpages * 0.50;
-
- for (i = 0; i < nr_preset_sizes; i++)
- printk("Compressed Cache: preset size %d: %u memory pages\n", i, preset_comp_cache[i].size);
-
- for (i = 0; i < 10; i++)
- latest_uncomp_misses[i] = 0;
- latest_miss = 0;
- #else
printk("Compressed Cache: initial size\n"
"Compressed Cache: %lu pages = %luKiB\n", init_num_comp_pages, (init_num_comp_pages * PAGE_SIZE)/1024);
- #endif
/* fiz zone watermarks */
--- 288,298 ----
***************
*** 353,357 ****
}
- #ifndef CONFIG_COMP_ADAPTIVITY
static int __init comp_cache_size(char *str)
{
--- 321,324 ----
***************
*** 366,370 ****
__setup("compsize=", comp_cache_size);
- #endif
/*
--- 333,336 ----
Index: swapin.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/swapin.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -C2 -r1.40 -r1.41
*** swapin.c 19 Jun 2002 12:18:44 -0000 1.40
--- swapin.c 20 Jun 2002 14:28:50 -0000 1.41
***************
*** 2,6 ****
* linux/mm/comp_cache/swapin.c
*
! * Time-stamp: <2002-06-19 08:47:06 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/swapin.c
*
! * Time-stamp: <2002-06-20 11:00:45 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 99,106 ****
goto out;
- #ifdef CONFIG_COMP_ADAPTIVITY
- adapt_comp_cache();
- #endif
-
if (!PageLocked(page))
BUG();
--- 99,102 ----
|