Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1304064 > unrolled thread

[PATCH v4 2/3] common: DMA-mapping: add DMA_ATTR_NOHUGEPAGE attribute

Started byDouglas Anderson <dianders@chromium.org>
First post2016-01-08 01:40 +0100
Last post2016-01-09 09:00 +0100
Articles 12 — 6 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v4 2/3] common: DMA-mapping: add DMA_ATTR_NOHUGEPAGE attribute Douglas Anderson <dianders@chromium.org> - 2016-01-08 01:40 +0100
    Re: [PATCH v4 2/3] common: DMA-mapping: add DMA_ATTR_NOHUGEPAGE  attribute Robin Murphy <robin.murphy@arm.com> - 2016-01-08 14:20 +0100
      Re: [PATCH v4 2/3] common: DMA-mapping: add DMA_ATTR_NOHUGEPAGE attribute Doug Anderson <dianders@chromium.org> - 2016-01-09 00:10 +0100
    Re: [PATCH v4 2/3] common: DMA-mapping: add DMA_ATTR_NOHUGEPAGE  attribute Russell King - ARM Linux <linux@arm.linux.org.uk> - 2016-01-08 14:40 +0100
      Re: [PATCH v4 2/3] common: DMA-mapping: add DMA_ATTR_NOHUGEPAGE attribute Doug Anderson <dianders@chromium.org> - 2016-01-09 00:10 +0100
        Re: [PATCH v4 2/3] common: DMA-mapping: add DMA_ATTR_NOHUGEPAGE  attribute Russell King - ARM Linux <linux@arm.linux.org.uk> - 2016-01-09 00:30 +0100
          Re: [PATCH v4 2/3] common: DMA-mapping: add DMA_ATTR_NOHUGEPAGE attribute Doug Anderson <dianders@chromium.org> - 2016-01-09 00:40 +0100
            Re: [PATCH v4 2/3] common: DMA-mapping: add DMA_ATTR_NOHUGEPAGE  attribute Christoph Hellwig <hch@infradead.org> - 2016-01-09 09:00 +0100
              Re: [PATCH v4 2/3] common: DMA-mapping: add DMA_ATTR_NOHUGEPAGE attribute Tomasz Figa <tfiga@chromium.org> - 2016-01-09 17:30 +0100
    Re: [PATCH v4 2/3] common: DMA-mapping: add DMA_ATTR_NOHUGEPAGE  attribute Christoph Hellwig <hch@infradead.org> - 2016-01-08 14:50 +0100
      Re: [PATCH v4 2/3] common: DMA-mapping: add DMA_ATTR_NOHUGEPAGE attribute Doug Anderson <dianders@chromium.org> - 2016-01-09 00:10 +0100
        Re: [PATCH v4 2/3] common: DMA-mapping: add DMA_ATTR_NOHUGEPAGE  attribute Christoph Hellwig <hch@infradead.org> - 2016-01-09 09:00 +0100

#1304064 — [PATCH v4 2/3] common: DMA-mapping: add DMA_ATTR_NOHUGEPAGE attribute

FromDouglas Anderson <dianders@chromium.org>
Date2016-01-08 01:40 +0100
Subject[PATCH v4 2/3] common: DMA-mapping: add DMA_ATTR_NOHUGEPAGE attribute
Message-ID<qOtfY-7iv-17@gated-at.bofh.it>
This patch adds the DMA_ATTR_NOHUGEPAGE attribute to the DMA-mapping
subsystem.

This attribute can be used as a hint to the DMA-mapping subsystem that
it's likely not worth it to try to allocation large pages behind the
scenes.  Large pages are likely to make an IOMMU TLB work more
efficiently but may not be worth it.  See the Documentation contained in
this patch for more details about this attribute and when to use it.

Note that the name of the hint (DMA_ATTR_NOHUGEPAGE) is based on the
name MADV_NOHUGEPAGE, which has the same meaning.  If we have expected
users, we could also add MADV_HUGEPAGE which has the opposite meaning of
this hint.

Signed-off-by: Douglas Anderson <dianders@chromium.org>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
Changes in v4:
- renamed DMA_ATTR_SEQUENTIAL to DMA_ATTR_NOHUGEPAGE
- added Marek's ack

Changes in v3:
- add DMA_ATTR_SEQUENTIAL attribute new for v3

