mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Fix loop device cache handling
@ 2004-06-01 17:03 Russell King
  2004-06-02  4:56 ` David S. Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Russell King @ 2004-06-01 17:03 UTC (permalink / raw)
  To: Linux Kernel List, Dave Miller

Back in the distant LKML past, davem hinted that the loop block device
driver was missing some cache handling for aliasing caches:

	http://lkml.org/lkml/2003/5/29/19

It appears the loop driver has had one flush_dcache_page() call
added for the case where it writes to the backing device page
cache pages.

However, it seems to be missing the call where it writes to its
own page cache pages.  This patch allows us to clearly demonstrate
the problem on ARM:

> @@ -85,9 +85,10 @@ static int transfer_none(struct loop_dev
>  	char *raw_buf = kmap_atomic(raw_page, KM_USER0) + raw_off;
>  	char *loop_buf = kmap_atomic(loop_page, KM_USER1) + loop_off;
>  
> -	if (cmd == READ)
> +	if (cmd == READ) {
> +int i; for (i = 0; i < PAGE_SIZE; i+=32) ((volatile unsigned char *)loop_buf)[i];
>  		memcpy(loop_buf, raw_buf, size);
> -	else
> +	} else
>  		memcpy(raw_buf, loop_buf, size);
>  
>  	kunmap_atomic(raw_buf, KM_USER0);

The effect of this is that we pull the loop device page into cache
to exhasibate the problem, since newly allocated pages are _not_
guaranteed to be completely clean of cache lines in their kernel
space mapping.

Note that other drivers need to be audited to ensure that any CPU
writes to page cache pages have a flush_dcache_page() call.

This patch adds the necessary missing flush:

--- orig/drivers/block/loop.c	Sun May 30 10:32:32 2004
+++ linux/drivers/block/loop.c	Tue Jun  1 17:46:47 2004
@@ -308,7 +308,9 @@ lo_read_actor(read_descriptor_t *desc, s
 		       page->index);
 		desc->error = -EINVAL;
 	}
-	
+
+	flush_dcache_page(p->page);
+
 	desc->count = count - size;
 	desc->written += size;
 	p->offset += size;


-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 PCMCIA      - http://pcmcia.arm.linux.org.uk/
                 2.6 Serial core

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

* Re: [PATCH] Fix loop device cache handling
  2004-06-01 17:03 [PATCH] Fix loop device cache handling Russell King
@ 2004-06-02  4:56 ` David S. Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David S. Miller @ 2004-06-02  4:56 UTC (permalink / raw)
  To: Russell King; +Cc: linux-kernel

On Tue, 1 Jun 2004 18:03:36 +0100
Russell King <rmk+lkml@arm.linux.org.uk> wrote:

> The effect of this is that we pull the loop device page into cache
> to exhasibate the problem, since newly allocated pages are _not_
> guaranteed to be completely clean of cache lines in their kernel
> space mapping.
> 
> Note that other drivers need to be audited to ensure that any CPU
> writes to page cache pages have a flush_dcache_page() call.
> 
> This patch adds the necessary missing flush:

I %100 agree with this patch.

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

end of thread, other threads:[~2004-06-02  4:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-01 17:03 [PATCH] Fix loop device cache handling Russell King
2004-06-02  4:56 ` David S. Miller

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®