mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michael Buesch <mb@bu3sch.de>
To: Valdis.Kletnieks@vt.edu
Cc: Andrew Morton <akpm@osdl.org>, linux-kernel@vger.kernel.org
Subject: Re: 2.6.17-rc4-mm3
Date: Mon, 22 May 2006 13:49:28 +0200	[thread overview]
Message-ID: <200605221349.28329.mb@bu3sch.de> (raw)
In-Reply-To: <200605221138.k4MBcgd2006492@turing-police.cc.vt.edu>

On Monday 22 May 2006 13:38, you wrote:
> On Mon, 22 May 2006 13:25:10 +0200, Michael Buesch said:
> > On Monday 22 May 2006 13:15, you wrote:
> 
> > > It looks to me line the old code stayed in a while() loop in rng_dev_read
> > > until it had fulfilled the read request (including possibly multiple
> > > calls to need_resched() and friends).  The new code will bail on an -EAGAIN
> > > as soon as the *first* poll fails, rather than waiting until something
> > > is available - even if it is NOT flagged O_NONBLOCK.
> > 
> > Yeah. That is how it works. I am wondering why userspace doesn't
> > simply retry, if it receives an EAGAIN.
> > Should we return ERESTARTSYS or something like that instead?
> 
> That's not the way it worked in previous kernels, and it's not the way that
> the current rng-utils RPM in Fedora expects it to work.
> 
> Here's a patch that makes it work the way it used to.  Adding the test
> for O_NONBLOCK is the biggie - the old code did a resched test at that
> point in the loop, so I added it here too.
> 
> --- linux-2.6.17-rc4-mm3/drivers/char/hw_random/core.c.rnd_fix	2006-05-22 07:23:34.000000000 -0400
> +++ linux-2.6.17-rc4-mm3/drivers/char/hw_random/core.c	2006-05-22 07:22:29.000000000 -0400
> @@ -125,7 +125,7 @@ static ssize_t rng_dev_read(struct file 
>  		mutex_unlock(&rng_mutex);
>  
>  		err = -EAGAIN;
> -		if (!bytes_read)
> +		if (filp->f_flags & O_NONBLOCK && !bytes_read)
>  			goto out;
>  
>  		err = -EFAULT;
> @@ -138,6 +138,9 @@ static ssize_t rng_dev_read(struct file 
>  			data >>= 8;
>  		}
>  
> +		if (need_resched())
> +                        schedule_timeout_interruptible(1);
> +

Andrew's comment on this:

	What's going on with the need_resched() tricks in there?  (Unobvious, needs
	a comment).  From my reading, it'll cause a caller to this function to hang
	for arbitrary periods of time if something if causing heavy scheduling
	pressure.

So I decided to remove it and return -EAGAIN, so userspace can retry.
But seems like it it does not. I thought glibc would handle that.

  reply	other threads:[~2006-05-22 11:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-22  9:27 2.6.17-rc4-mm3 Andrew Morton
2006-05-22 11:15 ` 2.6.17-rc4-mm3 Valdis.Kletnieks
2006-05-22 11:25   ` 2.6.17-rc4-mm3 Michael Buesch
2006-05-22 11:35     ` 2.6.17-rc4-mm3 Andrew Morton
2006-05-22 11:38     ` 2.6.17-rc4-mm3 Valdis.Kletnieks
2006-05-22 11:49       ` Michael Buesch [this message]
2006-05-22 12:46         ` 2.6.17-rc4-mm3 Valdis.Kletnieks
2006-05-23  9:43 ` 2.6.17-rc4-mm3 (can't compile kexec/ia64 on DIG) KAMEZAWA Hiroyuki
2006-05-23 21:07 ` 2.6.17-rc4-mm3 Michal Piotrowski
2006-05-23 21:35   ` [Alsa-devel] 2.6.17-rc4-mm3 Lee Revell
2006-05-23 21:51     ` Michal Piotrowski

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=200605221349.28329.mb@bu3sch.de \
    --to=mb@bu3sch.de \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®