From nobody Sun Feb 8 00:11:35 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 456CA200BA9; Mon, 2 Dec 2024 11:14:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733138062; cv=none; b=rc0AYNRs1jRFnPX5ZaNZDEWwt740l7NTx9P05s3O/b7lU13s1I7C01BJPJXiou3dPd5gIq5bri8zbuCHFS+cQNkvVBb5OJJa0WPAgy+pnVYcqmBTo/DRICluwLoNWVcjBxqmukXigFtASKr/PqyoMl4fQqgDddE2NpNfcaC/W4Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733138062; c=relaxed/simple; bh=wULnhvIlVk6jasiLq/4/fKlSCePEcLRwDykgAn7X150=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=t90HssmplqKt8RBqr1lmBUCEx9WUY7rEeuXVt8ak3WYCEP1BTUbf4X7lPAoIUSqEV9/Rnj2mNxOrLTCGTqyBQh8wnE4r92TfhRq0uIxJUTvAI2S/ZngoDjPLZZeBPr5nuy4ToqwcDE42rauOTV6828ZUWuYx9Ml/jWr441CDKME= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=aryY3eeE; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=86FS4UFg; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="aryY3eeE"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="86FS4UFg" Date: Mon, 02 Dec 2024 11:14:17 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1733138058; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hHExVCewHogB9drld7Pdw1Bt/bDGrt3y7WE4rpmN7lA=; b=aryY3eeE0Vxe4ASUiESr0j+YlnfPfa3FrqhuV65APWNE5GOjGYX9mfZcW2Mf+88U4uKTA/ 81B1/dThzHgJx3bkKJBtZv1JO/oUgdxPtfWV06elNJ4qoulg/WU24UL6oSazCvecnKyDM0 3P3QeOg5TteuiHc8p9MWX9C39W0X9adg+3Tddqun5nXHywFBZrPjPyR9UkIDCqowak3ptI drVYCpDbblqUpfzDxLE3xam7xCk9bA13L2gTjAOM+7T5JkKWIQgXwk1UeCqNyu+4aVkJiY Owy4353jQuVEAD3+Yo07bApYFMKffEeffimAUU+eMyZzNy5Fa5nmXA+7GrwhKg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1733138058; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hHExVCewHogB9drld7Pdw1Bt/bDGrt3y7WE4rpmN7lA=; b=86FS4UFgjP2cRdH9xOhC1m6b0dAvV0Z92RYsiP+PahWqjaOdm45CO7Jxjm1vMbUhcrgfFC 35eQ21sWx7bapxAw== From: "tip-bot2 for Dhananjay Ugwekar" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf/x86/rapl: Rename rapl_pmu variables Cc: Dhananjay Ugwekar , "Peter Zijlstra (Intel)" , "Gautham R. Shenoy" , Zhang Rui , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20241115060805.447565-5-Dhananjay.Ugwekar@amd.com> References: <20241115060805.447565-5-Dhananjay.Ugwekar@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <173313805723.412.9968826976353075696.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the perf/core branch of tip: Commit-ID: 8bf1c86e5ac828d7e8b44fe007bf3b14ac7f2b2d Gitweb: https://git.kernel.org/tip/8bf1c86e5ac828d7e8b44fe007bf3b14a= c7f2b2d Author: Dhananjay Ugwekar AuthorDate: Fri, 15 Nov 2024 06:08:00=20 Committer: Peter Zijlstra CommitterDate: Mon, 02 Dec 2024 12:01:35 +01:00 perf/x86/rapl: Rename rapl_pmu variables Rename struct rapl_pmu variables from "pmu" to "rapl_pmu", to avoid any confusion between the variables of two different structs pmu and rapl_pmu. As rapl_pmu also contains a pointer to struct pmu, which leads to situations in code like pmu->pmu, which is needlessly confusing. Above scenario is replaced with much more readable rapl_pmu->pmu with this change. Also rename "pmus" member in rapl_pmus struct, for same reason. No functional change. Signed-off-by: Dhananjay Ugwekar Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: "Gautham R. Shenoy" Reviewed-by: Zhang Rui Tested-by: Zhang Rui Link: https://lore.kernel.org/r/20241115060805.447565-5-Dhananjay.Ugwekar@a= md.com --- arch/x86/events/rapl.c | 91 ++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 45 deletions(-) diff --git a/arch/x86/events/rapl.c b/arch/x86/events/rapl.c index bf260f4..9b1ec8a 100644 --- a/arch/x86/events/rapl.c +++ b/arch/x86/events/rapl.c @@ -129,7 +129,7 @@ struct rapl_pmu { struct rapl_pmus { struct pmu pmu; unsigned int nr_rapl_pmu; - struct rapl_pmu *pmus[] __counted_by(nr_rapl_pmu); + struct rapl_pmu *rapl_pmu[] __counted_by(nr_rapl_pmu); }; =20 enum rapl_unit_quirk { @@ -228,34 +228,34 @@ static void rapl_start_hrtimer(struct rapl_pmu *pmu) =20 static enum hrtimer_restart rapl_hrtimer_handle(struct hrtimer *hrtimer) { - struct rapl_pmu *pmu =3D container_of(hrtimer, struct rapl_pmu, hrtimer); + struct rapl_pmu *rapl_pmu =3D container_of(hrtimer, struct rapl_pmu, hrti= mer); struct perf_event *event; unsigned long flags; =20 - if (!pmu->n_active) + if (!rapl_pmu->n_active) return HRTIMER_NORESTART; =20 - raw_spin_lock_irqsave(&pmu->lock, flags); + raw_spin_lock_irqsave(&rapl_pmu->lock, flags); =20 - list_for_each_entry(event, &pmu->active_list, active_entry) + list_for_each_entry(event, &rapl_pmu->active_list, active_entry) rapl_event_update(event); =20 - raw_spin_unlock_irqrestore(&pmu->lock, flags); + raw_spin_unlock_irqrestore(&rapl_pmu->lock, flags); =20 - hrtimer_forward_now(hrtimer, pmu->timer_interval); + hrtimer_forward_now(hrtimer, rapl_pmu->timer_interval); =20 return HRTIMER_RESTART; } =20 -static void rapl_hrtimer_init(struct rapl_pmu *pmu) +static void rapl_hrtimer_init(struct rapl_pmu *rapl_pmu) { - struct hrtimer *hr =3D &pmu->hrtimer; + struct hrtimer *hr =3D &rapl_pmu->hrtimer; =20 hrtimer_init(hr, CLOCK_MONOTONIC, HRTIMER_MODE_REL); hr->function =3D rapl_hrtimer_handle; } =20 -static void __rapl_pmu_event_start(struct rapl_pmu *pmu, +static void __rapl_pmu_event_start(struct rapl_pmu *rapl_pmu, struct perf_event *event) { if (WARN_ON_ONCE(!(event->hw.state & PERF_HES_STOPPED))) @@ -263,39 +263,39 @@ static void __rapl_pmu_event_start(struct rapl_pmu *p= mu, =20 event->hw.state =3D 0; =20 - list_add_tail(&event->active_entry, &pmu->active_list); + list_add_tail(&event->active_entry, &rapl_pmu->active_list); =20 local64_set(&event->hw.prev_count, rapl_read_counter(event)); =20 - pmu->n_active++; - if (pmu->n_active =3D=3D 1) - rapl_start_hrtimer(pmu); + rapl_pmu->n_active++; + if (rapl_pmu->n_active =3D=3D 1) + rapl_start_hrtimer(rapl_pmu); } =20 static void rapl_pmu_event_start(struct perf_event *event, int mode) { - struct rapl_pmu *pmu =3D event->pmu_private; + struct rapl_pmu *rapl_pmu =3D event->pmu_private; unsigned long flags; =20 - raw_spin_lock_irqsave(&pmu->lock, flags); - __rapl_pmu_event_start(pmu, event); - raw_spin_unlock_irqrestore(&pmu->lock, flags); + raw_spin_lock_irqsave(&rapl_pmu->lock, flags); + __rapl_pmu_event_start(rapl_pmu, event); + raw_spin_unlock_irqrestore(&rapl_pmu->lock, flags); } =20 static void rapl_pmu_event_stop(struct perf_event *event, int mode) { - struct rapl_pmu *pmu =3D event->pmu_private; + struct rapl_pmu *rapl_pmu =3D event->pmu_private; struct hw_perf_event *hwc =3D &event->hw; unsigned long flags; =20 - raw_spin_lock_irqsave(&pmu->lock, flags); + raw_spin_lock_irqsave(&rapl_pmu->lock, flags); =20 /* mark event as deactivated and stopped */ if (!(hwc->state & PERF_HES_STOPPED)) { - WARN_ON_ONCE(pmu->n_active <=3D 0); - pmu->n_active--; - if (pmu->n_active =3D=3D 0) - hrtimer_cancel(&pmu->hrtimer); + WARN_ON_ONCE(rapl_pmu->n_active <=3D 0); + rapl_pmu->n_active--; + if (rapl_pmu->n_active =3D=3D 0) + hrtimer_cancel(&rapl_pmu->hrtimer); =20 list_del(&event->active_entry); =20 @@ -313,23 +313,23 @@ static void rapl_pmu_event_stop(struct perf_event *ev= ent, int mode) hwc->state |=3D PERF_HES_UPTODATE; } =20 - raw_spin_unlock_irqrestore(&pmu->lock, flags); + raw_spin_unlock_irqrestore(&rapl_pmu->lock, flags); } =20 static int rapl_pmu_event_add(struct perf_event *event, int mode) { - struct rapl_pmu *pmu =3D event->pmu_private; + struct rapl_pmu *rapl_pmu =3D event->pmu_private; struct hw_perf_event *hwc =3D &event->hw; unsigned long flags; =20 - raw_spin_lock_irqsave(&pmu->lock, flags); + raw_spin_lock_irqsave(&rapl_pmu->lock, flags); =20 hwc->state =3D PERF_HES_UPTODATE | PERF_HES_STOPPED; =20 if (mode & PERF_EF_START) - __rapl_pmu_event_start(pmu, event); + __rapl_pmu_event_start(rapl_pmu, event); =20 - raw_spin_unlock_irqrestore(&pmu->lock, flags); + raw_spin_unlock_irqrestore(&rapl_pmu->lock, flags); =20 return 0; } @@ -343,7 +343,7 @@ static int rapl_pmu_event_init(struct perf_event *event) { u64 cfg =3D event->attr.config & RAPL_EVENT_MASK; int bit, ret =3D 0; - struct rapl_pmu *pmu; + struct rapl_pmu *rapl_pmu; unsigned int rapl_pmu_idx; =20 /* only look at RAPL events */ @@ -376,10 +376,11 @@ static int rapl_pmu_event_init(struct perf_event *eve= nt) return -EINVAL; =20 /* must be done before validate_group */ - pmu =3D rapl_pmus->pmus[rapl_pmu_idx]; - if (!pmu) + rapl_pmu =3D rapl_pmus->rapl_pmu[rapl_pmu_idx]; + if (!rapl_pmu) return -EINVAL; - event->pmu_private =3D pmu; + + event->pmu_private =3D rapl_pmu; event->hw.event_base =3D rapl_msrs[bit].msr; event->hw.config =3D cfg; event->hw.idx =3D bit; @@ -606,7 +607,7 @@ static void cleanup_rapl_pmus(void) int i; =20 for (i =3D 0; i < rapl_pmus->nr_rapl_pmu; i++) - kfree(rapl_pmus->pmus[i]); + kfree(rapl_pmus->rapl_pmu[i]); kfree(rapl_pmus); } =20 @@ -621,27 +622,27 @@ static const struct attribute_group *rapl_attr_update= [] =3D { =20 static int __init init_rapl_pmu(void) { - struct rapl_pmu *pmu; + struct rapl_pmu *rapl_pmu; int idx; =20 for (idx =3D 0; idx < rapl_pmus->nr_rapl_pmu; idx++) { - pmu =3D kzalloc(sizeof(*pmu), GFP_KERNEL); - if (!pmu) + rapl_pmu =3D kzalloc(sizeof(*rapl_pmu), GFP_KERNEL); + if (!rapl_pmu) goto free; =20 - raw_spin_lock_init(&pmu->lock); - INIT_LIST_HEAD(&pmu->active_list); - pmu->pmu =3D &rapl_pmus->pmu; - pmu->timer_interval =3D ms_to_ktime(rapl_timer_ms); - rapl_hrtimer_init(pmu); + raw_spin_lock_init(&rapl_pmu->lock); + INIT_LIST_HEAD(&rapl_pmu->active_list); + rapl_pmu->pmu =3D &rapl_pmus->pmu; + rapl_pmu->timer_interval =3D ms_to_ktime(rapl_timer_ms); + rapl_hrtimer_init(rapl_pmu); =20 - rapl_pmus->pmus[idx] =3D pmu; + rapl_pmus->rapl_pmu[idx] =3D rapl_pmu; } =20 return 0; free: for (; idx > 0; idx--) - kfree(rapl_pmus->pmus[idx - 1]); + kfree(rapl_pmus->rapl_pmu[idx - 1]); return -ENOMEM; } =20 @@ -655,7 +656,7 @@ static int __init init_rapl_pmus(void) rapl_pmu_scope =3D PERF_PMU_SCOPE_DIE; } =20 - rapl_pmus =3D kzalloc(struct_size(rapl_pmus, pmus, nr_rapl_pmu), GFP_KERN= EL); + rapl_pmus =3D kzalloc(struct_size(rapl_pmus, rapl_pmu, nr_rapl_pmu), GFP_= KERNEL); if (!rapl_pmus) return -ENOMEM;