Changes in v2: None

 Documentation/DMA-attributes.txt | 23 +++++++++++++++++++++++
 include/linux/dma-attrs.h        |  1 +
 2 files changed, 24 insertions(+)

diff --git a/Documentation/DMA-attributes.txt b/Documentation/DMA-attributes.txt
index 18dc52c4f2a0..0a2f56e9c5bd 100644
--- a/Documentation/DMA-attributes.txt
+++ b/Documentation/DMA-attributes.txt
@@ -100,3 +100,26 @@ allocated by dma_alloc_attrs() function from individual pages if it can
 be mapped as contiguous chunk into device dma address space. By
 specifying this attribute the allocated buffer is forced to be contiguous
 also in physical memory.
+
+DMA_ATTR_NOHUGEPAGE
+-------------------
+
+This is a hint to the DMA-mapping subsystem that it's probably not worth
+the time to try to allocate memory to in a way that gives better TLB
+efficiency (AKA it's not worth trying to build the mapping out of larger
+pages).  You might want to specify this if:
+- You know that the accesses to this memory won't thrash the TLB.
+  You might know that the accesses are likely to be sequential or
+  that they aren't sequential but it's unlikely you'll ping-ping
+  between many addresses that are likely to be in different physical
+  pages.
+- You know that the penalty of TLB misses while accessing the
+  memory will be small enough to be inconsequential.  If you are
+  doing a heavy operation like decryption or decompression this
+  might be the case.
+- You know that the DMA mapping is fairly transitory.  If you expect
+  the mapping to have a short lifetime then it may be worth it to
+  optimize allocation (avoid coming up with large pages) instead of
+  getting the slight performance win of larger pages.
+Setting this hint doesn't guarantee that you won't get huge pages, but it
+means that we won't try quite as hard to get them.
diff --git a/include/linux/dma-attrs.h b/include/linux/dma-attrs.h
index 99c0be00b47c..678662a235d1 100644
--- a/include/linux/dma-attrs.h
+++ b/include/linux/dma-attrs.h
@@ -18,6 +18,7 @@ enum dma_attr {
 	DMA_ATTR_NO_KERNEL_MAPPING,
 	DMA_ATTR_SKIP_CPU_SYNC,
 	DMA_ATTR_FORCE_CONTIGUOUS,
+	DMA_ATTR_NOHUGEPAGE,
 	DMA_ATTR_MAX,
 };
 
-- 
2.6.0.rc2.230.g3dd15c0

[toc] | [next] | [standalone]


#1304531 — Re: [PATCH v4 2/3] common: DMA-mapping: add DMA_ATTR_NOHUGEPAGE attribute

FromRobin Murphy <robin.murphy@arm.com>
Date2016-01-08 14:20 +0100
SubjectRe: [PATCH v4 2/3] common: DMA-mapping: add DMA_ATTR_NOHUGEPAGE attribute
Message-ID<qOF7t-7eQ-47@gated-at.bofh.it>
In reply to#1304064
Hi Doug,

On 08/01/16 00:36, Douglas Anderson wrote:
> This patch adds the DMA_ATTR_NOHUGEPAGE attribute to the DMA-mapping
> subsystem.
>
> This attribute can be used as a hint to the DMA-mapping subsystem that
> it's likely not worth it to try to allocation large pages behind the
> scenes.  Large pages are likely to make an IOMMU TLB work more
> efficiently but may not be worth it.  See the Documentation contained in
> this patch for more details about this attribute and when to use it.
>
> Note that the name of the hint (DMA_ATTR_NOHUGEPAGE) is based on the
> name MADV_NOHUGEPAGE, which has the same meaning.  If we have expected
> users, we could also add MADV_HUGEPAGE which has the opposite meaning of
> this hint.
>
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
> Changes in v4:
> - renamed DMA_ATTR_SEQUENTIAL to DMA_ATTR_NOHUGEPAGE
> - added Marek's ack
>
> Changes in v3:
> - add DMA_ATTR_SEQUENTIAL attribute new for v3
>
> Changes in v2: None
>
>   Documentation/DMA-attributes.txt | 23 +++++++++++++++++++++++
>   include/linux/dma-attrs.h        |  1 +
>   2 files changed, 24 insertions(+)
>
> diff --git a/Documentation/DMA-attributes.txt b/Documentation/DMA-attributes.txt
> index 18dc52c4f2a0..0a2f56e9c5bd 100644
> --- a/Documentation/DMA-attributes.txt
> +++ b/Documentation/DMA-attributes.txt
> @@ -100,3 +100,26 @@ allocated by dma_alloc_attrs() function from individual pages if it can
>   be mapped as contiguous chunk into device dma address space. By
>   specifying this attribute the allocated buffer is forced to be contiguous
>   also in physical memory.
> +
> +DMA_ATTR_NOHUGEPAGE
> +-------------------

