All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arun R Bharadwaj <arun@linux.vnet.ibm.com>
To: linux-kernel@vger.kernel.org, linux-pm@lists.linux-foundation.org
Cc: a.p.zijlstra@chello.nl, ego@in.ibm.com, tglx@linutronix.de,
	mingo@elte.hu, andi@firstfloor.org,
	venkatesh.pallipadi@intel.com, vatsa@linux.vnet.ibm.com,
	arjan@infradead.org, svaidy@linux.vnet.ibm.com,
	Arun Bharadwaj <arun@linux.vnet.ibm.com>
Subject: Re: [v4 RFC PATCH 4/4] timers: logic to move non pinned timers
Date: Wed, 1 Apr 2009 17:16:41 +0530	[thread overview]
Message-ID: <20090401114641.GF22478@linux.vnet.ibm.com> (raw)
In-Reply-To: <20090401113738.GE22478@linux.vnet.ibm.com>

* Arun R Bharadwaj <arun@linux.vnet.ibm.com> [2009-04-01 17:07:38]:

--------snip--------------
> Index: linux.trees.git/include/linux/hrtimer.h
> ===================================================================
> --- linux.trees.git.orig/include/linux/hrtimer.h
> +++ linux.trees.git/include/linux/hrtimer.h
> @@ -22,7 +22,6 @@
>  #include <linux/wait.h>
>  #include <linux/percpu.h>
> 
> -
>  struct hrtimer_clock_base;
>  struct hrtimer_cpu_base;
> 
> @@ -376,6 +375,24 @@ extern ktime_t hrtimer_get_remaining(con
>  extern int hrtimer_get_res(const clockid_t which_clock, struct timespec *tp);
> 
>  extern ktime_t hrtimer_get_next_event(void);
> +extern ktime_t hrtimer_get_next_event_on(int cpu);
> +
> +#define TICK_PERIOD_IN_NS	NSEC_PER_SEC / HZ
> +/*
> + * Helper function to check before migrating a hrtimer if it expires
> + * before the next timer interrupt on the target cpu.
> + */
> +static inline int check_hrtimer_latency(struct hrtimer *timer, int cpu)
> +{
> +	unsigned long next_hrtimeout, next_jiffies;
> +	next_jiffies = get_next_timer_interrupt_on(jiffies, cpu);
> +	next_jiffies = next_jiffies * TICK_PERIOD_IN_NS;
> +	next_hrtimeout = hrtimer_get_expires_ns(timer);
> +
> +	if (next_hrtimeout > next_jiffies)
> +		return 1;
> +	return 0;
> +}
>

This function can be greatly simplified.
Here i am getting the next timer interrupt on target_cpu.
The target_cpu is the idle load balancer.
So we can check if the hrtimer expiry is before the next tick
on the ilb or not.
By doing this we can eliminate a lot of extra code, which would
otherwise be needed in the form of helper functions for
get_next_timer_interrupt_on().

After simplification the code would simply look like
static inline int check_hrtimer_latency(struct hrtimer *timer, int cpu)
{
        unsigned long next_hrtimeout, next_jiffies;
        next_jiffies = (jiffies + 1) * TICK_PERIOD_IN_NS;
        next_hrtimeout = hrtimer_get_expires_ns(timer);

        if(.....)
}

--arun

>  /*
>   * A timer is active, when it is enqueued into the rbtree or the callback
> Index: linux.trees.git/include/linux/timer.h
> ===================================================================
> --- linux.trees.git.orig/include/linux/timer.h
> +++ linux.trees.git/include/linux/timer.h
> @@ -184,7 +184,7 @@ extern unsigned long next_timer_interrup
>   * jiffie.
>   */
>  extern unsigned long get_next_timer_interrupt(unsigned long now);
> -
> +extern unsigned long get_next_timer_interrupt_on(unsigned long now, int cpu);
>  /*
>   * Timer-statistics info:
>   */

  reply	other threads:[~2009-04-01 11:47 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-01 11:31 [v4 RFC PATCH 0/4] timers: Framework for migration of timers Arun R Bharadwaj
2009-04-01 11:32 ` [v4 RFC PATCH 1/4] timers: Framework for identifying pinned timers Arun R Bharadwaj
2009-04-01 11:32 ` Arun R Bharadwaj
2009-04-01 11:41   ` Andi Kleen
2009-04-01 11:41   ` Andi Kleen
2009-04-02  5:09     ` Arun R Bharadwaj
2009-04-02  5:09     ` Arun R Bharadwaj
2009-04-01 11:34 ` [v4 RFC PATCH 2/4] timers: Identifying the existing " Arun R Bharadwaj
2009-04-01 11:34 ` Arun R Bharadwaj
2009-04-01 11:36 ` [v4 RFC PATCH 3/4] timers: /proc/sys sysctl hook to enable timer migration Arun R Bharadwaj
2009-04-01 11:36 ` Arun R Bharadwaj
2009-04-01 11:37 ` [v4 RFC PATCH 4/4] timers: logic to move non pinned timers Arun R Bharadwaj
2009-04-01 11:37 ` Arun R Bharadwaj
2009-04-01 11:46   ` Arun R Bharadwaj [this message]
2009-04-01 11:46   ` Arun R Bharadwaj
2009-04-03 21:52   ` Thomas Gleixner
2009-04-03 21:52   ` Thomas Gleixner
2009-04-06  5:16     ` Arun R Bharadwaj
2009-04-06 10:42       ` Arun R Bharadwaj
2009-04-06 10:56         ` Thomas Gleixner
2009-04-06 10:56         ` Thomas Gleixner
2009-04-06 15:28           ` Arun R Bharadwaj
2009-04-06 15:31             ` Arun R Bharadwaj
2009-04-06 15:31             ` Arun R Bharadwaj
2009-04-06 15:35             ` Thomas Gleixner
2009-04-06 15:35               ` Thomas Gleixner
2009-04-06 16:00               ` Arun R Bharadwaj
2009-04-06 16:00               ` Arun R Bharadwaj
2009-04-06 15:28           ` Arun R Bharadwaj
2009-04-06 10:42       ` Arun R Bharadwaj
2009-04-06  5:16     ` Arun R Bharadwaj

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=20090401114641.GF22478@linux.vnet.ibm.com \
    --to=arun@linux.vnet.ibm.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=andi@firstfloor.org \
    --cc=arjan@infradead.org \
    --cc=ego@in.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=mingo@elte.hu \
    --cc=svaidy@linux.vnet.ibm.com \
    --cc=tglx@linutronix.de \
    --cc=vatsa@linux.vnet.ibm.com \
    --cc=venkatesh.pallipadi@intel.com \
    /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.