From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from merlin.infradead.org ([205.233.59.134]:55648 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727736AbeGTMkR (ORCPT ); Fri, 20 Jul 2018 08:40:17 -0400 Date: Fri, 20 Jul 2018 13:52:17 +0200 From: Peter Zijlstra To: Cong Wang Cc: linux-kernel@vger.kernel.org, Ingo Molnar , Linus Torvalds , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , stable@vger.kernel.org Subject: Re: [PATCH v2] perf/core: fix a possible deadlock scenario Message-ID: <20180720115217.GQ2494@hirez.programming.kicks-ass.net> References: <20180719132834.GF18667@krava> <20180719191253.3843-1-xiyou.wangcong@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180719191253.3843-1-xiyou.wangcong@gmail.com> Sender: stable-owner@vger.kernel.org List-ID: On Thu, Jul 19, 2018 at 12:12:53PM -0700, Cong Wang wrote: > hrtimer_cancel() busy-waits for the hrtimer callback to stop, > pretty much like del_timer_sync(). This creates a possible deadlock > scenario where we hold a spinlock before calling hrtimer_cancel() > while in trying to acquire the same spinlock in the callback. Has this actually been observed? > cpu_clock_event_init(): > perf_swevent_init_hrtimer(): > hwc->hrtimer.function = perf_swevent_hrtimer; > > perf_swevent_hrtimer(): > __perf_event_overflow(): > __perf_event_account_interrupt(): > perf_adjust_period(): > pmu->stop(): > cpu_clock_event_stop(): > perf_swevent_cancel(): > hrtimer_cancel() Please explain how a hrtimer event ever gets to perf_adjust_period(). Last I checked perf_swevent_init_hrtimer() results in attr.freq=0. > Getting stuck in an hrtimer is a disaster: You'll get NMI watchdog splats. Getting stuck in NMI context is far more 'interesting :-) > +#define PERF_EF_NO_WAIT 0x08 /* do not wait when stopping, for > + * example, waiting for a timer > + */ That's a broken comment style.