public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* swsusp: clean up reading
@ 2004-09-10  8:54 Pavel Machek
  2004-09-11 23:19 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Machek @ 2004-09-10  8:54 UTC (permalink / raw)
  To: kernel list, Andrew Morton, Patrick Mochel

Hi!

This removes one-line functions so that code is readable again. Test
is added so that we do not ignore I/O errors. It also turns
io_schedule() into yield() as suggested by Andrea. Please apply,

								Pavel


--- clean-mm/kernel/power/swsusp.c	2004-09-07 21:12:33.000000000 +0200
+++ linux-mm/kernel/power/swsusp.c	2004-09-09 08:56:20.000000000 +0200
@@ -994,24 +978,14 @@
 
 static atomic_t io_done = ATOMIC_INIT(0);
 
-static void start_io(void)
-{
-	atomic_set(&io_done,1);
-}
-
 static int end_io(struct bio * bio, unsigned int num, int err)
 {
-	atomic_set(&io_done,0);
+	if (!test_bit(BIO_UPTODATE, &bio->bi_flags))
+		panic("I/O error reading memory image");
+	atomic_set(&io_done, 0);
 	return 0;
 }
 
-static void wait_io(void)
-{
-	while(atomic_read(&io_done))
-		io_schedule();
-}
-
-
 static struct block_device * resume_bdev;
 
 /**
@@ -1046,9 +1020,12 @@
 
 	if (rw == WRITE)
 		bio_set_pages_dirty(bio);
-	start_io();
+
+	atomic_set(&io_done, 1);
 	submit_bio(rw | (1 << BIO_RW_SYNC), bio);
-	wait_io();
+	while (atomic_read(&io_done))
+		yield();
+
  Done:
 	bio_put(bio);
 	return error;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: swsusp: clean up reading
  2004-09-10  8:54 swsusp: clean up reading Pavel Machek
@ 2004-09-11 23:19 ` Andrew Morton
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2004-09-11 23:19 UTC (permalink / raw)
  To: Pavel Machek; +Cc: linux-kernel, mochel

Pavel Machek <pavel@ucw.cz> wrote:
>
>  -static void wait_io(void)
>  -{
>  -	while(atomic_read(&io_done))
>  -		io_schedule();
>  -}
>  -
>  -
>   static struct block_device * resume_bdev;
>   
> ...
> 
>  -	wait_io();
>  +	while (atomic_read(&io_done))
>  +		yield();

This doesn't seem to be much of an improvement, really.  It still runs the
risk that the caller might have SCHIED_FIFO policy and we end up in a
spinloop until I/O completion.

Why not stick a `struct completion' at bio->bi_private, do complete() in
the end_io handler and wait_for_completion() in the caller?

I'll add the current patch to -mm for now, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-09-11 23:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-10  8:54 swsusp: clean up reading Pavel Machek
2004-09-11 23:19 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox