From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>, Borislav Petkov <bp@alien8.de>,
Stephane Eranian <eranian@google.com>,
Harish Chegondi <harish.chegondi@intel.com>,
Kan Liang <kan.liang@intel.com>,
Andi Kleen <andi.kleen@intel.com>
Subject: [patch 05/11] x86/perf/intel_uncore: Make code readable
Date: Wed, 17 Feb 2016 13:47:34 -0000 [thread overview]
Message-ID: <20160217133932.117774541@linutronix.de> (raw)
In-Reply-To: 20160217132903.767990400@linutronix.de
[-- Attachment #1: x86-perf-intel_uncore--Make-code-readable.patch --]
[-- Type: text/plain, Size: 2905 bytes --]
Cleanup the code a bit before reworking it completely.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
arch/x86/kernel/cpu/perf_event_intel_uncore.c | 71 +++++++++++++-------------
1 file changed, 36 insertions(+), 35 deletions(-)
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
@@ -791,10 +791,8 @@ static void __init uncore_type_exit(stru
static void __init uncore_types_exit(struct intel_uncore_type **types)
{
- int i;
-
- for (i = 0; types[i]; i++)
- uncore_type_exit(types[i]);
+ while (*types)
+ uncore_type_exit(*types++);
}
static int __init uncore_type_init(struct intel_uncore_type *type)
@@ -898,9 +896,11 @@ static int uncore_pci_probe(struct pci_d
* some device types. Hence PCI device idx would be 0 for all devices.
* So increment pmu pointer to point to an unused array element.
*/
- if (boot_cpu_data.x86_model == 87)
+ if (boot_cpu_data.x86_model == 87) {
while (pmu->func_id >= 0)
pmu++;
+ }
+
if (pmu->func_id < 0)
pmu->func_id = pdev->devfn;
else
@@ -1158,44 +1158,45 @@ static int uncore_cpu_prepare(int cpu, i
return 0;
}
-static void
-uncore_change_context(struct intel_uncore_type **uncores, int old_cpu, int new_cpu)
+static void uncore_change_type_ctx(struct intel_uncore_type *type, int old_cpu,
+ int new_cpu)
{
- struct intel_uncore_type *type;
- struct intel_uncore_pmu *pmu;
+ struct intel_uncore_pmu *pmu = type->pmus;
struct intel_uncore_box *box;
- int i, j;
+ int i;
- for (i = 0; uncores[i]; i++) {
- type = uncores[i];
- for (j = 0; j < type->num_boxes; j++) {
- pmu = &type->pmus[j];
- if (old_cpu < 0)
- box = uncore_pmu_to_box(pmu, new_cpu);
- else
- box = uncore_pmu_to_box(pmu, old_cpu);
- if (!box)
- continue;
+ for (i = 0; i < type->num_boxes; i++, pmu++) {
+ if (old_cpu < 0)
+ box = uncore_pmu_to_box(pmu, new_cpu);
+ else
+ box = uncore_pmu_to_box(pmu, old_cpu);
+ if (!box)
+ continue;
+
+ if (old_cpu < 0) {
+ WARN_ON_ONCE(box->cpu != -1);
+ box->cpu = new_cpu;
+ continue;
+ }
- if (old_cpu < 0) {
- WARN_ON_ONCE(box->cpu != -1);
- box->cpu = new_cpu;
- continue;
- }
+ WARN_ON_ONCE(box->cpu != old_cpu);
+ box->cpu = -1;
+ if (new_cpu < 0)
+ continue;
- WARN_ON_ONCE(box->cpu != old_cpu);
- if (new_cpu >= 0) {
- uncore_pmu_cancel_hrtimer(box);
- perf_pmu_migrate_context(&pmu->pmu,
- old_cpu, new_cpu);
- box->cpu = new_cpu;
- } else {
- box->cpu = -1;
- }
- }
+ uncore_pmu_cancel_hrtimer(box);
+ perf_pmu_migrate_context(&pmu->pmu, old_cpu, new_cpu);
+ box->cpu = new_cpu;
}
}
+static void uncore_change_context(struct intel_uncore_type **uncores,
+ int old_cpu, int new_cpu)
+{
+ while (*uncores)
+ uncore_change_type_ctx(*uncores++, old_cpu, new_cpu);
+}
+
static void uncore_event_exit_cpu(int cpu)
{
int i, phys_id, target;
next prev parent reply other threads:[~2016-02-17 13:52 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-17 13:47 [patch 00/11] x86/perf/intel_uncore: Cleanup and enhancements Thomas Gleixner
2016-02-17 13:47 ` [patch 01/11] x86/perf/intel_uncore: Remove pointless mask check Thomas Gleixner
2016-02-17 13:47 ` [patch 02/11] x86/perf/intel_uncore: Simplify error rollback Thomas Gleixner
2016-02-17 13:47 ` [patch 04/11] x86/perf/intel_uncore: Cleanup hardware on exit Thomas Gleixner
2016-02-17 15:49 ` Liang, Kan
2016-02-17 18:16 ` Thomas Gleixner
2016-02-17 21:57 ` Liang, Kan
2016-02-17 22:00 ` Thomas Gleixner
2016-02-17 13:47 ` [patch 03/11] x86/perf/intel_uncore: Fix error handling Thomas Gleixner
2016-02-17 13:47 ` Thomas Gleixner [this message]
2016-02-17 13:47 ` [patch 07/11] x86/perf/uncore: Track packages not per cpu data Thomas Gleixner
2016-02-17 21:19 ` Stephane Eranian
2016-02-17 21:24 ` Andi Kleen
2016-02-17 21:56 ` Thomas Gleixner
2016-02-17 22:16 ` Andi Kleen
2016-02-17 22:31 ` Thomas Gleixner
2016-02-18 7:50 ` Ingo Molnar
2016-02-18 8:13 ` Peter Zijlstra
2016-02-18 9:35 ` Stephane Eranian
2016-02-18 9:51 ` Peter Zijlstra
2016-02-18 10:25 ` Thomas Gleixner
2016-02-18 10:22 ` Thomas Gleixner
2016-02-18 10:54 ` Thomas Gleixner
2016-02-19 8:39 ` Thomas Gleixner
2016-02-17 21:25 ` Thomas Gleixner
2016-02-17 13:47 ` [patch 06/11] x86/topology: Provide helper to retrieve number of cpu packages Thomas Gleixner
2016-02-17 13:47 ` [patch 08/11] x86/perf/intel_uncore: Clear all hardware state on exit Thomas Gleixner
2016-02-17 13:47 ` [patch 09/11] x86/perf/intel_uncore: Make PCI and MSR uncore independent Thomas Gleixner
2016-02-17 13:47 ` [patch 10/11] cpumask: Export cpumask_any_but Thomas Gleixner
2016-02-17 13:47 ` [patch 11/11] x86/perf/intel_uncore: Make it modular Thomas Gleixner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160217133932.117774541@linutronix.de \
--to=tglx@linutronix.de \
--cc=andi.kleen@intel.com \
--cc=bp@alien8.de \
--cc=eranian@google.com \
--cc=harish.chegondi@intel.com \
--cc=kan.liang@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).