From: Matthew Wilcox <hidden> Date: 2016-03-11 21:13:17
I did some experimenting with converting the DAX radix tree from storing
sector numbers to storing pfn_t. While we're not ready to do that
conversion yet, these pieces make sense to at least get reviewed now,
and maybe get upstream.
I think the first patch is worthwhile all by itself as a stepping stone to
making SG lists contain PFNs instead of pages.
Matthew Wilcox (3):
pfn_t: Change the encoding
pfn_t: Support for huge PFNs
pfn_t: New functions pfn_t_add and pfn_t_cmp
include/linux/pfn_t.h | 72 +++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 61 insertions(+), 11 deletions(-)
--
2.7.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
From: Matthew Wilcox <hidden> Date: 2016-03-11 21:13:10
We need to put entries in the radix tree that represent PMDs and PUDs.
Use another bit to determine if this PFN entry represents a huge page
or not. If it does, we know the bottom few bits of the PFN are zero,
so we can reuse them to distinguish between PMDs and PUDs. Thanks to
Neil Brown for suggesting this more compact encoding.
Signed-off-by: Matthew Wilcox <redacted>
---
include/linux/pfn_t.h | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
@@ -46,9 +58,12 @@ static inline pfn_t pfn_to_pfn_t(unsigned long pfn)return__pfn_to_pfn_t(pfn,0);}+/* The bottom bits of the PFN may be set if PFN_HUGE is set */staticinlineunsignedlongpfn_t_to_pfn(pfn_tpfn){unsignedlongv=pfn.val;+if(v&PFN_HUGE)+v&=~PFN_SIZE_MASK;returnv>>PFN_FLAG_BITS;}
--
2.7.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
From: Matthew Wilcox <hidden> Date: 2016-03-11 21:13:12
By moving the flag bits to the bottom, we encourage commonality
between SGs with pages and those using pfn_t. We can also then insert
a pfn_t into a radix tree, as it uses the same two bits for indirect &
exceptional indicators.
Signed-off-by: Matthew Wilcox <redacted>
---
include/linux/pfn_t.h | 41 ++++++++++++++++++++++++++++++-----------
1 file changed, 30 insertions(+), 11 deletions(-)
--
2.7.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
From: Matthew Wilcox <hidden> Date: 2016-03-11 21:13:20
When we find a huge PFN in the radix tree, we need to add the low
bits of the index to it in order to find the PFN we are looking for.
Since we want the result to stay in pfn_t form, create pfn_t_add().
We also need to compare PFNs, for example to determine if the PFN
represents a zero page. At the moment, we only have use for comparing
equality, but a general compare operation is no more code and may prove
useful in the future.
Signed-off-by: Matthew Wilcox <redacted>
---
include/linux/pfn_t.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
@@ -67,6 +67,22 @@ static inline unsigned long pfn_t_to_pfn(pfn_t pfn)returnv>>PFN_FLAG_BITS;}+staticinline__must_checkpfn_tpfn_t_add(constpfn_tpfn,intval)+{+pfn_ttmp=pfn;+if(tmp.val&PFN_HUGE)+tmp.val&=~PFN_SIZE_MASK;+tmp.val&=~PFN_SG_MASK;+tmp.val+=val<<PFN_FLAG_BITS;+returntmp;+}++/* Like memcmp, returns <0 if a<b, 0 if a=b and >0 if b>a */+staticinlineintpfn_t_cmp(pfn_ta,pfn_tb)+{+returnpfn_t_to_pfn(b)-pfn_t_to_pfn(a);+}+externpfn_tphys_to_pfn_t(phys_addr_taddr,u64flags);staticinlineboolpfn_t_has_page(pfn_tpfn)
--
2.7.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
From: Dan Williams <hidden> Date: 2016-03-11 21:40:23
On Fri, Mar 11, 2016 at 1:13 PM, Matthew Wilcox
[off-list ref] wrote:
By moving the flag bits to the bottom, we encourage commonality
between SGs with pages and those using pfn_t. We can also then insert
a pfn_t into a radix tree, as it uses the same two bits for indirect &
exceptional indicators.
It's not immediately clear to me what we gain with SG entry
commonality. The down side is that we lose the property that
pfn_to_pfn_t() is a nop. This was Dave's suggestion so that the
nominal case did not change the binary layout of a typical pfn.
Can we just bit swizzle a pfn_t on insertion/retrieval from the radix?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
From: Matthew Wilcox <hidden> Date: 2016-03-12 18:29:52
On Fri, Mar 11, 2016 at 01:40:20PM -0800, Dan Williams wrote:
On Fri, Mar 11, 2016 at 1:13 PM, Matthew Wilcox
[off-list ref] wrote:
quoted
By moving the flag bits to the bottom, we encourage commonality
between SGs with pages and those using pfn_t. We can also then insert
a pfn_t into a radix tree, as it uses the same two bits for indirect &
exceptional indicators.
It's not immediately clear to me what we gain with SG entry
commonality. The down side is that we lose the property that
pfn_to_pfn_t() is a nop. This was Dave's suggestion so that the
nominal case did not change the binary layout of a typical pfn.
I understand that motivation!
Can we just bit swizzle a pfn_t on insertion/retrieval from the radix?
Of course we *can*, but we end up doing more swizzling that way than we
do this way. In the Brave New Future where we're storing pfn_t in the
radix tree, on a page fault we find the pfn_t in the radix tree then
we want to insert it into the page tables. So DAX would first have to
convert the radix tree entry to a pfn_t, then the page table code has to
convert the pfn_t into a pte/pmd/pud (which we currently do by converting
a pfn_t to a pfn, then converting the pfn to a pte/pmd/pud, but I assume
that either the compiler optimises that into a single conversion, or we'll
add pfn_t_pte to each architecture in future if it's actually a problem).
Much easier to look up a pfn_t in the radix tree and pass it directly
to vm_insert_mixed().
If there's any part of the kernel that is doing a *lot* of conversion
between pfn_t and pfn, that surely indicates a place in the kernel where
we need to convert an interface from pfn to pfn_t.
(It occurs to me we can make the code simpler on architectures that
don't support PUDs. The PFN_HUGE bit is still available to distinguish
between PMDs and PTEs, but we won't need to clear the bottom bit of the
PFN if PFN_HUGE is set, since nobody can add a PUD pfn to the radix tree).
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
From: Dan Williams <hidden> Date: 2016-03-13 23:09:46
On Sat, Mar 12, 2016 at 10:30 AM, Matthew Wilcox [off-list ref] wrote:
On Fri, Mar 11, 2016 at 01:40:20PM -0800, Dan Williams wrote:
quoted
On Fri, Mar 11, 2016 at 1:13 PM, Matthew Wilcox
[off-list ref] wrote:
quoted
By moving the flag bits to the bottom, we encourage commonality
between SGs with pages and those using pfn_t. We can also then insert
a pfn_t into a radix tree, as it uses the same two bits for indirect &
exceptional indicators.
It's not immediately clear to me what we gain with SG entry
commonality. The down side is that we lose the property that
pfn_to_pfn_t() is a nop. This was Dave's suggestion so that the
nominal case did not change the binary layout of a typical pfn.
I understand that motivation!
quoted
Can we just bit swizzle a pfn_t on insertion/retrieval from the radix?
Of course we *can*, but we end up doing more swizzling that way than we
do this way. In the Brave New Future where we're storing pfn_t in the
radix tree, on a page fault we find the pfn_t in the radix tree then
we want to insert it into the page tables. So DAX would first have to
convert the radix tree entry to a pfn_t, then the page table code has to
convert the pfn_t into a pte/pmd/pud (which we currently do by converting
a pfn_t to a pfn, then converting the pfn to a pte/pmd/pud, but I assume
that either the compiler optimises that into a single conversion, or we'll
add pfn_t_pte to each architecture in future if it's actually a problem).
Much easier to look up a pfn_t in the radix tree and pass it directly
to vm_insert_mixed().
If there's any part of the kernel that is doing a *lot* of conversion
between pfn_t and pfn, that surely indicates a place in the kernel where
we need to convert an interface from pfn to pfn_t.
So this is dependent on where pfn_t gets pushed in the future. For
example, if we revive using a pfn_t in a bio then I think the
pfn_to_pfn_t() conversions will be more prevalent than the fs/dax.c
radix usages.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
From: Matthew Wilcox <hidden> Date: 2016-03-14 15:00:08
On Sun, Mar 13, 2016 at 04:09:38PM -0700, Dan Williams wrote:
On Sat, Mar 12, 2016 at 10:30 AM, Matthew Wilcox [off-list ref] wrote:
quoted
On Fri, Mar 11, 2016 at 01:40:20PM -0800, Dan Williams wrote:
quoted
Can we just bit swizzle a pfn_t on insertion/retrieval from the radix?
Of course we *can*, but we end up doing more swizzling that way than we
do this way. In the Brave New Future where we're storing pfn_t in the
radix tree, on a page fault we find the pfn_t in the radix tree then
we want to insert it into the page tables. So DAX would first have to
convert the radix tree entry to a pfn_t, then the page table code has to
convert the pfn_t into a pte/pmd/pud (which we currently do by converting
a pfn_t to a pfn, then converting the pfn to a pte/pmd/pud, but I assume
that either the compiler optimises that into a single conversion, or we'll
add pfn_t_pte to each architecture in future if it's actually a problem).
Much easier to look up a pfn_t in the radix tree and pass it directly
to vm_insert_mixed().
If there's any part of the kernel that is doing a *lot* of conversion
between pfn_t and pfn, that surely indicates a place in the kernel where
we need to convert an interface from pfn to pfn_t.
So this is dependent on where pfn_t gets pushed in the future. For
example, if we revive using a pfn_t in a bio then I think the
pfn_to_pfn_t() conversions will be more prevalent than the fs/dax.c
radix usages.
Yes, we'll be converting to a pfn_t in more places than we are now
... but what do we do with that pfn_t once we've got it into a bio?
Except for some rare cases (brd, maybe pmem), it gets converted into an
sg list which then gets DMA mapped, then the DMA addresses are converted
into whatever format the hardware wants. As long as we convert the sg
list before we convert the bio, there aren't going to be any additional
conversions from pfn_t to pfn. So I don't see this showing up as an
additional per-I/O cost.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>