[lc-checkins] CVS: linux/mm/comp_cache adaptivity.c,1.25,1.26 vswap.c,1.35,1.36
Status: Beta
Brought to you by:
nitin_sf
|
From: Rodrigo S. de C. <rc...@us...> - 2002-06-19 19:32:31
|
Update of /cvsroot/linuxcompressed/linux/mm/comp_cache
In directory usw-pr-cvs1:/tmp/cvs-serv23188/mm/comp_cache
Modified Files:
adaptivity.c vswap.c
Log Message:
Bug fix
o Improved the bug fix for failed vswap allocation for vswap resizing code
({grow,shrink}_vswap). Also fixed a potential bug introduced in the previous
bug fix.
Index: adaptivity.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/adaptivity.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -r1.25 -r1.26
*** adaptivity.c 19 Jun 2002 12:18:44 -0000 1.25
--- adaptivity.c 19 Jun 2002 19:32:25 -0000 1.26
***************
*** 2,6 ****
* linux/mm/comp_cache/adaptivity.c
*
! * Time-stamp: <2002-06-19 08:45:29 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/adaptivity.c
*
! * Time-stamp: <2002-06-19 16:20:02 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 258,262 ****
struct comp_cache_fragment * fragment;
struct vswap_address ** new_vswap_address;
! unsigned int total_scan = 0, failed_scan = 0;
unsigned long index, new_index;
swp_entry_t old_entry, entry;
--- 258,262 ----
struct comp_cache_fragment * fragment;
struct vswap_address ** new_vswap_address;
! unsigned int total_scan = 0, failed_scan = 0, failed_alloc = 0;
unsigned long index, new_index;
swp_entry_t old_entry, entry;
***************
*** 397,401 ****
* be reallocated */
if (!vswap_address[index]) {
! vswap_alloc_and_init(new_vswap_address, index);
continue;
}
--- 397,404 ----
* be reallocated */
if (!vswap_address[index]) {
! if (!vswap_alloc_and_init(new_vswap_address, index) && !failed_alloc) {
! failed_alloc = 1;
! last_vswap_allocated = index - 1;
! }
continue;
}
***************
*** 414,419 ****
}
! for (index = vswap_last_used + 1; index < vswap_new_num_entries; index++)
! vswap_alloc_and_init(new_vswap_address, index);
vfree(vswap_address);
--- 417,426 ----
}
! for (index = vswap_last_used + 1; index < vswap_new_num_entries; index++) {
! if (!vswap_alloc_and_init(new_vswap_address, index) && !failed_alloc) {
! failed_alloc = 1;
! last_vswap_allocated = index - 1;
! }
! }
vfree(vswap_address);
***************
*** 439,443 ****
grow_vswap(unsigned long vswap_new_num_entries) {
struct vswap_address ** new_vswap_address;
! unsigned int i;
if (vswap_last_used >= vswap_new_num_entries - 1)
--- 446,450 ----
grow_vswap(unsigned long vswap_new_num_entries) {
struct vswap_address ** new_vswap_address;
! unsigned int i, failed_alloc = 0;
if (vswap_last_used >= vswap_new_num_entries - 1)
***************
*** 463,467 ****
* vswap_last_used that have to be reallocated */
if (!vswap_address[i]) {
! vswap_alloc_and_init(new_vswap_address, i);
continue;
}
--- 470,477 ----
* vswap_last_used that have to be reallocated */
if (!vswap_address[i]) {
! if (!vswap_alloc_and_init(new_vswap_address, i) && !failed_alloc) {
! failed_alloc = 1;
! last_vswap_allocated = i - 1;
! }
continue;
}
***************
*** 473,479 ****
* than vswap_new_num_entries - 1, so we have to reallocate the
* missing entries */
! for (i = vswap_last_used + 1; i < vswap_new_num_entries; i++)
! vswap_alloc_and_init(new_vswap_address, i);
!
vfree(vswap_address);
vswap_address = new_vswap_address;
--- 483,492 ----
* than vswap_new_num_entries - 1, so we have to reallocate the
* missing entries */
! for (i = vswap_last_used + 1; i < vswap_new_num_entries; i++) {
! if (!vswap_alloc_and_init(new_vswap_address, i) && !failed_alloc) {
! failed_alloc = 1;
! last_vswap_allocated = i - 1;
! }
! }
vfree(vswap_address);
vswap_address = new_vswap_address;
***************
*** 493,498 ****
* vswap, only reallocate the empty entries */
for (i = 0; i < vswap_current_num_entries; i++) {
! if (!vswap_address[i])
! vswap_alloc_and_init(vswap_address, i);
}
--- 506,515 ----
* vswap, only reallocate the empty entries */
for (i = 0; i < vswap_current_num_entries; i++) {
! if (!vswap_address[i]) {
! if (!vswap_alloc_and_init(vswap_address, i) && !failed_alloc) {
! failed_alloc = 1;
! last_vswap_allocated = i - 1;
! }
! }
}
Index: vswap.c
===================================================================
RCS file: /cvsroot/linuxcompressed/linux/mm/comp_cache/vswap.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -r1.35 -r1.36
*** vswap.c 19 Jun 2002 18:10:20 -0000 1.35
--- vswap.c 19 Jun 2002 19:32:25 -0000 1.36
***************
*** 2,6 ****
* linux/mm/comp_cache/vswap.c
*
! * Time-stamp: <2002-06-19 14:48:47 rcastro>
*
* Linux Virtual Memory Compressed Cache
--- 2,6 ----
* linux/mm/comp_cache/vswap.c
*
! * Time-stamp: <2002-06-19 16:11:47 rcastro>
*
* Linux Virtual Memory Compressed Cache
***************
*** 51,56 ****
unsigned int vswap_last_used;
! /* last vswap which has been allocated (this index will be used to try
! * to allocate in case the vswap addresses are over) */
unsigned int last_vswap_allocated;
--- 51,57 ----
unsigned int vswap_last_used;
! /* last vswap index which has been allocated contiguously (the
! * following position is empty). This index will be used to try to
! * allocate in case the vswap addresses are over) */
unsigned int last_vswap_allocated;
***************
*** 62,65 ****
--- 63,67 ----
{
unsigned long i;
+ unsigned int failed_alloc = 0;
vswap_cachep = kmem_cache_create("comp_cache_vswap", sizeof(struct vswap_address), 0, SLAB_HWCACHE_ALIGN, NULL, NULL);
***************
*** 75,81 ****
vswap_num_swap_cache = 0;
! for (i = 0; i < NUM_VSWAP_ENTRIES && vswap_alloc_and_init(vswap_address, i); i++);
! last_vswap_allocated = i - 1;
!
return 1;
}
--- 77,86 ----
vswap_num_swap_cache = 0;
! for (i = 0; i < NUM_VSWAP_ENTRIES; i++) {
! if (!vswap_alloc_and_init(vswap_address, i) && !failed_alloc) {
! failed_alloc = 1;
! last_vswap_allocated = i - 1;
! }
! }
return 1;
}
***************
*** 103,106 ****
--- 108,112 ----
comp_cache_available_vswap(void) {
unsigned short available_mean_size;
+ unsigned long i;
/* that should avoid problems when looking for a place in
***************
*** 115,124 ****
if (last_vswap_allocated == NUM_VSWAP_ENTRIES - 1)
return 0;
!
/* allocate an index that has failed to allocate */
if (!vswap_alloc_and_init(vswap_address, last_vswap_allocated + 1))
return 0;
! last_vswap_allocated++;
return 1;
}
--- 121,135 ----
if (last_vswap_allocated == NUM_VSWAP_ENTRIES - 1)
return 0;
!
! if (vswap_address[last_vswap_allocated + 1])
! BUG();
!
/* allocate an index that has failed to allocate */
if (!vswap_alloc_and_init(vswap_address, last_vswap_allocated + 1))
return 0;
! for (i = last_vswap_allocated + 1; i < NUM_VSWAP_ENTRIES && vswap_address[i]; i++);
! last_vswap_allocated = i - 1;
!
return 1;
}
|