From nobody Sat Nov 30 07:45:31 2024 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 84A01189F3B; Tue, 10 Sep 2024 09:59:04 +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=1725962346; cv=none; b=HUk28s115cBG+oPT//jSRQ2ZuvROxVz7R82NPxREPbKVeV1sAVciw23tglKQ4paFwQt/NwdztmxkiU2LYq3NY8NswSaAx8fYGmjYWHRTgl+LJw86i1IkTzlltlFEU4ZzxJoMoDQbantojoqSATW5yrZwgurt0oeH1Jr5X74REcg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725962346; c=relaxed/simple; bh=LiH3D9j0J1D1EBxJOA0bfAFTDIYk7hTHSvpag/NdCp4=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=NxwH0GR0+jAnx/o4ERAj/rLgDzGUB4z5+mPFfPPsbgwB+2zLNVKyJ3K7751InvO3VxqZ1qaP3zw+mhGhvLbiFb7DSsP33f0Gvw3iKVQpYT7Lq3wlRdycljy0KqC2SBxHjPG7MuchRcTTb4OrCArOgzHmG9wnMC4vilCxy8tHYu4= 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=CiAjd1/m; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=8PibRn7d; 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="CiAjd1/m"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="8PibRn7d" Date: Tue, 10 Sep 2024 09:59:01 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1725962342; 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=grD5In4bGPaA+nhqFqj8epzcpTP1SHG7xTFJKKmUVzo=; b=CiAjd1/mVBw9tbxw5BIiGcJgP/Vlfqne70HZ9Uazkw9C3Xu7WE7lpgDnefzt7ZnT19+Dgq Lz6Gm/r32cnbVqz8roxJxcSCKQcCcYMuynP3srNVLePH6ePi1dkWji2FIHy6USEUf+csnQ UU0tHluObTkUgOfXbx+G+QcaUjrVHCLAkwlU+vL0N/EN8JKVnNTDn1eNC+TBAhw9VbTkrp 0U+1eYqcc7P6mriqVLwEKGLr3SJRzkY/u66ZknNs7lnY1QmAqaIXIZG73fGZiZCc5U/VDI hzvZO+kjzz5ItQtv954hSbXLjLv6kaGSxvSUTkPzT7VXFJ7Mk1csD/8zwUAGLg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1725962342; 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=grD5In4bGPaA+nhqFqj8epzcpTP1SHG7xTFJKKmUVzo=; b=8PibRn7dXM3dPADsXj6zR5IsXAAX49qWxDhnNWp5jcgn57cnMYTMhx7wnszn7mhfeOlGQR WPpm5Y/JGuoF4/AA== From: "tip-bot2 for Kan Liang" 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: Clean up cpumask and hotplug Cc: Kan Liang , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240802151643.1691631-8-kan.liang@linux.intel.com> References: <20240802151643.1691631-8-kan.liang@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <172596234170.2215.10591822479645117410.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: fa90a7dad75b47302f6d35f6c6a36d0c87450187 Gitweb: https://git.kernel.org/tip/fa90a7dad75b47302f6d35f6c6a36d0c8= 7450187 Author: Kan Liang AuthorDate: Fri, 02 Aug 2024 08:16:43 -07:00 Committer: Peter Zijlstra CommitterDate: Tue, 10 Sep 2024 11:44:14 +02:00 perf/x86/rapl: Clean up cpumask and hotplug The rapl pmu is die scope, which is supported by the generic perf_event subsystem now. Set the scope for the rapl PMU and remove all the cpumask and hotplug codes. Signed-off-by: Kan Liang Signed-off-by: Peter Zijlstra (Intel) Link: https://lore.kernel.org/r/20240802151643.1691631-8-kan.liang@linux.in= tel.com --- arch/x86/events/rapl.c | 80 +------------------------------------- include/linux/cpuhotplug.h | 1 +- 2 files changed, 2 insertions(+), 79 deletions(-) diff --git a/arch/x86/events/rapl.c b/arch/x86/events/rapl.c index d12f3a6..0f8f4eb 100644 --- a/arch/x86/events/rapl.c +++ b/arch/x86/events/rapl.c @@ -135,7 +135,6 @@ struct rapl_model { /* 1/2^hw_unit Joule */ static int rapl_hw_unit[NR_RAPL_DOMAINS] __read_mostly; static struct rapl_pmus *rapl_pmus; -static cpumask_t rapl_cpu_mask; static unsigned int rapl_cntr_mask; static u64 rapl_timer_ms; static struct perf_msr *rapl_msrs; @@ -340,8 +339,6 @@ static int rapl_pmu_event_init(struct perf_event *event) if (event->cpu < 0) return -EINVAL; =20 - event->event_caps |=3D PERF_EV_CAP_READ_ACTIVE_PKG; - if (!cfg || cfg >=3D NR_RAPL_DOMAINS + 1) return -EINVAL; =20 @@ -360,7 +357,6 @@ static int rapl_pmu_event_init(struct perf_event *event) pmu =3D cpu_to_rapl_pmu(event->cpu); if (!pmu) return -EINVAL; - event->cpu =3D pmu->cpu; event->pmu_private =3D pmu; event->hw.event_base =3D rapl_msrs[bit].msr; event->hw.config =3D cfg; @@ -374,23 +370,6 @@ static void rapl_pmu_event_read(struct perf_event *eve= nt) rapl_event_update(event); } =20 -static ssize_t rapl_get_attr_cpumask(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return cpumap_print_to_pagebuf(true, buf, &rapl_cpu_mask); -} - -static DEVICE_ATTR(cpumask, S_IRUGO, rapl_get_attr_cpumask, NULL); - -static struct attribute *rapl_pmu_attrs[] =3D { - &dev_attr_cpumask.attr, - NULL, -}; - -static struct attribute_group rapl_pmu_attr_group =3D { - .attrs =3D rapl_pmu_attrs, -}; - RAPL_EVENT_ATTR_STR(energy-cores, rapl_cores, "event=3D0x01"); RAPL_EVENT_ATTR_STR(energy-pkg , rapl_pkg, "event=3D0x02"); RAPL_EVENT_ATTR_STR(energy-ram , rapl_ram, "event=3D0x03"); @@ -438,7 +417,6 @@ static struct attribute_group rapl_pmu_format_group =3D= { }; =20 static const struct attribute_group *rapl_attr_groups[] =3D { - &rapl_pmu_attr_group, &rapl_pmu_format_group, &rapl_pmu_events_group, NULL, @@ -541,49 +519,6 @@ static struct perf_msr amd_rapl_msrs[] =3D { [PERF_RAPL_PSYS] =3D { 0, &rapl_events_psys_group, NULL, false, 0 }, }; =20 -static int rapl_cpu_offline(unsigned int cpu) -{ - struct rapl_pmu *pmu =3D cpu_to_rapl_pmu(cpu); - int target; - - /* Check if exiting cpu is used for collecting rapl events */ - if (!cpumask_test_and_clear_cpu(cpu, &rapl_cpu_mask)) - return 0; - - pmu->cpu =3D -1; - /* Find a new cpu to collect rapl events */ - target =3D cpumask_any_but(topology_die_cpumask(cpu), cpu); - - /* Migrate rapl events to the new target */ - if (target < nr_cpu_ids) { - cpumask_set_cpu(target, &rapl_cpu_mask); - pmu->cpu =3D target; - perf_pmu_migrate_context(pmu->pmu, cpu, target); - } - return 0; -} - -static int rapl_cpu_online(unsigned int cpu) -{ - struct rapl_pmu *pmu =3D cpu_to_rapl_pmu(cpu); - int target; - - if (!pmu) - return -ENOMEM; - - /* - * Check if there is an online cpu in the package which collects rapl - * events already. - */ - target =3D cpumask_any_and(&rapl_cpu_mask, topology_die_cpumask(cpu)); - if (target < nr_cpu_ids) - return 0; - - cpumask_set_cpu(cpu, &rapl_cpu_mask); - pmu->cpu =3D cpu; - return 0; -} - static int rapl_check_hw_unit(struct rapl_model *rm) { u64 msr_rapl_power_unit_bits; @@ -707,6 +642,7 @@ static int __init init_rapl_pmus(void) rapl_pmus->pmu.stop =3D rapl_pmu_event_stop; rapl_pmus->pmu.read =3D rapl_pmu_event_read; rapl_pmus->pmu.module =3D THIS_MODULE; + rapl_pmus->pmu.scope =3D PERF_PMU_SCOPE_DIE; rapl_pmus->pmu.capabilities =3D PERF_PMU_CAP_NO_EXCLUDE; =20 init_rapl_pmu(); @@ -857,24 +793,13 @@ static int __init rapl_pmu_init(void) if (ret) return ret; =20 - /* - * Install callbacks. Core will call them for each online cpu. - */ - ret =3D cpuhp_setup_state(CPUHP_AP_PERF_X86_RAPL_ONLINE, - "perf/x86/rapl:online", - rapl_cpu_online, rapl_cpu_offline); - if (ret) - goto out; - ret =3D perf_pmu_register(&rapl_pmus->pmu, "power", -1); if (ret) - goto out1; + goto out; =20 rapl_advertise(); return 0; =20 -out1: - cpuhp_remove_state(CPUHP_AP_PERF_X86_RAPL_ONLINE); out: pr_warn("Initialization failed (%d), disabled\n", ret); cleanup_rapl_pmus(); @@ -884,7 +809,6 @@ module_init(rapl_pmu_init); =20 static void __exit intel_rapl_exit(void) { - cpuhp_remove_state_nocalls(CPUHP_AP_PERF_X86_RAPL_ONLINE); perf_pmu_unregister(&rapl_pmus->pmu); cleanup_rapl_pmus(); } diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h index 2101ae2..801053c 100644 --- a/include/linux/cpuhotplug.h +++ b/include/linux/cpuhotplug.h @@ -207,7 +207,6 @@ enum cpuhp_state { CPUHP_AP_PERF_X86_UNCORE_ONLINE, CPUHP_AP_PERF_X86_AMD_UNCORE_ONLINE, CPUHP_AP_PERF_X86_AMD_POWER_ONLINE, - CPUHP_AP_PERF_X86_RAPL_ONLINE, CPUHP_AP_PERF_S390_CF_ONLINE, CPUHP_AP_PERF_S390_SF_ONLINE, CPUHP_AP_PERF_ARM_CCI_ONLINE,