Bikeshed: DMA_ATTR_NO_HUGEPAGE (or even DMA_ATTR_NO_HUGE_PAGE) would be 
more consistent with the naming style of the other attributes.

> +
> +This is a hint to the DMA-mapping subsystem that it's probably not worth
> +the time to try to allocate memory to in a way that gives better TLB
> +efficiency (AKA it's not worth trying to build the mapping out of larger
> +pages).  You might want to specify this if:
> +- You know that the accesses to this memory won't thrash the TLB.
> +  You might know that the accesses are likely to be sequential or
> +  that they aren't sequential but it's unlikely you'll ping-ping

                                                          ^ping-pong?

> +  between many addresses that are likely to be in different physical
> +  pages.
> +- You know that the penalty of TLB misses while accessing the
> +  memory will be small enough to be inconsequential.  If you are
> +  doing a heavy operation like decryption or decompression this
> +  might be the case.
> +- You know that the DMA mapping is fairly transitory.  If you expect
> +  the mapping to have a short lifetime then it may be worth it to
> +  optimize allocation (avoid coming up with large pages) instead of
> +  getting the slight performance win of larger pages.
> +Setting this hint doesn't guarantee that you won't get huge pages, but it
> +means that we won't try quite as hard to get them.

Nice detailed description, but I do worry it's a bit too ambiguous - it 
still parses perfectly well if you assume the references are to CPU TLBs 
and CPU accesses, rather than IOMMU TLBs and device accesses, especially 
given that the CPU is equally relevant to coherent DMA and there may not 
be an IOMMU at all. I assume that's not intentional, because otherwise 
it's also not quite accurate (I did once try to understand why we still 
have to split a CPU huge page for DMA even with a corresponding IOMMU 
huge page, but I remember getting completely lost somewhere in the 
bowels of the mm code).

Other than that, though, the rest of the series looks fine to me.

Thanks,
Robin.

> diff --git a/include/linux/dma-attrs.h b/include/linux/dma-attrs.h
> index 99c0be00b47c..678662a235d1 100644
> --- a/include/linux/dma-attrs.h
> +++ b/include/linux/dma-attrs.h
> @@ -18,6 +18,7 @@ enum dma_attr {
>   	DMA_ATTR_NO_KERNEL_MAPPING,
>   	DMA_ATTR_SKIP_CPU_SYNC,
>   	DMA_ATTR_FORCE_CONTIGUOUS,
> +	DMA_ATTR_NOHUGEPAGE,
>   	DMA_ATTR_MAX,
>   };
>
>

[toc] | [prev] | [next] | [standalone]


#1305060

FromDoug Anderson <dianders@chromium.org>
Date2016-01-09 00:10 +0100
Message-ID<qOOkq-5fH-21@gated-at.bofh.it>
In reply to#1304531
Hi,

On Fri, Jan 8, 2016 at 5:10 AM, Robin Murphy <robin.murphy@arm.com> wrote:
>> +DMA_ATTR_NOHUGEPAGE
>> +-------------------
>
>
> Bikeshed: DMA_ATTR_NO_HUGEPAGE (or even DMA_ATTR_NO_HUGE_PAGE) would be more
> consistent with the naming style of the other attributes.

Done.  I'm running out a paint, so crossing my fingers that this is
the final color.  ;)


>> +This is a hint to the DMA-mapping subsystem that it's probably not worth
>> +the time to try to allocate memory to in a way that gives better TLB
>> +efficiency (AKA it's not worth trying to build the mapping out of larger
>> +pages).  You might want to specify this if:
>> +- You know that the accesses to this memory won't thrash the TLB.
>> +  You might know that the accesses are likely to be sequential or
>> +  that they aren't sequential but it's unlikely you'll ping-ping
>
>
>                                                          ^ping-pong?

Done.


