linuxcompressed-checkins Mailing List for Linux Compressed Cache (Page 8)
Status: Beta
Brought to you by:
nitin_sf
You can subscribe to this list here.
| 2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
(31) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2002 |
Jan
(28) |
Feb
(50) |
Mar
(29) |
Apr
(6) |
May
(33) |
Jun
(36) |
Jul
(60) |
Aug
(7) |
Sep
(12) |
Oct
|
Nov
(13) |
Dec
(3) |
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(9) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2006 |
Jan
(13) |
Feb
(4) |
Mar
(4) |
Apr
(1) |
May
|
Jun
(22) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Rodrigo S. de C. <rc...@us...> - 2002-06-18 12:47:26
|
Update of /cvsroot/linuxcompressed/linux/mm/comp_cache
In directory usw-pr-cvs1:/tmp/cvs-serv12868/mm/comp_cache
Modified Files:
adaptivity.c aux.c main.c swapout.c vswap.c
Log Message:
Bug fixes
o Fixed compilation error when compressed cache is disabled
o Fixed bug that would store pages with buffers even if the page cache
support were disabled
o Fixed bug that would not account the comp pages with zero fragments in
/proc/comp_cache_hist. They were displayed in the total column, but not in
the zero fragments column.
o Fixed bug in comp_cache_fix_watermarks() that would set
zone_num_comp_pages to a bogus value of num_comp_page.
Other
o Added code to remove pages with buffers stored in the compressed
cache from LRU lists. These codes are within "#if 0" clauses.
o Allocate vswap table only when it is first used.
o Reduce compressed cache minimum size from 10 to 5%.
Index: adaptivity.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/adaptivity.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -r1.22 -r1.23
*** adaptivity.c 11 Jun 2002 13:20:49 -0000 1.22
--- adaptivity.c 18 Jun 2002 12:47:21 -0000 1.23
***************
*** 2,6 ****
* linux/mm/comp_cache/adaptivity.c
*
! * Time-stamp: <2002-06-10 13:32:33 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/adaptivity.c
*
! * Time-stamp: <2002-06-17 17:42:23 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 510,513 ****
--- 510,516 ----
static inline int
vswap_needs_to_shrink(void) {
+ if (!vswap_address)
+ return 0;
+
if (vswap_current_num_entries <= NUM_VSWAP_ENTRIES)
return 0;
***************
*** 631,634 ****
--- 634,640 ----
static inline int
vswap_needs_to_grow(void) {
+ if (!vswap_address)
+ return 0;
+
/* using vswap_last_used instead of vswap_current_num_entries
* forces us to grow the cache even if we started shrinking
Index: aux.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/aux.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -r1.30 -r1.31
*** aux.c 13 Jun 2002 20:18:32 -0000 1.30
--- aux.c 18 Jun 2002 12:47:21 -0000 1.31
***************
*** 2,6 ****
* linux/mm/comp_cache/aux.c
*
! * Time-stamp: <2002-06-13 17:15:16 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/aux.c
*
! * Time-stamp: <2002-06-17 16:14:31 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 232,235 ****
--- 232,236 ----
if (!comp_page->page)
num_fragments[6]++;
+ num_fragments[0]++;
break;
case 1:
Index: main.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/main.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -C2 -r1.44 -r1.45
*** main.c 13 Jun 2002 20:18:33 -0000 1.44
--- main.c 18 Jun 2002 12:47:21 -0000 1.45
***************
*** 2,6 ****
* linux/mm/comp_cache/main.c
*
! * Time-stamp: <2002-06-13 17:08:28 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/main.c
*
! * Time-stamp: <2002-06-17 17:47:11 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 147,150 ****
--- 147,151 ----
}
+ #ifdef CONFIG_COMP_PAGE_CACHE
void
steal_page_from_comp_cache(struct page * page, struct page * new_page)
***************
*** 179,183 ****
}
! comp_cache_free_locked(fragment);
PageClearMappedCompCache(old_page);
--- 180,189 ----
}
! #if 0
! if (page != new_page)
! lru_cache_add(page);
! #endif
!
! comp_cache_free_locked(fragment);
PageClearMappedCompCache(old_page);
***************
*** 198,203 ****
BUG();
if (PageMappedCompCache(*page))
! return 0;
if (page_count(*page) != 3)
--- 204,211 ----
BUG();
+ /* if mapped comp cache pages aren't removed from LRU queues,
+ * then here we should return 1, otherwise BUG() */
if (PageMappedCompCache(*page))
! return 1;
if (page_count(*page) != 3)
***************
*** 252,258 ****
--- 260,270 ----
ret = 1;
out:
+ #if 0
+ lru_cache_del(comp_page->page);
+ #endif
comp_cache_update_page_stats(comp_page->page, 0);
return ret;
}
+ #endif
extern void __init comp_cache_hash_init(void);
***************
*** 281,285 ****
max_num_comp_pages = num_physpages * 0.5;
! min_num_comp_pages = num_physpages * 0.1;
#ifndef CONFIG_COMP_ADAPTIVITY
--- 293,297 ----
max_num_comp_pages = num_physpages * 0.5;
! min_num_comp_pages = num_physpages * 0.05;
#ifndef CONFIG_COMP_ADAPTIVITY
***************
*** 300,304 ****
#ifdef CONFIG_COMP_ADAPTIVITY
printk("Compressed Cache: adaptivity\n");
! preset_comp_cache[0].size = num_physpages * 0.10;
preset_comp_cache[1].size = num_physpages * 0.23;
preset_comp_cache[2].size = num_physpages * 0.37;
--- 312,316 ----
#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;
***************
*** 328,334 ****
comp_cache_swp_buffer_init();
- /* virtual swap address */
comp_cache_vswap_init();
!
/* initialize each comp cache entry */
for (i = 0; i < num_comp_pages; i++) {
--- 340,345 ----
comp_cache_swp_buffer_init();
comp_cache_vswap_init();
!
/* initialize each comp cache entry */
for (i = 0; i < num_comp_pages; i++) {
Index: swapout.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/swapout.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -C2 -r1.49 -r1.50
*** swapout.c 13 Jun 2002 20:18:34 -0000 1.49
--- swapout.c 18 Jun 2002 12:47:21 -0000 1.50
***************
*** 2,6 ****
* /mm/comp_cache/swapout.c
*
! * Time-stamp: <2002-06-13 17:02:45 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* /mm/comp_cache/swapout.c
*
! * Time-stamp: <2002-06-17 17:39:26 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 201,206 ****
}
- extern unsigned short * last_page_size;
- extern unsigned short last_page;
extern struct address_space swapper_space;
--- 201,204 ----
Index: vswap.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/vswap.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -r1.30 -r1.31
*** vswap.c 15 May 2002 18:05:36 -0000 1.30
--- vswap.c 18 Jun 2002 12:47:21 -0000 1.31
***************
*** 2,6 ****
* linux/mm/comp_cache/vswap.c
*
! * Time-stamp: <2002-05-15 09:36:47 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/vswap.c
*
! * Time-stamp: <2002-06-17 17:52:54 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 23,27 ****
kmem_cache_t * vswap_cachep;
! struct vswap_address ** vswap_address;
struct list_head vswap_address_free_head;
struct list_head vswap_address_used_head;
--- 23,27 ----
kmem_cache_t * vswap_cachep;
! struct vswap_address ** vswap_address = NULL;
struct list_head vswap_address_free_head;
struct list_head vswap_address_used_head;
***************
*** 54,57 ****
--- 54,78 ----
unsigned short last_page = 0;
+ static void
+ comp_cache_vswap_alloc(void)
+ {
+ unsigned long i;
+
+ vswap_cachep = kmem_cache_create("comp_cache_vswap", sizeof(struct vswap_address), 0, SLAB_HWCACHE_ALIGN, NULL, NULL);
+
+ vswap_address = (struct vswap_address **) vmalloc(NUM_VSWAP_ENTRIES * sizeof(struct vswap_address*));
+
+ if (!vswap_address)
+ panic("comp_cache_vswap_init(): cannot allocate vswap_address");
+
+ vswap_current_num_entries = NUM_VSWAP_ENTRIES;
+ vswap_last_used = NUM_VSWAP_ENTRIES - 1;
+ vswap_num_used_entries = 0;
+ vswap_num_swap_cache = 0;
+
+ for (i = 0; i < NUM_VSWAP_ENTRIES; i++)
+ vswap_alloc_and_init(vswap_address, i);
+ }
+
static inline int
comp_cache_mean_size(void) {
***************
*** 138,141 ****
--- 159,165 ----
entry.val = 0;
+ if (!vswap_address)
+ comp_cache_vswap_alloc();
+
if (!comp_cache_available_vswap())
return entry;
***************
*** 659,682 ****
INIT_LIST_HEAD(&(vswap_address_free_head));
INIT_LIST_HEAD(&(vswap_address_used_head));
-
- vswap_cachep = kmem_cache_create("comp_cache_vswap", sizeof(struct vswap_address), 0, SLAB_HWCACHE_ALIGN, NULL, NULL);
-
- vswap_address = (struct vswap_address **) vmalloc(NUM_VSWAP_ENTRIES * sizeof(struct vswap_address*));
-
- if (!vswap_address)
- panic("comp_cache_vswap_init(): cannot allocate vswap_address");
-
- vswap_current_num_entries = NUM_VSWAP_ENTRIES;
- vswap_last_used = NUM_VSWAP_ENTRIES - 1;
- vswap_num_used_entries = 0;
- vswap_num_swap_cache = 0;
-
- for (i = 0; i < NUM_VSWAP_ENTRIES; i++)
- vswap_alloc_and_init(vswap_address, i);
comp_cache_freeable_space = PAGE_SIZE * num_comp_pages;
last_page_size = (unsigned short *) vmalloc(NUM_MEAN_PAGES * sizeof(unsigned short));
!
for (i = 0; i < NUM_MEAN_PAGES; i++)
last_page_size[i] = PAGE_SIZE/2;
--- 683,691 ----
INIT_LIST_HEAD(&(vswap_address_free_head));
INIT_LIST_HEAD(&(vswap_address_used_head));
comp_cache_freeable_space = PAGE_SIZE * num_comp_pages;
last_page_size = (unsigned short *) vmalloc(NUM_MEAN_PAGES * sizeof(unsigned short));
!
for (i = 0; i < NUM_MEAN_PAGES; i++)
last_page_size[i] = PAGE_SIZE/2;
|
|
From: Rodrigo S. de C. <rc...@us...> - 2002-06-18 12:47:25
|
Update of /cvsroot/linuxcompressed/linux/include/linux
In directory usw-pr-cvs1:/tmp/cvs-serv12868/include/linux
Modified Files:
comp_cache.h
Log Message:
Bug fixes
o Fixed compilation error when compressed cache is disabled
o Fixed bug that would store pages with buffers even if the page cache
support were disabled
o Fixed bug that would not account the comp pages with zero fragments in
/proc/comp_cache_hist. They were displayed in the total column, but not in
the zero fragments column.
o Fixed bug in comp_cache_fix_watermarks() that would set
zone_num_comp_pages to a bogus value of num_comp_page.
Other
o Added code to remove pages with buffers stored in the compressed
cache from LRU lists. These codes are within "#if 0" clauses.
o Allocate vswap table only when it is first used.
o Reduce compressed cache minimum size from 10 to 5%.
Index: comp_cache.h
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/include/linux/comp_cache.h,v
retrieving revision 1.74
retrieving revision 1.75
diff -C2 -r1.74 -r1.75
*** comp_cache.h 13 Jun 2002 20:18:29 -0000 1.74
--- comp_cache.h 18 Jun 2002 12:47:21 -0000 1.75
***************
*** 2,6 ****
* linux/mm/comp_cache.h
*
! * Time-stamp: <2002-06-13 10:36:18 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache.h
*
! * Time-stamp: <2002-06-17 17:39:43 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 326,330 ****
#define there_are_locked_comp_pages(mapping) (!list_empty(&(mapping)->locked_comp_pages))
#else
! static inline int read_comp_cache(struct address_space * mapping, unsigned long offset, struct page * page) { return -ENOENT; }
static inline int invalidate_comp_cache(struct address_space * mapping, unsigned long offset) { return -ENOENT; }
static inline int flush_comp_cache(struct page * page) { return -ENOENT; }
--- 326,330 ----
#define there_are_locked_comp_pages(mapping) (!list_empty(&(mapping)->locked_comp_pages))
#else
! static inline int read_comp_cache(struct address_space * mapping, unsigned long offset, struct page * page, int access) { return -ENOENT; }
static inline int invalidate_comp_cache(struct address_space * mapping, unsigned long offset) { return -ENOENT; }
static inline int flush_comp_cache(struct page * page) { return -ENOENT; }
***************
*** 345,351 ****
inline int compress_clean_page(struct page *, unsigned int);
- void steal_page_from_comp_cache(struct page *, struct page *);
- int comp_cache_try_to_release_page(struct page **, int);
-
extern int nr_swap_misses;
extern int nr_compressed_cache_misses;
--- 345,348 ----
***************
*** 362,368 ****
static inline int compress_clean_page(struct page * page, unsigned int gfp_mask) { return 0; }
- static inline void steal_page_from_comp_cache(struct page * page, struct page * new_page) {};
- static inline int comp_cache_try_to_release_page(struct page ** page, int gfp_mask) { return try_to_release_page(*page, gfp_mask); }
-
#define add_swap_miss() (0)
#define add_compressed_cache_miss() (0)
--- 359,362 ----
***************
*** 370,373 ****
--- 364,380 ----
#endif
+ #ifdef CONFIG_COMP_PAGE_CACHE
+
+ int comp_cache_try_to_release_page(struct page **, int);
+ void steal_page_from_comp_cache(struct page *, struct page *);
+
+ #else
+
+ static inline int comp_cache_try_to_release_page(struct page ** page, int gfp_mask) { return try_to_release_page(*page, gfp_mask); }
+ static inline void steal_page_from_comp_cache(struct page * page, struct page * new_page) {};
+
+ #endif
+
+
/* vswap.c */
struct vswap_address {
***************
*** 395,398 ****
--- 402,408 ----
extern unsigned long vswap_num_swap_cache;
extern unsigned int vswap_last_used;
+
+ extern unsigned short * last_page_size;
+ extern unsigned short last_page;
#define COMP_CACHE_SWP_TYPE MAX_SWAPFILES
|
|
From: Rodrigo S. de C. <rc...@us...> - 2002-06-18 12:47:25
|
Update of /cvsroot/linuxcompressed/linux/mm In directory usw-pr-cvs1:/tmp/cvs-serv12868/mm Modified Files: page_alloc.c Log Message: Bug fixes o Fixed compilation error when compressed cache is disabled o Fixed bug that would store pages with buffers even if the page cache support were disabled o Fixed bug that would not account the comp pages with zero fragments in /proc/comp_cache_hist. They were displayed in the total column, but not in the zero fragments column. o Fixed bug in comp_cache_fix_watermarks() that would set zone_num_comp_pages to a bogus value of num_comp_page. Other o Added code to remove pages with buffers stored in the compressed cache from LRU lists. These codes are within "#if 0" clauses. o Allocate vswap table only when it is first used. o Reduce compressed cache minimum size from 10 to 5%. Index: page_alloc.c =================================================================== RCS file: /cvsroot/linuxcompressed/linux/mm/page_alloc.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** page_alloc.c 11 Jun 2002 13:20:49 -0000 1.19 --- page_alloc.c 18 Jun 2002 12:47:21 -0000 1.20 *************** *** 637,640 **** --- 637,642 ---- zone_t *zone = contig_page_data.node_zones + j; + zone_num_comp_pages = num_comp_pages; + if (num_comp_pages > zone->size) num_comp_pages = zone->size; *************** *** 653,658 **** zone->pages_low = mask*2; zone->pages_high = mask*3; - - zone_num_comp_pages = num_comp_pages; } --- 655,658 ---- |
|
From: Rodrigo S. de C. <rc...@us...> - 2002-06-13 20:19:05
|
Update of /cvsroot/linuxcompressed/linux/mm
In directory usw-pr-cvs1:/tmp/cvs-serv8112/mm
Modified Files:
filemap.c swap_state.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: filemap.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/filemap.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -r1.28 -r1.29
*** filemap.c 11 Jun 2002 13:20:49 -0000 1.28
--- filemap.c 13 Jun 2002 20:18:31 -0000 1.29
***************
*** 749,754 ****
* and schedules an I/O to read in its contents from disk.
*/
! static int FASTCALL(page_cache_read(struct file * file, unsigned long offset));
! static int page_cache_read(struct file * file, unsigned long offset)
{
struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
--- 749,754 ----
* and schedules an I/O to read in its contents from disk.
*/
! static int FASTCALL(page_cache_read(struct file * file, unsigned long offset, int access));
! static int page_cache_read(struct file * file, unsigned long offset, int access)
{
struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
***************
*** 769,773 ****
int error = 0;
#ifdef CONFIG_COMP_PAGE_CACHE
! if (read_comp_cache(mapping, offset, page))
#endif
error = mapping->a_ops->readpage(file, page);
--- 769,773 ----
int error = 0;
#ifdef CONFIG_COMP_PAGE_CACHE
! if (read_comp_cache(mapping, offset, page, access))
#endif
error = mapping->a_ops->readpage(file, page);
***************
*** 796,800 ****
offset = CLUSTER_OFFSET(offset);
while ((pages-- > 0) && (offset < filesize)) {
! int error = page_cache_read(file, offset);
if (error < 0)
return error;
--- 796,800 ----
offset = CLUSTER_OFFSET(offset);
while ((pages-- > 0) && (offset < filesize)) {
! int error = page_cache_read(file, offset, 0);
if (error < 0)
return error;
***************
*** 1042,1046 ****
BUG();
! if (read_comp_cache(mapping, offset, cached_page)) {
UnlockPage(cached_page);
goto out;
--- 1042,1046 ----
BUG();
! if (read_comp_cache(mapping, offset, cached_page, 0)) {
UnlockPage(cached_page);
goto out;
***************
*** 1087,1091 ****
lru_cache_add(page);
#ifdef CONFIG_COMP_PAGE_CACHE
! if (!read_comp_cache(mapping, index, page)) {
if (TryLockPage(page))
BUG();
--- 1087,1091 ----
lru_cache_add(page);
#ifdef CONFIG_COMP_PAGE_CACHE
! if (!read_comp_cache(mapping, index, page, 0)) {
if (TryLockPage(page))
BUG();
***************
*** 1365,1369 ****
if ((raend + ahead) >= end_index)
break;
! if (page_cache_read(filp, raend + ahead) < 0)
break;
}
--- 1365,1369 ----
if ((raend + ahead) >= end_index)
break;
! if (page_cache_read(filp, raend + ahead, 0) < 0)
break;
}
***************
*** 1629,1633 ****
#ifdef CONFIG_COMP_PAGE_CACHE
! if (!read_comp_cache(mapping, index, page))
goto page_ok;
#endif
--- 1629,1633 ----
#ifdef CONFIG_COMP_PAGE_CACHE
! if (!read_comp_cache(mapping, index, page, 1))
goto page_ok;
#endif
***************
*** 1936,1940 ****
while (nr) {
! page_cache_read(file, index);
index++;
nr--;
--- 1936,1940 ----
while (nr) {
! page_cache_read(file, index, 0);
index++;
nr--;
***************
*** 2099,2103 ****
error = read_cluster_nonblocking(file, pgoff, size);
else
! error = page_cache_read(file, pgoff);
/*
--- 2099,2103 ----
error = read_cluster_nonblocking(file, pgoff, size);
else
! error = page_cache_read(file, pgoff, 1);
/*
***************
*** 2589,2593 ****
} else {
while ((start < end) && (start < size)) {
! error = page_cache_read(file, start);
start++;
if (error < 0)
--- 2589,2593 ----
} else {
while ((start < end) && (start < size)) {
! error = page_cache_read(file, start, 0);
start++;
if (error < 0)
***************
*** 2932,2936 ****
#ifdef CONFIG_COMP_PAGE_CACHE
! if (read_comp_cache(mapping, index, page))
#endif
err = filler(data, page);
--- 2932,2936 ----
#ifdef CONFIG_COMP_PAGE_CACHE
! if (read_comp_cache(mapping, index, page, 1))
#endif
err = filler(data, page);
Index: swap_state.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/swap_state.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -r1.28 -r1.29
*** swap_state.c 11 Jun 2002 13:20:49 -0000 1.28
--- swap_state.c 13 Jun 2002 20:18:31 -0000 1.29
***************
*** 230,234 ****
err = add_to_swap_cache(new_page, entry);
if (!err) {
! if (!read_comp_cache(&swapper_space, entry.val, new_page)) {
add_compressed_cache_miss();
return new_page;
--- 230,234 ----
err = add_to_swap_cache(new_page, entry);
if (!err) {
! if (!read_comp_cache(&swapper_space, entry.val, new_page, 1)) {
add_compressed_cache_miss();
return new_page;
|
|
From: Rodrigo S. de C. <rc...@us...> - 2002-06-13 20:19:03
|
Update of /cvsroot/linuxcompressed/linux/include/linux
In directory usw-pr-cvs1:/tmp/cvs-serv8112/include/linux
Modified Files:
comp_cache.h
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: comp_cache.h
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/include/linux/comp_cache.h,v
retrieving revision 1.73
retrieving revision 1.74
diff -C2 -r1.73 -r1.74
*** comp_cache.h 11 Jun 2002 13:20:48 -0000 1.73
--- comp_cache.h 13 Jun 2002 20:18:29 -0000 1.74
***************
*** 2,6 ****
* linux/mm/comp_cache.h
*
! * Time-stamp: <2002-06-10 15:02:12 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache.h
*
! * Time-stamp: <2002-06-13 10:36:18 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 36,40 ****
#define NUM_VSWAP_ENTRIES (3 * num_comp_pages)
! extern unsigned long num_comp_pages, num_swapper_fragments, new_num_comp_pages, max_num_comp_pages, zone_num_comp_pages;
struct pte_list {
--- 36,40 ----
#define NUM_VSWAP_ENTRIES (3 * num_comp_pages)
! extern unsigned long num_comp_pages, num_fragments, num_swapper_fragments, new_num_comp_pages, max_num_comp_pages, zone_num_comp_pages;
struct pte_list {
***************
*** 317,321 ****
extern int FASTCALL(flush_comp_cache(struct page *));
! int read_comp_cache(struct address_space *, unsigned long, struct page *);
int invalidate_comp_cache(struct address_space *, unsigned long);
void invalidate_comp_pages(struct address_space *);
--- 317,321 ----
extern int FASTCALL(flush_comp_cache(struct page *));
! int read_comp_cache(struct address_space *, unsigned long, struct page *, int);
int invalidate_comp_cache(struct address_space *, unsigned long);
void invalidate_comp_pages(struct address_space *);
***************
*** 541,544 ****
--- 541,545 ----
inline void add_fragment_to_lru_queue(comp_cache_fragment_t *);
+ inline void add_fragment_to_lru_queue_tail(comp_cache_fragment_t *);
inline void remove_fragment_from_lru_queue(comp_cache_fragment_t *);
|
|
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);
|
|
From: Rodrigo S. de C. <rc...@us...> - 2002-06-11 13:21:07
|
Update of /cvsroot/linuxcompressed/linux/include/linux
In directory usw-pr-cvs1:/tmp/cvs-serv3905/include/linux
Modified Files:
comp_cache.h mm.h sysctl.h
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: comp_cache.h
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/include/linux/comp_cache.h,v
retrieving revision 1.72
retrieving revision 1.73
diff -C2 -r1.72 -r1.73
*** comp_cache.h 30 May 2002 16:33:17 -0000 1.72
--- comp_cache.h 11 Jun 2002 13:20:48 -0000 1.73
***************
*** 2,6 ****
* linux/mm/comp_cache.h
*
! * Time-stamp: <2002-05-30 13:12:50 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache.h
*
! * Time-stamp: <2002-06-10 15:02:12 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 342,347 ****
void comp_cache_init(void);
inline void init_comp_page(comp_cache_t **,struct page *);
! inline int compress_dirty_page(struct page *, int (*writepage)(struct page *), unsigned int);
! inline int compress_clean_page(struct page *, unsigned int);
extern int nr_swap_misses;
--- 342,350 ----
void comp_cache_init(void);
inline void init_comp_page(comp_cache_t **,struct page *);
! inline void compress_dirty_page(struct page *, int (*writepage)(struct page *), unsigned int);
! inline int compress_clean_page(struct page *, unsigned int);
!
! void steal_page_from_comp_cache(struct page *, struct page *);
! int comp_cache_try_to_release_page(struct page **, int);
extern int nr_swap_misses;
***************
*** 359,362 ****
--- 362,368 ----
static inline int compress_clean_page(struct page * page, unsigned int gfp_mask) { return 0; }
+ static inline void steal_page_from_comp_cache(struct page * page, struct page * new_page) {};
+ static inline int comp_cache_try_to_release_page(struct page ** page, int gfp_mask) { return try_to_release_page(*page, gfp_mask); }
+
#define add_swap_miss() (0)
#define add_compressed_cache_miss() (0)
***************
*** 484,488 ****
/* aux.c */
unsigned long long big_division(unsigned long long, unsigned long long);
!
inline void check_all_fragments(comp_cache_t *);
--- 490,494 ----
/* aux.c */
unsigned long long big_division(unsigned long long, unsigned long long);
! inline void set_comp_page(comp_cache_t *, struct page *);
inline void check_all_fragments(comp_cache_t *);
***************
*** 548,551 ****
--- 554,558 ----
int comp_cache_stat_read_proc(char *, char **, off_t, int, int *, void *);
int comp_cache_hist_read_proc(char *, char **, off_t, int, int *, void *);
+ inline void comp_cache_update_page_stats(struct page *, int);
unsigned long free_space_count(int, unsigned long *);
Index: mm.h
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/include/linux/mm.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -r1.15 -r1.16
*** mm.h 1 Mar 2002 14:30:52 -0000 1.15
--- mm.h 11 Jun 2002 13:20:49 -0000 1.16
***************
*** 287,290 ****
--- 287,292 ----
#define PG_launder 15 /* written out by VM pressure.. */
#define PG_comp_cache 16 /* page with a fragment in compressed cache */
+ #define PG_mapped_comp_cache 17 /* page from page cache that is also mapped in
+ * the compressed cache */
/* Make it prettier to test the above... */
***************
*** 330,335 ****
--- 332,339 ----
#ifdef CONFIG_COMP_CACHE
#define PageCompCache(page) test_bit(PG_comp_cache, &(page)->flags)
+ #define PageMappedCompCache(page) test_bit(PG_mapped_comp_cache, &(page)->flags)
#else
#define PageCompCache(page) 0
+ #define PageMappedCompCache(page) 0
#endif
***************
*** 338,341 ****
--- 342,350 ----
#define PageTestandSetCompCache(page) test_and_set_bit(PG_comp_cache, &(page)->flags)
#define PageTestandClearCompCache(page) test_and_clear_bit(PG_comp_cache, &(page)->flags)
+
+ #define PageSetMappedCompCache(page) set_bit(PG_mapped_comp_cache, &(page)->flags)
+ #define PageClearMappedCompCache(page) clear_bit(PG_mapped_comp_cache, &(page)->flags)
+ #define PageTestandSetMappedCompCache(page) test_and_set_bit(PG_mapped_comp_cache, &(page)->flags)
+ #define PageTestandClearMappedCompCache(page) test_and_clear_bit(PG_mapped_comp_cache, &(page)->flags)
#define PageActive(page) test_bit(PG_active, &(page)->flags)
Index: sysctl.h
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/include/linux/sysctl.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** sysctl.h 13 Dec 2001 19:12:57 -0000 1.3
--- sysctl.h 11 Jun 2002 13:20:49 -0000 1.4
***************
*** 146,149 ****
--- 146,150 ----
};
+
/* CTL_NET names: */
enum
|
|
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 */
|
|
From: Rodrigo S. de C. <rc...@us...> - 2002-06-11 13:21:01
|
Update of /cvsroot/linuxcompressed/linux/mm/comp_cache
In directory usw-pr-cvs1:/tmp/cvs-serv3905/mm/comp_cache
Modified Files:
adaptivity.c aux.c free.c main.c proc.c swapin.c swapout.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: adaptivity.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/adaptivity.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -r1.21 -r1.22
*** adaptivity.c 30 May 2002 13:56:09 -0000 1.21
--- adaptivity.c 11 Jun 2002 13:20:49 -0000 1.22
***************
*** 2,6 ****
* linux/mm/comp_cache/adaptivity.c
*
! * Time-stamp: <2002-05-30 10:50:05 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/adaptivity.c
*
! * Time-stamp: <2002-06-10 13:32:33 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 570,578 ****
UnlockPage(empty_comp_page->page);
page_cache_release(empty_comp_page->page);
kmem_cache_free(comp_cachep, (empty_comp_page));
-
- comp_cache_freeable_space -= PAGE_SIZE;
- comp_cache_free_space -= PAGE_SIZE;
num_comp_pages--;
#if 0
--- 570,577 ----
UnlockPage(empty_comp_page->page);
+ set_comp_page(empty_comp_page, NULL);
+
page_cache_release(empty_comp_page->page);
kmem_cache_free(comp_cachep, (empty_comp_page));
num_comp_pages--;
#if 0
Index: aux.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/aux.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -r1.28 -r1.29
*** aux.c 29 May 2002 21:28:54 -0000 1.28
--- aux.c 11 Jun 2002 13:20:49 -0000 1.29
***************
*** 2,6 ****
* linux/mm/comp_cache/aux.c
*
! * Time-stamp: <2002-05-29 17:13:08 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/aux.c
*
! * Time-stamp: <2002-06-10 15:04:55 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 68,71 ****
--- 68,93 ----
}
+ inline void
+ set_comp_page(comp_cache_t * comp_page, struct page * page)
+ {
+ if (!comp_page)
+ BUG();
+ if (comp_page->page) {
+ if (page)
+ goto out;
+ comp_cache_freeable_space -= PAGE_SIZE;
+ comp_cache_free_space -= PAGE_SIZE;
+ goto out;
+ }
+
+ if (!page)
+ BUG();
+
+ comp_cache_freeable_space += PAGE_SIZE;
+ comp_cache_free_space += PAGE_SIZE;
+
+ out:
+ comp_page->page = page;
+ }
static void
***************
*** 169,173 ****
unsigned long total, total_fragments;
struct list_head * fragment_lh;
!
if (index < 0)
BUG();
--- 191,195 ----
unsigned long total, total_fragments;
struct list_head * fragment_lh;
!
if (index < 0)
BUG();
***************
*** 182,189 ****
total_fragments++;
! if (total_fragments > 3)
! num_fragments[3]++;
! else
! num_fragments[total_fragments]++;
}
--- 204,248 ----
total_fragments++;
! #if 0
! if (comp_page->page) {
! if (comp_page->page->buffers) {
! if (index != 0 && index != free_space_hash_size - 1)
! BUG();
! if (!comp_page->page->mapping)
! BUG();
! if (page_count(comp_page->page) != 2)
! BUG();
! }
! if (!comp_page->page->buffers && page_count(comp_page->page) != 1)
! BUG();
! if (PageDirty(comp_page->page))
! BUG();
! }
! else {
! if (index != free_space_hash_size - 1)
! BUG();
! if (comp_page->free_space != PAGE_SIZE)
! BUG();
! }
! #endif
!
! switch(total_fragments)
! {
! case 0:
! if (!comp_page->page)
! num_fragments[6]++;
! break;
! case 1:
! if (comp_page->page && comp_page->page->buffers)
! num_fragments[5]++;
! num_fragments[1]++;
! break;
! default:
! if (total_fragments > 3)
! num_fragments[4]++;
! else
! num_fragments[total_fragments]++;
! break;
! }
}
Index: free.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/free.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -r1.29 -r1.30
*** free.c 15 May 2002 18:05:36 -0000 1.29
--- free.c 11 Jun 2002 13:20:49 -0000 1.30
***************
*** 2,6 ****
* linux/mm/comp_cache/free.c
*
! * Time-stamp: <2002-05-15 10:05:47 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/free.c
*
! * Time-stamp: <2002-06-10 13:42:06 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 87,92 ****
if (!comp_page)
BUG();
- if (!comp_page->page)
- BUG();
if (not_compressed(fragment) && comp_page->free_space)
BUG();
--- 87,90 ----
***************
*** 94,98 ****
/* remove from the free space hash table to update it */
remove_comp_page_from_hash_table(comp_page);
!
/* fragment is added in the correct location to the comp_page
* list (see get_comp_cache_page():swapout.c) */
--- 92,96 ----
/* remove from the free space hash table to update it */
remove_comp_page_from_hash_table(comp_page);
!
/* fragment is added in the correct location to the comp_page
* list (see get_comp_cache_page():swapout.c) */
***************
*** 167,170 ****
--- 165,169 ----
comp_cache_free(comp_cache_fragment_t * fragment) {
comp_cache_t * comp_page;
+ int locked;
if (!fragment)
***************
*** 172,182 ****
comp_page = fragment->comp_page;
! if (TryLockPage(comp_page->page))
! BUG();
!
! comp_cache_free_locked(fragment);
! /* steal the page if we need to shrink the comp cache */
! shrink_comp_cache(comp_page);
}
--- 171,183 ----
comp_page = fragment->comp_page;
! locked = !TryLockPage(comp_page->page);
! comp_cache_free_locked(fragment);
!
! /* steal the page if we need to shrink the cache. The
! * page will be unlocked in shrink_comp_cache()
! * function */
! if (locked)
! shrink_comp_cache(comp_page);
}
Index: main.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/main.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -r1.42 -r1.43
*** main.c 31 May 2002 16:48:53 -0000 1.42
--- main.c 11 Jun 2002 13:20:50 -0000 1.43
***************
*** 2,6 ****
* linux/mm/comp_cache/main.c
*
! * Time-stamp: <2002-05-31 13:12:36 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/main.c
*
! * Time-stamp: <2002-06-10 15:15:24 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 43,62 ****
extern unsigned long num_physpages;
! extern comp_cache_t * get_comp_cache_page(struct page *, unsigned short, comp_cache_fragment_t **, int, unsigned int);
! inline int
compress_dirty_page(struct page * page, int (*writepage)(struct page *), unsigned int gfp_mask)
{
! int ret;
!
#ifdef CONFIG_COMP_PAGE_CACHE
! if (!shmem_page(page))
#else
! if (PageSwapCache(page))
#endif
! ret = compress_page(page, 1, gfp_mask);
! else
! ret = writepage(page);
! return ret;
}
--- 43,74 ----
extern unsigned long num_physpages;
! extern comp_cache_t * get_comp_cache_page(struct page *, unsigned short, comp_cache_fragment_t **, int, int, unsigned int);
! inline void
compress_dirty_page(struct page * page, int (*writepage)(struct page *), unsigned int gfp_mask)
{
! int write;
!
! write = !!page->buffers;
#ifdef CONFIG_COMP_PAGE_CACHE
! write |= shmem_page(page);
#else
! write |= !PageSwapCache(page);
#endif
! if (write)
! goto writepage;
!
! if (PageMappedCompCache(page))
! BUG();
!
! if (page->buffers)
! BUG();
!
! if (!compress_page(page, 1, gfp_mask))
! UnlockPage(page);
! return;
!
! writepage:
! writepage(page);
}
***************
*** 64,83 ****
compress_clean_page(struct page * page, unsigned int gfp_mask)
{
! if (PageCompCache(page))
! return 0;
#ifndef CONFIG_COMP_PAGE_CACHE
if (!PageSwapCache(page))
! return 0;
#endif
!
! page_cache_get(page);
! spin_unlock(&pagecache_lock);
!
! compress_page(page, 0, gfp_mask);
! page_cache_release(page);
!
! spin_lock(&pagemap_lru_lock);
! return 1;
}
--- 76,91 ----
compress_clean_page(struct page * page, unsigned int gfp_mask)
{
! /* that should not happen */
! if (PageMappedCompCache(page))
! BUG();
!
! if (page->buffers)
! BUG();
#ifndef CONFIG_COMP_PAGE_CACHE
if (!PageSwapCache(page))
! return 1;
#endif
! return compress_page(page, 0, gfp_mask);
}
***************
*** 110,114 ****
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, gfp_mask);
/* if comp_page == NULL, get_comp_cache_page() gave up
--- 118,122 ----
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);
/* if comp_page == NULL, get_comp_cache_page() gave up
***************
*** 135,140 ****
BUG();
UnlockPage(comp_page->page);
- UnlockPage(page);
return 1;
}
--- 143,256 ----
BUG();
UnlockPage(comp_page->page);
return 1;
+ }
+
+ void
+ steal_page_from_comp_cache(struct page * page, struct page * new_page)
+ {
+ comp_cache_fragment_t * fragment;
+ comp_cache_t * comp_page;
+ struct page * old_page;
+ int locked;
+
+ if (!PageMappedCompCache(page))
+ return;
+
+ if (find_comp_page(page->mapping, page->index, &fragment))
+ BUG();
+
+ if (CompFragmentIO(fragment))
+ BUG();
+ comp_page = fragment->comp_page;
+ old_page = comp_page->page;
+
+ if (old_page != page)
+ BUG();
+ locked = !TryLockPage(old_page);
+
+ set_comp_page(comp_page, new_page);
+
+ if (new_page) {
+ /* the reference got in the caller will be drop */
+ page_cache_get(new_page);
+ if (page_count(new_page) != 3)
+ BUG();
+ }
+
+ comp_cache_free_locked(fragment);
+ PageClearMappedCompCache(old_page);
+
+ if (locked)
+ UnlockPage(old_page);
+ }
+
+ int
+ comp_cache_try_to_release_page(struct page ** page, int gfp_mask)
+ {
+ comp_cache_fragment_t * fragment;
+ comp_cache_t * comp_page;
+ unsigned short comp_size, dirty;
+ struct page * old_page;
+ int ret = 0;
+
+ if (PageCompCache(*page))
+ BUG();
+
+ if (PageMappedCompCache(*page))
+ return 0;
+
+ if (page_count(*page) != 3)
+ return try_to_release_page(*page, gfp_mask);
+
+ if (PageSwapCache(*page)) {
+ swp_entry_t entry = (swp_entry_t) { (*page)->index };
+
+ if (vswap_address(entry))
+ BUG();
+ }
+
+ /* could we free the buffer without IO, so why store in
+ * compressed cache with the buffers? it can be ocasionally
+ * stored later as a clean page */
+ if (try_to_release_page(*page, 0))
+ return 1;
+
+ /* it's not mapped by any process, therefore we can trade this
+ * page with a page reserved for compressed cache use */
+ comp_size = PAGE_SIZE;
+ dirty = 0;
+
+ comp_page = get_comp_cache_page(*page, comp_size, &fragment, dirty, 0, gfp_mask);
+
+ if (!comp_page)
+ return ret;
+
+ /* let's swap the pages */
+ old_page = comp_page->page;
+ set_comp_page(comp_page, (*page));
+
+ PageSetMappedCompCache(comp_page->page);
+
+ /* whoops, no page to set to (*page), so it's time to leave */
+ if (!old_page)
+ goto out;
+
+ /* no need to call page_cache_get() since we have an extra
+ * reference got in shrink_cache() that won't be released
+ * (recall that we are setting *page to a new page) */
+ *page = old_page;
+ if (page_count(old_page) != 1)
+ BUG();
+ if (old_page->mapping)
+ BUG();
+ if (!PageLocked(old_page))
+ BUG();
+
+ UnlockPage(comp_page->page);
+ page_cache_release(comp_page->page);
+ ret = 1;
+ out:
+ comp_cache_update_page_stats(comp_page->page, 0);
+ return ret;
}
Index: proc.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/proc.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** proc.c 30 May 2002 16:33:18 -0000 1.13
--- proc.c 11 Jun 2002 13:20:50 -0000 1.14
***************
*** 2,6 ****
* linux/mm/comp_cache/proc.c
*
! * Time-stamp: <2002-05-30 13:21:25 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/proc.c
*
! * Time-stamp: <2002-06-10 14:46:20 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 65,68 ****
--- 65,83 ----
};
+ inline void
+ comp_cache_update_page_stats(struct page * page, int dirty)
+ {
+ #ifdef CONFIG_COMP_PAGE_CACHE
+ if (!PageSwapCache(page))
+ compression_algorithms[current_algorithm].stats.comp_page++;
+ else
+ #endif
+ compression_algorithms[current_algorithm].stats.comp_swap++;
+ if (dirty)
+ compression_algorithms[current_algorithm].stats.comp_dirty++;
+ else
+ compression_algorithms[current_algorithm].stats.comp_clean++;
+ }
+
static void
comp_cache_update_comp_stats(stats_page_t * comp_page_stats, struct page * page, int dirty)
***************
*** 92,105 ****
stats->comp_cycles_sum += comp_page_stats->comp_cycles;
! #ifdef CONFIG_COMP_PAGE_CACHE
! if (!PageSwapCache(page))
! compression_algorithms[current_algorithm].stats.comp_page++;
! else
! #endif
! compression_algorithms[current_algorithm].stats.comp_swap++;
! if (dirty)
! compression_algorithms[current_algorithm].stats.comp_dirty++;
! else
! compression_algorithms[current_algorithm].stats.comp_clean++;
}
--- 107,111 ----
stats->comp_cycles_sum += comp_page_stats->comp_cycles;
! comp_cache_update_page_stats(page, dirty);
}
***************
*** 374,379 ****
}
! #define FRAGMENTS_PRINTK num_fragments[0], num_fragments[1], num_fragments[2], num_fragments[3], num_fragments[4]
! #define FRAGMENTS_COUNT 5
int
--- 380,387 ----
}
! #define FRAGMENTS_PRINTK \
! num_fragments[0], num_fragments[1], num_fragments[2], num_fragments[3], \
! num_fragments[4], num_fragments[5], num_fragments[6]
! #define FRAGMENTS_COUNT 7
int
***************
*** 396,401 ****
total1 = free_space_count(0, num_fragments);
length += sprintf(page + length,
! " total 0f 1f 2f 3f more\n"
! " %4d: %8lu %5lu %5lu %5lu %5lu %5lu\n",
0,
total1,
--- 404,409 ----
total1 = free_space_count(0, num_fragments);
length += sprintf(page + length,
! " total 0f 1f 2f 3f more buffers nopg\n"
! " %4d: %7lu %5lu %5lu %5lu %5lu %5lu %5lu %5lu\n",
0,
total1,
***************
*** 408,412 ****
length += sprintf(page + length,
! "%4d - %4d: %8lu %5lu %5lu %5lu %5lu %5lu\n",
(i+1)*100-200?:1, (i+1)*100, total1 + total2,
FRAGMENTS_PRINTK);
--- 416,420 ----
length += sprintf(page + length,
! "%4d - %4d: %7lu %5lu %5lu %5lu %5lu %5lu %5lu %5lu\n",
(i+1)*100-200?:1, (i+1)*100, total1 + total2,
FRAGMENTS_PRINTK);
***************
*** 417,421 ****
total1 = free_space_count(free_space_hash_size - 1, num_fragments);
length += sprintf(page + length,
! "%4d - %4d: %8lu %5lu %5lu %5lu %5lu %5lu\n",
(free_space_hash_size - 2) * 100 + 1, (int) PAGE_SIZE,
total1,
--- 425,429 ----
total1 = free_space_count(free_space_hash_size - 1, num_fragments);
length += sprintf(page + length,
! "%4d - %4d: %7lu %5lu %5lu %5lu %5lu %5lu %5lu %5lu\n",
(free_space_hash_size - 2) * 100 + 1, (int) PAGE_SIZE,
total1,
Index: swapin.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/swapin.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -r1.37 -r1.38
*** swapin.c 31 May 2002 16:48:53 -0000 1.37
--- swapin.c 11 Jun 2002 13:20:50 -0000 1.38
***************
*** 2,6 ****
* linux/mm/comp_cache/swapin.c
*
! * Time-stamp: <2002-05-31 13:04:02 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/swapin.c
*
! * Time-stamp: <2002-06-10 18:05:50 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 37,41 ****
comp_cache_fragment_t * fragment;
int err = -ENOENT;
!
if (likely(!PageTestandClearCompCache(page)))
goto out;
--- 37,41 ----
comp_cache_fragment_t * fragment;
int err = -ENOENT;
!
if (likely(!PageTestandClearCompCache(page)))
goto out;
***************
*** 57,61 ****
__set_page_dirty(page);
}
-
comp_cache_free(fragment);
out:
--- 57,60 ----
***************
*** 108,111 ****
--- 107,112 ----
if (TryLockPage(fragment->comp_page->page))
BUG();
+ if (PageMappedCompCache(fragment->comp_page->page))
+ BUG();
/* move the fragment to the back of the lru list */
***************
*** 135,142 ****
fragment = list_entry(fragment_lh, comp_cache_fragment_t, mapping_list);
! if ((fragment->index < start) && (partial && (fragment->index + 1) != start))
! continue;
!
! comp_cache_free(fragment);
}
}
--- 136,152 ----
fragment = list_entry(fragment_lh, comp_cache_fragment_t, mapping_list);
! if ((fragment->index >= start) || (partial && (fragment->index + 1) == start)) {
! /***
! * Only valid if we are invalidating entries
! * in compressed cache. We could invalidate in
! * invalidate_inode_pages() each page, but
! * that would make us search comp cache for
! * every page, which is not wanted
! */
! if (PageMappedCompCache(fragment->comp_page->page))
! steal_page_from_comp_cache(fragment->comp_page->page, NULL);
! else
! comp_cache_free(fragment);
! }
}
}
***************
*** 190,193 ****
--- 200,205 ----
hash = page_hash(mapping, fragment->index);
+ if (PageMappedCompCache(fragment->comp_page->page))
+ BUG();
if (!CompFragmentTestandClearDirty(fragment))
BUG();
Index: swapout.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/swapout.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -C2 -r1.47 -r1.48
*** swapout.c 31 May 2002 16:48:53 -0000 1.47
--- swapout.c 11 Jun 2002 13:20:50 -0000 1.48
***************
*** 2,6 ****
* /mm/comp_cache/swapout.c
*
! * Time-stamp: <2002-05-31 13:32:50 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* /mm/comp_cache/swapout.c
*
! * Time-stamp: <2002-06-10 15:27:56 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 175,178 ****
--- 175,180 ----
struct swp_buffer * swp_buffer;
+ if (fragment->comp_page->page->buffers)
+ BUG();
swp_buffer = find_free_swp_buffer(fragment, gfp_mask);
***************
*** 233,236 ****
--- 235,271 ----
continue;
+ /* page which has/had buffer? */
+ if (PageMappedCompCache(page)) {
+ page_cache_get(page);
+ CompFragmentSetIO(fragment);
+ if (page->buffers && !try_to_release_page(page, gfp_mask)) {
+ UnlockPage(page);
+ page_cache_release(page);
+ CompFragmentClearIO(fragment);
+ continue;
+ }
+
+ if (PageSwapCache(page))
+ delete_from_swap_cache(page);
+ else {
+ __remove_inode_page(page);
+ page_cache_release(page);
+ }
+ PageClearMappedCompCache(page);
+ page->flags &= ~((1 << PG_uptodate) | (1 << PG_referenced));
+
+ if (CompFragmentTestandClearIO(fragment))
+ comp_cache_free_locked(fragment);
+ else
+ kmem_cache_free(fragment_cachep, (fragment));
+ UnlockPage(page);
+
+ if (page_count(page) != 1)
+ BUG();
+ if (PageDirty(page))
+ BUG();
+ continue;
+ }
+
/* clean page, let's free it */
if (!CompFragmentDirty(fragment)) {
***************
*** 308,311 ****
--- 343,350 ----
* @dirty: are we going to compress a dirty page?
*
+ * @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
***************
*** 313,321 ****
* @gfp_mask: we need to know if we can perform IO */
comp_cache_t *
! get_comp_cache_page(struct page * page, unsigned short compressed_size, comp_cache_fragment_t ** fragment_out, int dirty, unsigned int gfp_mask)
{
comp_cache_t * comp_page = NULL;
comp_cache_fragment_t * fragment = NULL, * previous_fragment = NULL;
struct list_head * fragment_lh;
unsigned short aux_comp_size;
int maxscan, maxtry;
--- 352,361 ----
* @gfp_mask: we need to know if we can perform IO */
comp_cache_t *
! get_comp_cache_page(struct page * page, unsigned short compressed_size, comp_cache_fragment_t ** fragment_out, int dirty, int alloc, unsigned int gfp_mask)
{
comp_cache_t * comp_page = NULL;
comp_cache_fragment_t * fragment = NULL, * previous_fragment = NULL;
struct list_head * fragment_lh;
+ struct page * new_page;
unsigned short aux_comp_size;
int maxscan, maxtry;
***************
*** 346,350 ****
if (comp_page->free_space != PAGE_SIZE)
BUG();
! goto new_page;
}
--- 386,394 ----
if (comp_page->free_space != PAGE_SIZE)
BUG();
! if (alloc)
! goto alloc_new_page;
!
! remove_comp_page_from_hash_table(comp_page);
! goto check_references;
}
***************
*** 389,404 ****
if (!dirty)
! goto out_unlock;
set_bits_back:
__set_page_dirty(page);
ClearPageLaunder(page);
- out_unlock:
- UnlockPage(page);
out_release:
page_cache_release(page);
return comp_page;
! new_page:
/* remove from free space hash table before update */
remove_comp_page_from_hash_table(comp_page);
--- 433,455 ----
if (!dirty)
! goto out_release;
set_bits_back:
__set_page_dirty(page);
ClearPageLaunder(page);
out_release:
page_cache_release(page);
+ /* debug */
+ if (comp_page && comp_page->page) {
+ if (comp_page->page->mapping)
+ BUG();
+ if (comp_page->page->buffers)
+ BUG();
+ if (page_count(comp_page->page) != 1)
+ BUG();
+ }
return comp_page;
! alloc_new_page:
/* remove from free space hash table before update */
remove_comp_page_from_hash_table(comp_page);
***************
*** 406,415 ****
if (comp_page->page)
BUG();
!
! comp_page->page = alloc_page(GFP_KERNEL);
! if (!comp_page->page)
! panic("get_comp_cache_page(): cannot allocate page");
if (TryLockPage(comp_page->page))
BUG();
--- 457,468 ----
if (comp_page->page)
BUG();
!
! new_page = alloc_page(gfp_mask);
! if (!new_page)
! goto failed;
+ set_comp_page(comp_page, new_page);
+
if (TryLockPage(comp_page->page))
BUG();
***************
*** 523,531 ****
failed:
add_comp_page_to_hash_table(comp_page);
! UnlockPage(comp_page->page);
comp_page = NULL;
if (!dirty)
! goto out_unlock;
goto set_bits_back;
}
--- 576,585 ----
failed:
add_comp_page_to_hash_table(comp_page);
! if (comp_page->page)
! UnlockPage(comp_page->page);
comp_page = NULL;
if (!dirty)
! goto out_release;
goto set_bits_back;
}
|
|
From: Rodrigo S. de C. <rc...@us...> - 2002-05-31 16:48:58
|
Update of /cvsroot/linuxcompressed/linux/mm
In directory usw-pr-cvs1:/tmp/cvs-serv26610/mm
Modified Files:
filemap.c
Log Message:
- Back out fixes for FS corruption under UML
- Swap buffer management was partially rewritten to fix another potential
bug which could hang the machine. Besides, get_comp_cache_page() now first
tries to free pages that have already been written by the swap buffers. Only
if it really can't make it, it writes out more fragments.
Index: filemap.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/filemap.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -r1.26 -r1.27
*** filemap.c 28 May 2002 19:16:14 -0000 1.26
--- filemap.c 31 May 2002 16:48:53 -0000 1.27
***************
*** 757,763 ****
int error = 0;
#ifdef CONFIG_COMP_PAGE_CACHE
! if (!read_comp_cache(mapping, offset, page))
! SetPageUptodate(page);
! else
#endif
error = mapping->a_ops->readpage(file, page);
--- 757,761 ----
int error = 0;
#ifdef CONFIG_COMP_PAGE_CACHE
! if (read_comp_cache(mapping, offset, page))
#endif
error = mapping->a_ops->readpage(file, page);
***************
*** 1614,1621 ****
#ifdef CONFIG_COMP_PAGE_CACHE
! if (!read_comp_cache(mapping, index, page)) {
! SetPageUptodate(page);
goto page_ok;
- }
#endif
goto readpage;
--- 1612,1617 ----
#ifdef CONFIG_COMP_PAGE_CACHE
! if (!read_comp_cache(mapping, index, page))
goto page_ok;
#endif
goto readpage;
***************
*** 2918,2924 ****
#ifdef CONFIG_COMP_PAGE_CACHE
! if (!read_comp_cache(mapping, index, page))
! SetPageUptodate(page);
! else
#endif
err = filler(data, page);
--- 2914,2918 ----
#ifdef CONFIG_COMP_PAGE_CACHE
! if (read_comp_cache(mapping, index, page))
#endif
err = filler(data, page);
|
|
From: Rodrigo S. de C. <rc...@us...> - 2002-05-31 16:48:58
|
Update of /cvsroot/linuxcompressed/linux/mm/comp_cache
In directory usw-pr-cvs1:/tmp/cvs-serv26610/mm/comp_cache
Modified Files:
main.c swapin.c swapout.c
Log Message:
- Back out fixes for FS corruption under UML
- Swap buffer management was partially rewritten to fix another potential
bug which could hang the machine. Besides, get_comp_cache_page() now first
tries to free pages that have already been written by the swap buffers. Only
if it really can't make it, it writes out more fragments.
Index: main.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/main.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -C2 -r1.41 -r1.42
*** main.c 28 May 2002 19:16:15 -0000 1.41
--- main.c 31 May 2002 16:48:53 -0000 1.42
***************
*** 2,6 ****
* linux/mm/comp_cache/main.c
*
! * Time-stamp: <2002-05-28 14:42:21 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/main.c
*
! * Time-stamp: <2002-05-31 13:12:36 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 15,21 ****
#include <linux/init.h>
#include <linux/pagemap.h>
#include <asm/page.h>
- #include <net/checksum.h>
/* compressed cache control variables */
--- 15,21 ----
#include <linux/init.h>
#include <linux/pagemap.h>
+ #include <linux/slab.h>
#include <asm/page.h>
/* compressed cache control variables */
***************
*** 131,135 ****
} else
memcpy(page_address(comp_page->page), page_address(page), PAGE_SIZE);
-
if (PageTestandSetCompCache(page))
--- 131,134 ----
Index: swapin.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/swapin.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -r1.36 -r1.37
*** swapin.c 28 May 2002 19:16:15 -0000 1.36
--- swapin.c 31 May 2002 16:48:53 -0000 1.37
***************
*** 2,6 ****
* linux/mm/comp_cache/swapin.c
*
! * Time-stamp: <2002-05-28 14:27:51 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/swapin.c
*
! * Time-stamp: <2002-05-31 13:04:02 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 17,21 ****
#include <asm/uaccess.h>
- #include <net/checksum.h>
int
--- 17,20 ----
***************
*** 84,88 ****
memcpy(page_address(page), page_address(comp_page->page), PAGE_SIZE);
! PageSetCompCache(page);
}
--- 83,88 ----
memcpy(page_address(page), page_address(comp_page->page), PAGE_SIZE);
! PageSetCompCache(page);
! SetPageUptodate(page);
}
***************
*** 114,118 ****
decompress_fragment(fragment, page);
!
/* update fault in stats */
comp_cache_update_faultin_stats(fragment);
--- 114,118 ----
decompress_fragment(fragment, page);
!
/* update fault in stats */
comp_cache_update_faultin_stats(fragment);
Index: swapout.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/swapout.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -r1.46 -r1.47
*** swapout.c 28 May 2002 19:16:15 -0000 1.46
--- swapout.c 31 May 2002 16:48:53 -0000 1.47
***************
*** 2,6 ****
* /mm/comp_cache/swapout.c
*
! * Time-stamp: <2002-05-28 14:51:56 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* /mm/comp_cache/swapout.c
*
! * Time-stamp: <2002-05-31 13:32:50 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 23,61 ****
struct list_head swp_free_buffer_head, swp_used_buffer_head;
! /**
! * find_free_swp_buffer - gets a swap buffer page
! * @fragment: the fragment which will be decompressed to this buffer
! * page.
! *
! * If there's a free buffer page, it will lock the page and
! * return. Otherwise we may sleep to get the lock.
! *
! */
! static struct swp_buffer *
! find_free_swp_buffer(comp_cache_fragment_t * fragment, unsigned int gfp_mask)
{
struct page * buffer_page;
- struct list_head * swp_buffer_lh, * tmp_lh;
struct swp_buffer * swp_buffer;
! comp_cache_fragment_t * old_fragment;
! int wait, maxscan = NUM_SWP_BUFFERS >> 2;
!
! if (!fragment)
! BUG();
!
! CompFragmentSetIO(fragment);
! if (!list_empty(&swp_free_buffer_head))
! goto get_a_page;
- wait = 0;
try_again:
! list_for_each_safe(swp_buffer_lh, tmp_lh, &swp_used_buffer_head) {
swp_buffer = list_entry(swp_buffer_lh, struct swp_buffer, list);
buffer_page = swp_buffer->page;
! old_fragment = swp_buffer->fragment;
! if (!maxscan--)
! break;
if (TryLockPage(buffer_page)) {
--- 23,48 ----
struct list_head swp_free_buffer_head, swp_used_buffer_head;
! static int
! refill_swp_buffer(unsigned int gfp_mask, int num_pages)
{
+ struct list_head * swp_buffer_lh;
struct page * buffer_page;
struct swp_buffer * swp_buffer;
! comp_cache_fragment_t * fragment;
! unsigned int gfp_mask_buffer;
! int wait, maxscan;
! gfp_mask_buffer = gfp_mask & ~__GFP_IO;
! maxscan = max(NUM_SWP_BUFFERS >> 2, (int) (num_pages * 1.5));
! wait = 0;
try_again:
! while(--maxscan >= 0 && (swp_buffer_lh = swp_used_buffer_head.prev) != &swp_used_buffer_head) {
swp_buffer = list_entry(swp_buffer_lh, struct swp_buffer, list);
buffer_page = swp_buffer->page;
! fragment = swp_buffer->fragment;
! list_del(swp_buffer_lh);
! list_add(swp_buffer_lh, &swp_used_buffer_head);
if (TryLockPage(buffer_page)) {
***************
*** 65,89 ****
lock_page(buffer_page);
}
!
/* its fragment was added to locked_pages list below,
* right before being returned to the caller, so let's
* remove it now from any mapping->*_pages list */
list_del(&buffer_page->list);
!
if (buffer_page->buffers) {
- unsigned int gfp_mask_buffer = gfp_mask;
-
- /***
- * we would like to try freeing the buffers
- * without syncing them to disk at this first
- * try, so let's get rid of __GFP_IO flag
- */
- if (!wait)
- gfp_mask_buffer &= ~__GFP_IO;
list_del_init(swp_buffer_lh);
if (!try_to_free_buffers(buffer_page, gfp_mask_buffer)) {
! list_add_tail(swp_buffer_lh, &swp_used_buffer_head);
! list_add(&buffer_page->list, &old_fragment->mapping->locked_comp_pages);
UnlockPage(buffer_page);
continue;
--- 52,67 ----
lock_page(buffer_page);
}
!
/* its fragment was added to locked_pages list below,
* right before being returned to the caller, so let's
* remove it now from any mapping->*_pages list */
list_del(&buffer_page->list);
!
if (buffer_page->buffers) {
list_del_init(swp_buffer_lh);
if (!try_to_free_buffers(buffer_page, gfp_mask_buffer)) {
! list_add(swp_buffer_lh, &swp_used_buffer_head);
! list_add(&buffer_page->list, &fragment->mapping->locked_comp_pages);
UnlockPage(buffer_page);
continue;
***************
*** 91,98 ****
}
! /* has the fragment we are swapping out been swapped
! * in? so let's free only the fragment struct */
! if (!CompFragmentIO(old_fragment)) {
! kmem_cache_free(fragment_cachep, (old_fragment));
goto out;
}
--- 69,78 ----
}
! /* has the fragment we are swapping out been already
! * freed? Given that we were on IO process,
! * comp_cache_free() didn't free the fragment struct,
! * so let's do it now */
! if (!CompFragmentIO(fragment)) {
! kmem_cache_free(fragment_cachep, (fragment));
goto out;
}
***************
*** 100,111 ****
/* in the case it is waiting for merge in
* comp_cache_free(), we can't free it */
! if (!old_fragment->mapping) {
! CompFragmentClearIO(old_fragment);
goto out;
}
/* it's not swapped out, so let' free it */
! CompFragmentClearIO(old_fragment);
! comp_cache_free(old_fragment);
out:
--- 80,91 ----
/* in the case it is waiting for merge in
* comp_cache_free(), we can't free it */
! if (!fragment->mapping) {
! CompFragmentClearIO(fragment);
goto out;
}
/* it's not swapped out, so let' free it */
! CompFragmentClearIO(fragment);
! comp_cache_free(fragment);
out:
***************
*** 115,144 ****
list_add_tail(swp_buffer_lh, &swp_free_buffer_head);
- /* has the fragment been totally (!IO) or partially
- * freed (Freed)? no need to swap it out any longer */
- if (!CompFragmentIO(fragment) || CompFragmentFreed(fragment)) {
- CompFragmentClearIO(fragment);
- UnlockPage(buffer_page);
- return NULL;
- }
-
UnlockPage(buffer_page);
!
! if (wait)
! goto get_a_page;
}
! /* couldn't free any swap buffer? so let's IO to finish */
! if (list_empty(&swp_free_buffer_head)) {
! maxscan = wait = 1;
! if (unlikely(current->need_resched)) {
! __set_current_state(TASK_RUNNING);
! schedule();
! }
goto try_again;
}
get_a_page:
! swp_buffer = list_entry(swp_buffer_lh = swp_free_buffer_head.next, struct swp_buffer, list);
buffer_page = swp_buffer->page;
--- 95,152 ----
list_add_tail(swp_buffer_lh, &swp_free_buffer_head);
UnlockPage(buffer_page);
! --num_pages;
}
! /* couldn't free any swap buffer? so let's perform IO, if
! * gfp_mask allows, to free the page buffers */
! 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);
goto try_again;
}
+
+ return (num_pages > 0?0:1);
+ }
+
+
+ /**
+ * find_free_swp_buffer - gets a swap buffer page
+ * @fragment: the fragment which will be decompressed to this buffer
+ * page.
+ *
+ * If there's a free buffer page, it will lock the page and
+ * return. Otherwise we may sleep to get the lock.
+ *
+ */
+ static struct swp_buffer *
+ find_free_swp_buffer(comp_cache_fragment_t * fragment, unsigned int gfp_mask)
+ {
+ struct page * buffer_page;
+ struct list_head * swp_buffer_lh;
+ struct swp_buffer * swp_buffer;
+
+ if (!fragment)
+ BUG();
+
+ CompFragmentSetIO(fragment);
+
+ if (!list_empty(&swp_free_buffer_head))
+ goto get_a_page;
+
+ if (!refill_swp_buffer(gfp_mask, 1))
+ panic("couldn't free a swap buffer\n");
+
+ /* has the fragment been totally (!IO) or partially
+ * freed (Freed)? no need to swap it out any longer */
+ if (!CompFragmentIO(fragment) || CompFragmentFreed(fragment)) {
+ CompFragmentClearIO(fragment);
+ return NULL;
+ }
get_a_page:
! swp_buffer = list_entry(swp_buffer_lh = swp_free_buffer_head.prev, struct swp_buffer, list);
buffer_page = swp_buffer->page;
***************
*** 148,152 ****
list_del(swp_buffer_lh);
! list_add_tail(swp_buffer_lh, &swp_used_buffer_head);
swp_buffer->fragment = fragment;
--- 156,160 ----
list_del(swp_buffer_lh);
! list_add(swp_buffer_lh, &swp_used_buffer_head);
swp_buffer->fragment = fragment;
***************
*** 365,370 ****
UnlockPage(page);
!
! writeout_fragments(gfp_mask);
if (TryLockPage(page)) {
--- 373,379 ----
UnlockPage(page);
!
! if (!refill_swp_buffer(gfp_mask, SWAP_CLUSTER_MAX >> 2))
! writeout_fragments(gfp_mask);
if (TryLockPage(page)) {
|
|
From: Rodrigo S. de C. <rc...@us...> - 2002-05-30 16:33:22
|
Update of /cvsroot/linuxcompressed/linux/mm/comp_cache
In directory usw-pr-cvs1:/tmp/cvs-serv6396/mm/comp_cache
Modified Files:
proc.c
Log Message:
Added a new kernel parameter ("compalg=") which selects the initial
compression algorithm.
0 - WKdm (default)
1 - WK4x4
2 - LZO
Index: proc.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/proc.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** proc.c 29 May 2002 21:28:55 -0000 1.12
--- proc.c 30 May 2002 16:33:18 -0000 1.13
***************
*** 2,6 ****
* linux/mm/comp_cache/proc.c
*
! * Time-stamp: <2002-05-29 18:16:35 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/proc.c
*
! * Time-stamp: <2002-05-30 13:21:25 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 30,34 ****
static int algorithm_min = WKDM_IDX;
static int algorithm_max = LZO_IDX;
! static int current_algorithm;
/* data used for compression */
--- 30,34 ----
static int algorithm_min = WKDM_IDX;
static int algorithm_max = LZO_IDX;
! static int current_algorithm = 0;
/* data used for compression */
***************
*** 238,241 ****
--- 238,243 ----
comp_cache_algorithms_init(void)
{
+ int i;
+
/* initialize our data for the `test' compressed_page */
comp_data.compressed_data = compresseddata;
***************
*** 248,256 ****
comp_data.tempLowBitsArray = compressedtempLowBitsArray;
! for (current_algorithm = 0; current_algorithm < NUM_ALGORITHMS; current_algorithm++) {
! memset((void *) &compression_algorithms[current_algorithm], 0, sizeof(stats_summary_t));
! compression_algorithms[current_algorithm].stats.comp_size_min = INF;
! compression_algorithms[current_algorithm].stats.comp_cycles_min = INF;
! compression_algorithms[current_algorithm].stats.decomp_cycles_min = INF;
}
--- 250,258 ----
comp_data.tempLowBitsArray = compressedtempLowBitsArray;
! for (i = 0; i < NUM_ALGORITHMS; i++) {
! memset((void *) &compression_algorithms[i], 0, sizeof(stats_summary_t));
! compression_algorithms[i].stats.comp_size_min = INF;
! compression_algorithms[i].stats.comp_cycles_min = INF;
! compression_algorithms[i].stats.decomp_cycles_min = INF;
}
***************
*** 270,275 ****
if (!wrkmem)
panic("comp_cache_algorithms_init(): cannot allocate wrkmem (for LZO)");
!
! current_algorithm = WKDM_IDX;
}
--- 272,280 ----
if (!wrkmem)
panic("comp_cache_algorithms_init(): cannot allocate wrkmem (for LZO)");
!
! if (!current_algorithm || current_algorithm < algorithm_min || current_algorithm > algorithm_max)
! current_algorithm = WKDM_IDX;
!
! printk("Compressed Cache: initial compression algorithm: %s\n", compression_algorithms[current_algorithm].name);
}
***************
*** 432,435 ****
--- 437,451 ----
return proc_calc_metrics(page, start, off, count, eof, length);
}
+
+ static int __init comp_cache_alg(char *str)
+ {
+ char * endp;
+
+ current_algorithm = simple_strtoul(str, &endp, 0);
+ return 1;
+ }
+
+ __setup("compalg=", comp_cache_alg);
+
/*
|
|
From: Rodrigo S. de C. <rc...@us...> - 2002-05-30 16:33:21
|
Update of /cvsroot/linuxcompressed/linux/include/linux
In directory usw-pr-cvs1:/tmp/cvs-serv6396/include/linux
Modified Files:
comp_cache.h
Log Message:
Added a new kernel parameter ("compalg=") which selects the initial
compression algorithm.
0 - WKdm (default)
1 - WK4x4
2 - LZO
Index: comp_cache.h
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/include/linux/comp_cache.h,v
retrieving revision 1.71
retrieving revision 1.72
diff -C2 -r1.71 -r1.72
*** comp_cache.h 29 May 2002 21:28:54 -0000 1.71
--- comp_cache.h 30 May 2002 16:33:17 -0000 1.72
***************
*** 2,6 ****
* linux/mm/comp_cache.h
*
! * Time-stamp: <2002-05-29 18:14:38 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache.h
*
! * Time-stamp: <2002-05-30 13:12:50 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 29,33 ****
#include <linux/WKcommon.h>
! #define COMP_CACHE_VERSION "0.23pre5"
/* maximum compressed size of a page */
--- 29,33 ----
#include <linux/WKcommon.h>
! #define COMP_CACHE_VERSION "0.23pre6"
/* maximum compressed size of a page */
|
|
From: Rodrigo S. de C. <rc...@us...> - 2002-05-30 13:56:12
|
Update of /cvsroot/linuxcompressed/linux/mm/comp_cache In directory usw-pr-cvs1:/tmp/cvs-serv16955/mm/comp_cache Modified Files: adaptivity.c Log Message: Fixed typo that caused compilation error Index: adaptivity.c =================================================================== RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/adaptivity.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -r1.20 -r1.21 *** adaptivity.c 29 May 2002 21:28:54 -0000 1.20 --- adaptivity.c 30 May 2002 13:56:09 -0000 1.21 *************** *** 2,6 **** * linux/mm/comp_cache/adaptivity.c * ! * Time-stamp: <2002-05-29 18:17:59 rcastro> * * Linux Virtual Memory Compressed Cache --- 2,6 ---- * linux/mm/comp_cache/adaptivity.c * ! * Time-stamp: <2002-05-30 10:50:05 rcastro> * * Linux Virtual Memory Compressed Cache *************** *** 26,30 **** #define comp_cache_total_space (preset_comp_cache[i].size * PAGE_SIZE) ! exter void comp_cache_fix_watermarks(int); /*** --- 26,30 ---- #define comp_cache_total_space (preset_comp_cache[i].size * PAGE_SIZE) ! extern void comp_cache_fix_watermarks(int); /*** |
|
From: Rodrigo S. de C. <rc...@us...> - 2002-05-29 21:28:58
|
Update of /cvsroot/linuxcompressed/linux/include/linux In directory usw-pr-cvs1:/tmp/cvs-serv29510/include/linux Modified Files: comp_cache.h Added Files: lzoconf.h minilzo.h Log Message: - Support for LZO compression algorithm is back echo 2 > /proc/sys/vm/comp_cache/algorithm - Now there is a /proc/comp_cache_hist that shows the free space histogram. That histogram now also displays how many fragments the pages have, so you have a better picture of what's going on in the compressed cache. Index: comp_cache.h =================================================================== RCS file: /cvsroot/linuxcompressed/linux/include/linux/comp_cache.h,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -r1.70 -r1.71 *** comp_cache.h 29 May 2002 13:05:22 -0000 1.70 --- comp_cache.h 29 May 2002 21:28:54 -0000 1.71 *************** *** 2,6 **** * linux/mm/comp_cache.h * ! * Time-stamp: <2002-05-28 17:33:09 rcastro> * * Linux Virtual Memory Compressed Cache --- 2,6 ---- * linux/mm/comp_cache.h * ! * Time-stamp: <2002-05-29 18:14:38 rcastro> * * Linux Virtual Memory Compressed Cache *************** *** 136,146 **** #define CF_IO 1 ! /* CF_WKdm/CF_WK4x4: defines the algorithm the fragment has been ! * compressed (if it's been compressed) */ #define CF_WKdm 2 #define CF_WK4x4 3 /* CF_Dirty: is the fragment dirty? */ ! #define CF_Dirty 4 #define CompFragmentFreed(fragment) test_bit(CF_Freed, &(fragment)->flags) --- 136,147 ---- #define CF_IO 1 ! /* CF_WKdm/CF_WK4x4/CF_LZO: defines the algorithm the fragment has ! * been compressed (if it's been compressed) */ #define CF_WKdm 2 #define CF_WK4x4 3 + #define CF_LZO 4 /* CF_Dirty: is the fragment dirty? */ ! #define CF_Dirty 5 #define CompFragmentFreed(fragment) test_bit(CF_Freed, &(fragment)->flags) *************** *** 166,169 **** --- 167,175 ---- #define CompFragmentClearWK4x4(fragment) clear_bit(CF_WK4x4, &(fragment)->flags) + #define CompFragmentLZO(fragment) test_bit(CF_LZO, &(fragment)->flags) + #define CompFragmentSetLZO(fragment) set_bit(CF_LZO, &(fragment)->flags) + #define CompFragmentTestandSetLZO(fragment) test_and_set_bit(CF_LZO, &(fragment)->flags) + #define CompFragmentClearLZO(fragment) clear_bit(CF_LZO, &(fragment)->flags) + #define CompFragmentDirty(fragment) test_bit(CF_Dirty, &(fragment)->flags) #define CompFragmentSetDirty(fragment) set_bit(CF_Dirty, &(fragment)->flags) *************** *** 273,276 **** --- 279,284 ---- WK_word *tempQPosArray; WK_word *tempLowBitsArray; + + unsigned short compressed_size; } comp_data_t; *************** *** 539,543 **** void print_comp_cache_stats(unsigned short, char *, int *); int comp_cache_stat_read_proc(char *, char **, off_t, int, int *, void *); ! unsigned long free_space_count(int); --- 547,552 ---- void print_comp_cache_stats(unsigned short, char *, int *); int comp_cache_stat_read_proc(char *, char **, off_t, int, int *, void *); ! int comp_cache_hist_read_proc(char *, char **, off_t, int, int *, void *); ! unsigned long free_space_count(int, unsigned long *); |
|
From: Rodrigo S. de C. <rc...@us...> - 2002-05-29 21:28:58
|
Update of /cvsroot/linuxcompressed/linux/mm/comp_cache
In directory usw-pr-cvs1:/tmp/cvs-serv29510/mm/comp_cache
Modified Files:
Makefile adaptivity.c aux.c proc.c
Added Files:
minilzo.c
Log Message:
- Support for LZO compression algorithm is back
echo 2 > /proc/sys/vm/comp_cache/algorithm
- Now there is a /proc/comp_cache_hist that shows the free space histogram.
That histogram now also displays how many fragments the pages have, so you
have a better picture of what's going on in the compressed cache.
--- NEW FILE ---
/* minilzo.c -- mini subset of the LZO real-time data compression library
This file is part of the LZO real-time data compression library.
Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
The LZO library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
The LZO library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
[...2809 lines suppressed...]
input_overrun:
*out_len = op - out;
return LZO_E_INPUT_OVERRUN;
#endif
#if defined(HAVE_NEED_OP)
output_overrun:
*out_len = op - out;
return LZO_E_OUTPUT_OVERRUN;
#endif
#if defined(LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND)
lookbehind_overrun:
*out_len = op - out;
return LZO_E_LOOKBEHIND_OVERRUN;
#endif
}
/***** End of minilzo.c *****/
Index: Makefile
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/Makefile,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** Makefile 21 Mar 2002 19:24:17 -0000 1.7
--- Makefile 29 May 2002 21:28:54 -0000 1.8
***************
*** 7,11 ****
export-objs := swapin.o
! obj-y := main.o vswap.o free.o swapout.o swapin.o adaptivity.o aux.o proc.o WK4x4.o WKdm.o
include $(TOPDIR)/Rules.make
--- 7,11 ----
export-objs := swapin.o
! obj-y := main.o vswap.o free.o swapout.o swapin.o adaptivity.o aux.o proc.o WK4x4.o WKdm.o minilzo.o
include $(TOPDIR)/Rules.make
Index: adaptivity.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/adaptivity.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** adaptivity.c 28 May 2002 19:16:15 -0000 1.19
--- adaptivity.c 29 May 2002 21:28:54 -0000 1.20
***************
*** 2,6 ****
* linux/mm/comp_cache/adaptivity.c
*
! * Time-stamp: <2002-05-28 15:44:25 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/adaptivity.c
*
! * Time-stamp: <2002-05-29 18:17:59 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 25,28 ****
--- 25,30 ----
#define comp_cache_total_space (preset_comp_cache[i].size * PAGE_SIZE)
+
+ exter void comp_cache_fix_watermarks(int);
/***
Index: aux.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/aux.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -r1.27 -r1.28
*** aux.c 29 May 2002 13:05:25 -0000 1.27
--- aux.c 29 May 2002 21:28:54 -0000 1.28
***************
*** 2,6 ****
* linux/mm/comp_cache/aux.c
*
! * Time-stamp: <2002-05-28 17:32:52 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/aux.c
*
! * Time-stamp: <2002-05-29 17:13:08 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 165,171 ****
unsigned long
! free_space_count(int index) {
comp_cache_t * comp_page;
! unsigned long total;
if (index < 0)
--- 165,172 ----
unsigned long
! free_space_count(int index, unsigned long * num_fragments) {
comp_cache_t * comp_page;
! unsigned long total, total_fragments;
! struct list_head * fragment_lh;
if (index < 0)
***************
*** 174,179 ****
if (index >= free_space_hash_size)
BUG();
!
! for (comp_page = free_space_hash[index], total = 0; comp_page; comp_page = comp_page->next_hash, total++);
return total;
--- 175,190 ----
if (index >= free_space_hash_size)
BUG();
!
! for (comp_page = free_space_hash[index], total = 0; comp_page; comp_page = comp_page->next_hash, total++) {
! total_fragments = 0;
!
! for_each_fragment(fragment_lh, comp_page)
! total_fragments++;
!
! if (total_fragments > 3)
! num_fragments[3]++;
! else
! num_fragments[total_fragments]++;
! }
return total;
Index: proc.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/proc.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** proc.c 29 May 2002 13:05:26 -0000 1.11
--- proc.c 29 May 2002 21:28:55 -0000 1.12
***************
*** 2,6 ****
* linux/mm/comp_cache/proc.c
*
! * Time-stamp: <2002-05-28 17:56:39 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/proc.c
*
! * Time-stamp: <2002-05-29 18:16:35 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 12,23 ****
#include <linux/comp_cache.h>
#include <linux/sysctl.h>
#include <linux/WKcommon.h>
#include <linux/WKdm.h>
#include <linux/WK4x4.h>
! #define NUM_ALGORITHMS 2
#define WKDM_IDX 0
#define WK4X4_IDX 1
extern unsigned long new_num_comp_pages, max_num_comp_pages, min_num_comp_pages;
--- 12,27 ----
#include <linux/comp_cache.h>
#include <linux/sysctl.h>
+ #include <linux/slab.h>
+ #include <linux/vmalloc.h>
#include <linux/WKcommon.h>
#include <linux/WKdm.h>
#include <linux/WK4x4.h>
+ #include <linux/minilzo.h>
! #define NUM_ALGORITHMS 3
#define WKDM_IDX 0
#define WK4X4_IDX 1
+ #define LZO_IDX 2
extern unsigned long new_num_comp_pages, max_num_comp_pages, min_num_comp_pages;
***************
*** 25,29 ****
static compression_algorithm_t compression_algorithms[NUM_ALGORITHMS];
static int algorithm_min = WKDM_IDX;
! static int algorithm_max = WK4X4_IDX;
static int current_algorithm;
--- 29,33 ----
static compression_algorithm_t compression_algorithms[NUM_ALGORITHMS];
static int algorithm_min = WKDM_IDX;
! static int algorithm_max = LZO_IDX;
static int current_algorithm;
***************
*** 41,44 ****
--- 45,50 ----
static DictionaryElement compresseddictionary[DICTIONARY_SIZE];
+ lzo_byte * wrkmem;
+
enum
{
***************
*** 146,153 ****
set_fragment_algorithm(comp_cache_fragment_t * fragment, unsigned short algorithm)
{
! if (algorithm == WKDM_IDX)
CompFragmentSetWKdm(fragment);
! else
CompFragmentSetWK4x4(fragment);
}
--- 152,196 ----
set_fragment_algorithm(comp_cache_fragment_t * fragment, unsigned short algorithm)
{
! switch (algorithm) {
! case WKDM_IDX:
CompFragmentSetWKdm(fragment);
! break;
! case WK4X4_IDX:
CompFragmentSetWK4x4(fragment);
+ break;
+ case LZO_IDX:
+ CompFragmentSetLZO(fragment);
+ break;
+ default:
+ BUG();
+ }
+ }
+
+ static unsigned int
+ lzo_wrapper_compress(unsigned long * from, unsigned long * to, unsigned int words, void * page)
+ {
+ int error;
+ lzo_uint out_len;
+
+ error = lzo1x_1_compress((lzo_byte *) from, words * sizeof(unsigned long), (lzo_byte *) to, &out_len, wrkmem);
+
+ if (error != LZO_E_OK)
+ BUG();
+
+ return out_len;
+ }
+
+ static void
+ lzo_wrapper_decompress(unsigned long * from, unsigned long * to, unsigned int words, void * page)
+ {
+ int error;
+ lzo_uint new_len;
+
+ error = lzo1x_decompress((lzo_byte *) from, ((comp_data_t *) page)->compressed_size, (lzo_byte *) to, &new_len, NULL);
+
+ if (error != LZO_E_OK || new_len != PAGE_SIZE) {
+ printk(KERN_EMERG "internal error - decompression failed: %d\n", error);
+ BUG();
+ }
}
***************
*** 174,185 ****
{
stats_page_t comp_page_stats;
void * from = page_address(fragment->comp_page->page) + fragment->offset;
void * to = page_address(page);
- unsigned int algorithm;
! if (CompFragmentWKdm(fragment))
! algorithm = WKDM_IDX;
! else
algorithm = WK4X4_IDX;
START_ZEN_TIME(comp_page_stats.myTimer);
--- 217,230 ----
{
stats_page_t comp_page_stats;
+ unsigned int algorithm = WKDM_IDX;
void * from = page_address(fragment->comp_page->page) + fragment->offset;
void * to = page_address(page);
! if (CompFragmentWK4x4(fragment))
algorithm = WK4X4_IDX;
+ else if (CompFragmentLZO(fragment)) {
+ algorithm = LZO_IDX;
+ comp_data.compressed_size = fragment->compressed_size;
+ }
START_ZEN_TIME(comp_page_stats.myTimer);
***************
*** 217,220 ****
--- 262,273 ----
compression_algorithms[WK4X4_IDX].comp = WK4x4_compress;
compression_algorithms[WK4X4_IDX].decomp = WK4x4_decompress;
+
+ strcpy(compression_algorithms[LZO_IDX].name, "LZO");
+ compression_algorithms[LZO_IDX].comp = lzo_wrapper_compress;
+ compression_algorithms[LZO_IDX].decomp = lzo_wrapper_decompress;
+
+ wrkmem = (lzo_byte *) kmalloc(LZO1X_1_MEM_COMPRESS, GFP_ATOMIC);
+ if (!wrkmem)
+ panic("comp_cache_algorithms_init(): cannot allocate wrkmem (for LZO)");
current_algorithm = WKDM_IDX;
***************
*** 237,241 ****
print_comp_cache_stats(unsigned short alg_idx, char * page, int * length)
{
! unsigned int compression_ratio, discard_ratio, i;
unsigned int mean_size, mean_comp_cycles, mean_decomp_cycles;
unsigned long total_comp_pages, total_wout_pages, total_decomp_pages, total_faultin_pages;
--- 290,294 ----
print_comp_cache_stats(unsigned short alg_idx, char * page, int * length)
{
! unsigned int compression_ratio, discard_ratio;
unsigned int mean_size, mean_comp_cycles, mean_decomp_cycles;
unsigned long total_comp_pages, total_wout_pages, total_decomp_pages, total_faultin_pages;
***************
*** 314,335 ****
stats->decomp_cycles_max,
mean_decomp_cycles);
!
! *length += sprintf(page + *length,
! "Free Space Histogram\n"
! " Zero: %8lu\n",
! free_space_count(0));
! for (i = 1; i < free_space_hash_size - 1; i += 2) {
! *length += sprintf(page + *length,
! " %4d - %4d: %8lu\n",
! (i+1)*100-200?:1, (i+1)*100,
! free_space_count(i) + free_space_count(i+1));
}
! *length += sprintf(page + *length,
! " Page Size: %8lu\n",
! free_space_count(free_space_hash_size - 1));
!
}
--- 367,423 ----
stats->decomp_cycles_max,
mean_decomp_cycles);
! }
! #define FRAGMENTS_PRINTK num_fragments[0], num_fragments[1], num_fragments[2], num_fragments[3], num_fragments[4]
! #define FRAGMENTS_COUNT 5
!
! int
! comp_cache_hist_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data)
! {
! unsigned long * num_fragments, total1, total2;
! int length = 0, i;
!
! num_fragments = (unsigned long *) vmalloc(FRAGMENTS_COUNT * sizeof(unsigned long));
!
! if (!num_fragments) {
! printk("couldn't allocate data structures for free space histogram\n");
! goto out;
}
! length = sprintf(page, "compressed cache - free space histogram\n");
!
! memset((void *) num_fragments, 0, FRAGMENTS_COUNT * sizeof(unsigned long));
!
! total1 = free_space_count(0, num_fragments);
! length += sprintf(page + length,
! " total 0f 1f 2f 3f more\n"
! " %4d: %8lu %5lu %5lu %5lu %5lu %5lu\n",
! 0,
! total1,
! FRAGMENTS_PRINTK);
!
! for (i = 1; i < free_space_hash_size - 1; i += 2) {
! memset((void *) num_fragments, 0, FRAGMENTS_COUNT * sizeof(unsigned long));
! total1 = free_space_count(i, num_fragments);
! total2 = free_space_count(i + 1, num_fragments);
!
! length += sprintf(page + length,
! "%4d - %4d: %8lu %5lu %5lu %5lu %5lu %5lu\n",
! (i+1)*100-200?:1, (i+1)*100, total1 + total2,
! FRAGMENTS_PRINTK);
! }
!
! memset((void *) num_fragments, 0, FRAGMENTS_COUNT * sizeof(unsigned long));
! total1 = free_space_count(free_space_hash_size - 1, num_fragments);
! length += sprintf(page + length,
! "%4d - %4d: %8lu %5lu %5lu %5lu %5lu %5lu\n",
! (free_space_hash_size - 2) * 100 + 1, (int) PAGE_SIZE,
! total1,
! FRAGMENTS_PRINTK);
!
! vfree(num_fragments);
! out:
! return proc_calc_metrics(page, start, off, count, eof, length);
}
|
|
From: Rodrigo S. de C. <rc...@us...> - 2002-05-29 21:28:58
|
Update of /cvsroot/linuxcompressed/linux/fs/proc
In directory usw-pr-cvs1:/tmp/cvs-serv29510/fs/proc
Modified Files:
proc_misc.c
Log Message:
- Support for LZO compression algorithm is back
echo 2 > /proc/sys/vm/comp_cache/algorithm
- Now there is a /proc/comp_cache_hist that shows the free space histogram.
That histogram now also displays how many fragments the pages have, so you
have a better picture of what's going on in the compressed cache.
Index: proc_misc.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/fs/proc/proc_misc.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** proc_misc.c 15 May 2002 18:05:35 -0000 1.4
--- proc_misc.c 29 May 2002 21:28:54 -0000 1.5
***************
*** 525,528 ****
--- 525,529 ----
#ifdef CONFIG_COMP_CACHE
{"comp_cache_stat", comp_cache_stat_read_proc},
+ {"comp_cache_hist", comp_cache_hist_read_proc},
#endif
{"devices", devices_read_proc},
|
|
From: Rodrigo S. de C. <rc...@us...> - 2002-05-29 13:05:30
|
Update of /cvsroot/linuxcompressed/linux/include/linux In directory usw-pr-cvs1:/tmp/cvs-serv29963/include/linux Modified Files: comp_cache.h Log Message: Add "Free Space Histogram" section to /proc/comp_cache_stat Index: comp_cache.h =================================================================== RCS file: /cvsroot/linuxcompressed/linux/include/linux/comp_cache.h,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -r1.69 -r1.70 *** comp_cache.h 28 May 2002 19:16:14 -0000 1.69 --- comp_cache.h 29 May 2002 13:05:22 -0000 1.70 *************** *** 2,6 **** * linux/mm/comp_cache.h * ! * Time-stamp: <2002-05-26 12:08:33 rcastro> * * Linux Virtual Memory Compressed Cache --- 2,6 ---- * linux/mm/comp_cache.h * ! * Time-stamp: <2002-05-28 17:33:09 rcastro> * * Linux Virtual Memory Compressed Cache *************** *** 539,542 **** --- 539,544 ---- void print_comp_cache_stats(unsigned short, char *, int *); int comp_cache_stat_read_proc(char *, char **, off_t, int, int *, void *); + unsigned long free_space_count(int); + #endif /* _LINUX_COMP_CACHE_H */ |
|
From: Rodrigo S. de C. <rc...@us...> - 2002-05-29 13:05:29
|
Update of /cvsroot/linuxcompressed/linux/mm/comp_cache
In directory usw-pr-cvs1:/tmp/cvs-serv29963/mm/comp_cache
Modified Files:
aux.c proc.c
Log Message:
Add "Free Space Histogram" section to /proc/comp_cache_stat
Index: aux.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/aux.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -r1.26 -r1.27
*** aux.c 21 May 2002 18:49:06 -0000 1.26
--- aux.c 29 May 2002 13:05:25 -0000 1.27
***************
*** 2,6 ****
* linux/mm/comp_cache/aux.c
*
! * Time-stamp: <2002-05-21 12:34:55 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/aux.c
*
! * Time-stamp: <2002-05-28 17:32:52 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 21,25 ****
unsigned int fragment_hash_bits;
! comp_cache_t ** free_space_hash;
unsigned int free_space_hash_size;
unsigned int free_space_interval;
--- 21,25 ----
unsigned int fragment_hash_bits;
! static comp_cache_t ** free_space_hash;
unsigned int free_space_hash_size;
unsigned int free_space_interval;
***************
*** 162,165 ****
--- 162,181 ----
fragment_hash_used--;
+ }
+
+ unsigned long
+ free_space_count(int index) {
+ comp_cache_t * comp_page;
+ unsigned long total;
+
+ if (index < 0)
+ BUG();
+
+ if (index >= free_space_hash_size)
+ BUG();
+
+ for (comp_page = free_space_hash[index], total = 0; comp_page; comp_page = comp_page->next_hash, total++);
+
+ return total;
}
Index: proc.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/proc.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** proc.c 23 May 2002 21:25:33 -0000 1.10
--- proc.c 29 May 2002 13:05:26 -0000 1.11
***************
*** 2,6 ****
* linux/mm/comp_cache/proc.c
*
! * Time-stamp: <2002-05-23 18:00:34 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/proc.c
*
! * Time-stamp: <2002-05-28 17:56:39 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 237,241 ****
print_comp_cache_stats(unsigned short alg_idx, char * page, int * length)
{
! unsigned int compression_ratio, discard_ratio;
unsigned int mean_size, mean_comp_cycles, mean_decomp_cycles;
unsigned long total_comp_pages, total_wout_pages, total_decomp_pages, total_faultin_pages;
--- 237,241 ----
print_comp_cache_stats(unsigned short alg_idx, char * page, int * length)
{
! unsigned int compression_ratio, discard_ratio, i;
unsigned int mean_size, mean_comp_cycles, mean_decomp_cycles;
unsigned long total_comp_pages, total_wout_pages, total_decomp_pages, total_faultin_pages;
***************
*** 314,317 ****
--- 314,335 ----
stats->decomp_cycles_max,
mean_decomp_cycles);
+
+ *length += sprintf(page + *length,
+ "Free Space Histogram\n"
+ " Zero: %8lu\n",
+ free_space_count(0));
+
+ for (i = 1; i < free_space_hash_size - 1; i += 2) {
+ *length += sprintf(page + *length,
+ " %4d - %4d: %8lu\n",
+ (i+1)*100-200?:1, (i+1)*100,
+ free_space_count(i) + free_space_count(i+1));
+ }
+
+ *length += sprintf(page + *length,
+ " Page Size: %8lu\n",
+ free_space_count(free_space_hash_size - 1));
+
+
}
|
|
From: Rodrigo S. de C. <rc...@us...> - 2002-05-28 19:16:19
|
Update of /cvsroot/linuxcompressed/linux/mm/comp_cache In directory usw-pr-cvs1:/tmp/cvs-serv8044/mm/comp_cache Modified Files: adaptivity.c main.c swapin.c swapout.c Log Message: - Fixed a bug that caused FS corruption (hit under UML). Details: http://sourceforge.net/tracker/index.php?func=detail&aid=561171&group_id=13472&atid=113472 - Resizing compressed cache size now fix normal Zone Watermarks too Index: adaptivity.c =================================================================== RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/adaptivity.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** adaptivity.c 15 May 2002 18:05:36 -0000 1.18 --- adaptivity.c 28 May 2002 19:16:15 -0000 1.19 *************** *** 2,6 **** * linux/mm/comp_cache/adaptivity.c * ! * Time-stamp: <2002-05-15 10:31:44 rcastro> * * Linux Virtual Memory Compressed Cache --- 2,6 ---- * linux/mm/comp_cache/adaptivity.c * ! * Time-stamp: <2002-05-28 15:44:25 rcastro> * * Linux Virtual Memory Compressed Cache *************** *** 473,477 **** vswap_address = new_vswap_address; ! //printk("VSWAP - resized from %ld to %ld\n", vswap_current_num_entries, vswap_new_num_entries); vswap_current_num_entries = vswap_new_num_entries; vswap_last_used = vswap_new_num_entries - 1; --- 473,479 ---- vswap_address = new_vswap_address; ! #if 0 ! printk("VSWAP - resized from %ld to %ld\n", vswap_current_num_entries, vswap_new_num_entries); ! #endif vswap_current_num_entries = vswap_new_num_entries; vswap_last_used = vswap_new_num_entries - 1; *************** *** 534,537 **** --- 536,545 ---- } + static inline int + zone_wrong_watermarks_shrink(void) + { + return (zone_num_comp_pages > num_comp_pages); + } + int shrink_comp_cache(comp_cache_t * comp_page) *************** *** 543,547 **** if (!list_empty(&(comp_page->fragments))) { UnlockPage(comp_page->page); ! goto out; } --- 551,555 ---- if (!list_empty(&(comp_page->fragments))) { UnlockPage(comp_page->page); ! goto check_shrink; } *************** *** 549,555 **** if (!comp_cache_needs_to_shrink()) { UnlockPage(comp_page->page); ! return retval; } empty_comp_page = comp_page; retval = 1; --- 557,564 ---- if (!comp_cache_needs_to_shrink()) { UnlockPage(comp_page->page); ! goto out; } + /* we need to shrink and have a empty page, so let's do it */ empty_comp_page = comp_page; retval = 1; *************** *** 565,574 **** comp_cache_free_space -= PAGE_SIZE; num_comp_pages--; ! //printk("shrink new %lu real %lu\n", new_num_comp_pages, num_comp_pages); ! ! out: ! if (comp_cache_needs_to_shrink() && !fragment_failed_alloc && !vswap_failed_alloc) ! goto check_empty_pages; if (fragment_hash_needs_to_shrink()) resize_fragment_hash_table(); --- 574,592 ---- comp_cache_free_space -= PAGE_SIZE; num_comp_pages--; ! #if 0 ! printk("shrink new %lu real %lu\n", new_num_comp_pages, num_comp_pages); ! #endif ! ! check_shrink: ! if (comp_cache_needs_to_shrink()) { ! if (!fragment_failed_alloc && !vswap_failed_alloc) ! goto check_empty_pages; ! } ! else { ! if (zone_wrong_watermarks_shrink()) ! comp_cache_fix_watermarks(num_comp_pages); ! } + out: if (fragment_hash_needs_to_shrink()) resize_fragment_hash_table(); *************** *** 621,624 **** --- 639,648 ---- } + static inline int + zone_wrong_watermarks_grow(void) + { + return (zone_num_comp_pages < num_comp_pages); + } + inline void grow_comp_cache(zone_t * zone, int nr_pages) *************** *** 644,652 **** comp_cache_free_space += PAGE_SIZE; num_comp_pages++; ! //printk("grow real %lu\n", num_comp_pages); } ! if (comp_cache_needs_to_grow() && !fragment_failed_alloc && !vswap_failed_alloc) ! return; if (fragment_hash_needs_to_grow()) --- 668,684 ---- comp_cache_free_space += PAGE_SIZE; num_comp_pages++; ! #if 0 ! printk("grow real %lu\n", num_comp_pages); ! #endif } ! if (comp_cache_needs_to_grow()) { ! if (!fragment_failed_alloc && !vswap_failed_alloc) ! return; ! } ! else { ! if (zone_wrong_watermarks_grow()) ! comp_cache_fix_watermarks(num_comp_pages); ! } if (fragment_hash_needs_to_grow()) Index: main.c =================================================================== RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/main.c,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -r1.40 -r1.41 *** main.c 24 May 2002 14:41:36 -0000 1.40 --- main.c 28 May 2002 19:16:15 -0000 1.41 *************** *** 2,6 **** * linux/mm/comp_cache/main.c * ! * Time-stamp: <2002-05-24 11:11:39 rcastro> * * Linux Virtual Memory Compressed Cache --- 2,6 ---- * linux/mm/comp_cache/main.c * ! * Time-stamp: <2002-05-28 14:42:21 rcastro> * * Linux Virtual Memory Compressed Cache *************** *** 19,23 **** #include <net/checksum.h> ! /* compressed cache */ unsigned long num_comp_pages = 0; unsigned long num_swapper_fragments = 0; --- 19,23 ---- #include <net/checksum.h> ! /* compressed cache control variables */ unsigned long num_comp_pages = 0; unsigned long num_swapper_fragments = 0; *************** *** 29,32 **** --- 29,36 ---- unsigned long min_num_comp_pages = 0; + /* stores the last number of compressed pages that has been used to + * fix the normal zone watermarks */ + unsigned long zone_num_comp_pages = 0; + unsigned long comp_cache_free_space; *************** *** 67,71 **** return 0; #endif ! page_cache_get(page); spin_unlock(&pagecache_lock); --- 71,75 ---- return 0; #endif ! page_cache_get(page); spin_unlock(&pagecache_lock); *************** *** 151,155 **** } ! extern void comp_cache_fix_watermarks(int num_comp_pages); void __init --- 155,159 ---- } ! extern void __init comp_cache_init_fix_watermarks(int num_comp_pages); void __init *************** *** 197,201 **** /* fiz zone watermarks */ ! comp_cache_fix_watermarks(init_num_comp_pages); /* create slab caches */ --- 201,205 ---- /* fiz zone watermarks */ ! comp_cache_init_fix_watermarks(init_num_comp_pages); /* create slab caches */ Index: swapin.c =================================================================== RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/swapin.c,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -r1.35 -r1.36 *** swapin.c 21 May 2002 18:49:06 -0000 1.35 --- swapin.c 28 May 2002 19:16:15 -0000 1.36 *************** *** 2,6 **** * linux/mm/comp_cache/swapin.c * ! * Time-stamp: <2002-05-21 11:27:43 rcastro> * * Linux Virtual Memory Compressed Cache --- 2,6 ---- * linux/mm/comp_cache/swapin.c * ! * Time-stamp: <2002-05-28 14:27:51 rcastro> * * Linux Virtual Memory Compressed Cache *************** *** 85,89 **** PageSetCompCache(page); - SetPageUptodate(page); } --- 85,88 ---- Index: swapout.c =================================================================== RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/swapout.c,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -r1.45 -r1.46 *** swapout.c 24 May 2002 14:41:38 -0000 1.45 --- swapout.c 28 May 2002 19:16:15 -0000 1.46 *************** *** 2,6 **** * /mm/comp_cache/swapout.c * ! * Time-stamp: <2002-05-24 10:32:39 rcastro> * * Linux Virtual Memory Compressed Cache --- 2,6 ---- * /mm/comp_cache/swapout.c * ! * Time-stamp: <2002-05-28 14:51:56 rcastro> * * Linux Virtual Memory Compressed Cache |
|
From: Rodrigo S. de C. <rc...@us...> - 2002-05-28 19:16:18
|
Update of /cvsroot/linuxcompressed/linux/mm In directory usw-pr-cvs1:/tmp/cvs-serv8044/mm Modified Files: filemap.c page_alloc.c Log Message: - Fixed a bug that caused FS corruption (hit under UML). Details: http://sourceforge.net/tracker/index.php?func=detail&aid=561171&group_id=13472&atid=113472 - Resizing compressed cache size now fix normal Zone Watermarks too Index: filemap.c =================================================================== RCS file: /cvsroot/linuxcompressed/linux/mm/filemap.c,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -r1.25 -r1.26 *** filemap.c 8 May 2002 20:24:34 -0000 1.25 --- filemap.c 28 May 2002 19:16:14 -0000 1.26 *************** *** 757,761 **** int error = 0; #ifdef CONFIG_COMP_PAGE_CACHE ! if (read_comp_cache(mapping, offset, page)) #endif error = mapping->a_ops->readpage(file, page); --- 757,763 ---- int error = 0; #ifdef CONFIG_COMP_PAGE_CACHE ! if (!read_comp_cache(mapping, offset, page)) ! SetPageUptodate(page); ! else #endif error = mapping->a_ops->readpage(file, page); *************** *** 1612,1617 **** #ifdef CONFIG_COMP_PAGE_CACHE ! if (!read_comp_cache(mapping, index, page)) goto page_ok; #endif goto readpage; --- 1614,1621 ---- #ifdef CONFIG_COMP_PAGE_CACHE ! if (!read_comp_cache(mapping, index, page)) { ! SetPageUptodate(page); goto page_ok; + } #endif goto readpage; *************** *** 2914,2918 **** #ifdef CONFIG_COMP_PAGE_CACHE ! if (read_comp_cache(mapping, index, page)) #endif err = filler(data, page); --- 2918,2924 ---- #ifdef CONFIG_COMP_PAGE_CACHE ! if (!read_comp_cache(mapping, index, page)) ! SetPageUptodate(page); ! else #endif err = filler(data, page); Index: page_alloc.c =================================================================== RCS file: /cvsroot/linuxcompressed/linux/mm/page_alloc.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** page_alloc.c 21 May 2002 18:49:06 -0000 1.17 --- page_alloc.c 28 May 2002 19:16:14 -0000 1.18 *************** *** 19,22 **** --- 19,23 ---- #include <linux/slab.h> #include <linux/compiler.h> + #include <linux/comp_cache.h> int nr_swap_pages; *************** *** 627,631 **** #ifdef CONFIG_COMP_CACHE ! void comp_cache_fix_watermarks(int num_comp_pages) { unsigned long mask; --- 628,633 ---- #ifdef CONFIG_COMP_CACHE ! void ! comp_cache_fix_watermarks(int num_comp_pages) { unsigned long mask; *************** *** 646,657 **** mask = zone_balance_max[j]; - printk("Compressed Cache: page watermarks (normal zone)\n" - "Compressed Cache: (%lu, %lu, %lu) -> ", - zone->pages_min, zone->pages_low, zone->pages_high); zone->pages_min = mask; zone->pages_low = mask*2; zone->pages_high = mask*3; printk("(%lu, %lu, %lu)\n", zone->pages_min, zone->pages_low, zone->pages_high); } #endif --- 648,669 ---- mask = zone_balance_max[j]; zone->pages_min = mask; zone->pages_low = mask*2; zone->pages_high = mask*3; + + zone_num_comp_pages = num_comp_pages; + } + + void __init + comp_cache_init_fix_watermarks(int num_comp_pages) + { + zone_t *zone = contig_page_data.node_zones + ZONE_NORMAL; + + printk("Compressed Cache: page watermarks (normal zone)\nCompressed Cache: (%lu, %lu, %lu) -> ", + zone->pages_min, zone->pages_low, zone->pages_high); + comp_cache_fix_watermarks(num_comp_pages); printk("(%lu, %lu, %lu)\n", zone->pages_min, zone->pages_low, zone->pages_high); } + #endif |
|
From: Rodrigo S. de C. <rc...@us...> - 2002-05-28 19:16:17
|
Update of /cvsroot/linuxcompressed/linux/include/linux In directory usw-pr-cvs1:/tmp/cvs-serv8044/include/linux Modified Files: comp_cache.h Log Message: - Fixed a bug that caused FS corruption (hit under UML). Details: http://sourceforge.net/tracker/index.php?func=detail&aid=561171&group_id=13472&atid=113472 - Resizing compressed cache size now fix normal Zone Watermarks too Index: comp_cache.h =================================================================== RCS file: /cvsroot/linuxcompressed/linux/include/linux/comp_cache.h,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -r1.68 -r1.69 *** comp_cache.h 23 May 2002 13:52:44 -0000 1.68 --- comp_cache.h 28 May 2002 19:16:14 -0000 1.69 *************** *** 2,6 **** * linux/mm/comp_cache.h * ! * Time-stamp: <2002-05-23 10:20:14 rcastro> * * Linux Virtual Memory Compressed Cache --- 2,6 ---- * linux/mm/comp_cache.h * ! * Time-stamp: <2002-05-26 12:08:33 rcastro> * * Linux Virtual Memory Compressed Cache *************** *** 36,40 **** #define NUM_VSWAP_ENTRIES (3 * num_comp_pages) ! extern unsigned long num_comp_pages, num_swapper_fragments, new_num_comp_pages, max_num_comp_pages; struct pte_list { --- 36,40 ---- #define NUM_VSWAP_ENTRIES (3 * num_comp_pages) ! extern unsigned long num_comp_pages, num_swapper_fragments, new_num_comp_pages, max_num_comp_pages, zone_num_comp_pages; struct pte_list { |
|
From: Rodrigo S. de C. <rc...@us...> - 2002-05-24 14:41:47
|
Update of /cvsroot/linuxcompressed/linux/mm/comp_cache
In directory usw-pr-cvs1:/tmp/cvs-serv11967/mm/comp_cache
Modified Files:
main.c swapout.c
Log Message:
- Fixed a bug that would allow a compressed cache smaller than 10% of your
memory size. If you enter compsize=4096, for instance, it'd set a compressed
cache of 1 memory page (on i386).
- Fixed a bug that could make the list_for_each() in find_free_swp_buffer()
loop forever. There was no max_scan variable, so if it happens that the head
got removed, our for would be endless and since there was no schedule()
call, it would hang the system.
Index: main.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/main.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -C2 -r1.39 -r1.40
*** main.c 23 May 2002 21:25:33 -0000 1.39
--- main.c 24 May 2002 14:41:36 -0000 1.40
***************
*** 2,6 ****
* linux/mm/comp_cache/main.c
*
! * Time-stamp: <2002-05-23 17:49:09 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/main.c
*
! * Time-stamp: <2002-05-24 11:11:39 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 164,168 ****
#ifndef CONFIG_COMP_ADAPTIVITY
! if (!init_num_comp_pages || init_num_comp_pages > max_num_comp_pages)
#endif
init_num_comp_pages = min_num_comp_pages;
--- 164,168 ----
#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;
Index: swapout.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/swapout.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -C2 -r1.44 -r1.45
*** swapout.c 21 May 2002 20:33:25 -0000 1.44
--- swapout.c 24 May 2002 14:41:38 -0000 1.45
***************
*** 2,6 ****
* /mm/comp_cache/swapout.c
*
! * Time-stamp: <2002-05-21 16:52:13 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* /mm/comp_cache/swapout.c
*
! * Time-stamp: <2002-05-24 10:32:39 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 39,44 ****
struct swp_buffer * swp_buffer;
comp_cache_fragment_t * old_fragment;
! int wait;
!
if (!fragment)
BUG();
--- 39,44 ----
struct swp_buffer * swp_buffer;
comp_cache_fragment_t * old_fragment;
! int wait, maxscan = NUM_SWP_BUFFERS >> 2;
!
if (!fragment)
BUG();
***************
*** 56,59 ****
--- 56,62 ----
old_fragment = swp_buffer->fragment;
+ if (!maxscan--)
+ break;
+
if (TryLockPage(buffer_page)) {
if (!wait)
***************
*** 128,132 ****
/* couldn't free any swap buffer? so let's IO to finish */
if (list_empty(&swp_free_buffer_head)) {
! wait = 1;
goto try_again;
}
--- 131,139 ----
/* couldn't free any swap buffer? so let's IO to finish */
if (list_empty(&swp_free_buffer_head)) {
! maxscan = wait = 1;
! if (unlikely(current->need_resched)) {
! __set_current_state(TASK_RUNNING);
! schedule();
! }
goto try_again;
}
|
|
From: Rodrigo S. de C. <rc...@us...> - 2002-05-23 21:25:36
|
Update of /cvsroot/linuxcompressed/linux/mm/comp_cache
In directory usw-pr-cvs1:/tmp/cvs-serv6532/mm/comp_cache
Modified Files:
main.c proc.c
Log Message:
- Fixed a buglet that wouldn't let the user to resize the compressed cache
size to a value smaller than the initial number of compressed pages.
- Added a file "actual_size" to /proc/sys/vm/comp_cache directory. This file
displays the actual size of compressed cache. The current "size" file shows
the new size (the size we are trying to resize to), not its current size.
Index: main.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/main.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -r1.38 -r1.39
*** main.c 23 May 2002 13:52:44 -0000 1.38
--- main.c 23 May 2002 21:25:33 -0000 1.39
***************
*** 2,6 ****
* linux/mm/comp_cache/main.c
*
! * Time-stamp: <2002-05-23 10:38:17 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/main.c
*
! * Time-stamp: <2002-05-23 17:49:09 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 161,170 ****
max_num_comp_pages = num_physpages * 0.5;
#ifndef CONFIG_COMP_ADAPTIVITY
if (!init_num_comp_pages || init_num_comp_pages > max_num_comp_pages)
#endif
! init_num_comp_pages = num_physpages * 0.10;
! new_num_comp_pages = min_num_comp_pages = num_comp_pages = init_num_comp_pages;
printk("Compressed Cache: %s\n", COMP_CACHE_VERSION);
--- 161,171 ----
max_num_comp_pages = num_physpages * 0.5;
+ min_num_comp_pages = num_physpages * 0.1;
#ifndef CONFIG_COMP_ADAPTIVITY
if (!init_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);
Index: proc.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/proc.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** proc.c 21 May 2002 18:49:06 -0000 1.9
--- proc.c 23 May 2002 21:25:33 -0000 1.10
***************
*** 2,6 ****
* linux/mm/comp_cache/proc.c
*
! * Time-stamp: <2002-05-16 14:11:49 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/proc.c
*
! * Time-stamp: <2002-05-23 18:00:34 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 44,48 ****
{
CC_SIZE=1,
! CC_ALGORITHM=2
};
--- 44,49 ----
{
CC_SIZE=1,
! CC_ACTUAL_SIZE=2,
! CC_ALGORITHM=3
};
***************
*** 51,54 ****
--- 52,56 ----
&proc_dointvec_minmax, &sysctl_intvec, NULL, &min_num_comp_pages,
&max_num_comp_pages},
+ {CC_ACTUAL_SIZE, "actual_size", &num_comp_pages, sizeof(int), 0444, NULL, &proc_dointvec},
{CC_ALGORITHM, "algorithm", ¤t_algorithm, sizeof(int), 0644, NULL,
&proc_dointvec_minmax, &sysctl_intvec, NULL, &algorithm_min,
|
|
From: Rodrigo S. de C. <rc...@us...> - 2002-05-23 13:52:47
|
Update of /cvsroot/linuxcompressed/linux/include/linux In directory usw-pr-cvs1:/tmp/cvs-serv28265/include/linux Modified Files: comp_cache.h Log Message: - our kernel parameter "compsize=" will accept as input the same values as mem=, so you can enter the number of megabytes, kilobytes or even gigabytes (although a compressed cache cannot have that size) without having to convert this number into the number of memory pages. For example, compsize=16M or compsize=1024K will work now. Index: comp_cache.h =================================================================== RCS file: /cvsroot/linuxcompressed/linux/include/linux/comp_cache.h,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -r1.67 -r1.68 *** comp_cache.h 21 May 2002 18:49:06 -0000 1.67 --- comp_cache.h 23 May 2002 13:52:44 -0000 1.68 *************** *** 2,6 **** * linux/mm/comp_cache.h * ! * Time-stamp: <2002-05-21 15:10:13 rcastro> * * Linux Virtual Memory Compressed Cache --- 2,6 ---- * linux/mm/comp_cache.h * ! * Time-stamp: <2002-05-23 10:20:14 rcastro> * * Linux Virtual Memory Compressed Cache *************** *** 29,33 **** #include <linux/WKcommon.h> ! #define COMP_CACHE_VERSION "0.23pre4" /* maximum compressed size of a page */ --- 29,33 ---- #include <linux/WKcommon.h> ! #define COMP_CACHE_VERSION "0.23pre5" /* maximum compressed size of a page */ |