From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754281Ab3F0T4Y (ORCPT ); Thu, 27 Jun 2013 15:56:24 -0400 Received: from e23smtp02.au.ibm.com ([202.81.31.144]:42562 "EHLO e23smtp02.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754249Ab3F0T4T (ORCPT ); Thu, 27 Jun 2013 15:56:19 -0400 From: "Srivatsa S. Bhat" Subject: [PATCH v3 03/45] Documentation, CPU hotplug: Recommend usage of get/put_online_cpus_atomic() To: tglx@linutronix.de, peterz@infradead.org, tj@kernel.org, oleg@redhat.com, paulmck@linux.vnet.ibm.com, rusty@rustcorp.com.au, mingo@kernel.org, akpm@linux-foundation.org, namhyung@kernel.org, walken@google.com, vincent.guittot@linaro.org, laijs@cn.fujitsu.com, David.Laight@aculab.com Cc: rostedt@goodmis.org, wangyun@linux.vnet.ibm.com, xiaoguangrong@linux.vnet.ibm.com, sbw@mit.edu, fweisbec@gmail.com, zhong@linux.vnet.ibm.com, nikunj@linux.vnet.ibm.com, srivatsa.bhat@linux.vnet.ibm.com, linux-pm@vger.kernel.org, linux-arch@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Rob Landley , linux-doc@vger.kernel.org, "Srivatsa S. Bhat" Date: Fri, 28 Jun 2013 01:22:52 +0530 Message-ID: <20130627195252.29830.17952.stgit@srivatsabhat.in.ibm.com> In-Reply-To: <20130627195136.29830.10445.stgit@srivatsabhat.in.ibm.com> References: <20130627195136.29830.10445.stgit@srivatsabhat.in.ibm.com> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13062719-5490-0000-0000-000003BA3092 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Once stop_machine() is gone from the CPU offline path, we won't be able to depend on disabling preemption to prevent CPUs from going offline from under us. So add documentation to recommend using the new get/put_online_cpus_atomic() APIs to prevent CPUs from going offline, while invoking from atomic context. Cc: Rob Landley Cc: linux-doc@vger.kernel.org Signed-off-by: Srivatsa S. Bhat --- Documentation/cpu-hotplug.txt | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Documentation/cpu-hotplug.txt b/Documentation/cpu-hotplug.txt index 9f40135..7b3ca60 100644 --- a/Documentation/cpu-hotplug.txt +++ b/Documentation/cpu-hotplug.txt @@ -113,13 +113,18 @@ Never use anything other than cpumask_t to represent bitmap of CPUs. #include get_online_cpus() and put_online_cpus(): -The above calls are used to inhibit cpu hotplug operations. While the +The above calls are used to inhibit cpu hotplug operations, when invoked from +non-atomic contexts (because the above functions can sleep). While the cpu_hotplug.refcount is non zero, the cpu_online_mask will not change. -If you merely need to avoid cpus going away, you could also use -preempt_disable() and preempt_enable() for those sections. -Just remember the critical section cannot call any -function that can sleep or schedule this process away. The preempt_disable() -will work as long as stop_machine_run() is used to take a cpu down. + +However, if you are executing in atomic context (ie., you can't afford to +sleep), and you merely need to avoid cpus going offline, you can use +get_online_cpus_atomic() and put_online_cpus_atomic() for those sections. +Just remember the critical section cannot call any function that can sleep or +schedule this process away. Using preempt_disable() will also work, as long +as stop_machine() is used to take a CPU down. But we are going to get rid of +stop_machine() in the CPU offline path soon, so it is strongly recommended +to use the APIs mentioned above. CPU Hotplug - Frequently Asked Questions. @@ -360,6 +365,9 @@ A: There are two ways. If your code can be run in interrupt context, use return err; } + If my_func_on_cpu() itself cannot block, use get/put_online_cpus_atomic() + instead of get/put_online_cpus(), to prevent CPUs from going offline. + Q: How do we determine how many CPUs are available for hotplug. A: There is no clear spec defined way from ACPI that can give us that information today. Based on some input from Natalie of Unisys, From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Srivatsa S. Bhat" Subject: [PATCH v3 03/45] Documentation, CPU hotplug: Recommend usage of get/put_online_cpus_atomic() Date: Fri, 28 Jun 2013 01:22:52 +0530 Message-ID: <20130627195252.29830.17952.stgit@srivatsabhat.in.ibm.com> References: <20130627195136.29830.10445.stgit@srivatsabhat.in.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20130627195136.29830.10445.stgit@srivatsabhat.in.ibm.com> Sender: linux-kernel-owner@vger.kernel.org To: tglx@linutronix.de, peterz@infradead.org, tj@kernel.org, oleg@redhat.com, paulmck@linux.vnet.ibm.com, rusty@rustcorp.com.au, mingo@kernel.org, akpm@linux-foundation.org, namhyung@kernel.org, walken@google.com, vincent.guittot@linaro.org, laijs@cn.fujitsu.com, David.Laight@aculab.com Cc: rostedt@goodmis.org, wangyun@linux.vnet.ibm.com, xiaoguangrong@linux.vnet.ibm.com, sbw@mit.edu, fweisbec@gmail.com, zhong@linux.vnet.ibm.com, nikunj@linux.vnet.ibm.com, srivatsa.bhat@linux.vnet.ibm.com, linux-pm@vger.kernel.org, linux-arch@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Rob Landley , linux-doc@vger.kernel.org"Srivatsa S. Bhat" List-Id: linux-arch.vger.kernel.org Once stop_machine() is gone from the CPU offline path, we won't be able to depend on disabling preemption to prevent CPUs from going offline from under us. So add documentation to recommend using the new get/put_online_cpus_atomic() APIs to prevent CPUs from going offline, while invoking from atomic context. Cc: Rob Landley Cc: linux-doc@vger.kernel.org Signed-off-by: Srivatsa S. Bhat --- Documentation/cpu-hotplug.txt | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Documentation/cpu-hotplug.txt b/Documentation/cpu-hotplug.txt index 9f40135..7b3ca60 100644 --- a/Documentation/cpu-hotplug.txt +++ b/Documentation/cpu-hotplug.txt @@ -113,13 +113,18 @@ Never use anything other than cpumask_t to represent bitmap of CPUs. #include get_online_cpus() and put_online_cpus(): -The above calls are used to inhibit cpu hotplug operations. While the +The above calls are used to inhibit cpu hotplug operations, when invoked from +non-atomic contexts (because the above functions can sleep). While the cpu_hotplug.refcount is non zero, the cpu_online_mask will not change. -If you merely need to avoid cpus going away, you could also use -preempt_disable() and preempt_enable() for those sections. -Just remember the critical section cannot call any -function that can sleep or schedule this process away. The preempt_disable() -will work as long as stop_machine_run() is used to take a cpu down. + +However, if you are executing in atomic context (ie., you can't afford to +sleep), and you merely need to avoid cpus going offline, you can use +get_online_cpus_atomic() and put_online_cpus_atomic() for those sections. +Just remember the critical section cannot call any function that can sleep or +schedule this process away. Using preempt_disable() will also work, as long +as stop_machine() is used to take a CPU down. But we are going to get rid of +stop_machine() in the CPU offline path soon, so it is strongly recommended +to use the APIs mentioned above. CPU Hotplug - Frequently Asked Questions. @@ -360,6 +365,9 @@ A: There are two ways. If your code can be run in interrupt context, use return err; } + If my_func_on_cpu() itself cannot block, use get/put_online_cpus_atomic() + instead of get/put_online_cpus(), to prevent CPUs from going offline. + Q: How do we determine how many CPUs are available for hotplug. A: There is no clear spec defined way from ACPI that can give us that information today. Based on some input from Natalie of Unisys, From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from e23smtp03.au.ibm.com (e23smtp03.au.ibm.com [202.81.31.145]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "e23smtp03.au.ibm.com", Issuer "GeoTrust SSL CA" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 6559C2C02AD for ; Fri, 28 Jun 2013 05:56:20 +1000 (EST) Received: from /spool/local by e23smtp03.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 28 Jun 2013 05:46:48 +1000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [9.190.234.120]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 2EDF82BB0052 for ; Fri, 28 Jun 2013 05:56:15 +1000 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r5RJfNHb67043508 for ; Fri, 28 Jun 2013 05:41:23 +1000 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r5RJuDLd009343 for ; Fri, 28 Jun 2013 05:56:14 +1000 From: "Srivatsa S. Bhat" Subject: [PATCH v3 03/45] Documentation, CPU hotplug: Recommend usage of get/put_online_cpus_atomic() To: tglx@linutronix.de, peterz@infradead.org, tj@kernel.org, oleg@redhat.com, paulmck@linux.vnet.ibm.com, rusty@rustcorp.com.au, mingo@kernel.org, akpm@linux-foundation.org, namhyung@kernel.org, walken@google.com, vincent.guittot@linaro.org, laijs@cn.fujitsu.com, David.Laight@aculab.com Date: Fri, 28 Jun 2013 01:22:52 +0530 Message-ID: <20130627195252.29830.17952.stgit@srivatsabhat.in.ibm.com> In-Reply-To: <20130627195136.29830.10445.stgit@srivatsabhat.in.ibm.com> References: <20130627195136.29830.10445.stgit@srivatsabhat.in.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Cc: linux-arch@vger.kernel.org, nikunj@linux.vnet.ibm.com, zhong@linux.vnet.ibm.com, linux-pm@vger.kernel.org, fweisbec@gmail.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, rostedt@goodmis.org, xiaoguangrong@linux.vnet.ibm.com, sbw@mit.edu, wangyun@linux.vnet.ibm.com, "Srivatsa S. Bhat" , netdev@vger.kernel.org, Rob Landley , linuxppc-dev@lists.ozlabs.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Once stop_machine() is gone from the CPU offline path, we won't be able to depend on disabling preemption to prevent CPUs from going offline from under us. So add documentation to recommend using the new get/put_online_cpus_atomic() APIs to prevent CPUs from going offline, while invoking from atomic context. Cc: Rob Landley Cc: linux-doc@vger.kernel.org Signed-off-by: Srivatsa S. Bhat --- Documentation/cpu-hotplug.txt | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Documentation/cpu-hotplug.txt b/Documentation/cpu-hotplug.txt index 9f40135..7b3ca60 100644 --- a/Documentation/cpu-hotplug.txt +++ b/Documentation/cpu-hotplug.txt @@ -113,13 +113,18 @@ Never use anything other than cpumask_t to represent bitmap of CPUs. #include get_online_cpus() and put_online_cpus(): -The above calls are used to inhibit cpu hotplug operations. While the +The above calls are used to inhibit cpu hotplug operations, when invoked from +non-atomic contexts (because the above functions can sleep). While the cpu_hotplug.refcount is non zero, the cpu_online_mask will not change. -If you merely need to avoid cpus going away, you could also use -preempt_disable() and preempt_enable() for those sections. -Just remember the critical section cannot call any -function that can sleep or schedule this process away. The preempt_disable() -will work as long as stop_machine_run() is used to take a cpu down. + +However, if you are executing in atomic context (ie., you can't afford to +sleep), and you merely need to avoid cpus going offline, you can use +get_online_cpus_atomic() and put_online_cpus_atomic() for those sections. +Just remember the critical section cannot call any function that can sleep or +schedule this process away. Using preempt_disable() will also work, as long +as stop_machine() is used to take a CPU down. But we are going to get rid of +stop_machine() in the CPU offline path soon, so it is strongly recommended +to use the APIs mentioned above. CPU Hotplug - Frequently Asked Questions. @@ -360,6 +365,9 @@ A: There are two ways. If your code can be run in interrupt context, use return err; } + If my_func_on_cpu() itself cannot block, use get/put_online_cpus_atomic() + instead of get/put_online_cpus(), to prevent CPUs from going offline. + Q: How do we determine how many CPUs are available for hotplug. A: There is no clear spec defined way from ACPI that can give us that information today. Based on some input from Natalie of Unisys,