>> +  between many addresses that are likely to be in different physical
>> +  pages.
>> +- You know that the penalty of TLB misses while accessing the
>> +  memory will be small enough to be inconsequential.  If you are
>> +  doing a heavy operation like decryption or decompression this
>> +  might be the case.
>> +- You know that the DMA mapping is fairly transitory.  If you expect
>> +  the mapping to have a short lifetime then it may be worth it to
>> +  optimize allocation (avoid coming up with large pages) instead of
>> +  getting the slight performance win of larger pages.
>> +Setting this hint doesn't guarantee that you won't get huge pages, but it
>> +means that we won't try quite as hard to get them.
>
>
> Nice detailed description, but I do worry it's a bit too ambiguous - it
> still parses perfectly well if you assume the references are to CPU TLBs and
> CPU accesses, rather than IOMMU TLBs and device accesses, especially given
> that the CPU is equally relevant to coherent DMA and there may not be an
> IOMMU at all. I assume that's not intentional, because otherwise it's also
> not quite accurate (I did once try to understand why we still have to split
> a CPU huge page for DMA even with a corresponding IOMMU huge page, but I
> remember getting completely lost somewhere in the bowels of the mm code).

Hmm.  Well, the original ambiguity was sorta intentional.
Specifically anyone accessing this data through an MMU is likely to
have a TLB and allocating large chunks is more likely to increase the
efficiency of that TLB.  If Linux today can't manage to take advantage
of these large chunks to optimize CPU TLB efficiency that's not really
something I think we need to take into account in the API.  The API
should be OK even as Linux changes if possible...

If we happen to have no MMU at all between the DMA device and the
memory then presumably it need to be totally contiguous.  That would
be OK.  Presumably if the client knew that there was no MMU it would
specify DMA_ATTR_FORCE_CONTIGUOUS anyway...  ...and if the DMA
subsubsystem wanted to make things contiguous despite the "no huge
page" hint that doesn't violate the hint--it is legal to ignore it.


I'm really just a visitor to the DMA subsystem, though.  I would up
here down the rabbit hole of chasing down a bug.  If I'm totally
misunderstanding something please correct me.  ;)


-Doug

[toc] | [prev] | [next] | [standalone]


#1304545 — Re: [PATCH v4 2/3] common: DMA-mapping: add DMA_ATTR_NOHUGEPAGE attribute

FromRussell King - ARM Linux <linux@arm.linux.org.uk>
Date2016-01-08 14:40 +0100
SubjectRe: [PATCH v4 2/3] common: DMA-mapping: add DMA_ATTR_NOHUGEPAGE attribute
Message-ID<qOFqO-7nf-21@gated-at.bofh.it>
In reply to#1304064
On Thu, Jan 07, 2016 at 04:36:44PM -0800, Douglas Anderson wrote:
> This patch adds the DMA_ATTR_NOHUGEPAGE attribute to the DMA-mapping
> subsystem.

It would be nicer to keep things in the positive-logic sense if at all
possible: flags that indicate "we don't want something" tend to end up
with double or triple negatives somewhere which makes understanding
the code much harder.  It's a shame we have MADV_NOHUGEPAGE...

That's not a strong view, but a preference.

-- 
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

[toc] | [prev] | [next] | [standalone]


#1305054

FromDoug Anderson <dianders@chromium.org>
Date2016-01-09 00:10 +0100
Message-ID<qOOkq-5fH-13@gated-at.bofh.it>
In reply to#1304545
Hi,

On Fri, Jan 8, 2016 at 5:35 AM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
> On Thu, Jan 07, 2016 at 04:36:44PM -0800, Douglas Anderson wrote:
>> This patch adds the DMA_ATTR_NOHUGEPAGE attribute to the DMA-mapping
>> subsystem.
>
> It would be nicer to keep things in the positive-logic sense if at all
> possible: flags that indicate "we don't want something" tend to end up
> with double or triple negatives somewhere which makes understanding
> the code much harder.  It's a shame we have MADV_NOHUGEPAGE...
>
> That's not a strong view, but a preference.

Thanks for your thoughts.  I agree that double-negatives can be confusing...

IMHO There are two problems with changing to DMA_ATTR_HUGE_PAGE, though:

