From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755241Ab2BHJbD (ORCPT ); Wed, 8 Feb 2012 04:31:03 -0500 Received: from mail-ee0-f46.google.com ([74.125.83.46]:40514 "EHLO mail-ee0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753869Ab2BHJa6 convert rfc822-to-8bit (ORCPT ); Wed, 8 Feb 2012 04:30:58 -0500 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: linux-kernel@vger.kernel.org, "Gilad Ben-Yossef" Cc: "Chris Metcalf" , "Christoph Lameter" , "Frederic Weisbecker" , "Russell King" , linux-mm@kvack.org, "Pekka Enberg" , "Matt Mackall" , "Sasha Levin" , "Rik van Riel" , "Andi Kleen" , "Alexander Viro" , linux-fsdevel@vger.kernel.org, "Avi Kivity" , "Kosaki Motohiro" , "Andrew Morton" , "Milton Miller" Subject: Re: [PATCH v8 4/8] smp: add func to IPI cpus based on parameter func References: <1328448800-15794-1-git-send-email-gilad@benyossef.com> <1328449722-15959-3-git-send-email-gilad@benyossef.com> Date: Wed, 08 Feb 2012 10:30:51 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT From: "Michal Nazarewicz" Message-ID: In-Reply-To: <1328449722-15959-3-git-send-email-gilad@benyossef.com> User-Agent: Opera Mail/11.61 (Linux) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 05 Feb 2012 14:48:38 +0100, Gilad Ben-Yossef wrote: > Add the on_each_cpu_cond() function that wraps on_each_cpu_mask() > and calculates the cpumask of cpus to IPI by calling a function supplied > as a parameter in order to determine whether to IPI each specific cpu. > > The function works around allocation failure of cpumask variable in > CONFIG_CPUMASK_OFFSTACK=y by itereating over cpus sending an IPI a > time via smp_call_function_single(). > > The function is useful since it allows to seperate the specific > code that decided in each case whether to IPI a specific cpu for > a specific request from the common boilerplate code of handling > creating the mask, handling failures etc. > > Signed-off-by: Gilad Ben-Yossef > Acked-by: Peter Zijlstra > CC: Chris Metcalf > CC: Christoph Lameter > CC: Frederic Weisbecker > CC: Russell King > CC: linux-mm@kvack.org > CC: Pekka Enberg > CC: Matt Mackall > CC: Sasha Levin > CC: Rik van Riel > CC: Andi Kleen > CC: Alexander Viro > CC: linux-fsdevel@vger.kernel.org > CC: Avi Kivity > CC: Michal Nazarewicz > CC: Kosaki Motohiro > CC: Andrew Morton > CC: Milton Miller > --- > include/linux/smp.h | 24 ++++++++++++++++++++ > kernel/smp.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 84 insertions(+), 0 deletions(-) > > diff --git a/include/linux/smp.h b/include/linux/smp.h > index d0adb78..da4d034 100644 > --- a/include/linux/smp.h > +++ b/include/linux/smp.h > @@ -153,6 +162,21 @@ static inline int up_smp_call_function(smp_call_func_t func, void *info) > local_irq_enable(); \ > } \ > } while (0) > +/* > + * Preemption is disabled here to make sure the > + * cond_func is called under the same condtions in UP > + * and SMP. > + */ > +#define on_each_cpu_cond(cond_func, func, info, wait, gfp_flags) \ > + do { \ How about: void *__info = (info); as to avoid double execution. > + preempt_disable(); \ > + if (cond_func(0, info)) { \ > + local_irq_disable(); \ > + (func)(info); \ > + local_irq_enable(); \ > + } \ > + preempt_enable(); \ > + } while (0) > static inline void smp_send_reschedule(int cpu) { } > #define num_booting_cpus() 1 -- Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Michał “mina86” Nazarewicz (o o) ooo +------------------ooO--(_)--Ooo-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michal Nazarewicz" Subject: Re: [PATCH v8 4/8] smp: add func to IPI cpus based on parameter func Date: Wed, 08 Feb 2012 10:30:51 +0100 Message-ID: References: <1328448800-15794-1-git-send-email-gilad@benyossef.com> <1328449722-15959-3-git-send-email-gilad@benyossef.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable Cc: "Chris Metcalf" , "Christoph Lameter" , "Frederic Weisbecker" , "Russell King" , linux-mm@kvack.org, "Pekka Enberg" , "Matt Mackall" , "Sasha Levin" , "Rik van Riel" , "Andi Kleen" , "Alexander Viro" , linux-fsdevel@vger.kernel.org, "Avi Kivity" , "Kosaki Motohiro" , "Andrew Morton" , "Milton Miller" To: linux-kernel@vger.kernel.org, "Gilad Ben-Yossef" Return-path: In-Reply-To: <1328449722-15959-3-git-send-email-gilad@benyossef.com> Sender: owner-linux-mm@kvack.org List-Id: linux-fsdevel.vger.kernel.org On Sun, 05 Feb 2012 14:48:38 +0100, Gilad Ben-Yossef wrote: > Add the on_each_cpu_cond() function that wraps on_each_cpu_mask() > and calculates the cpumask of cpus to IPI by calling a function suppli= ed > as a parameter in order to determine whether to IPI each specific cpu.= > > The function works around allocation failure of cpumask variable in > CONFIG_CPUMASK_OFFSTACK=3Dy by itereating over cpus sending an IPI a > time via smp_call_function_single(). > > The function is useful since it allows to seperate the specific > code that decided in each case whether to IPI a specific cpu for > a specific request from the common boilerplate code of handling > creating the mask, handling failures etc. > > Signed-off-by: Gilad Ben-Yossef > Acked-by: Peter Zijlstra > CC: Chris Metcalf > CC: Christoph Lameter > CC: Frederic Weisbecker > CC: Russell King > CC: linux-mm@kvack.org > CC: Pekka Enberg > CC: Matt Mackall > CC: Sasha Levin > CC: Rik van Riel > CC: Andi Kleen > CC: Alexander Viro > CC: linux-fsdevel@vger.kernel.org > CC: Avi Kivity > CC: Michal Nazarewicz > CC: Kosaki Motohiro > CC: Andrew Morton > CC: Milton Miller > --- > include/linux/smp.h | 24 ++++++++++++++++++++ > kernel/smp.c | 60 ++++++++++++++++++++++++++++++++++++++++++= +++++++++ > 2 files changed, 84 insertions(+), 0 deletions(-) > > diff --git a/include/linux/smp.h b/include/linux/smp.h > index d0adb78..da4d034 100644 > --- a/include/linux/smp.h > +++ b/include/linux/smp.h > @@ -153,6 +162,21 @@ static inline int up_smp_call_function(smp_call_f= unc_t func, void *info) > local_irq_enable(); \ > } \ > } while (0) > +/* > + * Preemption is disabled here to make sure the > + * cond_func is called under the same condtions in UP > + * and SMP. > + */ > +#define on_each_cpu_cond(cond_func, func, info, wait, gfp_flags) \ > + do { \ How about: void *__info =3D (info); as to avoid double execution. > + preempt_disable(); \ > + if (cond_func(0, info)) { \ > + local_irq_disable(); \ > + (func)(info); \ > + local_irq_enable(); \ > + } \ > + preempt_enable(); \ > + } while (0) > static inline void smp_send_reschedule(int cpu) { } > #define num_booting_cpus() 1 -- = Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=3D./ `o ..o | Computer Science, Micha=C5=82 =E2=80=9Cmina86=E2=80=9D Nazarewicz= (o o) ooo +------------------ooO--(_)--Ooo-- -- 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org