Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756577AbZJAODX (ORCPT ); Thu, 1 Oct 2009 10:03:23 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756561AbZJAODX (ORCPT ); Thu, 1 Oct 2009 10:03:23 -0400 Received: from victor.provo.novell.com ([137.65.250.26]:40162 "EHLO victor.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756559AbZJAODV (ORCPT ); Thu, 1 Oct 2009 10:03:21 -0400 From: Suresh Jayaraman To: Linus Torvalds , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: netdev@vger.kernel.org, Neil Brown , Miklos Szeredi , Wouter Verhelst , Peter Zijlstra , trond.myklebust@fys.uio.no, Suresh Jayaraman Subject: [PATCH 01/31] mm: serialize access to min_free_kbytes Date: Thu, 1 Oct 2009 19:34:31 +0530 Message-Id: <1254405871-15687-1-git-send-email-sjayaraman@suse.de> X-Mailer: git-send-email 1.6.0.2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2224 Lines: 70 From: Peter Zijlstra 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 Signed-off-by: Suresh Jayaraman --- 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 from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/