mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Stephane Eranian <eranian@google.com>
Cc: linux-kernel@vger.kernel.org, peterz@infradead.org,
	mingo@elte.hu, ak@linux.intel.com, acme@redhat.com,
	namhyung.kim@lge.com
Subject: Re: [PATCH v4 2/2] perf: add sysfs entry to adjust multiplexing interval per PMU
Date: Tue, 19 Feb 2013 20:24:03 +0100	[thread overview]
Message-ID: <20130219192403.GA17767@krava.redhat.com> (raw)
In-Reply-To: <1361210084-14409-3-git-send-email-eranian@google.com>

On Mon, Feb 18, 2013 at 06:54:44PM +0100, Stephane Eranian wrote:

SNIP

> +perf_event_mux_interval_ms_store(struct device *dev,
> +				 struct device_attribute *attr,
> +				 const char *buf, size_t count)
> +{
> +	struct pmu *pmu = dev_get_drvdata(dev);
> +	int timer, cpu, ret;
> +
> +	ret = kstrtoint(buf, 0, &timer);
> +	if (ret)
> +		return ret;
> +
> +	if (timer < 1)
> +		return -EINVAL;
> +
> +	pmu->hrtimer_interval_ms = timer;
> +
> +	/* update all cpuctx for this PMU */
> +	for_each_possible_cpu(cpu) {
> +		struct perf_cpu_context *cpuctx;
> +		cpuctx = per_cpu_ptr(pmu->pmu_cpu_context, cpu);
> +		cpuctx->hrtimer_interval = ns_to_ktime(NSEC_PER_MSEC * timer);
> +	}

If we set the timer to some big value like few minutes,
then run the meassurements and then set the value back to 1,
we actually need to wait till the big timer is expired before
the new value takes place.

I think we need to cancel the possible running timer in here
like in the atached patch, but maybe consider some locking.

jirka


diff --git a/kernel/events/core.c b/kernel/events/core.c
index 7c3f00f..ce9cd54 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -6038,6 +6038,9 @@ perf_event_mux_interval_ms_store(struct device *dev,
 		struct perf_cpu_context *cpuctx;
 		cpuctx = per_cpu_ptr(pmu->pmu_cpu_context, cpu);
 		cpuctx->hrtimer_interval = ns_to_ktime(NSEC_PER_MSEC * timer);
+
+		if (hrtimer_active(&cpuctx->hrtimer))
+			hrtimer_cancel(&cpuctx->hrtimer);
 	}
 
 	return count;

  reply	other threads:[~2013-02-19 19:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-18 17:54 [PATCH v4 0/2] perf: use hrtimer for event multiplexing Stephane Eranian
2013-02-18 17:54 ` [PATCH v4 1/2] " Stephane Eranian
2013-02-18 17:54 ` [PATCH v4 2/2] perf: add sysfs entry to adjust multiplexing interval per PMU Stephane Eranian
2013-02-19 19:24   ` Jiri Olsa [this message]
2013-02-20 19:59     ` Stephane Eranian

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=20130219192403.GA17767@krava.redhat.com \
    --to=jolsa@redhat.com \
    --cc=acme@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=eranian@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=namhyung.kim@lge.com \
    --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

Powered by JetHome