All of lore.kernel.org
 help / color / mirror / Atom feed
From: Davide Libenzi <davidel@xmailserver.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [patch 6/13] signal/timer/event fds v9 - timerfd core ...
Date: Sun, 1 Apr 2007 10:00:13 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0704010941490.26331@alien.or.mcafeemobile.com> (raw)
In-Reply-To: <1175418341.28263.64.camel@localhost.localdomain>

On Sun, 1 Apr 2007, Thomas Gleixner wrote:

> On Sat, 2007-03-31 at 13:09 -0700, Davide Libenzi wrote:
> > +/*
> > + * This gets called when the timer event triggers. We increment the
> > + * tick count and wake the possible waiters. If the timer in a
> > + * sequential one (->tintv.tv64 != 0), we re-arm it with hrtimer_forward().
> > + */
> > +static enum hrtimer_restart timerfd_tmrproc(struct hrtimer *htmr)
> > +{
> > +	struct timerfd_ctx *ctx = container_of(htmr, struct timerfd_ctx, tmr);
> > +	enum hrtimer_restart rval = HRTIMER_NORESTART;
> > +	unsigned long flags;
> > +
> > +	spin_lock_irqsave(&ctx->lock, flags);
> > +	ctx->ticks++;
> > +	wake_up_locked(&ctx->wqh);
> > +	if (ctx->tintv.tv64 != 0) {
> > +		hrtimer_forward(htmr, hrtimer_cb_get_time(htmr), ctx->tintv);
> > +		rval = HRTIMER_RESTART;
> > +	}
> > +	spin_unlock_irqrestore(&ctx->lock, flags);
> > +
> > +	return rval;
> > +}
> 
> For periodic timers we probably want to know also about missed ticks,
> i.e. when the timer was delayed.
> 
> I changed recently the rearm handling code of itimers to prevent DoS
> attacks. See commit 8bfd9a7a229b5f3d3eda5d7d45c2eebec5b4ba16. The posix
> timer code has a similar mechanism.
> 
> Probably we should do the same here. That means that we defer the
> restart of the timer to the process context.

But timerfd has that implicit, in the ticks counter. So if you get ticks > 1
it means you did not read-out (miss) one or more.
By re-arming the timer whenever you read it, that may be some time after 
it expired. IMO the behaviour is better as it is now, and if you want the 
new timer sequence start at a new timeframe, you just use timerfd with the 
same fd.
I do not know about DoS on timers (did not follow the thread), but I could 
easily implement it here, by capping the counter to some value, and return 
POLLERR in poll().
I'd prefer that instead of the re-arm on read thing.


- Davide



  reply	other threads:[~2007-04-01 17:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-31 20:09 [patch 6/13] signal/timer/event fds v9 - timerfd core Davide Libenzi
2007-04-01  9:05 ` Thomas Gleixner
2007-04-01 17:00   ` Davide Libenzi [this message]
2007-04-01 17:08     ` Davide Libenzi
2007-04-02  7:22     ` Thomas Gleixner
2007-04-02 17:30       ` Davide Libenzi
2007-04-02 17:47         ` Thomas Gleixner
2007-04-02 17:52           ` Davide Libenzi

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=Pine.LNX.4.64.0704010941490.26331@alien.or.mcafeemobile.com \
    --to=davidel@xmailserver.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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.