Useless locking in mm/numa.c
PATCH 1/1 Useless locking in mm/numa.c
There is a lock that is apparently protecting nothing. The node_lock spinlock in mm/numa.c is protecting read-only accesses to pgdat_list. Here is a patch to get rid of it.
Cheers!
-Matt
mm/numa.c.fixed renamed from mm/numa.c +0 -6
@@ -44,15 +44,11 @@ #define LONG_ALIGN(x) (((x)+(sizeof(long))-1)&~((sizeof(long))-1)) -static spinlock_t node_lock = SPIN_LOCK_UNLOCKED; - void show_free_areas_node(pg_data_t *pgdat) { unsigned long flags; - spin_lock_irqsave(&node_lock, flags); show_free_areas_core(pgdat); - spin_unlock_irqrestore(&node_lock, flags); } /*
@@ -106,11 +102,9 @@ #ifdef CONFIG_NUMA temp = NODE_DATA(numa_node_id()); #else - spin_lock_irqsave(&node_lock, flags); if (!next) next = pgdat_list; temp = next; next = next->node_next; - spin_unlock_irqrestore(&node_lock, flags); #endif start = temp; while (temp) {
I think I put in the locks in the initial version of the file becase the idea was that show_free_areas_node() could be invoked from any cpu in a multinode system (via the sysrq keys or other intr sources), and the spin lock would provide sanity in the print out.
For nonnuma discontig machines, isn't the spin lock providing protection in the pgdat list chain walking in _alloc_pages()?
Kanoj
Quoted 33 lines · --- Matthew Dobson
There is a lock that is apparently protecting
nothing. Thenode_lockspinlock
inmm/numa.cis protecting read-only accesses topgdat_list. Here is a patch
to get rid of it.Cheers!
-Matt
Quoted 1 line
---
linux-2.5.26-vanilla/mm/numa.cTue Jul 1616:49:30 2002
+++ linux-2.5.26-vanilla/mm/numa.c.fixed Thu Jul 18
17:59:35 2002mm/numa.c.fixed renamed from mm/numa.c +0
-4@@ -44,15 +44,11 @@ #define LONG_ALIGN(x) (((x)+(sizeof(long))-1)&~((sizeof(long))-1)) -static spinlock_t node_lock = SPIN_LOCK_UNLOCKED; - void show_free_areas_node(pg_data_t *pgdat) { unsigned long flags; - spin_lock_irqsave(&node_lock, flags); show_free_areas_core(pgdat); - spin_unlock_irqrestore(&node_lock, flags); }/*
mm/numa.c.fixed renamed from mm/numa.c +0
-0@@ -106,11 +102,9 @@ #ifdef CONFIG_NUMA
mm/numa.c.fixed line 110
Quoted 10 lines
mm/numa.c.fixed renamed from mm/numa.c +0
-2temp = NODE_DATA(numa_node_id()); #else - spin_lock_irqsave(&node_lock, flags); if (!next) next = pgdat_list; temp = next; next = next->node_next; - spin_unlock_irqrestore(&node_lock, flags); #endif start = temp; while (temp) {
__________________________________________________
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.com
--
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/
Quoted 10 lines · Kanoj Sarcar
I think I put in the locks in the initial version of the file becase the idea was that
show_free_areas_node()could be invoked from any cpu in a multinode system (via the sysrq keys or other intr sources), and the spin lock would provide sanity in the print out.
For nonnuma discontig machines, isn't the spin lock providing protection in the pgdat list chain walking in_alloc_pages()?
Kanoj
Since I just posted a patch removing the entire function, exactly where is this called from? A grep of current 2.5 shows that it's never called from anywhere.
Cheers,
Bill
--
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/
Quoted 24 lines · --- William Lee Irwin III
Quoted 1 line · Kanoj Sarcar
I think I put in the locks in the initial version
of
Quoted 2 lines
the file becase the idea was that
show_free_areas_node()could be invoked from anycpu
Quoted 4 lines
in a multinode system (via the sysrq keys or other intr sources), and the spin lock would provide sanity in the print out.
For nonnuma discontig machines, isn't the spinlock
Quoted 1 line
providing protection in the pgdat list chain
walking
Quoted 2 lines
in
_alloc_pages()?
KanojSince I just posted a patch removing the entire
function, exactly
where is this called from? A grep of current 2.5
shows that it's
never called from anywhere.
Quoted 2 lines
Cheers,
Bill
Ok. I was just pointing out why the lock was added initially. The reasons might not make sense anymore.
Kanoj
__________________________________________________
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.com
--
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/
Quoted 4 lines · Kanoj Sarcar
I think I put in the locks in the initial version of
the file becase the idea was thatshow_free_areas_node()could be invoked from any cpu in a multinode system (via the sysrq keys or other
intr sources), and the spin lock would provide sanity in the print out.
As Bill mentioned, a grep through the source shows that show_free_areas_node() is never called, and since it boils down to *just* a call to show_free_areas_core() w/out the locking, the revised patch pulls it out entirely.
Quoted 3 lines
For nonnuma discontig machines, isn't the spin lock providing protection in the pgdat list chain walking in
_alloc_pages()?
Uhh... kinda? Since *next is static, it means that at best case, 2 processes walking the pgdat_list chain will hip-hop over nodes... If it is racy code, the *best* that lock is currently doing is making it mildy less racy, and at worst, hiding the fact that there is a race there.
I'm sure the lock was useful at some point, but it no longer is... Attatched is the new version, please apply..
Cheers!
-Matt
Quoted 47 lines
Kanoj
Quoted 42 lines · --- Matthew Dobson
There is a lock that is apparently protecting
nothing. Thenode_lockspinlock inmm/numa.cis protecting read-only accesses topgdat_list. Here is a patch to get rid of it.Cheers!
-Matt
Quoted 1 line
---
linux-2.5.26-vanilla/mm/numa.cTue Jul 1616:49:30 2002
+++ linux-2.5.26-vanilla/mm/numa.c.fixed Thu Jul 18
17:59:35 2002(quoted diff) +0
-4@@ -44,15 +44,11 @@ #define LONG_ALIGN(x) (((x)+(sizeof(long))-1)&~((sizeof(long))-1)) -static spinlock_t node_lock = SPIN_LOCK_UNLOCKED; - void show_free_areas_node(pg_data_t *pgdat) { unsigned long flags; - spin_lock_irqsave(&node_lock, flags); show_free_areas_core(pgdat); - spin_unlock_irqrestore(&node_lock, flags); }/*
(quoted diff) +0
-2@@ -106,11 +102,9 @@ #ifdef CONFIG_NUMA temp = NODE_DATA(numa_node_id()); #else - spin_lock_irqsave(&node_lock, flags); if (!next) next = pgdat_list; temp = next; next = next->node_next; - spin_unlock_irqrestore(&node_lock, flags); #endif start = temp; while (temp) {
Quoted 9 lines
Quoted 1 line
__________________________________________________
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.com
mm/numa.c.fixed renamed from mm/numa.c +0 -13
@@ -43,17 +43,6 @@ #ifdef CONFIG_DISCONTIGMEM #define LONG_ALIGN(x) (((x)+(sizeof(long))-1)&~((sizeof(long))-1)) - -static spinlock_t node_lock = SPIN_LOCK_UNLOCKED; - -void show_free_areas_node(pg_data_t *pgdat) -{ - unsigned long flags; - - spin_lock_irqsave(&node_lock, flags); - show_free_areas_core(pgdat); - spin_unlock_irqrestore(&node_lock, flags); -} /* * Nodes can be initialized parallely, in no particular order.
@@ -106,11 +103,9 @@ #ifdef CONFIG_NUMA temp = NODE_DATA(numa_node_id()); #else - spin_lock_irqsave(&node_lock, flags); if (!next) next = pgdat_list; temp = next; next = next->node_next; - spin_unlock_irqrestore(&node_lock, flags); #endif start = temp; while (temp) {
Whoops! wli pointed out that I forgot a reference to show_free_areas_node() in mm.h. This patch should remedy that!
Cheers!
-Matt
Quoted 104 lines · Matthew Dobson
Quoted 4 lines · Kanoj Sarcar
I think I put in the locks in the initial version of
the file becase the idea was thatshow_free_areas_node()could be invoked from any cpu in a multinode system (via the sysrq keys or other
intr sources), and the spin lock would provide sanity in the print out.As Bill mentioned, a grep through the source shows that
show_free_areas_node()is never called, and since it boils down to *just* a call toshow_free_areas_core()w/out the locking, the revised patch pulls it out entirely.Quoted 3 lines
For nonnuma discontig machines, isn't the spin lock providing protection in the pgdat list chain walking in
_alloc_pages()?Uhh... kinda? Since *next is static, it means that at best case, 2 processes walking the
pgdat_listchain will hip-hop over nodes... If it is racy code, the *best* that lock is currently doing is making it mildy less racy, and at worst, hiding the fact that there is a race there.I'm sure the lock was useful at some point, but it no longer is... Attatched is the new version, please apply..
Cheers!
-Matt
Quoted 48 lines
Kanoj
Quoted 43 lines · --- Matthew Dobson
There is a lock that is apparently protecting
nothing. Thenode_lockspinlock inmm/numa.cis protecting read-only accesses topgdat_list. Here is a patch to get rid of it.Cheers!
-Matt
Quoted 1 line
---
linux-2.5.26-vanilla/mm/numa.cTue Jul 1616:49:30 2002
+++ linux-2.5.26-vanilla/mm/numa.c.fixed Thu Jul 18
17:59:35 2002(quoted diff) +0
-4@@ -44,15 +44,11 @@ #define LONG_ALIGN(x) (((x)+(sizeof(long))-1)&~((sizeof(long))-1)) -static spinlock_t node_lock = SPIN_LOCK_UNLOCKED; - void show_free_areas_node(pg_data_t *pgdat) { unsigned long flags; - spin_lock_irqsave(&node_lock, flags); show_free_areas_core(pgdat); - spin_unlock_irqrestore(&node_lock, flags); }/*
(quoted diff) +0
-2@@ -106,11 +102,9 @@ #ifdef CONFIG_NUMA temp = NODE_DATA(numa_node_id()); #else - spin_lock_irqsave(&node_lock, flags); if (!next) next = pgdat_list; temp = next; next = next->node_next; - spin_unlock_irqrestore(&node_lock, flags); #endif start = temp; while (temp) {Quoted 9 lines
Quoted 1 line
__________________________________________________
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.com------------------------------------------------------------------------
mm/numa.c.fixed renamed from mm/numa.c +0
-11@@ -43,17 +43,6 @@ #ifdef CONFIG_DISCONTIGMEM #define LONG_ALIGN(x) (((x)+(sizeof(long))-1)&~((sizeof(long))-1)) - -static spinlock_t node_lock = SPIN_LOCK_UNLOCKED; - -void show_free_areas_node(pg_data_t *pgdat) -{ - unsigned long flags; - - spin_lock_irqsave(&node_lock, flags); - show_free_areas_core(pgdat); - spin_unlock_irqrestore(&node_lock, flags); -} /* * Nodes can be initialized parallely, in no particular order.@@ -106,11 +103,9 @@ #ifdef CONFIG_NUMA
mm/numa.c.fixed line 111
Quoted 10 lines
mm/numa.c.fixed renamed from mm/numa.c +0
-2temp = NODE_DATA(numa_node_id()); #else - spin_lock_irqsave(&node_lock, flags); if (!next) next = pgdat_list; temp = next; next = next->node_next; - spin_unlock_irqrestore(&node_lock, flags); #endif start = temp; while (temp) {
mm/numa.c.fixed renamed from mm/numa.c +0 -13
@@ -43,17 +43,6 @@ #ifdef CONFIG_DISCONTIGMEM #define LONG_ALIGN(x) (((x)+(sizeof(long))-1)&~((sizeof(long))-1)) - -static spinlock_t node_lock = SPIN_LOCK_UNLOCKED; - -void show_free_areas_node(pg_data_t *pgdat) -{ - unsigned long flags; - - spin_lock_irqsave(&node_lock, flags); - show_free_areas_core(pgdat); - spin_unlock_irqrestore(&node_lock, flags); -} /* * Nodes can be initialized parallely, in no particular order.
@@ -106,11 +103,9 @@ #ifdef CONFIG_NUMA temp = NODE_DATA(numa_node_id()); #else - spin_lock_irqsave(&node_lock, flags); if (!next) next = pgdat_list; temp = next; next = next->node_next; - spin_unlock_irqrestore(&node_lock, flags); #endif start = temp; while (temp) {
include/linux/mm.h.fixed renamed from include/linux/mm.h +0 -1
@@ -319,7 +319,6 @@ extern struct page *mem_map; extern void show_free_areas(void); -extern void show_free_areas_node(pg_data_t *pgdat); extern int fail_writepage(struct page *); struct page * shmem_nopage(struct vm_area_struct * vma, unsigned long address, int unused);