All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: "kan.liang@intel.com" <kan.liang@intel.com>
Cc: "a.p.zijlstra@chello.nl" <a.p.zijlstra@chello.nl>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"acme@kernel.org" <acme@kernel.org>,
	"eranian@google.com" <eranian@google.com>,
	"ak@linux.intel.com" <ak@linux.intel.com>,
	"adrian.hunter@intel.com" <adrian.hunter@intel.com>,
	"dsahern@gmail.com" <dsahern@gmail.com>,
	"jolsa@kernel.org" <jolsa@kernel.org>,
	"namhyung@kernel.org" <namhyung@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/9] perf/x86: core_misc PMU disable and enable support
Date: Fri, 17 Jul 2015 13:11:41 +0100	[thread overview]
Message-ID: <20150717121141.GC26091@leverpostej> (raw)
In-Reply-To: <1437078831-10152-3-git-send-email-kan.liang@intel.com>

On Thu, Jul 16, 2015 at 09:33:44PM +0100, kan.liang@intel.com wrote:
> From: Kan Liang <kan.liang@intel.com>
> 
> This patch implements core_misc PMU disable and enable functions.
> core_misc PMU counters are free running counters, so it's impossible to
> stop/start them.

Doesn't that effectively mean you can't group them? You'll get arbitrary
noise because counters will be incrementing as you read them.

[...]

> @@ -927,6 +933,10 @@ int p6_pmu_init(void);
>  
>  int knc_pmu_init(void);
>  
> +void intel_core_misc_pmu_enable(void);
> +
> +void intel_core_misc_pmu_disable(void);
> +
>  ssize_t events_sysfs_show(struct device *dev, struct device_attribute *attr,
>  			  char *page);
>  
> diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
> index b9826a9..651a86d 100644
> --- a/arch/x86/kernel/cpu/perf_event_intel.c
> +++ b/arch/x86/kernel/cpu/perf_event_intel.c
> @@ -1586,6 +1586,8 @@ static int intel_pmu_handle_irq(struct pt_regs *regs)
>  	if (!x86_pmu.late_ack)
>  		apic_write(APIC_LVTPC, APIC_DM_NMI);
>  	__intel_pmu_disable_all();
> +	if (cpuc->core_misc_active_mask)
> +		intel_core_misc_pmu_disable();

Huh? Free running counters have nothing to do with the PMU interrupt;
there's nothing they can do to trigger it. This feels very hacky.

If this is necessary, surely it should live in __intel_pmu_disable_all?

[...]

> +void intel_core_misc_pmu_enable(void)
> +{
> +	struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
> +	struct perf_event *event;
> +	u64 start;
> +	int bit;
> +
> +	for_each_set_bit(bit, cpuc->core_misc_active_mask,
> +			 X86_CORE_MISC_COUNTER_MAX) {
> +		event = cpuc->core_misc_events[bit];
> +		start = core_misc_pmu_read_counter(event);
> +		local64_set(&event->hw.prev_count, start);
> +	}
> +}
> +
> +void intel_core_misc_pmu_disable(void)
> +{
> +	struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
> +	int bit;
> +
> +	for_each_set_bit(bit, cpuc->core_misc_active_mask,
> +			 X86_CORE_MISC_COUNTER_MAX) {
> +		core_misc_pmu_event_update(cpuc->core_misc_events[bit]);
> +	}
> +}
> +
>  static void core_misc_pmu_event_del(struct perf_event *event, int mode)
>  {
>  	core_misc_pmu_event_stop(event, PERF_EF_UPDATE);
> @@ -863,6 +899,11 @@ static void __init core_misc_pmus_register(void)
>  			.capabilities	= PERF_PMU_CAP_NO_INTERRUPT,
>  		};
>  
> +		if (type->type == perf_intel_core_misc_thread) {
> +			type->pmu.pmu_disable = (void *) intel_core_misc_pmu_disable;
> +			type->pmu.pmu_enable = (void *) intel_core_misc_pmu_enable;

Why are you suprressing an entirely valid compiler warning here?

The signatures of intel_core_misc_pmu_{enable,disable} aren't right. Fix
them to take a struct pmu *.

Mark.

  reply	other threads:[~2015-07-17 12:12 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-16 20:33 [PATCH 0/9] Intel core misc PMUs support kan.liang
2015-07-16 20:33 ` [PATCH 1/9] perf/x86: Add " kan.liang
2015-07-16 20:33 ` [PATCH 2/9] perf/x86: core_misc PMU disable and enable support kan.liang
2015-07-17 12:11   ` Mark Rutland [this message]
2015-07-17 13:46     ` Peter Zijlstra
2015-07-17 13:51       ` Peter Zijlstra
2015-07-17 15:35         ` Liang, Kan
2015-07-17 17:01           ` Andy Lutomirski
2015-07-17 17:52             ` Liang, Kan
2015-07-17 17:58               ` Andy Lutomirski
2015-07-17 18:15                 ` Liang, Kan
2015-07-17 18:56                   ` Andy Lutomirski
2015-07-17 21:11                   ` Peter Zijlstra
2015-07-16 20:33 ` [PATCH 3/9] perf/x86: Add is_hardware_event kan.liang
2015-07-17 10:48   ` Mark Rutland
2015-07-17 15:03     ` Liang, Kan
2015-07-17 15:47       ` Mark Rutland
2015-07-17 16:11         ` Mark Rutland
2015-07-16 20:33 ` [PATCH 4/9] perf/x86: special case per-cpu core misc PMU events kan.liang
2015-07-17 12:21   ` Mark Rutland
2015-07-17 12:55     ` Peter Zijlstra
2015-07-17 18:11       ` Stephane Eranian
2015-07-17 20:17     ` Andi Kleen
2015-07-20 16:12       ` Mark Rutland
2015-07-16 20:33 ` [PATCH 5/9] perf,tools: open event with it's own cpus and threads kan.liang
2015-07-16 20:33 ` [PATCH 6/9] perf,tools: Dump per-sample freq in report -D kan.liang
2015-07-16 20:33 ` [PATCH 7/9] perf,tools: save APERF/MPERF/TSC in struct perf_sample kan.liang
2015-07-16 20:33 ` [PATCH 8/9] perf,tools: caculate and save tsc/avg/bzy freq in he_stat kan.liang
2015-07-17 20:25   ` Andi Kleen
2015-07-17 20:57     ` Liang, Kan
2015-07-17 21:27       ` Andi Kleen
2015-07-16 20:33 ` [PATCH 9/9] perf,tools: Show freq in perf report --stdio kan.liang
2015-07-17 11:39 ` [PATCH 0/9] Intel core misc PMUs support Ingo Molnar

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=20150717121141.GC26091@leverpostej \
    --to=mark.rutland@arm.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.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 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.