* [PATCH 01/31] mm: serialize access to min_free_kbytes
@ 2009-10-01 14:04 Suresh Jayaraman
2009-10-01 20:35 ` David Rientjes
0 siblings, 1 reply; 3+ messages in thread
From: Suresh Jayaraman @ 2009-10-01 14:04 UTC (permalink / raw)
To: Linus Torvalds, Andrew Morton, linux-kernel, linux-mm
Cc: netdev, Neil Brown, Miklos Szeredi, Wouter Verhelst,
Peter Zijlstra, trond.myklebust, Suresh Jayaraman
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
There is a small race between the procfs caller and the memory hotplug caller
of setup_per_zone_wmarks(). Not a big deal, but the next patch will add yet
another caller. Time to close the gap.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
---
mm/page_alloc.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
Index: mmotm/mm/page_alloc.c
===================================================================
--- mmotm.orig/mm/page_alloc.c
+++ mmotm/mm/page_alloc.c
@@ -121,6 +121,7 @@ static char * const zone_names[MAX_NR_ZO
"Movable",
};
+static DEFINE_SPINLOCK(min_free_lock);
int min_free_kbytes = 1024;
unsigned long __meminitdata nr_kernel_pages;
@@ -4448,13 +4449,13 @@ static void setup_per_zone_lowmem_reserv
}
/**
- * setup_per_zone_wmarks - called when min_free_kbytes changes
+ * __setup_per_zone_wmarks - called when min_free_kbytes changes
* or when memory is hot-{added|removed}
*
* Ensures that the watermark[min,low,high] values for each zone are set
* correctly with respect to min_free_kbytes.
*/
-void setup_per_zone_wmarks(void)
+static void __setup_per_zone_wmarks(void)
{
unsigned long pages_min = min_free_kbytes >> (PAGE_SHIFT - 10);
unsigned long lowmem_pages = 0;
@@ -4552,6 +4553,15 @@ static void __init setup_per_zone_inacti
calculate_zone_inactive_ratio(zone);
}
+void setup_per_zone_wmarks(void)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&min_free_lock, flags);
+ __setup_per_zone_wmarks();
+ spin_unlock_irqrestore(&min_free_lock, flags);
+}
+
/*
* Initialise min_free_kbytes.
*
@@ -4587,7 +4597,7 @@ static int __init init_per_zone_wmark_mi
min_free_kbytes = 128;
if (min_free_kbytes > 65536)
min_free_kbytes = 65536;
- setup_per_zone_wmarks();
+ __setup_per_zone_wmarks();
setup_per_zone_lowmem_reserve();
setup_per_zone_inactive_ratio();
return 0;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 01/31] mm: serialize access to min_free_kbytes
2009-10-01 14:04 [PATCH 01/31] mm: serialize access to min_free_kbytes Suresh Jayaraman
@ 2009-10-01 20:35 ` David Rientjes
2009-10-02 5:20 ` Neil Brown
0 siblings, 1 reply; 3+ messages in thread
From: David Rientjes @ 2009-10-01 20:35 UTC (permalink / raw)
To: Suresh Jayaraman
Cc: Linus Torvalds, Andrew Morton, linux-kernel, linux-mm, netdev,
Neil Brown, Miklos Szeredi, Wouter Verhelst, Peter Zijlstra,
trond.myklebust
On Thu, 1 Oct 2009, Suresh Jayaraman wrote:
> From: Peter Zijlstra <a.p.zijlstra@chello.nl>
>
> There is a small race between the procfs caller and the memory hotplug caller
> of setup_per_zone_wmarks(). Not a big deal, but the next patch will add yet
> another caller. Time to close the gap.
>
By "next patch," you mean "mm: emegency pool" (patch 08/31)?
If so, can't you eliminate var_free_mutex entirely from that patch and
take min_free_lock in adjust_memalloc_reserve() instead?
[ __adjust_memalloc_reserve() would call __setup_per_zone_wmarks()
under lock instead, now. ]
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 01/31] mm: serialize access to min_free_kbytes
2009-10-01 20:35 ` David Rientjes
@ 2009-10-02 5:20 ` Neil Brown
0 siblings, 0 replies; 3+ messages in thread
From: Neil Brown @ 2009-10-02 5:20 UTC (permalink / raw)
To: David Rientjes
Cc: Suresh Jayaraman, Linus Torvalds, Andrew Morton, linux-kernel,
linux-mm, netdev, Miklos Szeredi, Wouter Verhelst, Peter Zijlstra,
trond.myklebust
On Thursday October 1, rientjes@google.com wrote:
> On Thu, 1 Oct 2009, Suresh Jayaraman wrote:
>
> > From: Peter Zijlstra <a.p.zijlstra@chello.nl>
> >
> > There is a small race between the procfs caller and the memory hotplug caller
> > of setup_per_zone_wmarks(). Not a big deal, but the next patch will add yet
> > another caller. Time to close the gap.
> >
>
> By "next patch," you mean "mm: emegency pool" (patch 08/31)?
:-) It is always safer to say "a subsequent patch", isn't it....
>
> If so, can't you eliminate var_free_mutex entirely from that patch and
> take min_free_lock in adjust_memalloc_reserve() instead?
adjust_memalloc_reserve does a test alloc/free cycle under a lock.
That cannot be done under a spin-lock, it must be a mutex.
So I don't think you can eliminate var_free_mutex.
Thanks,
NeilBrown
>
> [ __adjust_memalloc_reserve() would call __setup_per_zone_wmarks()
> under lock instead, now. ]
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-10-02 5:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-01 14:04 [PATCH 01/31] mm: serialize access to min_free_kbytes Suresh Jayaraman
2009-10-01 20:35 ` David Rientjes
2009-10-02 5:20 ` Neil Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).