From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx111.postini.com [74.125.245.111]) by kanga.kvack.org (Postfix) with SMTP id D10E66B01A3 for ; Wed, 1 May 2013 18:17:29 -0400 (EDT) Received: from /spool/local by e8.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 1 May 2013 18:17:28 -0400 Received: from d01relay01.pok.ibm.com (d01relay01.pok.ibm.com [9.56.227.233]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id E5DE86E803C for ; Wed, 1 May 2013 18:17:22 -0400 (EDT) Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay01.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r41MHPjW287962 for ; Wed, 1 May 2013 18:17:25 -0400 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r41MHPVc010430 for ; Wed, 1 May 2013 18:17:25 -0400 From: Cody P Schafer Subject: [PATCH 0/4] misc patches related to resizing nodes & zones Date: Wed, 1 May 2013 15:17:11 -0700 Message-Id: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> Sender: owner-linux-mm@kvack.org List-ID: To: Andrew Morton Cc: Linux MM , LKML , Cody P Schafer The first 3 are simply comment fixes and clarifications on locking. The last 1 adds additional locking when updating node_present_pages based on the existing documentation. Cody P Schafer (4): mmzone: make holding lock_memory_hotplug() a requirement for updating pgdat size mm: fix comment referring to non-existent size_seqlock, change to span_seqlock mmzone: note that node_size_lock should be manipulated via pgdat_resize_lock() memory_hotplug: use pgdat_resize_lock() when updating node_present_pages include/linux/mmzone.h | 7 ++++++- mm/memory_hotplug.c | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) -- 1.8.2.2 -- 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx125.postini.com [74.125.245.125]) by kanga.kvack.org (Postfix) with SMTP id BC6636B01A5 for ; Wed, 1 May 2013 18:17:30 -0400 (EDT) Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 1 May 2013 18:17:29 -0400 Received: from d01relay05.pok.ibm.com (d01relay05.pok.ibm.com [9.56.227.237]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id AFC4738C801A for ; Wed, 1 May 2013 18:17:26 -0400 (EDT) Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay05.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r41MHQTZ339940 for ; Wed, 1 May 2013 18:17:26 -0400 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r41MHQs8010510 for ; Wed, 1 May 2013 18:17:26 -0400 From: Cody P Schafer Subject: [PATCH 1/4] mmzone: make holding lock_memory_hotplug() a requirement for updating pgdat size Date: Wed, 1 May 2013 15:17:12 -0700 Message-Id: <1367446635-12856-2-git-send-email-cody@linux.vnet.ibm.com> In-Reply-To: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> Sender: owner-linux-mm@kvack.org List-ID: To: Andrew Morton Cc: Linux MM , LKML , Cody P Schafer All updaters of pgdat size (spanned_pages, start_pfn, and present_pages) currently also hold lock_memory_hotplug() (in addition to pgdat_resize_lock()). Document this and make holding of that lock a requirement on the update side for now, but keep the pgdat_resize_lock() around for readers that can't lock a mutex. Signed-off-by: Cody P Schafer --- include/linux/mmzone.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 5c76737..09ac172 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -716,6 +716,9 @@ typedef struct pglist_data { * or node_spanned_pages stay constant. Holding this will also * guarantee that any pfn_valid() stays that way. * + * Updaters of any of these fields also must hold + * lock_memory_hotplug(). + * * Nests above zone->lock and zone->size_seqlock. */ spinlock_t node_size_lock; -- 1.8.2.2 -- 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx199.postini.com [74.125.245.199]) by kanga.kvack.org (Postfix) with SMTP id 1C95E6B01A5 for ; Wed, 1 May 2013 18:17:32 -0400 (EDT) Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 1 May 2013 18:17:31 -0400 Received: from d01relay05.pok.ibm.com (d01relay05.pok.ibm.com [9.56.227.237]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 8BF9F38C801A for ; Wed, 1 May 2013 18:17:28 -0400 (EDT) Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay05.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r41MHSsC327820 for ; Wed, 1 May 2013 18:17:28 -0400 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r41MHSEI008972 for ; Wed, 1 May 2013 18:17:28 -0400 From: Cody P Schafer Subject: [PATCH 2/4] mm: fix comment referring to non-existent size_seqlock, change to span_seqlock Date: Wed, 1 May 2013 15:17:13 -0700 Message-Id: <1367446635-12856-3-git-send-email-cody@linux.vnet.ibm.com> In-Reply-To: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> Sender: owner-linux-mm@kvack.org List-ID: To: Andrew Morton Cc: Linux MM , LKML , Cody P Schafer Signed-off-by: Cody P Schafer --- include/linux/mmzone.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 09ac172..afd0aa5 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -719,7 +719,7 @@ typedef struct pglist_data { * Updaters of any of these fields also must hold * lock_memory_hotplug(). * - * Nests above zone->lock and zone->size_seqlock. + * Nests above zone->lock and zone->span_seqlock */ spinlock_t node_size_lock; #endif -- 1.8.2.2 -- 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx147.postini.com [74.125.245.147]) by kanga.kvack.org (Postfix) with SMTP id D1B416B01A7 for ; Wed, 1 May 2013 18:17:35 -0400 (EDT) Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 1 May 2013 18:17:34 -0400 Received: from d01relay06.pok.ibm.com (d01relay06.pok.ibm.com [9.56.227.116]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id D642738C8042 for ; Wed, 1 May 2013 18:17:31 -0400 (EDT) Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay06.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r41MHVSj36962508 for ; Wed, 1 May 2013 18:17:32 -0400 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r41MHV1w010851 for ; Wed, 1 May 2013 18:17:31 -0400 From: Cody P Schafer Subject: [PATCH 4/4] memory_hotplug: use pgdat_resize_lock() when updating node_present_pages Date: Wed, 1 May 2013 15:17:15 -0700 Message-Id: <1367446635-12856-5-git-send-email-cody@linux.vnet.ibm.com> In-Reply-To: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> Sender: owner-linux-mm@kvack.org List-ID: To: Andrew Morton Cc: Linux MM , LKML , Cody P Schafer mmzone.h documents node_size_lock (which pgdat_resize_lock() locks) as guarding against changes to node_present_pages, so actually lock it when we update node_present_pages to keep that promise. Signed-off-by: Cody P Schafer --- mm/memory_hotplug.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index a221fac..0bdca10 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -915,6 +915,7 @@ static void node_states_set_node(int node, struct memory_notify *arg) int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_type) { + unsigned long flags; unsigned long onlined_pages = 0; struct zone *zone; int need_zonelists_rebuild = 0; @@ -993,7 +994,11 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ zone->managed_pages += onlined_pages; zone->present_pages += onlined_pages; + + pgdat_resize_lock(zone->zone_pgdat, &flags); zone->zone_pgdat->node_present_pages += onlined_pages; + pgdat_resize_unlock(zone->zone_pgdat, &flags); + if (onlined_pages) { node_states_set_node(zone_to_nid(zone), &arg); if (need_zonelists_rebuild) -- 1.8.2.2 -- 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx192.postini.com [74.125.245.192]) by kanga.kvack.org (Postfix) with SMTP id 422496B01AA for ; Wed, 1 May 2013 18:17:37 -0400 (EDT) Received: from /spool/local by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 1 May 2013 16:17:36 -0600 Received: from d03relay03.boulder.ibm.com (d03relay03.boulder.ibm.com [9.17.195.228]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id DF10D3E4003F for ; Wed, 1 May 2013 16:17:18 -0600 (MDT) Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay03.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r41MHWxp105876 for ; Wed, 1 May 2013 16:17:32 -0600 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r41MHW2D006857 for ; Wed, 1 May 2013 16:17:32 -0600 From: Cody P Schafer Subject: [PATCH 3/4] mmzone: note that node_size_lock should be manipulated via pgdat_resize_lock() Date: Wed, 1 May 2013 15:17:14 -0700 Message-Id: <1367446635-12856-4-git-send-email-cody@linux.vnet.ibm.com> In-Reply-To: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> Sender: owner-linux-mm@kvack.org List-ID: To: Andrew Morton Cc: Linux MM , LKML , Cody P Schafer Signed-off-by: Cody P Schafer --- include/linux/mmzone.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index afd0aa5..45be383 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -716,6 +716,8 @@ typedef struct pglist_data { * or node_spanned_pages stay constant. Holding this will also * guarantee that any pfn_valid() stays that way. * + * Use pgdat_resize_lock() and pgdat_resize_unlock() to manipulate. + * * Updaters of any of these fields also must hold * lock_memory_hotplug(). * -- 1.8.2.2 -- 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx200.postini.com [74.125.245.200]) by kanga.kvack.org (Postfix) with SMTP id E4DAB6B01AE for ; Wed, 1 May 2013 18:26:39 -0400 (EDT) Received: by mail-pd0-f173.google.com with SMTP id v14so1025555pde.32 for ; Wed, 01 May 2013 15:26:39 -0700 (PDT) Date: Wed, 1 May 2013 15:26:37 -0700 (PDT) From: David Rientjes Subject: Re: [PATCH 1/4] mmzone: make holding lock_memory_hotplug() a requirement for updating pgdat size In-Reply-To: <1367446635-12856-2-git-send-email-cody@linux.vnet.ibm.com> Message-ID: References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> <1367446635-12856-2-git-send-email-cody@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-linux-mm@kvack.org List-ID: To: Cody P Schafer Cc: Andrew Morton , Linux MM , LKML On Wed, 1 May 2013, Cody P Schafer wrote: > All updaters of pgdat size (spanned_pages, start_pfn, and > present_pages) currently also hold lock_memory_hotplug() (in addition > to pgdat_resize_lock()). > > Document this and make holding of that lock a requirement on the update > side for now, but keep the pgdat_resize_lock() around for readers that > can't lock a mutex. > > Signed-off-by: Cody P Schafer Nack, these fields are initialized at boot without lock_memory_hotplug(), so you're statement is wrong, and all you need is pgdat_resize_lock(). -- 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx141.postini.com [74.125.245.141]) by kanga.kvack.org (Postfix) with SMTP id 1289E6B01F0 for ; Wed, 1 May 2013 18:27:57 -0400 (EDT) Received: by mail-pa0-f41.google.com with SMTP id kq12so1074161pab.14 for ; Wed, 01 May 2013 15:27:57 -0700 (PDT) Date: Wed, 1 May 2013 15:27:55 -0700 (PDT) From: David Rientjes Subject: Re: [PATCH 2/4] mm: fix comment referring to non-existent size_seqlock, change to span_seqlock In-Reply-To: <1367446635-12856-3-git-send-email-cody@linux.vnet.ibm.com> Message-ID: References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> <1367446635-12856-3-git-send-email-cody@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-linux-mm@kvack.org List-ID: To: Cody P Schafer Cc: Andrew Morton , Linux MM , LKML On Wed, 1 May 2013, Cody P Schafer wrote: > Signed-off-by: Cody P Schafer Acked-by: David Rientjes -- 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx196.postini.com [74.125.245.196]) by kanga.kvack.org (Postfix) with SMTP id C16A66B01F2 for ; Wed, 1 May 2013 18:29:42 -0400 (EDT) Received: by mail-pd0-f179.google.com with SMTP id y10so1023201pdj.10 for ; Wed, 01 May 2013 15:29:42 -0700 (PDT) Date: Wed, 1 May 2013 15:29:40 -0700 (PDT) From: David Rientjes Subject: Re: [PATCH 3/4] mmzone: note that node_size_lock should be manipulated via pgdat_resize_lock() In-Reply-To: <1367446635-12856-4-git-send-email-cody@linux.vnet.ibm.com> Message-ID: References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> <1367446635-12856-4-git-send-email-cody@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-linux-mm@kvack.org List-ID: To: Cody P Schafer Cc: Andrew Morton , Linux MM , LKML On Wed, 1 May 2013, Cody P Schafer wrote: > Signed-off-by: Cody P Schafer Nack, pgdat_resize_unlock() is unnecessary if irqs are known to be disabled. -- 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx206.postini.com [74.125.245.206]) by kanga.kvack.org (Postfix) with SMTP id 7D2BC6B01F4 for ; Wed, 1 May 2013 18:30:55 -0400 (EDT) Received: by mail-pd0-f170.google.com with SMTP id 15so1022660pdi.29 for ; Wed, 01 May 2013 15:30:54 -0700 (PDT) Date: Wed, 1 May 2013 15:30:52 -0700 (PDT) From: David Rientjes Subject: Re: [PATCH 4/4] memory_hotplug: use pgdat_resize_lock() when updating node_present_pages In-Reply-To: <1367446635-12856-5-git-send-email-cody@linux.vnet.ibm.com> Message-ID: References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> <1367446635-12856-5-git-send-email-cody@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-linux-mm@kvack.org List-ID: To: Cody P Schafer Cc: Andrew Morton , Linux MM , LKML On Wed, 1 May 2013, Cody P Schafer wrote: > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index a221fac..0bdca10 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -915,6 +915,7 @@ static void node_states_set_node(int node, struct memory_notify *arg) > > int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_type) > { > + unsigned long flags; > unsigned long onlined_pages = 0; > struct zone *zone; > int need_zonelists_rebuild = 0; > @@ -993,7 +994,11 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ > > zone->managed_pages += onlined_pages; > zone->present_pages += onlined_pages; > + > + pgdat_resize_lock(zone->zone_pgdat, &flags); > zone->zone_pgdat->node_present_pages += onlined_pages; > + pgdat_resize_unlock(zone->zone_pgdat, &flags); > + > if (onlined_pages) { > node_states_set_node(zone_to_nid(zone), &arg); > if (need_zonelists_rebuild) Why? You can't get a partial read of a word-sized data structure. -- 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx146.postini.com [74.125.245.146]) by kanga.kvack.org (Postfix) with SMTP id 1C6826B01F6 for ; Wed, 1 May 2013 18:32:12 -0400 (EDT) Received: from /spool/local by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 1 May 2013 16:32:11 -0600 Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id 1E88019D8048 for ; Wed, 1 May 2013 16:32:02 -0600 (MDT) Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r41MW7Hc108744 for ; Wed, 1 May 2013 16:32:07 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r41MW7Of018385 for ; Wed, 1 May 2013 16:32:07 -0600 Message-ID: <518197E2.7050004@linux.vnet.ibm.com> Date: Wed, 01 May 2013 15:32:02 -0700 From: Cody P Schafer MIME-Version: 1.0 Subject: Re: [PATCH 1/4] mmzone: make holding lock_memory_hotplug() a requirement for updating pgdat size References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> <1367446635-12856-2-git-send-email-cody@linux.vnet.ibm.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: David Rientjes Cc: Andrew Morton , Linux MM , LKML On 05/01/2013 03:26 PM, David Rientjes wrote: > On Wed, 1 May 2013, Cody P Schafer wrote: > >> All updaters of pgdat size (spanned_pages, start_pfn, and >> present_pages) currently also hold lock_memory_hotplug() (in addition >> to pgdat_resize_lock()). >> >> Document this and make holding of that lock a requirement on the update >> side for now, but keep the pgdat_resize_lock() around for readers that >> can't lock a mutex. >> >> Signed-off-by: Cody P Schafer > > Nack, these fields are initialized at boot without lock_memory_hotplug(), > so you're statement is wrong, and all you need is pgdat_resize_lock(). They are also initialized at boot without pgdat_resize_lock(), if we consider boot time, quite a few of the statements on when locking is required are wrong. That said, you are correct that it is not strictly required to hold lock_memory_hotplug() when updating the fields in question because pgdat_resize_lock() is used. -- 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx173.postini.com [74.125.245.173]) by kanga.kvack.org (Postfix) with SMTP id 4FC466B01F8 for ; Wed, 1 May 2013 18:36:58 -0400 (EDT) Received: from /spool/local by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 1 May 2013 16:36:56 -0600 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id 0517019D803E for ; Wed, 1 May 2013 16:36:45 -0600 (MDT) Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r41Maocw372050 for ; Wed, 1 May 2013 16:36:50 -0600 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r41MaodA018458 for ; Wed, 1 May 2013 16:36:50 -0600 Message-ID: <51819900.1010301@linux.vnet.ibm.com> Date: Wed, 01 May 2013 15:36:48 -0700 From: Cody P Schafer MIME-Version: 1.0 Subject: Re: [PATCH 3/4] mmzone: note that node_size_lock should be manipulated via pgdat_resize_lock() References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> <1367446635-12856-4-git-send-email-cody@linux.vnet.ibm.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: David Rientjes Cc: Andrew Morton , Linux MM , LKML On 05/01/2013 03:29 PM, David Rientjes wrote: > On Wed, 1 May 2013, Cody P Schafer wrote: > >> Signed-off-by: Cody P Schafer > > Nack, pgdat_resize_unlock() is unnecessary if irqs are known to be > disabled. > All this patch does is is indicate that rather than using node_size_lock directly (as it won't be around without CONFIG_MEMORY_HOTPLUG), one should use the pgdat_resize_[un]lock() helper macros. And yes, _strictly_ speaking, one could want to avoid the spin_lock_irqsave/restore that pgdat_resize_*lock() does. Right now we don't provide helpers that do that. Do you see a need for them? -- 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx130.postini.com [74.125.245.130]) by kanga.kvack.org (Postfix) with SMTP id 0494D6B01FB for ; Wed, 1 May 2013 18:39:35 -0400 (EDT) Received: by mail-da0-f48.google.com with SMTP id h32so1920dak.21 for ; Wed, 01 May 2013 15:39:35 -0700 (PDT) Date: Wed, 1 May 2013 15:39:33 -0700 (PDT) From: David Rientjes Subject: Re: [PATCH 1/4] mmzone: make holding lock_memory_hotplug() a requirement for updating pgdat size In-Reply-To: <518197E2.7050004@linux.vnet.ibm.com> Message-ID: References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> <1367446635-12856-2-git-send-email-cody@linux.vnet.ibm.com> <518197E2.7050004@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-linux-mm@kvack.org List-ID: To: Cody P Schafer Cc: Andrew Morton , Linux MM , LKML On Wed, 1 May 2013, Cody P Schafer wrote: > They are also initialized at boot without pgdat_resize_lock(), if we consider > boot time, quite a few of the statements on when locking is required are > wrong. > > That said, you are correct that it is not strictly required to hold > lock_memory_hotplug() when updating the fields in question because > pgdat_resize_lock() is used. > I think you've confused node size fields with zone size fields. -- 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx120.postini.com [74.125.245.120]) by kanga.kvack.org (Postfix) with SMTP id A7F4B6B01FE for ; Wed, 1 May 2013 18:41:07 -0400 (EDT) Received: from /spool/local by e39.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 1 May 2013 16:41:05 -0600 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id 3341A19D8043 for ; Wed, 1 May 2013 16:40:58 -0600 (MDT) Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r41Mf38r265024 for ; Wed, 1 May 2013 16:41:03 -0600 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r41Mf3LO011862 for ; Wed, 1 May 2013 16:41:03 -0600 Message-ID: <518199FE.7060908@linux.vnet.ibm.com> Date: Wed, 01 May 2013 15:41:02 -0700 From: Cody P Schafer MIME-Version: 1.0 Subject: Re: [PATCH 4/4] memory_hotplug: use pgdat_resize_lock() when updating node_present_pages References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> <1367446635-12856-5-git-send-email-cody@linux.vnet.ibm.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: David Rientjes Cc: Andrew Morton , Linux MM , LKML On 05/01/2013 03:30 PM, David Rientjes wrote: > On Wed, 1 May 2013, Cody P Schafer wrote: > >> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c >> index a221fac..0bdca10 100644 >> --- a/mm/memory_hotplug.c >> +++ b/mm/memory_hotplug.c >> @@ -915,6 +915,7 @@ static void node_states_set_node(int node, struct memory_notify *arg) >> >> int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_type) >> { >> + unsigned long flags; >> unsigned long onlined_pages = 0; >> struct zone *zone; >> int need_zonelists_rebuild = 0; >> @@ -993,7 +994,11 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ >> >> zone->managed_pages += onlined_pages; >> zone->present_pages += onlined_pages; >> + >> + pgdat_resize_lock(zone->zone_pgdat, &flags); >> zone->zone_pgdat->node_present_pages += onlined_pages; >> + pgdat_resize_unlock(zone->zone_pgdat, &flags); >> + >> if (onlined_pages) { >> node_states_set_node(zone_to_nid(zone), &arg); >> if (need_zonelists_rebuild) > > Why? You can't get a partial read of a word-sized data structure. > Guaranteed to be stable means that if I'm a reader and pgdat_resize_lock(), node_present_pages had better not change at all until I pgdat_resize_unlock(). If nothing needs this guarantee, we should change the rules of pgdat_resize_lock(). I played it safe and went with following the existing rules. -- 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx161.postini.com [74.125.245.161]) by kanga.kvack.org (Postfix) with SMTP id 23F726B0200 for ; Wed, 1 May 2013 18:42:46 -0400 (EDT) Received: by mail-pa0-f53.google.com with SMTP id kq12so2681pab.26 for ; Wed, 01 May 2013 15:42:45 -0700 (PDT) Date: Wed, 1 May 2013 15:42:43 -0700 (PDT) From: David Rientjes Subject: Re: [PATCH 3/4] mmzone: note that node_size_lock should be manipulated via pgdat_resize_lock() In-Reply-To: <51819900.1010301@linux.vnet.ibm.com> Message-ID: References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> <1367446635-12856-4-git-send-email-cody@linux.vnet.ibm.com> <51819900.1010301@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-linux-mm@kvack.org List-ID: To: Cody P Schafer Cc: Andrew Morton , Linux MM , LKML On Wed, 1 May 2013, Cody P Schafer wrote: > > > Signed-off-by: Cody P Schafer > > > > Nack, pgdat_resize_unlock() is unnecessary if irqs are known to be > > disabled. > > > > All this patch does is is indicate that rather than using node_size_lock > directly (as it won't be around without CONFIG_MEMORY_HOTPLUG), one should use > the pgdat_resize_[un]lock() helper macros. > I think that's obvious given the lock is surrounded by #ifdef CONFIG_MEMORY_HOTPLUG. The fact remains that hotplug code need not use pgdat_resize_lock() if irqs are disabled. -- 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx107.postini.com [74.125.245.107]) by kanga.kvack.org (Postfix) with SMTP id F0C6C6B01FA for ; Wed, 1 May 2013 18:45:22 -0400 (EDT) Received: from /spool/local by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 1 May 2013 16:45:22 -0600 Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id B574619D8046 for ; Wed, 1 May 2013 16:44:57 -0600 (MDT) Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r41Mj3Bk090396 for ; Wed, 1 May 2013 16:45:03 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r41Mj2gt011784 for ; Wed, 1 May 2013 16:45:03 -0600 Message-ID: <51819AED.9090408@linux.vnet.ibm.com> Date: Wed, 01 May 2013 15:45:01 -0700 From: Cody P Schafer MIME-Version: 1.0 Subject: Re: [PATCH 1/4] mmzone: make holding lock_memory_hotplug() a requirement for updating pgdat size References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> <1367446635-12856-2-git-send-email-cody@linux.vnet.ibm.com> <518197E2.7050004@linux.vnet.ibm.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: David Rientjes Cc: Andrew Morton , Linux MM , LKML On 05/01/2013 03:39 PM, David Rientjes wrote: > On Wed, 1 May 2013, Cody P Schafer wrote: > >> They are also initialized at boot without pgdat_resize_lock(), if we consider >> boot time, quite a few of the statements on when locking is required are >> wrong. >> >> That said, you are correct that it is not strictly required to hold >> lock_memory_hotplug() when updating the fields in question because >> pgdat_resize_lock() is used. >> > > I think you've confused node size fields with zone size fields. > Where? I'm afraid I don't see where I'm mixing them. -- 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx116.postini.com [74.125.245.116]) by kanga.kvack.org (Postfix) with SMTP id 77D6C6B0204 for ; Wed, 1 May 2013 18:48:07 -0400 (EDT) Received: by mail-pb0-f41.google.com with SMTP id mc17so4367pbc.14 for ; Wed, 01 May 2013 15:48:06 -0700 (PDT) Date: Wed, 1 May 2013 15:48:05 -0700 (PDT) From: David Rientjes Subject: Re: [PATCH 4/4] memory_hotplug: use pgdat_resize_lock() when updating node_present_pages In-Reply-To: <518199FE.7060908@linux.vnet.ibm.com> Message-ID: References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> <1367446635-12856-5-git-send-email-cody@linux.vnet.ibm.com> <518199FE.7060908@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-linux-mm@kvack.org List-ID: To: Cody P Schafer Cc: Andrew Morton , Linux MM , LKML On Wed, 1 May 2013, Cody P Schafer wrote: > Guaranteed to be stable means that if I'm a reader and pgdat_resize_lock(), > node_present_pages had better not change at all until I pgdat_resize_unlock(). > > If nothing needs this guarantee, we should change the rules of > pgdat_resize_lock(). I played it safe and went with following the existing > rules. > __offline_pages() breaks your guarantee. -- 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx123.postini.com [74.125.245.123]) by kanga.kvack.org (Postfix) with SMTP id 1E8BA6B0206 for ; Wed, 1 May 2013 18:48:12 -0400 (EDT) Received: from /spool/local by e8.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 1 May 2013 18:48:11 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id C3016C90028 for ; Wed, 1 May 2013 18:48:00 -0400 (EDT) Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r41Mm0MA260100 for ; Wed, 1 May 2013 18:48:01 -0400 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r41Mm0Cx026205 for ; Wed, 1 May 2013 16:48:00 -0600 Message-ID: <51819B9F.3090407@linux.vnet.ibm.com> Date: Wed, 01 May 2013 15:47:59 -0700 From: Cody P Schafer MIME-Version: 1.0 Subject: Re: [PATCH 3/4] mmzone: note that node_size_lock should be manipulated via pgdat_resize_lock() References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> <1367446635-12856-4-git-send-email-cody@linux.vnet.ibm.com> <51819900.1010301@linux.vnet.ibm.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: David Rientjes Cc: Andrew Morton , Linux MM , LKML On 05/01/2013 03:42 PM, David Rientjes wrote: > On Wed, 1 May 2013, Cody P Schafer wrote: > >>>> Signed-off-by: Cody P Schafer >>> >>> Nack, pgdat_resize_unlock() is unnecessary if irqs are known to be >>> disabled. >>> >> >> All this patch does is is indicate that rather than using node_size_lock >> directly (as it won't be around without CONFIG_MEMORY_HOTPLUG), one should use >> the pgdat_resize_[un]lock() helper macros. >> > > I think that's obvious given the lock is surrounded by > #ifdef CONFIG_MEMORY_HOTPLUG. The fact remains that hotplug code need not > use pgdat_resize_lock() if irqs are disabled. > Obvious how? This comment is the documentation on how to handle locking of pg_data_t, and doesn't mention pgdat_resize_lock() at all. Sure, a newcomer would probably find pgdat_resize_lock() eventually, even more so if they were interested in performance gains from not re-disabling local irqs. I don't see a convincing reason to omit relevant documentation and make it more difficult to find the "right" way to do things. -- 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx137.postini.com [74.125.245.137]) by kanga.kvack.org (Postfix) with SMTP id C67D96B0208 for ; Wed, 1 May 2013 18:51:06 -0400 (EDT) Received: from /spool/local by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 1 May 2013 16:51:05 -0600 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id C5CAF19D804E for ; Wed, 1 May 2013 16:50:56 -0600 (MDT) Received: from d03av06.boulder.ibm.com (d03av06.boulder.ibm.com [9.17.195.245]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r41Mp2qF358008 for ; Wed, 1 May 2013 16:51:02 -0600 Received: from d03av06.boulder.ibm.com (loopback [127.0.0.1]) by d03av06.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r41Mru5c009920 for ; Wed, 1 May 2013 16:53:57 -0600 Message-ID: <51819C54.3030704@linux.vnet.ibm.com> Date: Wed, 01 May 2013 15:51:00 -0700 From: Cody P Schafer MIME-Version: 1.0 Subject: Re: [PATCH 4/4] memory_hotplug: use pgdat_resize_lock() when updating node_present_pages References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> <1367446635-12856-5-git-send-email-cody@linux.vnet.ibm.com> <518199FE.7060908@linux.vnet.ibm.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: David Rientjes Cc: Andrew Morton , Linux MM , LKML On 05/01/2013 03:48 PM, David Rientjes wrote: > On Wed, 1 May 2013, Cody P Schafer wrote: > >> Guaranteed to be stable means that if I'm a reader and pgdat_resize_lock(), >> node_present_pages had better not change at all until I pgdat_resize_unlock(). >> >> If nothing needs this guarantee, we should change the rules of >> pgdat_resize_lock(). I played it safe and went with following the existing >> rules. >> > > __offline_pages() breaks your guarantee. > Thanks for pointing that out. Seems I fixed online_pages() but missed __offline_pages(). -- 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759279Ab3EAWRe (ORCPT ); Wed, 1 May 2013 18:17:34 -0400 Received: from e9.ny.us.ibm.com ([32.97.182.139]:58555 "EHLO e9.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757383Ab3EAWRc (ORCPT ); Wed, 1 May 2013 18:17:32 -0400 From: Cody P Schafer To: Andrew Morton Cc: Linux MM , LKML , Cody P Schafer Subject: [PATCH 2/4] mm: fix comment referring to non-existent size_seqlock, change to span_seqlock Date: Wed, 1 May 2013 15:17:13 -0700 Message-Id: <1367446635-12856-3-git-send-email-cody@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.2.2 In-Reply-To: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13050122-7182-0000-0000-0000067F1AE0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Cody P Schafer --- include/linux/mmzone.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 09ac172..afd0aa5 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -719,7 +719,7 @@ typedef struct pglist_data { * Updaters of any of these fields also must hold * lock_memory_hotplug(). * - * Nests above zone->lock and zone->size_seqlock. + * Nests above zone->lock and zone->span_seqlock */ spinlock_t node_size_lock; #endif -- 1.8.2.2 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759572Ab3EAWRi (ORCPT ); Wed, 1 May 2013 18:17:38 -0400 Received: from e9.ny.us.ibm.com ([32.97.182.139]:58663 "EHLO e9.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759298Ab3EAWRf (ORCPT ); Wed, 1 May 2013 18:17:35 -0400 From: Cody P Schafer To: Andrew Morton Cc: Linux MM , LKML , Cody P Schafer Subject: [PATCH 4/4] memory_hotplug: use pgdat_resize_lock() when updating node_present_pages Date: Wed, 1 May 2013 15:17:15 -0700 Message-Id: <1367446635-12856-5-git-send-email-cody@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.2.2 In-Reply-To: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13050122-7182-0000-0000-0000067F1AE9 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org mmzone.h documents node_size_lock (which pgdat_resize_lock() locks) as guarding against changes to node_present_pages, so actually lock it when we update node_present_pages to keep that promise. Signed-off-by: Cody P Schafer --- mm/memory_hotplug.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index a221fac..0bdca10 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -915,6 +915,7 @@ static void node_states_set_node(int node, struct memory_notify *arg) int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_type) { + unsigned long flags; unsigned long onlined_pages = 0; struct zone *zone; int need_zonelists_rebuild = 0; @@ -993,7 +994,11 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ zone->managed_pages += onlined_pages; zone->present_pages += onlined_pages; + + pgdat_resize_lock(zone->zone_pgdat, &flags); zone->zone_pgdat->node_present_pages += onlined_pages; + pgdat_resize_unlock(zone->zone_pgdat, &flags); + if (onlined_pages) { node_states_set_node(zone_to_nid(zone), &arg); if (need_zonelists_rebuild) -- 1.8.2.2 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759787Ab3EAWRo (ORCPT ); Wed, 1 May 2013 18:17:44 -0400 Received: from e38.co.us.ibm.com ([32.97.110.159]:44365 "EHLO e38.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759306Ab3EAWRh (ORCPT ); Wed, 1 May 2013 18:17:37 -0400 From: Cody P Schafer To: Andrew Morton Cc: Linux MM , LKML , Cody P Schafer Subject: [PATCH 3/4] mmzone: note that node_size_lock should be manipulated via pgdat_resize_lock() Date: Wed, 1 May 2013 15:17:14 -0700 Message-Id: <1367446635-12856-4-git-send-email-cody@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.2.2 In-Reply-To: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13050122-5518-0000-0000-00000E32186E Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Cody P Schafer --- include/linux/mmzone.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index afd0aa5..45be383 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -716,6 +716,8 @@ typedef struct pglist_data { * or node_spanned_pages stay constant. Holding this will also * guarantee that any pfn_valid() stays that way. * + * Use pgdat_resize_lock() and pgdat_resize_unlock() to manipulate. + * * Updaters of any of these fields also must hold * lock_memory_hotplug(). * -- 1.8.2.2 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758958Ab3EAWRb (ORCPT ); Wed, 1 May 2013 18:17:31 -0400 Received: from e9.ny.us.ibm.com ([32.97.182.139]:58541 "EHLO e9.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757383Ab3EAWR3 (ORCPT ); Wed, 1 May 2013 18:17:29 -0400 From: Cody P Schafer To: Andrew Morton Cc: Linux MM , LKML , Cody P Schafer Subject: [PATCH 0/4] misc patches related to resizing nodes & zones Date: Wed, 1 May 2013 15:17:11 -0700 Message-Id: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.2.2 X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13050122-7182-0000-0000-0000067F1AD5 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The first 3 are simply comment fixes and clarifications on locking. The last 1 adds additional locking when updating node_present_pages based on the existing documentation. Cody P Schafer (4): mmzone: make holding lock_memory_hotplug() a requirement for updating pgdat size mm: fix comment referring to non-existent size_seqlock, change to span_seqlock mmzone: note that node_size_lock should be manipulated via pgdat_resize_lock() memory_hotplug: use pgdat_resize_lock() when updating node_present_pages include/linux/mmzone.h | 7 ++++++- mm/memory_hotplug.c | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) -- 1.8.2.2 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760160Ab3EAWSX (ORCPT ); Wed, 1 May 2013 18:18:23 -0400 Received: from e8.ny.us.ibm.com ([32.97.182.138]:51266 "EHLO e8.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757669Ab3EAWRa (ORCPT ); Wed, 1 May 2013 18:17:30 -0400 From: Cody P Schafer To: Andrew Morton Cc: Linux MM , LKML , Cody P Schafer Subject: [PATCH 1/4] mmzone: make holding lock_memory_hotplug() a requirement for updating pgdat size Date: Wed, 1 May 2013 15:17:12 -0700 Message-Id: <1367446635-12856-2-git-send-email-cody@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.2.2 In-Reply-To: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13050122-9360-0000-0000-000011FCD099 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org All updaters of pgdat size (spanned_pages, start_pfn, and present_pages) currently also hold lock_memory_hotplug() (in addition to pgdat_resize_lock()). Document this and make holding of that lock a requirement on the update side for now, but keep the pgdat_resize_lock() around for readers that can't lock a mutex. Signed-off-by: Cody P Schafer --- include/linux/mmzone.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 5c76737..09ac172 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -716,6 +716,9 @@ typedef struct pglist_data { * or node_spanned_pages stay constant. Holding this will also * guarantee that any pfn_valid() stays that way. * + * Updaters of any of these fields also must hold + * lock_memory_hotplug(). + * * Nests above zone->lock and zone->size_seqlock. */ spinlock_t node_size_lock; -- 1.8.2.2 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758709Ab3EAW0l (ORCPT ); Wed, 1 May 2013 18:26:41 -0400 Received: from mail-pb0-f48.google.com ([209.85.160.48]:54894 "EHLO mail-pb0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756218Ab3EAW0j (ORCPT ); Wed, 1 May 2013 18:26:39 -0400 Date: Wed, 1 May 2013 15:26:37 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Cody P Schafer cc: Andrew Morton , Linux MM , LKML Subject: Re: [PATCH 1/4] mmzone: make holding lock_memory_hotplug() a requirement for updating pgdat size In-Reply-To: <1367446635-12856-2-git-send-email-cody@linux.vnet.ibm.com> Message-ID: References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> <1367446635-12856-2-git-send-email-cody@linux.vnet.ibm.com> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 1 May 2013, Cody P Schafer wrote: > All updaters of pgdat size (spanned_pages, start_pfn, and > present_pages) currently also hold lock_memory_hotplug() (in addition > to pgdat_resize_lock()). > > Document this and make holding of that lock a requirement on the update > side for now, but keep the pgdat_resize_lock() around for readers that > can't lock a mutex. > > Signed-off-by: Cody P Schafer Nack, these fields are initialized at boot without lock_memory_hotplug(), so you're statement is wrong, and all you need is pgdat_resize_lock(). From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760309Ab3EAW17 (ORCPT ); Wed, 1 May 2013 18:27:59 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:56362 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758073Ab3EAW15 (ORCPT ); Wed, 1 May 2013 18:27:57 -0400 Date: Wed, 1 May 2013 15:27:55 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Cody P Schafer cc: Andrew Morton , Linux MM , LKML Subject: Re: [PATCH 2/4] mm: fix comment referring to non-existent size_seqlock, change to span_seqlock In-Reply-To: <1367446635-12856-3-git-send-email-cody@linux.vnet.ibm.com> Message-ID: References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> <1367446635-12856-3-git-send-email-cody@linux.vnet.ibm.com> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 1 May 2013, Cody P Schafer wrote: > Signed-off-by: Cody P Schafer Acked-by: David Rientjes From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760462Ab3EAW3o (ORCPT ); Wed, 1 May 2013 18:29:44 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:35508 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758569Ab3EAW3m (ORCPT ); Wed, 1 May 2013 18:29:42 -0400 Date: Wed, 1 May 2013 15:29:40 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Cody P Schafer cc: Andrew Morton , Linux MM , LKML Subject: Re: [PATCH 3/4] mmzone: note that node_size_lock should be manipulated via pgdat_resize_lock() In-Reply-To: <1367446635-12856-4-git-send-email-cody@linux.vnet.ibm.com> Message-ID: References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> <1367446635-12856-4-git-send-email-cody@linux.vnet.ibm.com> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 1 May 2013, Cody P Schafer wrote: > Signed-off-by: Cody P Schafer Nack, pgdat_resize_unlock() is unnecessary if irqs are known to be disabled. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760039Ab3EAWa7 (ORCPT ); Wed, 1 May 2013 18:30:59 -0400 Received: from mail-da0-f51.google.com ([209.85.210.51]:50829 "EHLO mail-da0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757497Ab3EAWaz (ORCPT ); Wed, 1 May 2013 18:30:55 -0400 Date: Wed, 1 May 2013 15:30:52 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Cody P Schafer cc: Andrew Morton , Linux MM , LKML Subject: Re: [PATCH 4/4] memory_hotplug: use pgdat_resize_lock() when updating node_present_pages In-Reply-To: <1367446635-12856-5-git-send-email-cody@linux.vnet.ibm.com> Message-ID: References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> <1367446635-12856-5-git-send-email-cody@linux.vnet.ibm.com> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 1 May 2013, Cody P Schafer wrote: > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index a221fac..0bdca10 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -915,6 +915,7 @@ static void node_states_set_node(int node, struct memory_notify *arg) > > int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_type) > { > + unsigned long flags; > unsigned long onlined_pages = 0; > struct zone *zone; > int need_zonelists_rebuild = 0; > @@ -993,7 +994,11 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ > > zone->managed_pages += onlined_pages; > zone->present_pages += onlined_pages; > + > + pgdat_resize_lock(zone->zone_pgdat, &flags); > zone->zone_pgdat->node_present_pages += onlined_pages; > + pgdat_resize_unlock(zone->zone_pgdat, &flags); > + > if (onlined_pages) { > node_states_set_node(zone_to_nid(zone), &arg); > if (need_zonelists_rebuild) Why? You can't get a partial read of a word-sized data structure. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759802Ab3EAWcO (ORCPT ); Wed, 1 May 2013 18:32:14 -0400 Received: from e37.co.us.ibm.com ([32.97.110.158]:43547 "EHLO e37.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759209Ab3EAWcL (ORCPT ); Wed, 1 May 2013 18:32:11 -0400 Message-ID: <518197E2.7050004@linux.vnet.ibm.com> Date: Wed, 01 May 2013 15:32:02 -0700 From: Cody P Schafer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: David Rientjes CC: Andrew Morton , Linux MM , LKML Subject: Re: [PATCH 1/4] mmzone: make holding lock_memory_hotplug() a requirement for updating pgdat size References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> <1367446635-12856-2-git-send-email-cody@linux.vnet.ibm.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13050122-7408-0000-0000-00000FB7B14D Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/01/2013 03:26 PM, David Rientjes wrote: > On Wed, 1 May 2013, Cody P Schafer wrote: > >> All updaters of pgdat size (spanned_pages, start_pfn, and >> present_pages) currently also hold lock_memory_hotplug() (in addition >> to pgdat_resize_lock()). >> >> Document this and make holding of that lock a requirement on the update >> side for now, but keep the pgdat_resize_lock() around for readers that >> can't lock a mutex. >> >> Signed-off-by: Cody P Schafer > > Nack, these fields are initialized at boot without lock_memory_hotplug(), > so you're statement is wrong, and all you need is pgdat_resize_lock(). They are also initialized at boot without pgdat_resize_lock(), if we consider boot time, quite a few of the statements on when locking is required are wrong. That said, you are correct that it is not strictly required to hold lock_memory_hotplug() when updating the fields in question because pgdat_resize_lock() is used. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759606Ab3EAWg5 (ORCPT ); Wed, 1 May 2013 18:36:57 -0400 Received: from e32.co.us.ibm.com ([32.97.110.150]:35733 "EHLO e32.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757677Ab3EAWgy (ORCPT ); Wed, 1 May 2013 18:36:54 -0400 Message-ID: <51819900.1010301@linux.vnet.ibm.com> Date: Wed, 01 May 2013 15:36:48 -0700 From: Cody P Schafer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: David Rientjes CC: Andrew Morton , Linux MM , LKML Subject: Re: [PATCH 3/4] mmzone: note that node_size_lock should be manipulated via pgdat_resize_lock() References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> <1367446635-12856-4-git-send-email-cody@linux.vnet.ibm.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13050122-5406-0000-0000-0000081E7032 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/01/2013 03:29 PM, David Rientjes wrote: > On Wed, 1 May 2013, Cody P Schafer wrote: > >> Signed-off-by: Cody P Schafer > > Nack, pgdat_resize_unlock() is unnecessary if irqs are known to be > disabled. > All this patch does is is indicate that rather than using node_size_lock directly (as it won't be around without CONFIG_MEMORY_HOTPLUG), one should use the pgdat_resize_[un]lock() helper macros. And yes, _strictly_ speaking, one could want to avoid the spin_lock_irqsave/restore that pgdat_resize_*lock() does. Right now we don't provide helpers that do that. Do you see a need for them? From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758945Ab3EAWjh (ORCPT ); Wed, 1 May 2013 18:39:37 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:37459 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757608Ab3EAWjf (ORCPT ); Wed, 1 May 2013 18:39:35 -0400 Date: Wed, 1 May 2013 15:39:33 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Cody P Schafer cc: Andrew Morton , Linux MM , LKML Subject: Re: [PATCH 1/4] mmzone: make holding lock_memory_hotplug() a requirement for updating pgdat size In-Reply-To: <518197E2.7050004@linux.vnet.ibm.com> Message-ID: References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> <1367446635-12856-2-git-send-email-cody@linux.vnet.ibm.com> <518197E2.7050004@linux.vnet.ibm.com> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 1 May 2013, Cody P Schafer wrote: > They are also initialized at boot without pgdat_resize_lock(), if we consider > boot time, quite a few of the statements on when locking is required are > wrong. > > That said, you are correct that it is not strictly required to hold > lock_memory_hotplug() when updating the fields in question because > pgdat_resize_lock() is used. > I think you've confused node size fields with zone size fields. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759405Ab3EAWlJ (ORCPT ); Wed, 1 May 2013 18:41:09 -0400 Received: from e31.co.us.ibm.com ([32.97.110.149]:54350 "EHLO e31.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757704Ab3EAWlI (ORCPT ); Wed, 1 May 2013 18:41:08 -0400 Message-ID: <518199FE.7060908@linux.vnet.ibm.com> Date: Wed, 01 May 2013 15:41:02 -0700 From: Cody P Schafer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: David Rientjes CC: Andrew Morton , Linux MM , LKML Subject: Re: [PATCH 4/4] memory_hotplug: use pgdat_resize_lock() when updating node_present_pages References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> <1367446635-12856-5-git-send-email-cody@linux.vnet.ibm.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13050122-7282-0000-0000-000016B56E86 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/01/2013 03:30 PM, David Rientjes wrote: > On Wed, 1 May 2013, Cody P Schafer wrote: > >> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c >> index a221fac..0bdca10 100644 >> --- a/mm/memory_hotplug.c >> +++ b/mm/memory_hotplug.c >> @@ -915,6 +915,7 @@ static void node_states_set_node(int node, struct memory_notify *arg) >> >> int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_type) >> { >> + unsigned long flags; >> unsigned long onlined_pages = 0; >> struct zone *zone; >> int need_zonelists_rebuild = 0; >> @@ -993,7 +994,11 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ >> >> zone->managed_pages += onlined_pages; >> zone->present_pages += onlined_pages; >> + >> + pgdat_resize_lock(zone->zone_pgdat, &flags); >> zone->zone_pgdat->node_present_pages += onlined_pages; >> + pgdat_resize_unlock(zone->zone_pgdat, &flags); >> + >> if (onlined_pages) { >> node_states_set_node(zone_to_nid(zone), &arg); >> if (need_zonelists_rebuild) > > Why? You can't get a partial read of a word-sized data structure. > Guaranteed to be stable means that if I'm a reader and pgdat_resize_lock(), node_present_pages had better not change at all until I pgdat_resize_unlock(). If nothing needs this guarantee, we should change the rules of pgdat_resize_lock(). I played it safe and went with following the existing rules. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758041Ab3EAWms (ORCPT ); Wed, 1 May 2013 18:42:48 -0400 Received: from mail-pb0-f43.google.com ([209.85.160.43]:48966 "EHLO mail-pb0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757217Ab3EAWmp (ORCPT ); Wed, 1 May 2013 18:42:45 -0400 Date: Wed, 1 May 2013 15:42:43 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Cody P Schafer cc: Andrew Morton , Linux MM , LKML Subject: Re: [PATCH 3/4] mmzone: note that node_size_lock should be manipulated via pgdat_resize_lock() In-Reply-To: <51819900.1010301@linux.vnet.ibm.com> Message-ID: References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> <1367446635-12856-4-git-send-email-cody@linux.vnet.ibm.com> <51819900.1010301@linux.vnet.ibm.com> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 1 May 2013, Cody P Schafer wrote: > > > Signed-off-by: Cody P Schafer > > > > Nack, pgdat_resize_unlock() is unnecessary if irqs are known to be > > disabled. > > > > All this patch does is is indicate that rather than using node_size_lock > directly (as it won't be around without CONFIG_MEMORY_HOTPLUG), one should use > the pgdat_resize_[un]lock() helper macros. > I think that's obvious given the lock is surrounded by #ifdef CONFIG_MEMORY_HOTPLUG. The fact remains that hotplug code need not use pgdat_resize_lock() if irqs are disabled. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759140Ab3EAWpL (ORCPT ); Wed, 1 May 2013 18:45:11 -0400 Received: from e39.co.us.ibm.com ([32.97.110.160]:38231 "EHLO e39.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757471Ab3EAWpH (ORCPT ); Wed, 1 May 2013 18:45:07 -0400 Message-ID: <51819AED.9090408@linux.vnet.ibm.com> Date: Wed, 01 May 2013 15:45:01 -0700 From: Cody P Schafer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: David Rientjes CC: Andrew Morton , Linux MM , LKML Subject: Re: [PATCH 1/4] mmzone: make holding lock_memory_hotplug() a requirement for updating pgdat size References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> <1367446635-12856-2-git-send-email-cody@linux.vnet.ibm.com> <518197E2.7050004@linux.vnet.ibm.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13050122-3620-0000-0000-00000249C287 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/01/2013 03:39 PM, David Rientjes wrote: > On Wed, 1 May 2013, Cody P Schafer wrote: > >> They are also initialized at boot without pgdat_resize_lock(), if we consider >> boot time, quite a few of the statements on when locking is required are >> wrong. >> >> That said, you are correct that it is not strictly required to hold >> lock_memory_hotplug() when updating the fields in question because >> pgdat_resize_lock() is used. >> > > I think you've confused node size fields with zone size fields. > Where? I'm afraid I don't see where I'm mixing them. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759675Ab3EAWsJ (ORCPT ); Wed, 1 May 2013 18:48:09 -0400 Received: from mail-pb0-f52.google.com ([209.85.160.52]:33531 "EHLO mail-pb0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757477Ab3EAWsH (ORCPT ); Wed, 1 May 2013 18:48:07 -0400 Date: Wed, 1 May 2013 15:48:05 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Cody P Schafer cc: Andrew Morton , Linux MM , LKML Subject: Re: [PATCH 4/4] memory_hotplug: use pgdat_resize_lock() when updating node_present_pages In-Reply-To: <518199FE.7060908@linux.vnet.ibm.com> Message-ID: References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> <1367446635-12856-5-git-send-email-cody@linux.vnet.ibm.com> <518199FE.7060908@linux.vnet.ibm.com> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 1 May 2013, Cody P Schafer wrote: > Guaranteed to be stable means that if I'm a reader and pgdat_resize_lock(), > node_present_pages had better not change at all until I pgdat_resize_unlock(). > > If nothing needs this guarantee, we should change the rules of > pgdat_resize_lock(). I played it safe and went with following the existing > rules. > __offline_pages() breaks your guarantee. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759881Ab3EAWsR (ORCPT ); Wed, 1 May 2013 18:48:17 -0400 Received: from e8.ny.us.ibm.com ([32.97.182.138]:57522 "EHLO e8.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759778Ab3EAWsN (ORCPT ); Wed, 1 May 2013 18:48:13 -0400 Message-ID: <51819B9F.3090407@linux.vnet.ibm.com> Date: Wed, 01 May 2013 15:47:59 -0700 From: Cody P Schafer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: David Rientjes CC: Andrew Morton , Linux MM , LKML Subject: Re: [PATCH 3/4] mmzone: note that node_size_lock should be manipulated via pgdat_resize_lock() References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> <1367446635-12856-4-git-send-email-cody@linux.vnet.ibm.com> <51819900.1010301@linux.vnet.ibm.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13050122-9360-0000-0000-000011FCE076 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/01/2013 03:42 PM, David Rientjes wrote: > On Wed, 1 May 2013, Cody P Schafer wrote: > >>>> Signed-off-by: Cody P Schafer >>> >>> Nack, pgdat_resize_unlock() is unnecessary if irqs are known to be >>> disabled. >>> >> >> All this patch does is is indicate that rather than using node_size_lock >> directly (as it won't be around without CONFIG_MEMORY_HOTPLUG), one should use >> the pgdat_resize_[un]lock() helper macros. >> > > I think that's obvious given the lock is surrounded by > #ifdef CONFIG_MEMORY_HOTPLUG. The fact remains that hotplug code need not > use pgdat_resize_lock() if irqs are disabled. > Obvious how? This comment is the documentation on how to handle locking of pg_data_t, and doesn't mention pgdat_resize_lock() at all. Sure, a newcomer would probably find pgdat_resize_lock() eventually, even more so if they were interested in performance gains from not re-disabling local irqs. I don't see a convincing reason to omit relevant documentation and make it more difficult to find the "right" way to do things. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760091Ab3EAWvI (ORCPT ); Wed, 1 May 2013 18:51:08 -0400 Received: from e34.co.us.ibm.com ([32.97.110.152]:36148 "EHLO e34.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758355Ab3EAWvG (ORCPT ); Wed, 1 May 2013 18:51:06 -0400 Message-ID: <51819C54.3030704@linux.vnet.ibm.com> Date: Wed, 01 May 2013 15:51:00 -0700 From: Cody P Schafer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: David Rientjes CC: Andrew Morton , Linux MM , LKML Subject: Re: [PATCH 4/4] memory_hotplug: use pgdat_resize_lock() when updating node_present_pages References: <1367446635-12856-1-git-send-email-cody@linux.vnet.ibm.com> <1367446635-12856-5-git-send-email-cody@linux.vnet.ibm.com> <518199FE.7060908@linux.vnet.ibm.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13050122-2876-0000-0000-000008331950 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/01/2013 03:48 PM, David Rientjes wrote: > On Wed, 1 May 2013, Cody P Schafer wrote: > >> Guaranteed to be stable means that if I'm a reader and pgdat_resize_lock(), >> node_present_pages had better not change at all until I pgdat_resize_unlock(). >> >> If nothing needs this guarantee, we should change the rules of >> pgdat_resize_lock(). I played it safe and went with following the existing >> rules. >> > > __offline_pages() breaks your guarantee. > Thanks for pointing that out. Seems I fixed online_pages() but missed __offline_pages().