From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6D7C9372058 for ; Thu, 13 Aug 2026 09:09:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786612170; cv=none; b=GxvdgHXXQhiA8Cj/IU9NkNXcJY1o5+aAqhAVLo2eA6zOPre+63+13a++UEnnWG7KH3wBYdqnZ8ChuH1EAfxceWDGrHH/4Ow/DB2cRwuYpPthHPvWl7URslGwQfD2I2gx+wE9unLZLvmpx1PZu8ouDVixqhE5Nsjzhn3I1HkTBBM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786612170; c=relaxed/simple; bh=ua1G1nNjY9yykDJ4/9Vo4C02CNYaRzfGUD5Azmq86sI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qB88tT8ROPVsxJjwml6F/fQ4I1T/wmtum1vBdO5iutJqEBg5VMMZkK+B4I0HPTMHxRfaS+ekJIVfU5Yt1zWG0AGOyYdRgQcQDn0TzH0zUw/LuPffbfgmQOU9aqBGJFdeWlOpVOvekTIWBTCZqbQk4j3V6lcCjpw2EiHKxBDF94U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=WkCWz62E; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="WkCWz62E" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7A689153B; Thu, 13 Aug 2026 02:09:23 -0700 (PDT) Received: from localhost (unknown [10.2.196.114]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 06E563F673; Thu, 13 Aug 2026 02:09:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1786612167; bh=ua1G1nNjY9yykDJ4/9Vo4C02CNYaRzfGUD5Azmq86sI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WkCWz62ExNR1e12y1hlkqkIISMBo3mBFUvSX3nAKSZfyC6OAHELvWSYkslN77vpQg ICsJgM9GZa/o4hCZ4bzwjovCdZV1K42RWCa517lYsiugDQ+44Fsk0fmFSTM2/Wcv60 Sh+jGmjzozMjcvFu7+iFK4jZ+//KE7hfHq4H97VE= Date: Thu, 13 Aug 2026 10:09:24 +0100 From: Leo Yan To: James Clark Cc: Suzuki K Poulose , Mike Leach , Suyash Mahar , Yeoreum Yun , Greg Kroah-Hartman , Qi Liu , Junhao He , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jonathan Cameron , sashiko-bot Subject: Re: [PATCH v3 2/8] coresight: configfs: Don't assume active until cscfg_mgr is set Message-ID: <20260813090924.GA8904@e132581.arm.com> References: <20260728-james-cs-multiple-per-threads-v3-0-6aee7579f1dc@linaro.org> <20260728-james-cs-multiple-per-threads-v3-2-6aee7579f1dc@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260728-james-cs-multiple-per-threads-v3-2-6aee7579f1dc@linaro.org> On Tue, Jul 28, 2026 at 04:00:14PM +0100, James Clark wrote: > Perf's etm_setup_aux() calls cscfg_activate_config() and dereferences > cscfg_mgr, which can be done after coresight_init() has initialized the > Perf PMU but before cscfg_init() has finished while the driver is still > loading. For this patch, if Perf PMU is dependent on cscfg, why we cannot adjust the init sequence that first call cscfg_init(), then register cs_etm PMU event? In _cscfg_activate_config(), I can see it dereferences cscfg_mgr: if (cscfg_mgr->load_state == CSCFG_UNLOAD) This patch does not check if cscfg_mgr is set. If we try to check cscfg_mgr every time before dereferences it, this approach is quite fragile. > Fix it by only assuming cscfg is initialized if cscfg_mgr is set. > > Reported-by: sashiko-bot > Fixes: a0114b4740dd ("coresight: etm-perf: Update to activate selected configuration") > Signed-off-by: James Clark > --- > drivers/hwtracing/coresight/coresight-syscfg.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/hwtracing/coresight/coresight-syscfg.c b/drivers/hwtracing/coresight/coresight-syscfg.c > index 2bfdd7b45e49..475e8fefa100 100644 > --- a/drivers/hwtracing/coresight/coresight-syscfg.c > +++ b/drivers/hwtracing/coresight/coresight-syscfg.c > @@ -581,7 +581,7 @@ int cscfg_load_config_sets(struct cscfg_config_desc **config_descs, > int err = 0; > > mutex_lock(&cscfg_mutex); > - if (cscfg_mgr->load_state != CSCFG_NONE) { > + if (!cscfg_mgr || cscfg_mgr->load_state != CSCFG_NONE) { > mutex_unlock(&cscfg_mutex); > return -EBUSY; If cscfg_mgr is NULL, would directly bail out? This can avoid adding check for every dereference. Thanks, Leo P.S. For me, this kind of rare race condition reported by Sashiko can sometimes distract from the main issue. Trying to address it in the same series may mix different issues together. I miss the simpler approach where issues could be resolved with clear boundary.