lkml.org 
[lkml]   [1998]   [Mar]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectSome bugs in swap_state.c
Hi,

I was going through the swap_state.c code and would like to report the
following bugs/suggestions.

1. There is a call to free_page (addr) at the end of the function
free_page_and_swap_cache (unsigned long addr). Since we are calling
__free_page (page) in remove_from_swap_cache this call is not correct. Can
anyone tell me hte problems which can be caused due to freeing a page
which is already freed. Are the necessary checks for this in place?

2. Function find_in_swap_cache(struct page *page) dosent seem to be used
anywhere, so might as well remove it from the file. The name also dosent
make any sense.

3. I have removed a trivial check from the function lookup_swap_cache as
it seems to be unnecessary after the call to find_page.

Rik, let me have your views on this and if it is fine please do the
necessary.

I havent tested the fixes, but it seems they will work. :-)

yet-another-mm-hacker,
Chirayu



--- swap_state.c Thu Mar 19 11:52:38 1998
+++ swap_state.suggested_fixes.c Sun Mar 22 18:41:45 1998
@@ -166,22 +166,6 @@
}


-long find_in_swap_cache(struct page *page)
-{
-#ifdef SWAP_CACHE_INFO
- swap_cache_find_total++;
-#endif
- if (PageSwapCache (page)) {
- long entry = page->offset;
-#ifdef SWAP_CACHE_INFO
- swap_cache_find_success++;
-#endif
- remove_from_swap_cache (page);
- return entry;
- }
- return 0;
-}
-
int delete_from_swap_cache(struct page *page)
{
#ifdef SWAP_CACHE_INFO
@@ -204,11 +188,6 @@
return 0;
}

-/*
- * Perform a free_page(), also freeing any swap cache associated with
- * this page if it is the last user of the page.
- */
-
void free_page_and_swap_cache(unsigned long addr)
{
struct page *page = mem_map + MAP_NR(addr);
@@ -219,7 +198,6 @@
delete_from_swap_cache(page);
}

- free_page(addr);
}


@@ -237,8 +215,7 @@
found = find_page(&swapper_inode, entry);
if (!found)
return 0;
- if (found->inode != &swapper_inode
- || !PageSwapCache(found)) {
+ if (!PageSwapCache(found)) {
__free_page(found);
printk ("VM: Found a non-swapper swap page!\n");
return 0;


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu

\
 
 \ /
  Last update: 2005-03-22 13:41    [W:4.930 / U:0.900 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site