public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Shawn Bohrer <shawn.bohrer@gmail.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Davide Libenzi <davidel@xmailserver.org>,
	Simon Kirby <sim@hostway.ca>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: sys_epoll_wait high CPU load in 2.6.37
Date: Wed, 26 Jan 2011 11:20:06 -0600	[thread overview]
Message-ID: <20110126172006.GA9568@BohrerMBP.rgmadvisors.com> (raw)
In-Reply-To: <1296058409.2899.81.camel@edumazet-laptop>

On Wed, Jan 26, 2011 at 05:13:29PM +0100, Eric Dumazet wrote:
> Le mercredi 26 janvier 2011 à 16:59 +0100, Eric Dumazet a écrit :
> > Le mercredi 26 janvier 2011 à 07:52 -0800, Davide Libenzi a écrit :
> > 
> > > For "above", I meant the current epoll expire time calculation, which was 
> > > described above in the message ;)
> > 
> > Well, problem was not an overflow, but doing a loop 2.000.000 times ;)
> > 
> > > 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)?
> > 
> > Apparently its done differently in poll(), using
> > poll_select_set_timeout() helper.
> > 
> > 
> > Give me some minutes I'll try to cook an alternate patch
> > 
> 
> Here is the alternate patch, using poll_select_set_timeout() helper
> 
> Thanks
> 
> [PATCH v2] epoll: epoll_wait() should not use timespec_add_ns()
> 
> commit 95aac7b1cd224f (epoll: make epoll_wait() use the hrtimer range
> feature) added a performance regression because it uses
> timespec_add_ns() with potential very large 'ns' values.
> 
> Use poll_select_set_timeout() helper like poll()/select()
> 
> Reported-by: Simon Kirby <sim@hostway.ca>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> CC: Shawn Bohrer <shawn.bohrer@gmail.com>
> CC: Davide Libenzi <davidel@xmailserver.org>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Andrew Morton <akpm@linux-foundation.org>
> ---
>  fs/eventpoll.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/eventpoll.c b/fs/eventpoll.c
> index cc8a9b7..94d887b 100644
> --- a/fs/eventpoll.c
> +++ b/fs/eventpoll.c
> @@ -1125,8 +1125,8 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
>  	ktime_t expires, *to = NULL;
>  
>  	if (timeout > 0) {
> -		ktime_get_ts(&end_time);
> -		timespec_add_ns(&end_time, (u64)timeout * NSEC_PER_MSEC);
> +		poll_select_set_timeout(&end_time, timeout / MSEC_PER_SEC,
> +				NSEC_PER_MSEC * (timeout % MSEC_PER_SEC));
>  		slack = select_estimate_accuracy(&end_time);
>  		to = &expires;
>  		*to = timespec_to_ktime(end_time);

poll_select_set_timeout() jumps through some extra hoops that
aren't necessary in the epoll case so I actually like your previous
patch better.

--
Shawn

  reply	other threads:[~2011-01-26 17:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-26  0:09 sys_epoll_wait high CPU load in 2.6.37 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
2011-01-26 15:59           ` Eric Dumazet
2011-01-26 16:13             ` Eric Dumazet
2011-01-26 17:20               ` Shawn Bohrer [this message]
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=20110126172006.GA9568@BohrerMBP.rgmadvisors.com \
    --to=shawn.bohrer@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=davidel@xmailserver.org \
    --cc=eric.dumazet@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sim@hostway.ca \
    --cc=tglx@linutronix.de \
    /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