From nobody Wed Dec 31 15:00:59 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 180B8C4167B for ; Thu, 2 Nov 2023 15:33:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376833AbjKBPdd (ORCPT ); Thu, 2 Nov 2023 11:33:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347638AbjKBPdK (ORCPT ); Thu, 2 Nov 2023 11:33:10 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B43418E for ; Thu, 2 Nov 2023 08:32:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-Id:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=R8zokz8HpLYR/tS6Df4K9QtMMliKooDPknNNGx1Aq0A=; b=V3eJxy3aHR8sSOdEp2w15Upf3d /3SI+v3WkjGk9NFqxZbFJcgZTvJ79bAaWRNVfLFnbTBafrkhG6t62hkQx0oOa30hg/CHkjhSTKs8T cUWG0PDkodBntmFopGQYrkx+PV1dRnXtnJM9cfwRyafcWNHWZSInWD3PWjf6L3pInbgNwtEodyh/r jvbAavQzJNrczRFhhIF08eaT/eWLXij8kmL47lj4Cop0Kvl1GhC2HqMzAxVQg3h4JAbPTV91m5nFo tt4Qg5y/dxqrNQM8HTUXLIUcM7R/Mv5kfFiB4vG5DsijKr4/Ow0TsTbb7u8CqbMTal5AaY71DpjC5 Coafv0AQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1qyZgV-0005PK-Fo; Thu, 02 Nov 2023 15:32:40 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 5C2CA302D66; Thu, 2 Nov 2023 16:32:39 +0100 (CET) Message-Id: <20231102152018.768730519@infradead.org> User-Agent: quilt/0.65 Date: Thu, 02 Nov 2023 16:09:28 +0100 From: Peter Zijlstra To: mingo@kernel.org Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, irogers@google.com, adrian.hunter@intel.com Subject: [PATCH 09/13] perf: Simplify perf_event_modify_attr() References: <20231102150919.719936610@infradead.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Zijlstra (Intel) --- kernel/events/core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -3172,7 +3172,7 @@ static int perf_event_modify_attr(struct =20 WARN_ON_ONCE(event->ctx->parent_ctx); =20 - mutex_lock(&event->child_mutex); + guard(mutex)(&event->child_mutex); /* * Event-type-independent attributes must be copied before event-type * modification, which will validate that final attributes match the @@ -3181,16 +3181,16 @@ static int perf_event_modify_attr(struct perf_event_modify_copy_attr(&event->attr, attr); err =3D func(event, attr); if (err) - goto out; + return err; + list_for_each_entry(child, &event->child_list, child_list) { perf_event_modify_copy_attr(&child->attr, attr); err =3D func(child, attr); if (err) - goto out; + return err; } -out: - mutex_unlock(&event->child_mutex); - return err; + + return 0; } =20 static void __pmu_ctx_sched_out(struct perf_event_pmu_context *pmu_ctx,