mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Davide Libenzi <davidel@xmailserver.org>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Simon Kirby <sim@hostway.ca>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Shawn Bohrer <shawn.bohrer@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: sys_epoll_wait high CPU load in 2.6.37
Date: Wed, 26 Jan 2011 07:52:23 -0800 (PST)	[thread overview]
Message-ID: <alpine.DEB.2.00.1101260747320.1889@localhost6.localdomain6> (raw)
In-Reply-To: <1296056600.2899.66.camel@edumazet-laptop>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1285 bytes --]

On Wed, 26 Jan 2011, Eric Dumazet wrote:

> Le mercredi 26 janvier 2011 à 07:31 -0800, Davide Libenzi a écrit :
> > On Wed, 26 Jan 2011, Eric Dumazet wrote:
> > 
> 
> > > diff --git a/fs/eventpoll.c b/fs/eventpoll.c
> > > index cc8a9b7..7ec0890 100644
> > > --- a/fs/eventpoll.c
> > > +++ b/fs/eventpoll.c
> > > @@ -1126,7 +1126,9 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
> > >  
> > >  	if (timeout > 0) {
> > >  		ktime_get_ts(&end_time);
> > > -		timespec_add_ns(&end_time, (u64)timeout * NSEC_PER_MSEC);
> > > +		end_time.tv_sec += timeout / MSEC_PER_SEC;
> > > +		timeout %= MSEC_PER_SEC;
> > > +		timespec_add_ns(&end_time, timeout * NSEC_PER_MSEC);
> > >  		slack = select_estimate_accuracy(&end_time);
> > >  		to = &expires;
> > >  		*to = timespec_to_ktime(end_time);
> > 
> > Yep, we can overflow the timeout, with the calculation above.
> > A timespec_add_ms()?
> 
> Well, given timeout after modulo contains a number between 0 and 999,
> multiply by 1.000.000 (NSEC_PER_MSEC) cant overflow.

For "above", I meant the current epoll expire time calculation, which was 
described above in the message ;)
The hint for a timespec_add_ms() was because we must be doing something 
similar in poll, don't we (/me got no code in front ATM)?

  reply	other threads:[~2011-01-26 15:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-26  0:09 Simon Kirby
2011-01-26  7:18 ` Eric Dumazet
2011-01-26 11:16   ` Eric Dumazet
2011-01-26 15:31     ` Davide Libenzi
2011-01-26 15:43       ` Eric Dumazet
2011-01-26 15:52         ` Davide Libenzi [this message]
2011-01-26 15:59           ` Eric Dumazet
2011-01-26 16:13             ` Eric Dumazet
2011-01-26 17:20               ` Shawn Bohrer
2011-01-26 17:51                 ` Eric Dumazet
2011-01-26 18:06                   ` Davide Libenzi
2011-01-26 18:18                     ` Eric Dumazet
2011-01-26 18:45                       ` Eric Dumazet
2011-01-28  0:17                         ` 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=alpine.DEB.2.00.1101260747320.1889@localhost6.localdomain6 \
    --to=davidel@xmailserver.org \
    --cc=akpm@linux-foundation.org \
    --cc=eric.dumazet@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shawn.bohrer@gmail.com \
    --cc=sim@hostway.ca \
    /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

all inboxes | Powered by JetHome®