All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: Matt Fleming <matt@console-pimps.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>, Jiri Olsa <jolsa@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-kernel@vger.kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	Matt Fleming <matt.fleming@intel.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: Re: [PATCH 08/11] perf/x86/intel: Add Intel Cache QoS Monitoring support
Date: Wed, 24 Sep 2014 09:40:10 -0700	[thread overview]
Message-ID: <874mvx6kgl.fsf@tassilo.jf.intel.com> (raw)
In-Reply-To: <1411567455-31264-9-git-send-email-matt@console-pimps.org> (Matt Fleming's message of "Wed, 24 Sep 2014 15:04:12 +0100")

Matt Fleming <matt@console-pimps.org> writes:
>
> diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
> index 7e1fd4e08552..8abb18fbcd13 100644
> --- a/arch/x86/kernel/cpu/Makefile
> +++ b/arch/x86/kernel/cpu/Makefile
> @@ -38,7 +38,7 @@ obj-$(CONFIG_CPU_SUP_INTEL)		+= perf_event_p6.o perf_event_knc.o perf_event_p4.o
>  obj-$(CONFIG_CPU_SUP_INTEL)		+= perf_event_intel_lbr.o perf_event_intel_ds.o perf_event_intel.o
>  obj-$(CONFIG_CPU_SUP_INTEL)		+= perf_event_intel_uncore.o perf_event_intel_uncore_snb.o
>  obj-$(CONFIG_CPU_SUP_INTEL)		+= perf_event_intel_uncore_snbep.o perf_event_intel_uncore_nhmex.o
> -obj-$(CONFIG_CPU_SUP_INTEL)		+= perf_event_intel_rapl.o
> +obj-$(CONFIG_CPU_SUP_INTEL)		+= perf_event_intel_rapl.o perf_event_intel_cqm.o

What's missing to be able to make this a module?

> +
> +	/*
> +	 * Is @cpu a designated cqm reader?
> +	 */
> +	if (!cpumask_test_and_clear_cpu(cpu, &cqm_cpumask))
> +		return;
> +
> +	for_each_online_cpu(i) {

Likely possible cpus to avoid races? Otherwise you'll need more locking.

> +		if (i == cpu)
> +			continue;
> +
> +		if (phys_id == topology_physical_package_id(i)) {
> +			cpumask_set_cpu(i, &cqm_cpumask);
> +			break;
> +		}
> +	}
> +}
> +
> +static int intel_cqm_cpu_notifier(struct notifier_block *nb,
> +				  unsigned long action, void *hcpu)
> +{
> +	unsigned int cpu  = (unsigned long)hcpu;
> +
> +	switch (action & ~CPU_TASKS_FROZEN) {
> +	case CPU_UP_PREPARE:
> +		intel_cqm_cpu_prepare(cpu);
> +		break;
> +	case CPU_DOWN_PREPARE:
> +		intel_cqm_cpu_exit(cpu);
> +		break;
> +	case CPU_STARTING:
> +		cqm_pick_event_reader(cpu);
> +		break;
> +	}
> +
> +	return NOTIFY_OK;
> +}
> +
> +static int __init intel_cqm_init(void)
> +{
> +	int i, cpu, ret;
> +
> +	if (!cpu_has(&boot_cpu_data, X86_FEATURE_CQM_OCCUP_LLC))
> +		return -ENODEV;

This should use cpufeature.h

> +
> +	cqm_l3_scale = boot_cpu_data.x86_cache_occ_scale;
> +
> +	/*
> +	 * It's possible that not all resources support the same number
> +	 * of RMIDs. Instead of making scheduling much more complicated
> +	 * (where we have to match a task's RMID to a cpu that supports
> +	 * that many RMIDs) just find the minimum RMIDs supported across
> +	 * all cpus.
> +	 *
> +	 * Also, check that the scales match on all cpus.
> +	 */
> +	for_each_online_cpu(cpu) {

And this should take the cpu hotplug lock (although it may be
latent at this point if it's only running at early initializion)

But in fact what good is the test then if you only
every likely check cpu #0?

> +		struct cpuinfo_x86 *c = &cpu_data(cpu);
> +
> +		if (c->x86_cache_max_rmid < cqm_max_rmid)
> +			cqm_max_rmid = c->x86_cache_max_rmid;
> +
> +		if (c->x86_cache_occ_scale != cqm_l3_scale) {
> +			pr_err("Multiple LLC scale values, disabling\n");
> +			return -EINVAL;
> +		}
> +	}
> +
> +	ret = intel_cqm_setup_rmid_cache();
> +	if (ret)
> +		return ret;
> +
> +	for_each_online_cpu(i) {
> +		intel_cqm_cpu_prepare(i);
> +		cqm_pick_event_reader(i);
> +	}


-Andi

-- 
ak@linux.intel.com -- Speaking for myself only

  reply	other threads:[~2014-09-24 16:40 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-24 14:04 [PATCH 00/11] perf: Intel Cache QoS Monitoring support Matt Fleming
2014-09-24 14:04 ` [PATCH 01/11] perf stat: Fix AGGR_CORE segfault on multi-socket system Matt Fleming
2014-09-24 14:04 ` [PATCH 02/11] perf tools: Refactor unit and scale function parameters Matt Fleming
2014-09-29  9:21   ` Jiri Olsa
2014-10-03  5:25   ` [tip:perf/core] " tip-bot for Matt Fleming
2014-09-24 14:04 ` [PATCH 03/11] perf tools: Parse event per-package info files Matt Fleming
2014-09-24 14:04 ` [PATCH 04/11] perf: Make perf_cgroup_from_task() global Matt Fleming
2014-10-07 18:51   ` Peter Zijlstra
2014-10-08 10:27     ` Matt Fleming
2014-09-24 14:04 ` [PATCH 05/11] perf: Add ->count() function to read per-package counters Matt Fleming
2014-09-24 14:04 ` [PATCH 06/11] perf: Move cgroup init before PMU ->event_init() Matt Fleming
2014-10-07 19:34   ` Peter Zijlstra
2014-10-08 10:32     ` Matt Fleming
2014-10-08 10:49       ` Peter Zijlstra
2014-09-24 14:04 ` [PATCH 07/11] x86: Add support for Intel Cache QoS Monitoring (CQM) detection Matt Fleming
2014-09-24 14:04 ` [PATCH 08/11] perf/x86/intel: Add Intel Cache QoS Monitoring support Matt Fleming
2014-09-24 16:40   ` Andi Kleen [this message]
2014-09-24 20:27     ` Matt Fleming
2014-09-24 20:39       ` Andi Kleen
2014-09-29 18:51         ` Matt Fleming
2014-10-07 19:43   ` Peter Zijlstra
2014-10-08 10:36     ` Matt Fleming
2014-10-08 12:15       ` Matt Fleming
2014-10-08 14:47         ` Peter Zijlstra
2014-10-08 20:51           ` Peter Zijlstra
2014-09-24 14:04 ` [PATCH 09/11] perf/x86/intel: Implement LRU monitoring ID allocation for CQM Matt Fleming
2014-10-08  9:51   ` Peter Zijlstra
2014-10-08 10:53     ` Matt Fleming
2014-09-24 14:04 ` [PATCH 10/11] perf/x86/intel: Support task events with Intel CQM Matt Fleming
2014-09-24 14:45   ` Matt Fleming
2014-10-08 10:01   ` Peter Zijlstra
2014-10-08 11:07   ` Peter Zijlstra
2014-10-08 12:10     ` Matt Fleming
2014-10-08 14:49       ` Peter Zijlstra
2014-10-10 12:02         ` Matt Fleming
2014-10-10 14:02           ` Peter Zijlstra
2014-10-10 10:54     ` Peter Zijlstra
2014-10-10 11:10       ` Matt Fleming
2014-09-24 14:04 ` [PATCH 11/11] perf/x86/intel: Perform rotation on Intel CQM RMIDs Matt Fleming
2014-10-08 11:19   ` Peter Zijlstra
2014-10-08 11:56     ` Matt Fleming
2014-10-08 18:08   ` Peter Zijlstra
2014-10-08 19:02     ` Thomas Gleixner
2014-10-08 19:59       ` Matt Fleming
2014-10-08 18:10   ` Peter Zijlstra
2014-10-08 20:04     ` Matt Fleming

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=874mvx6kgl.fsf@tassilo.jf.intel.com \
    --to=andi@firstfloor.org \
    --cc=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matt.fleming@intel.com \
    --cc=matt@console-pimps.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.