[linux-mm-cc] [PATCH 08/12] avoid OOM : divide free_chunk_head
IKEDA Munehiro
m-ikeda at ds.jp.nec.com
Fri Jul 20 06:45:23 EDT 2007
Divide free_chunk_head() into two functions.
One function named __free_chunk_head() is a core part
which puts back all chunks connected to
the chunk_head but doesn't free the chunk_head itself.
Another is free_chunk_head() which calls __free_chunk_head()
and then frees the chunk_head.
This is a preparation for following patches to shrink
ccache area. Formerly free_chunk_head() was called only
from error path. The porpose of this patch is to make
function which can be used by normal path to free chunk_head.
Signed-off-by: IKEDA, Munehiro <m-ikeda at ds.jp.nec.com>
---
mm/ccache.c | 34 ++++++++++++++++++++++++----------
1 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/mm/ccache.c b/mm/ccache.c
index 640ea7a..316e686 100644
--- a/mm/ccache.c
+++ b/mm/ccache.c
@@ -287,28 +287,42 @@ repeat:
}
/*
- * put back all chunks connected to this chunk_head
- * back on free list and free the chunk_head
+ * free_chunk_head() core function but not free the chunk head
*/
-static void free_chunk_head(struct chunk_head *ch)
+static int __free_chunk_head(struct chunk_head *ch)
{
struct chunk *chunk, *tmp;
- CC_DEBUG("free_chunk_head: chunk_head=%p", ch);
- if (!ch)
- return;
+ int freed = 0;
+
chunk = ch->chunk_list;
/* put back all chunks on free list */
while (chunk) {
+ freed += ChunkSize(chunk);
tmp = chunk->next;
merge_chunk(chunk);
- spin_lock(&ccache_lock);
- chunk->next = free_head;
- free_head = chunk;
- spin_unlock(&ccache_lock);
chunk = tmp;
}
+ ch->chunk_list = NULL;
+ return freed;
+}
+
+
+/*
+ * put back all chunks connected to this chunk_head
+ * back on free list and free the chunk_head
+ */
+static int free_chunk_head(struct chunk_head *ch)
+{
+ int freed = 0;
+
+ CC_DEBUG("free_chunk_head: chunk_head=%p", ch);
+ if (!ch)
+ return 0;
+ freed = __free_chunk_head(ch);
kfree(ch);
+
+ return freed;
}
/*
--
1.4.4.4
More information about the linux-mm-cc
mailing list