1. I have to go and touch all existing DMA-mapping code to set
DMA_ATTR_HUGE_PAGE.  That will be a big patchset and touch more code,
making it more likely to break something.  If I have to do that I can,
but I prefer not to because changing defaults like this tends to make
for subtle bugs.  One other thing to think about is that it's my
understanding that a large chunk of the ARM developers out there are
working on various differing versions of the kernel.  If you've got
drivers in your tree that haven't been patched to account for the new
default but you pick my patch you won't get a compile time
error--you'll get a very subtle performance regression.  Maybe we
don't care too much about those out-of-tree and old kernel folks, but
it's something to think about.

2. Personally I think of this attribute like a tristate with 3 values:

A) Do whatever you think best.  Maybe allocate huge pages if it's
super easy and there are lots of huge pages around.  AKA similar to
today's behavior.

B) Try extra hard to get huge pages.  Maybe do some extra sorting of
pages to build up big ones.  Maybe do a little extra collection.
Something like that.

C) Don't waste even en extra CPU cycle getting huge pages.  I don't need them.

Encoding a tristate with bitfields basically means you need two
opposite bit definitions: DMA_ATTR_NO_HUGE_PAGE and DMA_ATTR_HUGE_PAGE
(and specifying both is an error case).

Right now I only need two states of the theoretical tristate: A) and
C).  I could add "DMA_ATTR_HUGE_PAGE" in my patch, but I have no
patches queued up to use it.  As Christoph Hellwig has reinforced in
his reply, folks tend not to want unused code in the kernel, so my
thoughts are that someone can add this second attribute when they have
a use for it.


-Doug

[toc] | [prev] | [next] | [standalone]


#1305080 — Re: [PATCH v4 2/3] common: DMA-mapping: add DMA_ATTR_NOHUGEPAGE attribute

FromRussell King - ARM Linux <linux@arm.linux.org.uk>
Date2016-01-09 00:30 +0100
SubjectRe: [PATCH v4 2/3] common: DMA-mapping: add DMA_ATTR_NOHUGEPAGE attribute
Message-ID<qOODM-5p4-7@gated-at.bofh.it>
In reply to#1305054
On Fri, Jan 08, 2016 at 03:05:13PM -0800, Doug Anderson wrote:
> 1. I have to go and touch all existing DMA-mapping code to set
> DMA_ATTR_HUGE_PAGE.  That will be a big patchset and touch more code,
> making it more likely to break something.
...

Indeed, I was actually thinking of a positive "prefer/only use/force
smaller pages" thing rather than "allow huge pages" as a way to get
rid of the "no huge pages" negative as a way to get around that.
It has the same meaning when set as DMA_ATTR_NO_HUGE_PAGE but
avoids the problem of wondering what

	!dma_get_attr(DMA_ATTR_NO_HUGE_PAGE, attrs)

means.

I wasn't thinking of DMA_ATTR_HUGE_PAGE as that would certainly be
wrong when CONFIG_HAVE_DMA_ATTRS is disabled (when dma_get_attr()
always returns 0.)

-- 
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

[toc] | [prev] | [next] | [standalone]


#1305083

FromDoug Anderson <dianders@chromium.org>
Date2016-01-09 00:40 +0100
Message-ID<qOONr-5sr-1@gated-at.bofh.it>
In reply to#1305080
Russell,

On Fri, Jan 8, 2016 at 3:18 PM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
> On Fri, Jan 08, 2016 at 03:05:13PM -0800, Doug Anderson wrote:
>> 1. I have to go and touch all existing DMA-mapping code to set
>> DMA_ATTR_HUGE_PAGE.  That will be a big patchset and touch more code,
>> making it more likely to break something.
> ...
>
> Indeed, I was actually thinking of a positive "prefer/only use/force
> smaller pages" thing rather than "allow huge pages" as a way to get
> rid of the "no huge pages" negative as a way to get around that.
> It has the same meaning when set as DMA_ATTR_NO_HUGE_PAGE but
> avoids the problem of wondering what
>
>         !dma_get_attr(DMA_ATTR_NO_HUGE_PAGE, attrs)
>
> means.
>
> I wasn't thinking of DMA_ATTR_HUGE_PAGE as that would certainly be
> wrong when CONFIG_HAVE_DMA_ATTRS is disabled (when dma_get_attr()
> always returns 0.)

Ah, that makes so much more sense now!  :)  So you were suggesting
something like DMA_ATTR_SMALL_PAGES_OK.  Then you if we wanted all
possible states you'd have 0 vs. DMA_ATTR_SMALL_PAGES_OK vs.
DMA_ATTR_HUGE_PAGE?  That would avoid the double-negative but does
have the downside that it's less obvious that DMA_ATTR_SMALL_PAGES_OK
is the opposite of DMA_ATTR_HUGE_PAGE.


