Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp900435lqo; Fri, 17 May 2024 05:18:16 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWDxBpJ6a5dzUaoQm4AEBMob0JaxVr8nh4T0mitdeu+ieh+XojEGx2edjG4zDO2rCRcxY6zPQHDar+u7rOdiLBv++6KLBiajUQu/MpDzQ== X-Google-Smtp-Source: AGHT+IF5VWK494j/LvYttoAXDAnLrG5c1jUEXVtqE9nihi7Y/oGovZeD7Aj3Wk2wSZm9woqwgN/F X-Received: by 2002:a05:620a:22b4:b0:792:be53:8b46 with SMTP id af79cd13be357-792c75a2a8bmr2051026485a.30.1715948296056; Fri, 17 May 2024 05:18:16 -0700 (PDT) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-792e4c10721si962132985a.685.2024.05.17.05.18.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 05:18:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182093-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-182093-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182093-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C3B361C20C03 for ; Fri, 17 May 2024 12:18:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1233041213; Fri, 17 May 2024 12:18:10 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A39CF18651 for ; Fri, 17 May 2024 12:18:07 +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=1715948289; cv=none; b=oyg/v2HAs3snVL3g9yMGEfiw2SDwWAokMe3+sFYHukxM7i4ymu359wyI5SJFRK8SsGeNnbNlclWAS/Yj+FBj0MARKCecVl9PD/W/1IxTRnNqF9nqT5jLvqXjJiCUxqzmD82wBZsC1kOc3/dU+waOClNl2tNEmsFcaMY0UmEEtC4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715948289; c=relaxed/simple; bh=f0gaVWT5snPFYZw8tW/tFNWcykyJ1pBRVQcUhIEnkQs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=eaMn8bfi8K4eRaFtCiAZpoOwE1UrqkDNwrEVbxCrsjqu4fy5pbqlEkD7NkGJhjcjhv9FYZGUalpjdouH+egpaLWTVHLOjo4BFD+s7Ge+pMvjMz/rwT3gYhwRKOo11oNfAqC6i1ISSvtnwWILTLxk6Vg0q87s8PyGvHNgLednIKY= 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; 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 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 16DD21477; Fri, 17 May 2024 05:18:31 -0700 (PDT) Received: from J2N7QTR9R3 (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 955213F7A6; Fri, 17 May 2024 05:18:05 -0700 (PDT) Date: Fri, 17 May 2024 14:17:59 +0200 From: Mark Rutland To: Will Deacon Cc: Namhyung Kim , Ingo Molnar , Peter Zijlstra , LKML , linux-arm-kernel@lists.infradead.org, Greg Thelen , Robin Murphy , Tuan Phan Subject: Re: [PATCH] perf/arm-dmc620: Fix lockdep assert in ->event_init() Message-ID: References: <20240514180050.182454-1-namhyung@kernel.org> <20240517120234.GA32598@willie-the-truck> 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: <20240517120234.GA32598@willie-the-truck> On Fri, May 17, 2024 at 01:02:34PM +0100, Will Deacon wrote: > On Tue, May 14, 2024 at 11:00:50AM -0700, Namhyung Kim wrote: > > for_each_sibling_event() checks leader's ctx but it doesn't have the ctx > > yet if it's the leader. Like in perf_event_validate_size(), we should > > skip checking siblings in that case. > > > > Fixes: f3c0eba287049 ("perf: Add a few assertions") > > Reported-by: Greg Thelen > > Cc: Robin Murphy > > Cc: Tuan Phan > > Signed-off-by: Namhyung Kim > > --- > > drivers/perf/arm_dmc620_pmu.c | 9 ++++++--- > > 1 file changed, 6 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/perf/arm_dmc620_pmu.c b/drivers/perf/arm_dmc620_pmu.c > > index 8a81be2dd5ec..88c17c1d6d49 100644 > > --- a/drivers/perf/arm_dmc620_pmu.c > > +++ b/drivers/perf/arm_dmc620_pmu.c > > @@ -542,12 +542,16 @@ static int dmc620_pmu_event_init(struct perf_event *event) > > if (event->cpu < 0) > > return -EINVAL; > > > > + hwc->idx = -1; > > + > > + if (event->group_leader == event) > > + return 0; > > + > > /* > > * We can't atomically disable all HW counters so only one event allowed, > > * although software events are acceptable. > > */ > > - if (event->group_leader != event && > > - !is_software_event(event->group_leader)) > > + if (!is_software_event(event->group_leader)) > > return -EINVAL; > > > > for_each_sibling_event(sibling, event->group_leader) { > > @@ -556,7 +560,6 @@ static int dmc620_pmu_event_init(struct perf_event *event) > > return -EINVAL; > > } > > > > - hwc->idx = -1; > > return 0; > > } > > Thanks, I'll pick this up, although Mark reckoned he'd found some other > issues over at: > > https://lore.kernel.org/r/Zg0l642PgQ7T3a8Z@FVFF77S0Q05N > > but didn't elaborate on what exactly he'd found :/ Sorry; what I was referring to was that some drivers (including this one) also forgot to validate that the group size could actually fit on the PMU, which we're *supposed* to check, but if we fail to do so the only fallout is that events won't count and we waste a bit of time trying to schedule events unnecessarily. For this patch as-is: Acked-by: Mark Rutland .. and I'll try to take a look at the rest when I'm back in the UK. Mark.