linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
To: Trond Myklebust
	<Trond.Myklebust-HgOvQuBEEgTQT0dZR+AlfA@public.gmane.org>
Cc: "Russell King - ARM Linux"
	<linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org>,
	"James Bottomley"
	<James.Bottomley-JuX6DAaQMKPCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	"Marc Kleine-Budde" <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
	"Uwe Kleine-König"
	<u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
	"Marc Kleine-Budde"
	<m.kleine-budde-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	"Parisc List"
	<linux-parisc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	linux-arch-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: still nfs problems [Was: Linux 2.6.37-rc8]
Date: Wed, 5 Jan 2011 13:30:34 -0800	[thread overview]
Message-ID: <AANLkTi=3Gu-rz=-OdNtUXn4qw60Df6=YePnzvB=s-+Ov@mail.gmail.com> (raw)
In-Reply-To: <1294262208.2952.4.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>

On Wed, Jan 5, 2011 at 1:16 PM, Trond Myklebust
<Trond.Myklebust-HgOvQuBEEgTQT0dZR+AlfA@public.gmane.org> wrote:
>
> So what should be the preferred way to ensure data gets flushed when
> you've written directly to a page, and then want to read through the
> vm_map_ram() virtual range? Should we be adding new semantics to
> flush_kernel_dcache_page()?

The "preferred way" is actually simple: "don't do that". IOW, if some
page is accessed through a virtual mapping you've set up, then
_always_ access it through that virtual mapping.

Now, when that is impossible (and yes, it sometimes is), then you
should flush after doing all writes. And if you do the write through
the regular kernel mapping, you should use flush_dcache_page(). And if
you did it through the virtual mapping, you should use
"flush_kernel_vmap_range()" or whatever.

NOTE! I really didn't look those up very closely, and if the accesses
can happen concurrently you are basically screwed, so you do need to
do locking or something else to guarantee that there is some nice
sequential order.  And maybe I forgot something.  Which is why I do
suggest "don't do that" as a primary approach to the problem if at all
possible.

Oh, and you may need to flush before reading too (and many writes do
end up being "read-modify-write" cycles) in case it's possible that
you have stale data from a previous read that was then invalidated by
a write to the aliasing address. Even if that write was flushed out,
the stale read data may exist at the virtual address. I forget what
all we required - in the end the only sane model is "virtual caches
suck so bad that anybody who does them should be laughed at for being
a retard".

                            Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: "Russell King - ARM Linux" <linux@arm.linux.org.uk>,
	"James Bottomley" <James.Bottomley@hansenpartnership.com>,
	linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Marc Kleine-Budde" <mkl@pengutronix.de>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Marc Kleine-Budde" <m.kleine-budde@pengutronix.de>,
	linux-arm-kernel@lists.infradead.org,
	"Parisc List" <linux-parisc@vger.kernel.org>,
	linux-arch@vger.kernel.org
Subject: Re: still nfs problems [Was: Linux 2.6.37-rc8]
Date: Wed, 5 Jan 2011 13:30:34 -0800	[thread overview]
Message-ID: <AANLkTi=3Gu-rz=-OdNtUXn4qw60Df6=YePnzvB=s-+Ov@mail.gmail.com> (raw)
Message-ID: <20110105213034.qz2KiUhEhrTwr9-3QSdgyMVhXNaSSSr_CB71ghJs-zQ@z> (raw)
In-Reply-To: <1294262208.2952.4.camel@heimdal.trondhjem.org>

On Wed, Jan 5, 2011 at 1:16 PM, Trond Myklebust
<Trond.Myklebust@netapp.com> wrote:
>
> So what should be the preferred way to ensure data gets flushed when
> you've written directly to a page, and then want to read through the
> vm_map_ram() virtual range? Should we be adding new semantics to
> flush_kernel_dcache_page()?

The "preferred way" is actually simple: "don't do that". IOW, if some
page is accessed through a virtual mapping you've set up, then
_always_ access it through that virtual mapping.

Now, when that is impossible (and yes, it sometimes is), then you
should flush after doing all writes. And if you do the write through
the regular kernel mapping, you should use flush_dcache_page(). And if
you did it through the virtual mapping, you should use
"flush_kernel_vmap_range()" or whatever.

NOTE! I really didn't look those up very closely, and if the accesses
can happen concurrently you are basically screwed, so you do need to
do locking or something else to guarantee that there is some nice
sequential order.  And maybe I forgot something.  Which is why I do
suggest "don't do that" as a primary approach to the problem if at all
possible.

Oh, and you may need to flush before reading too (and many writes do
end up being "read-modify-write" cycles) in case it's possible that
you have stale data from a previous read that was then invalidated by
a write to the aliasing address. Even if that write was flushed out,
the stale read data may exist at the virtual address. I forget what
all we required - in the end the only sane model is "virtual caches
suck so bad that anybody who does them should be laughed at for being
a retard".

                            Linus

  parent reply	other threads:[~2011-01-05 21:30 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-05 19:05 still nfs problems [Was: Linux 2.6.37-rc8] James Bottomley
2011-01-05 19:18 ` Linus Torvalds
     [not found]   ` <AANLkTi=VZUxNFd7n-qwf5aiOeK5rkk8qBmo+kOpgg7up-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-01-05 19:36     ` James Bottomley
2011-01-05 19:36       ` James Bottomley
2011-01-05 19:49       ` Linus Torvalds
2011-01-05 20:35         ` James Bottomley
     [not found]       ` <1294256169.16957.18.camel-0iu6Cu4xQGLYCGPCin2YbQ@public.gmane.org>
2011-01-05 20:00         ` Russell King - ARM Linux
2011-01-05 20:00           ` Russell King - ARM Linux
2011-01-05 20:33           ` James Bottomley
2011-01-05 20:33             ` James Bottomley
2011-01-05 20:48             ` Linus Torvalds
     [not found]               ` <AANLkTimzzBsdtWcZtP5E_CH1hUZugGMoaHOiMdQJf764-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-01-05 21:04                 ` Russell King - ARM Linux
2011-01-05 21:04                   ` Russell King - ARM Linux
2011-01-05 21:08                   ` Linus Torvalds
2011-01-05 21:08                     ` Linus Torvalds
     [not found]                     ` <AANLkTi=EXXBTW7oWHq3D+PHsx=thF1CpkRjn0ax2p5rm-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-01-05 21:16                       ` Trond Myklebust
2011-01-05 21:16                         ` Trond Myklebust
     [not found]                         ` <1294262208.2952.4.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2011-01-05 21:30                           ` Linus Torvalds [this message]
2011-01-05 21:30                             ` Linus Torvalds
2011-01-05 23:06                             ` Trond Myklebust
2011-01-05 23:06                               ` Trond Myklebust
2011-01-05 23:28                               ` James Bottomley
2011-01-06 17:40                                 ` James Bottomley
2011-01-06 17:47                                   ` Trond Myklebust
2011-01-06 17:51                                     ` James Bottomley
2011-01-06 17:55                                     ` Linus Torvalds
2011-01-06 17:55                                       ` Linus Torvalds
2011-01-07 18:53                                       ` Trond Myklebust
     [not found]                                         ` <1294426405.2929.23.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2011-01-07 19:02                                           ` Russell King - ARM Linux
2011-01-07 19:02                                             ` Russell King - ARM Linux
2011-01-07 19:11                                             ` James Bottomley
2011-01-07 19:11                                               ` James Bottomley
     [not found]                                               ` <1294427467.4895.66.camel-0iu6Cu4xQGLYCGPCin2YbQ@public.gmane.org>
2011-01-08 16:49                                                 ` Trond Myklebust
2011-01-08 16:49                                                   ` Trond Myklebust
2011-01-08 23:15                                                   ` Trond Myklebust
2011-01-08 23:15                                                     ` Trond Myklebust
     [not found]                                                     ` <1294528551.4181.19.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2011-01-10 10:50                                                       ` Uwe Kleine-König
2011-01-10 10:50                                                         ` Uwe Kleine-König
2011-01-10 16:25                                                         ` Trond Myklebust
     [not found]                                                           ` <1294676734.3349.10.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2011-01-10 17:08                                                             ` Marc Kleine-Budde
2011-01-10 17:08                                                               ` Marc Kleine-Budde
2011-01-10 17:20                                                               ` Trond Myklebust
     [not found]                                                                 ` <1294680035.3349.19.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2011-01-10 17:26                                                                   ` Marc Kleine-Budde
2011-01-10 17:26                                                                     ` Marc Kleine-Budde
2011-01-10 19:25                                                                 ` Uwe Kleine-König
     [not found]                                                                   ` <20110110192552.GG24920-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2011-01-10 19:29                                                                     ` Trond Myklebust
2011-01-10 19:29                                                                       ` Trond Myklebust
2011-01-10 19:31                                                                       ` James Bottomley
2011-01-10 19:34                                                                       ` Linus Torvalds
2011-01-10 19:34                                                                         ` Linus Torvalds
2011-01-10 20:15                                                                         ` Trond Myklebust
2011-01-10 12:44                                                       ` Marc Kleine-Budde
2011-01-10 12:44                                                         ` Marc Kleine-Budde
2011-01-07 19:13                                             ` Trond Myklebust
2011-01-07 19:05                                         ` James Bottomley
     [not found]                                   ` <1294335614.22825.154.camel-0iu6Cu4xQGLYCGPCin2YbQ@public.gmane.org>
2011-01-06 18:05                                     ` Russell King - ARM Linux
2011-01-06 18:05                                       ` Russell King - ARM Linux
2011-01-06 18:14                                       ` James Bottomley
2011-01-06 18:14                                         ` James Bottomley
     [not found]                                         ` <1294337670.22825.199.camel-0iu6Cu4xQGLYCGPCin2YbQ@public.gmane.org>
2011-01-06 18:25                                           ` James Bottomley
2011-01-06 18:25                                             ` James Bottomley
2011-01-06 21:07                                             ` James Bottomley
2011-01-06 21:07                                               ` James Bottomley
2011-01-06 20:19                                   ` John Stoffel
2011-01-06 20:19                                     ` John Stoffel
2011-01-05 23:28                               ` Linus Torvalds
2011-01-05 23:28                                 ` Linus Torvalds
     [not found]                                 ` <AANLkTi=SjMinMp+m726GS1iehj6cQgNy1RqSoUqKhjtv-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-01-05 23:59                                   ` Russell King - ARM Linux
2011-01-05 23:59                                     ` Russell King - ARM Linux
2011-01-05 21:16               ` James Bottomley
2011-01-05 21:16                 ` James Bottomley

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='AANLkTi=3Gu-rz=-OdNtUXn4qw60Df6=YePnzvB=s-+Ov@mail.gmail.com' \
    --to=torvalds-de/tnxtf+jlsfhdxvbkv3wd2fqjk+8+b@public.gmane.org \
    --cc=James.Bottomley-JuX6DAaQMKPCXq6kfMZ53/egYHeGw8Jk@public.gmane.org \
    --cc=Trond.Myklebust-HgOvQuBEEgTQT0dZR+AlfA@public.gmane.org \
    --cc=linux-arch-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org \
    --cc=linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-parisc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=m.kleine-budde-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
    --cc=mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
    --cc=u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.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;
as well as URLs for NNTP newsgroup(s).