mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Russell King <rmk+lkml@arm.linux.org.uk>
To: Linux Kernel List <linux-kernel@vger.kernel.org>,
	Dave Miller <davem@redhat.com>
Subject: [PATCH] Fix loop device cache handling
Date: Tue, 1 Jun 2004 18:03:36 +0100	[thread overview]
Message-ID: <20040601180336.C31301@flint.arm.linux.org.uk> (raw)

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

             reply	other threads:[~2004-06-01 17:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-01 17:03 Russell King [this message]
2004-06-02  4:56 ` David S. Miller

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=20040601180336.C31301@flint.arm.linux.org.uk \
    --to=rmk+lkml@arm.linux.org.uk \
    --cc=davem@redhat.com \
    --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®