slob:Use _safe funtion to iterate partially free list.
PATCH 1/1 slob:Use _safe funtion to iterate partially free list.
Since a list entry may be removed, so use list_for_each_entry_safe instead of list_for_each_entry.
--- mm/slob.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
mm/slob.c +2 -2
@@ -320,7 +320,7 @@ static void *slob_page_alloc(struct slob_page *sp, size_t size, int align)*/ static void *slob_alloc (size_t size,gfp_t gfp,int align,int node) { -struct slob_page *sp; +struct slob_page *sp, *tmp;struct list_head *prev;struct list_head *slob_list;slob_t *b =NULL ;
@@ -335,7 +335,7 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)spin_lock_irqsave (&slob_lock, flags);/* Iterate through each partially free page, try to find room */ -list_for_each_entry (sp, slob_list, list) { +list_for_each_entry_safe (sp, tmp, slob_list, list) {#ifdef CONFIG_NUMA /* * If there's a node specification, search for a partial
Signature · 7 lines
1.5.6.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 22 lines · Bob Liu
Since a list entry may be removed, so use
list_for_each_entry_safeinstead oflist_for_each_entry.Signed-off-by Bob Liu <[email protected]>--- mm/slob.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)mm/slob.c +1
-1@@ -320,7 +320,7 @@ static void *slob_page_alloc(struct slob_page *sp, size_t size, int align)*/ static void *slob_alloc (size_t size,gfp_t gfp,int align,int node) { -struct slob_page *sp; +struct slob_page *sp, *tmp;struct list_head *prev;struct list_head *slob_list;slob_t *b =NULL ;
mm/slob.c static void *slob_alloc(size_t size, gfp_t gfp, int align, int node) · line 339
Quoted 6 lines
mm/slob.c +1
-1@@ -335,7 +335,7 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)spin_lock_irqsave (&slob_lock, flags);/* Iterate through each partially free page, try to find room */ -list_for_each_entry (sp, slob_list, list) { +list_for_each_entry_safe (sp, tmp, slob_list, list) {#ifdef CONFIG_NUMA
sp's list head is only modified if an allocation was successful, but then the iteration stops as well. So I see no reason for your patch. Did I overlook something?
Hannes
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 24 lines · Johannes Weiner
Quoted 23 lines · Bob Liu
Since a list entry may be removed, so use
list_for_each_entry_safeinstead oflist_for_each_entry.Signed-off-by Bob Liu <[email protected]>---
mm/slob.c | 4 ++--1 files changed, 2 insertions(+), 2 deletions(-)mm/slob.c +1
-1@@ -320,7 +320,7 @@ static void *slob_page_alloc(struct slob_page *sp, size_t size, int align)*/ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node) { - struct slob_page *sp; + struct slob_page *sp, *tmp; struct list_head *prev; struct list_head *slob_list; slob_t *b = NULL;@@ -335,7 +335,7 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
Quoted 10 lines
mm/slob.c static void *slob_alloc(size_t size, gfp_t gfp, int align, int node) · line 339
Quoted 5 lines
mm/slob.c +1
-1spin_lock_irqsave(&slob_lock, flags); /* Iterate through each partially free page, try to find room */ - list_for_each_entry(sp, slob_list, list) { + list_for_each_entry_safe(sp, tmp, slob_list, list) { #ifdef CONFIG_NUMAsp's list head is only modified if an allocation was successful, but then the iteration stops as well. So I see no reason for your patch. Did I overlook something?
Sorry, I am wrong. Please ignore this patch.
Thanks for your comment.
But It seems that the slob_list maybe have some member's next pointer NULL. Because I triggered a NULL pointer access error.
And after I changed spin_lock_irqsave(&slob_lock, flags) before set slob_list. This bug seems disappeared.
I will resend a patch, Please review.
Thanks!
Signature · 8 lines
Regards, --Bob -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>