I think I still have a bit of a bias towards matching the MADV API,
but I also am happy to change things if that's what people want.  How
about if I see other people chiming in saying that they'd prefer
something like "DMA_ATTR_SMALL_PAGES_OK" then I'll change it,
otherwise I'll leave it as-is (since you said you didn't have a strong
opinion on it).


-Doug

[toc] | [prev] | [next] | [standalone]


#1305191 — Re: [PATCH v4 2/3] common: DMA-mapping: add DMA_ATTR_NOHUGEPAGE attribute

FromChristoph Hellwig <hch@infradead.org>
Date2016-01-09 09:00 +0100
SubjectRe: [PATCH v4 2/3] common: DMA-mapping: add DMA_ATTR_NOHUGEPAGE attribute
Message-ID<qOWBk-2oY-9@gated-at.bofh.it>
In reply to#1305083
On Fri, Jan 08, 2016 at 03:31:29PM -0800, Doug Anderson wrote:
> Ah, that makes so much more sense now!  :)  So you were suggesting
> something like DMA_ATTR_SMALL_PAGES_OK.  Then you if we wanted all
> possible states you'd have 0 vs. DMA_ATTR_SMALL_PAGES_OK vs.
> DMA_ATTR_HUGE_PAGE?  That would avoid the double-negative but does
> have the downside that it's less obvious that DMA_ATTR_SMALL_PAGES_OK
> is the opposite of DMA_ATTR_HUGE_PAGE.

or DMA_ATTR_4K_PAGES if that's what you want.  We have at least 4k, 8k,
16k and 64k page support in the kernel, not sure if 32k and 256k ever
made it mainline.  What does your hardware actually require?

This needs to be documented properly and hpefully also reflected in the
name of the fag.  Otherwise we'll end up with a giant desaster like
GFP_DMA that means something slightly different on every architecture.

[toc] | [prev] | [next] | [standalone]


#1305273

FromTomasz Figa <tfiga@chromium.org>
Date2016-01-09 17:30 +0100
Message-ID<qP4yU-83p-45@gated-at.bofh.it>
In reply to#1305191
On Sat, Jan 9, 2016 at 4:55 PM, Christoph Hellwig <hch@infradead.org> wrote:
> On Fri, Jan 08, 2016 at 03:31:29PM -0800, Doug Anderson wrote:
>> Ah, that makes so much more sense now!  :)  So you were suggesting
>> something like DMA_ATTR_SMALL_PAGES_OK.  Then you if we wanted all
>> possible states you'd have 0 vs. DMA_ATTR_SMALL_PAGES_OK vs.
>> DMA_ATTR_HUGE_PAGE?  That would avoid the double-negative but does
>> have the downside that it's less obvious that DMA_ATTR_SMALL_PAGES_OK
>> is the opposite of DMA_ATTR_HUGE_PAGE.
>
> or DMA_ATTR_4K_PAGES if that's what you want.

Or maybe just DMA_ATTR_USE_SMALL_PAGES?

> We have at least 4k, 8k,
> 16k and 64k page support in the kernel, not sure if 32k and 256k ever
> made it mainline.  What does your hardware actually require?

The hardware in question doesn't require any specific page size - the
IOMMU can map anything in granularity of 4KiB, which I believe
corresponds to the small page size on its platform (4KiB, ARM). Also
basically this attribute would translate into alloc_pages() with zero
order, so I guess that means small pages. (or we could perhaps make it
DMA_ATTR_ALLOC_SINGLE_PAGES...)

>
> This needs to be documented properly and hpefully also reflected in the
> name of the fag.  Otherwise we'll end up with a giant desaster like
> GFP_DMA that means something slightly different on every architecture.

Agreed.

Best regards,
Tomasz

[toc] | [prev] | [next] | [standalone]


#1304551 — Re: [PATCH v4 2/3] common: DMA-mapping: add DMA_ATTR_NOHUGEPAGE attribute

