From: Thomas Gleixner <tglx@linutronix.de>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH 2/2]: pkt_sched: Convert CBQ to tasklet_hrtimer.
Date: Sat, 22 Aug 2009 11:17:53 +0200 (CEST) [thread overview]
Message-ID: <alpine.LFD.2.00.0908221041290.1769@localhost.localdomain> (raw)
In-Reply-To: <20090821.170333.153413841.davem@davemloft.net>
On Fri, 21 Aug 2009, David Miller wrote:
> This code expects to run in softirq context, and bare hrtimers
> run in hw IRQ context.
>
> Signed-off-by: David S. Miller <davem@davemloft.net>
> @@ -510,12 +512,12 @@ static void cbq_ovl_delay(struct cbq_class *cl)
>
> expires = ktime_set(0, 0);
> expires = ktime_add_ns(expires, PSCHED_TICKS2NS(sched));
> - if (hrtimer_try_to_cancel(&q->delay_timer) &&
> - ktime_to_ns(ktime_sub(
> - hrtimer_get_expires(&q->delay_timer),
> - expires)) > 0)
> - hrtimer_set_expires(&q->delay_timer, expires);
> - hrtimer_restart(&q->delay_timer);
> + ht = &q->delay_timer.timer;
> + if (hrtimer_try_to_cancel(ht) &&
> + ktime_to_ns(ktime_sub(hrtimer_get_expires(ht),
> + expires)) > 0)
> + hrtimer_set_expires(ht, expires);
> + hrtimer_restart(ht);
This code looks still wrong. The new expiry time is only set when the
timer is already active. If the timer is not active then you restart
it with the last stale expiry time which is probably in the past, but
might be somewhere in the future as well. I doubt that this is the
intention.
So what you really want is:
cl->cpriority = TC_CBQ_MAXPRIO;
q->pmask |= (1<<TC_CBQ_MAXPRIO);
- expires = ktime_set(0, 0);
- expires = ktime_add_ns(expires, PSCHED_TICKS2NS(sched));
- if (hrtimer_try_to_cancel(&q->delay_timer) &&
- ktime_to_ns(ktime_sub(
- hrtimer_get_expires(&q->delay_timer),
- expires)) > 0)
- hrtimer_set_expires(&q->delay_timer, expires);
- hrtimer_restart(&q->delay_timer);
+ ht = &q->delay_timer.timer;
+ expires = ns_to_ktime(PSCHED_TICKS2NS(sched));
+ if (!hrtimer_active(ht) ||
+ expires.tv64 < hrtimer_get_expires(ht).tv64)
+ hrtimer_start(ht, expires, HRTIMER_MODE_ABS);
cl->delayed = 1;
cl->xstats.overactions++;
return;
This starts the timer when
1) the timer is not active
2) the timer is active and the new expiry time is before the
current one. (hrtimer_start takes care of stopping the active
timer)
Thanks,
tglx
next prev parent reply other threads:[~2009-08-22 9:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-22 0:03 [PATCH 2/2]: pkt_sched: Convert CBQ to tasklet_hrtimer David Miller
2009-08-22 9:17 ` Thomas Gleixner [this message]
2009-08-23 1:08 ` David Miller
2009-08-23 7:22 ` Thomas Gleixner
2009-08-24 1:54 ` David Miller
2009-08-28 15:54 ` Eric Dumazet
2009-08-28 19:30 ` David Miller
2009-08-28 19:51 ` 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=alpine.LFD.2.00.0908221041290.1769@localhost.localdomain \
--to=tglx@linutronix.de \
--cc=davem@davemloft.net \
--cc=netdev@vger.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 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).