From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754882AbdKASeT (ORCPT ); Wed, 1 Nov 2017 14:34:19 -0400 Received: from mail-oi0-f52.google.com ([209.85.218.52]:51590 "EHLO mail-oi0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751428AbdKASeR (ORCPT ); Wed, 1 Nov 2017 14:34:17 -0400 X-Google-Smtp-Source: ABhQp+QknAowgeWtP/WeE7ex/fhlag3BZDRiUVZSM7S3E06v8oSLy4L8DIs7LUVpcReNCzJp/RHbgQ== Date: Wed, 1 Nov 2017 11:34:14 -0700 From: Guenter Roeck To: Don Zickus Cc: Thomas Gleixner , Peter Zijlstra , linux-kernel@vger.kernel.org, Ingo Molnar Subject: Re: Crashes in perf_event_ctx_lock_nested Message-ID: <20171101183414.GA2929@roeck-us.net> References: <20171030224512.GA13592@roeck-us.net> <20171031134850.ynix2zqypmca2mtt@hirez.programming.kicks-ass.net> <20171031221107.GA12133@roeck-us.net> <20171101181126.j727fqjmdthjz4xk@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171101181126.j727fqjmdthjz4xk@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 01, 2017 at 02:11:27PM -0400, Don Zickus wrote: > > > > Maybe watchdog_cpus needs to be atomic ? > > I switched it to atomic and it solves that problem. The functionality isn't > broken currently, just the informational message. > > Patch attached to try. > Tested-by: Guenter Roeck Thanks! Guenter > Cheers, > Don > > ---8<-------------- > > diff --git a/kernel/watchdog_hld.c b/kernel/watchdog_hld.c > index a7f137c1933a..8ee4da223b35 100644 > --- a/kernel/watchdog_hld.c > +++ b/kernel/watchdog_hld.c > @@ -14,6 +14,7 @@ > #include > #include > #include > +#include Alphabetical order, maybe ? > > #include > #include > @@ -25,7 +26,7 @@ static DEFINE_PER_CPU(struct perf_event *, dead_event); > static struct cpumask dead_events_mask; > > static unsigned long hardlockup_allcpu_dumped; > -static unsigned int watchdog_cpus; > +static atomic_t watchdog_cpus = ATOMIC_INIT(0); > > void arch_touch_nmi_watchdog(void) > { > @@ -189,7 +190,8 @@ void hardlockup_detector_perf_enable(void) > if (hardlockup_detector_event_create()) > return; > > - if (!watchdog_cpus++) > + /* use original value for check */ > + if (!atomic_fetch_inc(&watchdog_cpus)) > pr_info("Enabled. Permanently consumes one hw-PMU counter.\n"); > > perf_event_enable(this_cpu_read(watchdog_ev)); > @@ -207,7 +209,7 @@ void hardlockup_detector_perf_disable(void) > this_cpu_write(watchdog_ev, NULL); > this_cpu_write(dead_event, event); > cpumask_set_cpu(smp_processor_id(), &dead_events_mask); > - watchdog_cpus--; > + atomic_dec(&watchdog_cpus); > } > } >