* [PATCH] x86/platform/uv: Dont use smp_processor_id while preemptable @ 2022-05-20 20:37 Mike Travis 2022-05-21 13:57 ` Hans de Goede 2022-05-26 15:30 ` Dave Hansen 0 siblings, 2 replies; 5+ messages in thread From: Mike Travis @ 2022-05-20 20:37 UTC (permalink / raw) To: Borislav Petkov, Dave Hansen, Ingo Molnar, Thomas Gleixner, Steve Wahl, x86 Cc: Mike Travis, Dimitri Sivanich, Andy Shevchenko, Darren Hart, H. Peter Anvin, Russ Anderson, linux-kernel, platform-driver-x86 To avoid a "BUG: using smp_processor_id() in preemptible" debug warning message, disable preemption around use of the processor id. Signed-off-by: Mike Travis <mike.travis@hpe.com> Reviewed-by: Steve Wahl <steve.wahl@hpe.com> Reviewed-by: Dimitri Sivanich <dimitri.sivanich@hpe.com> --- arch/x86/platform/uv/uv_time.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/x86/platform/uv/uv_time.c b/arch/x86/platform/uv/uv_time.c index 54663f3e00cb..094190814a28 100644 --- a/arch/x86/platform/uv/uv_time.c +++ b/arch/x86/platform/uv/uv_time.c @@ -275,14 +275,17 @@ static int uv_rtc_unset_timer(int cpu, int force) */ static u64 uv_read_rtc(struct clocksource *cs) { - unsigned long offset; + unsigned long offset, time; + unsigned int cpu = get_cpu(); if (uv_get_min_hub_revision_id() == 1) offset = 0; else - offset = (uv_blade_processor_id() * L1_CACHE_BYTES) % PAGE_SIZE; + offset = (uv_cpu_blade_processor_id(cpu) * L1_CACHE_BYTES) % PAGE_SIZE; - return (u64)uv_read_local_mmr(UVH_RTC | offset); + time = (u64)uv_read_local_mmr(UVH_RTC | offset); + put_cpu(); + return time; } /* -- 2.26.2 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/platform/uv: Dont use smp_processor_id while preemptable 2022-05-20 20:37 [PATCH] x86/platform/uv: Dont use smp_processor_id while preemptable Mike Travis @ 2022-05-21 13:57 ` Hans de Goede 2022-05-21 18:50 ` Travis, Mike 2022-05-26 15:30 ` Dave Hansen 1 sibling, 1 reply; 5+ messages in thread From: Hans de Goede @ 2022-05-21 13:57 UTC (permalink / raw) To: Mike Travis, Borislav Petkov, Dave Hansen, Ingo Molnar, Thomas Gleixner, Steve Wahl, x86 Cc: Dimitri Sivanich, Andy Shevchenko, Darren Hart, H. Peter Anvin, Russ Anderson, linux-kernel, platform-driver-x86 Hi Mike, On 5/20/22 22:37, Mike Travis wrote: > To avoid a "BUG: using smp_processor_id() in preemptible" debug > warning message, disable preemption around use of the processor id. > > Signed-off-by: Mike Travis <mike.travis@hpe.com> > Reviewed-by: Steve Wahl <steve.wahl@hpe.com> > Reviewed-by: Dimitri Sivanich <dimitri.sivanich@hpe.com> A git blame shows that this code has been around for quite a while; so presumably this should be backported to some of the stable kernel series ? Maybe add an appropriate Cc: stable tag with the range of kernels this should be added to and/or add a Fixes: tag? Regards, Hans > --- > arch/x86/platform/uv/uv_time.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/platform/uv/uv_time.c b/arch/x86/platform/uv/uv_time.c > index 54663f3e00cb..094190814a28 100644 > --- a/arch/x86/platform/uv/uv_time.c > +++ b/arch/x86/platform/uv/uv_time.c > @@ -275,14 +275,17 @@ static int uv_rtc_unset_timer(int cpu, int force) > */ > static u64 uv_read_rtc(struct clocksource *cs) > { > - unsigned long offset; > + unsigned long offset, time; > + unsigned int cpu = get_cpu(); > > if (uv_get_min_hub_revision_id() == 1) > offset = 0; > else > - offset = (uv_blade_processor_id() * L1_CACHE_BYTES) % PAGE_SIZE; > + offset = (uv_cpu_blade_processor_id(cpu) * L1_CACHE_BYTES) % PAGE_SIZE; > > - return (u64)uv_read_local_mmr(UVH_RTC | offset); > + time = (u64)uv_read_local_mmr(UVH_RTC | offset); > + put_cpu(); > + return time; > } > > /* ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/platform/uv: Dont use smp_processor_id while preemptable 2022-05-21 13:57 ` Hans de Goede @ 2022-05-21 18:50 ` Travis, Mike 0 siblings, 0 replies; 5+ messages in thread From: Travis, Mike @ 2022-05-21 18:50 UTC (permalink / raw) To: Hans de Goede, Borislav Petkov, Dave Hansen, Ingo Molnar, Thomas Gleixner, Wahl, Steve, x86 Cc: Sivanich, Dimitri, Andy Shevchenko, Darren Hart, H. Peter Anvin, Anderson, Russ, linux-kernel, platform-driver-x86, Travis, Mike Thanks, I'll do that. ________________________________________ From: Hans de Goede <hdegoede@redhat.com> Sent: Saturday, May 21, 2022 6:57 AM To: Travis, Mike; Borislav Petkov; Dave Hansen; Ingo Molnar; Thomas Gleixner; Wahl, Steve; x86@kernel.org Cc: Sivanich, Dimitri; Andy Shevchenko; Darren Hart; H. Peter Anvin; Anderson, Russ; linux-kernel@vger.kernel.org; platform-driver-x86@vger.kernel.org Subject: Re: [PATCH] x86/platform/uv: Dont use smp_processor_id while preemptable Hi Mike, On 5/20/22 22:37, Mike Travis wrote: > To avoid a "BUG: using smp_processor_id() in preemptible" debug > warning message, disable preemption around use of the processor id. > > Signed-off-by: Mike Travis <mike.travis@hpe.com> > Reviewed-by: Steve Wahl <steve.wahl@hpe.com> > Reviewed-by: Dimitri Sivanich <dimitri.sivanich@hpe.com> A git blame shows that this code has been around for quite a while; so presumably this should be backported to some of the stable kernel series ? Maybe add an appropriate Cc: stable tag with the range of kernels this should be added to and/or add a Fixes: tag? Regards, Hans > --- > arch/x86/platform/uv/uv_time.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/platform/uv/uv_time.c b/arch/x86/platform/uv/uv_time.c > index 54663f3e00cb..094190814a28 100644 > --- a/arch/x86/platform/uv/uv_time.c > +++ b/arch/x86/platform/uv/uv_time.c > @@ -275,14 +275,17 @@ static int uv_rtc_unset_timer(int cpu, int force) > */ > static u64 uv_read_rtc(struct clocksource *cs) > { > - unsigned long offset; > + unsigned long offset, time; > + unsigned int cpu = get_cpu(); > > if (uv_get_min_hub_revision_id() == 1) > offset = 0; > else > - offset = (uv_blade_processor_id() * L1_CACHE_BYTES) % PAGE_SIZE; > + offset = (uv_cpu_blade_processor_id(cpu) * L1_CACHE_BYTES) % PAGE_SIZE; > > - return (u64)uv_read_local_mmr(UVH_RTC | offset); > + time = (u64)uv_read_local_mmr(UVH_RTC | offset); > + put_cpu(); > + return time; > } > > /* ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/platform/uv: Dont use smp_processor_id while preemptable 2022-05-20 20:37 [PATCH] x86/platform/uv: Dont use smp_processor_id while preemptable Mike Travis 2022-05-21 13:57 ` Hans de Goede @ 2022-05-26 15:30 ` Dave Hansen 2022-05-26 22:53 ` Travis, Mike 1 sibling, 1 reply; 5+ messages in thread From: Dave Hansen @ 2022-05-26 15:30 UTC (permalink / raw) To: Mike Travis, Borislav Petkov, Dave Hansen, Ingo Molnar, Thomas Gleixner, Steve Wahl, x86 Cc: Dimitri Sivanich, Andy Shevchenko, Darren Hart, H. Peter Anvin, Russ Anderson, linux-kernel, platform-driver-x86 On 5/20/22 13:37, Mike Travis wrote: > To avoid a "BUG: using smp_processor_id() in preemptible" debug > warning message, disable preemption around use of the processor id. I'm sure this gets rid of the warning. But, could you please take a quick look at the callers and ensure that they can handle if this read comes from another CPU? In other words, what would actually go wrong if uv_read_rtc() got preempted in this region? What would this actually fix? ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/platform/uv: Dont use smp_processor_id while preemptable 2022-05-26 15:30 ` Dave Hansen @ 2022-05-26 22:53 ` Travis, Mike 0 siblings, 0 replies; 5+ messages in thread From: Travis, Mike @ 2022-05-26 22:53 UTC (permalink / raw) To: Dave Hansen, Borislav Petkov, Dave Hansen, Ingo Molnar, Thomas Gleixner, Wahl, Steve, x86 Cc: Sivanich, Dimitri, Andy Shevchenko, Darren Hart, H. Peter Anvin, Anderson, Russ, linux-kernel, platform-driver-x86, Travis, Mike Dave Hansen <dave.hansen@intel.com> wrote: On 5/20/22 13:37, Mike Travis wrote: > To avoid a "BUG: using smp_processor_id() in preemptible" debug > warning message, disable preemption around use of the processor id. >I'm sure this gets rid of the warning. But, could you please take a >quick look at the callers and ensure that they can handle if this read >comes from another CPU? > >In other words, what would actually go wrong if uv_read_rtc() got >preempted in this region? What would this actually fix? I talked with the author of this driver and among the preemption scenarios it always returns the same system time. And due to the round robin aspect of the request scheduling, getting an earlier time when a second CPU reads it's time is not possible. So getting rid of the debug warning message seems to be the only benefit from this patch. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-05-26 22:55 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-05-20 20:37 [PATCH] x86/platform/uv: Dont use smp_processor_id while preemptable Mike Travis 2022-05-21 13:57 ` Hans de Goede 2022-05-21 18:50 ` Travis, Mike 2022-05-26 15:30 ` Dave Hansen 2022-05-26 22:53 ` Travis, Mike
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.