From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 563DDC25B75 for ; Wed, 15 May 2024 12:12:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LhA0sFsFKZVtvFyauzBnHp0A5WTVBCbyDuyf3TbeR5I=; b=siNEOYwhcSdU9z LXqnR9IT656Cfz0ODvKeWT/Jm/dbMWgMhWmRuz/1dGW+UAk34LQy6+XW1f9rJmq9sr7/tF/kZObEv z8cdJh42GPQTaQ8ggu3i9je3shVXMZ+ujBUGdODRMVdx90zCDOeVX5xXjuWOz0A3t4ow4BEGriwzA 8JXxt9LU1kUk8MB/iEa317zD1lQm+QBsDXYmDfyo+MyfL6esRE07GFlCZtjU7fTRMOyOpeypen+AN jw4NokfcIdggl8RBmuUOvyJzee8zsqFssBoryf9nj5fvyLLYPeIPl0GbfillTigLPwOA+9n74XDPY t9aau+3rAKb9v4m6lhoA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7DUR-00000001T2K-1ViC; Wed, 15 May 2024 12:12:11 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7DUN-00000001Szv-201p for linux-arm-kernel@lists.infradead.org; Wed, 15 May 2024 12:12:09 +0000 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 374C41042; Wed, 15 May 2024 05:12:29 -0700 (PDT) Received: from [10.57.5.6] (unknown [10.57.5.6]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E2CC23F641; Wed, 15 May 2024 05:12:02 -0700 (PDT) Message-ID: <0a454227-ab99-4eb9-a736-1c826cfeb97d@arm.com> Date: Wed, 15 May 2024 13:12:02 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] perf/arm-dmc620: Fix lockdep assert in ->event_init() To: Namhyung Kim , Will Deacon , Mark Rutland Cc: Ingo Molnar , Peter Zijlstra , LKML , linux-arm-kernel@lists.infradead.org, Greg Thelen , Tuan Phan References: <20240514180050.182454-1-namhyung@kernel.org> From: Robin Murphy Content-Language: en-GB In-Reply-To: <20240514180050.182454-1-namhyung@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240515_051207_635116_8EDD341E X-CRM114-Status: GOOD ( 25.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2024-05-14 7:00 pm, 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. Ugh, looking around for_each_sibling_event() sites, it looks like there are a fair few other drivers using this pattern as well :( I'd love for groups to be less horribly complicated, but I think I can follow the underlying reasoning here. I suppose one could argue that the assertion could take into account that there's nothing to protect in the case where event->ctx is still NULL, since nobody else should be able to touch the event's own empty sibling list at this point before perf_event_open() has even returned. However by the same token there's also no real reason for drivers *not* to return early when they equally can tell that the sibling list must be empty, and indeed that seems to be a fairly common pattern too, so I see no issue with fixing up all the offending drivers for consistency either. Reviewed-by: Robin Murphy > 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; > } > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel