In light of James Bottomsley's commit[1] declaring that kmap() and
friends now have to take care of coherency issues, is the patch "mm:
D-cache aliasing issue in cow_user_page"[2] correct, or could it
potentially cause a slowdown by calling flush_dcache_page() a second
time (i.e. once in an architecture-specific kmap() implementation, and
once in cow_user_page())?
Matt
[1] http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=a6ca1b99ed434f3fb41bbed647ed36c0420501e5
[2] http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=c4ec7b0de4bc18ccb4380de638550984d9a65c25
From: "Matt Reimer" <[email protected]>
Date: Mon, 4 Dec 2006 23:38:13 -0800
> In light of James Bottomsley's commit[1] declaring that kmap() and
> friends now have to take care of coherency issues, is the patch "mm:
> D-cache aliasing issue in cow_user_page"[2] correct, or could it
> potentially cause a slowdown by calling flush_dcache_page() a second
> time (i.e. once in an architecture-specific kmap() implementation, and
> once in cow_user_page())?
kmap() is a NOP unless HIGHMEM is configured.
Therefore, it cannot possibly take care of D-cache aliasing issues
across the board.
On 12/5/06, David Miller <[email protected]> wrote:
> From: "Matt Reimer" <[email protected]>
> Date: Mon, 4 Dec 2006 23:38:13 -0800
>
> > In light of James Bottomsley's commit[1] declaring that kmap() and
> > friends now have to take care of coherency issues, is the patch "mm:
> > D-cache aliasing issue in cow_user_page"[2] correct, or could it
> > potentially cause a slowdown by calling flush_dcache_page() a second
> > time (i.e. once in an architecture-specific kmap() implementation, and
> > once in cow_user_page())?
>
> kmap() is a NOP unless HIGHMEM is configured.
>
> Therefore, it cannot possibly take care of D-cache aliasing issues
> across the board.
Right, but isn't he declaring that each architecture needs to take
care of this? So, say, on ARM we'd need to make kunmap() not a NOP and
call flush_dcache_page() ?
Matt
From: "Matt Reimer" <[email protected]>
Date: Tue, 5 Dec 2006 16:57:12 -0800
> Right, but isn't he declaring that each architecture needs to take
> care of this? So, say, on ARM we'd need to make kunmap() not a NOP and
> call flush_dcache_page() ?
No. He is only solving a problem that occurs on HIGHMEM
configurations on systems which can have D-cache aliasing
issues.
On 12/5/06, David Miller <[email protected]> wrote:
> From: "Matt Reimer" <[email protected]>
> Date: Tue, 5 Dec 2006 16:57:12 -0800
>
> > Right, but isn't he declaring that each architecture needs to take
> > care of this? So, say, on ARM we'd need to make kunmap() not a NOP and
> > call flush_dcache_page() ?
>
> No. He is only solving a problem that occurs on HIGHMEM
> configurations on systems which can have D-cache aliasing
> issues.
Ok. Thanks for the clarification.
Matt
On 12/5/06, David Miller <[email protected]> wrote:
> From: "Matt Reimer" <[email protected]>
> Date: Tue, 5 Dec 2006 16:57:12 -0800
>
> > Right, but isn't he declaring that each architecture needs to take
> > care of this? So, say, on ARM we'd need to make kunmap() not a NOP and
> > call flush_dcache_page() ?
>
> No. He is only solving a problem that occurs on HIGHMEM
> configurations on systems which can have D-cache aliasing
> issues.
Are you sure? James specifically mentions "non-highmem architectures,"
and "all architectures with coherence issues," which would seem to
include ARM (which is my concern).
For your convenience I quote the whole commit message below.
Matt
[PATCH] update to the kernel kmap/kunmap API
Give non-highmem architectures access to the kmap API for the purposes of
overriding (this is what the attached patch does).
The proposal is that we should now require all architectures with coherence
issues to manage data coherence via the kmap/kunmap API. Thus driver
writers never have to write code like
kmap(page)
modify data in page
flush_kernel_dcache_page(page)
kunmap(page)
instead, kmap/kunmap will manage the coherence and driver (and filesystem)
writers don't need to worry about how to flush between kmap and kunmap.
For most architectures, the page only needs to be flushed if it was
actually written to *and* there are user mappings of it, so the best
implementation looks to be: clear the page dirty pte bit in the kernel page
tables on kmap and on kunmap, check page->mappings for user maps, and then
the dirty bit, and only flush if it both has user mappings and is dirty.
From: "Matt Reimer" <[email protected]>
Date: Wed, 6 Dec 2006 13:19:41 -0800
> On 12/5/06, David Miller <[email protected]> wrote:
> > From: "Matt Reimer" <[email protected]>
> > Date: Tue, 5 Dec 2006 16:57:12 -0800
> >
> > > Right, but isn't he declaring that each architecture needs to take
> > > care of this? So, say, on ARM we'd need to make kunmap() not a NOP and
> > > call flush_dcache_page() ?
> >
> > No. He is only solving a problem that occurs on HIGHMEM
> > configurations on systems which can have D-cache aliasing
> > issues.
>
> Are you sure? James specifically mentions "non-highmem architectures,"
> and "all architectures with coherence issues," which would seem to
> include ARM (which is my concern).
>
> For your convenience I quote the whole commit message below.
Ok, I see.
He's providing it an alternative way to solve the coherency
issues.
You can still solve it the traditional way via cache flushing
in flush_dcache_page() and {copy,clear}_user_page().
On 12/6/06, David Miller <[email protected]> wrote:
> From: "Matt Reimer" <[email protected]>
> Date: Wed, 6 Dec 2006 13:19:41 -0800
>
> > On 12/5/06, David Miller <[email protected]> wrote:
> > > From: "Matt Reimer" <[email protected]>
> > > Date: Tue, 5 Dec 2006 16:57:12 -0800
> > >
> > > > Right, but isn't he declaring that each architecture needs to take
> > > > care of this? So, say, on ARM we'd need to make kunmap() not a NOP and
> > > > call flush_dcache_page() ?
> > >
> > > No. He is only solving a problem that occurs on HIGHMEM
> > > configurations on systems which can have D-cache aliasing
> > > issues.
> >
> > Are you sure? James specifically mentions "non-highmem architectures,"
> > and "all architectures with coherence issues," which would seem to
> > include ARM (which is my concern).
> >
> > For your convenience I quote the whole commit message below.
>
> Ok, I see.
>
> He's providing it an alternative way to solve the coherency
> issues.
>
> You can still solve it the traditional way via cache flushing
> in flush_dcache_page() and {copy,clear}_user_page().
Ok, good to know, since that's what we're doing with ARM drivers
presently. What's the preferred method going forward?
If architectures with coherency problems have to take care of this in
their kmap() implementations, wouldn't commits like [1] below result
in a pessmization for these architectures, since effectively the flush
would happen twice (once by architecture-specific kunmap, and once by
the flush_dcache_page() being added in this commit)?
Matt
[1] http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=c4ec7b0de4bc18ccb4380de638550984d9a65c25
From: "Matt Reimer" <[email protected]>
Date: Wed, 6 Dec 2006 22:20:22 -0800
> Ok, good to know, since that's what we're doing with ARM drivers
> presently. What's the preferred method going forward?
There are multiple ways provided to solve the problem so that
platforms can use whichever variant works best.