From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965079AbcJTObG (ORCPT ); Thu, 20 Oct 2016 10:31:06 -0400 Received: from mx4-phx2.redhat.com ([209.132.183.25]:58059 "EHLO mx4-phx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752900AbcJTObE (ORCPT ); Thu, 20 Oct 2016 10:31:04 -0400 Date: Thu, 20 Oct 2016 10:30:29 -0400 (EDT) From: CAI Qian To: Jiri Olsa Cc: Peter Zijlstra , Rob Herring , Kan Liang , Greg Kroah-Hartman , linux-kernel , Ingo Molnar Message-ID: <1110984561.1204029.1476973829969.JavaMail.zimbra@redhat.com> In-Reply-To: <20161020111011.GA13361@krava> References: <907882571.66590.1476113724660.JavaMail.zimbra@redhat.com> <1035662571.647973.1476888331396.JavaMail.zimbra@redhat.com> <20161019191943.GA7951@krava> <20161020053944.GQ3102@twins.programming.kicks-ass.net> <20161020085803.GA31721@krava> <20161020090416.GS3102@twins.programming.kicks-ass.net> <20161020094259.GA14853@krava> <20161020111011.GA13361@krava> Subject: Re: [PATCH] perf: Protect pmu device removal with pmu_bus_running check CONFIG_DEBUG_TEST_DRIVER_REMOVE kernel panic MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.18.41.13] X-Mailer: Zimbra 8.0.6_GA_5922 (ZimbraWebClient - GC45 (Linux)/8.0.6_GA_5922) Thread-Topic: perf: Protect pmu device removal with pmu_bus_running check CONFIG_DEBUG_TEST_DRIVER_REMOVE kernel panic Thread-Index: TiIlpA9LDUItdh2VwJ6Bd8+QsugN+Q== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > CAI Qian reported crash [1] in uncore device removal related > to CONFIG_DEBUG_TEST_DRIVER_REMOVE option. > > The reason for crash is that perf_pmu_unregister tries to remove > pmu device which is not added at this point. We add pmu devices > only after pmu_bus is registered which happens in perf_event_sysfs_init > init call and sets pmu_bus_running flag. > > The fix is to get the pmu_bus_running flag state at the point > the pmu is taken out of the pmus list and remove the device > later only if it's set. > > [1] https://marc.info/?l=linux-kernel&m=147688837328451 > > Reported-by: CAI Qian > Signed-off-by: Jiri Olsa Tested-by: CAI Qian