FromChristoph Hellwig <hch@infradead.org>
Date2016-01-08 14:50 +0100
SubjectRe: [PATCH v4 2/3] common: DMA-mapping: add DMA_ATTR_NOHUGEPAGE attribute
Message-ID<qOFAu-7qR-17@gated-at.bofh.it>
In reply to#1304064
On Thu, Jan 07, 2016 at 04:36:44PM -0800, Douglas Anderson wrote:
> This patch adds the DMA_ATTR_NOHUGEPAGE attribute to the DMA-mapping
> subsystem.
> 
> This attribute can be used as a hint to the DMA-mapping subsystem that
> it's likely not worth it to try to allocation large pages behind the
> scenes.  Large pages are likely to make an IOMMU TLB work more
> efficiently but may not be worth it.  See the Documentation contained in
> this patch for more details about this attribute and when to use it.
> 
> Note that the name of the hint (DMA_ATTR_NOHUGEPAGE) is based on the
> name MADV_NOHUGEPAGE, which has the same meaning.  If we have expected
> users, we could also add MADV_HUGEPAGE which has the opposite meaning of
> this hint.

A user of this features seems to be missing in the series.  Please don't
add any clutter with unclear usage to the kernel unless there is a real
need which can be deonstrated in form of patches and numbers.

[toc] | [prev] | [next] | [standalone]


#1305053

FromDoug Anderson <dianders@chromium.org>
Date2016-01-09 00:10 +0100
Message-ID<qOOkq-5fH-11@gated-at.bofh.it>
In reply to#1304551
Hi,

On Fri, Jan 8, 2016 at 5:42 AM, Christoph Hellwig <hch@infradead.org> wrote:
> On Thu, Jan 07, 2016 at 04:36:44PM -0800, Douglas Anderson wrote:
>> This patch adds the DMA_ATTR_NOHUGEPAGE attribute to the DMA-mapping
>> subsystem.
>>
>> This attribute can be used as a hint to the DMA-mapping subsystem that
>> it's likely not worth it to try to allocation large pages behind the
>> scenes.  Large pages are likely to make an IOMMU TLB work more
>> efficiently but may not be worth it.  See the Documentation contained in
>> this patch for more details about this attribute and when to use it.
>>
>> Note that the name of the hint (DMA_ATTR_NOHUGEPAGE) is based on the
>> name MADV_NOHUGEPAGE, which has the same meaning.  If we have expected
>> users, we could also add MADV_HUGEPAGE which has the opposite meaning of
>> this hint.
>
> A user of this features seems to be missing in the series.  Please don't
> add any clutter with unclear usage to the kernel unless there is a real
> need which can be deonstrated in form of patches and numbers.

In my cover letter I tried to address this.  See
<http://comments.gmane.org/gmane.linux.kernel/2121364>.  I said:

> Notably missing from this series is the fourth patch that adds teeth to
> the second and third.  You can find that out of tree at
> <https://chromium-review.googlesource.com/#/c/320498/>.  Unfortunately
> the rk3288_vpu, which is what I'm working on, is out of tree.

...but today I realized that I also needed to do work to get Exynos's
MFC codec using this patch and MFC _is_ upstream.  ...so my next
series will include the MFC patch.  Hopefully that will help address
your concerns.

[toc] | [prev] | [next] | [standalone]


#1305190 — Re: [PATCH v4 2/3] common: DMA-mapping: add DMA_ATTR_NOHUGEPAGE attribute

FromChristoph Hellwig <hch@infradead.org>
Date2016-01-09 09:00 +0100
SubjectRe: [PATCH v4 2/3] common: DMA-mapping: add DMA_ATTR_NOHUGEPAGE attribute
Message-ID<qOWBk-2oY-5@gated-at.bofh.it>
In reply to#1305053
On Fri, Jan 08, 2016 at 03:05:23PM -0800, Doug Anderson wrote:
> In my cover letter I tried to address this.  See
> <http://comments.gmane.org/gmane.linux.kernel/2121364>.  I said:
> 
> > Notably missing from this series is the fourth patch that adds teeth to
> > the second and third.  You can find that out of tree at
> > <https://chromium-review.googlesource.com/#/c/320498/>.  Unfortunately
> > the rk3288_vpu, which is what I'm working on, is out of tree.

Yes, I read that.  And that's exactly why I said we should not add
crazy workarounds for code that's not even in the kernel.

> ...but today I realized that I also needed to do work to get Exynos's
> MFC codec using this patch and MFC _is_ upstream.  ...so my next
> series will include the MFC patch.  Hopefully that will help address
> your concerns.

Ok.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web