linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu/vt-d: add NUMA awareness to intel_alloc_coherent()
@ 2018-01-31 22:45 Eric Dumazet
  2018-02-01  1:46 ` Eric Dumazet
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Eric Dumazet @ 2018-01-31 22:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Benjamin Serebrin, David Woodhouse, Joerg Roedel, iommu, netdev,
	Eric Dumazet

From: Eric Dumazet <edumazet@google.com>

Some devices (like mlx4) try hard to allocate memory on selected
NUMA node, but it turns out intel_alloc_coherent() is not NUMA
aware yet.

Note that dma_generic_alloc_coherent() in arch/x86/kernel/pci-dma.c
gets this right.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Benjamin Serebrin <serebrin@google.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Joerg Roedel <joro@8bytes.org>
---
 drivers/iommu/intel-iommu.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index a1373cf343269455808f66ad18dc0a2fb7aa73f2..0efef077abc099eb29ebc5cefdd1b996f025dffd 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -3734,8 +3734,11 @@ static void *intel_alloc_coherent(struct device *dev, size_t size,
 		}
 	}
 
-	if (!page)
-		page = alloc_pages(flags, order);
+	if (!page) {
+		page = alloc_pages_node(dev_to_node(dev), flags, order);
+		if (!page)
+			page = alloc_pages(flags, order);
+	}
 	if (!page)
 		return NULL;
 	memset(page_address(page), 0, size);

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] iommu/vt-d: add NUMA awareness to intel_alloc_coherent()
  2018-01-31 22:45 [PATCH] iommu/vt-d: add NUMA awareness to intel_alloc_coherent() Eric Dumazet
@ 2018-02-01  1:46 ` Eric Dumazet
  2018-02-01  6:33 ` [PATCH v2] " Eric Dumazet
  2018-02-02 18:53 ` [PATCH] " Christoph Hellwig
  2 siblings, 0 replies; 7+ messages in thread
From: Eric Dumazet @ 2018-02-01  1:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: Benjamin Serebrin, David Woodhouse, Joerg Roedel, iommu, netdev,
	Eric Dumazet

On Wed, 2018-01-31 at 14:45 -0800, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> Some devices (like mlx4) try hard to allocate memory on selected
> NUMA node, but it turns out intel_alloc_coherent() is not NUMA
> aware yet.
> 
> Note that dma_generic_alloc_coherent() in arch/x86/kernel/pci-dma.c
> gets this right.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Benjamin Serebrin <serebrin@google.com>
> Cc: David Woodhouse <dwmw2@infradead.org>
> Cc: Joerg Roedel <joro@8bytes.org>
> ---
>  drivers/iommu/intel-iommu.c |    7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
> index a1373cf343269455808f66ad18dc0a2fb7aa73f2..0efef077abc099eb29ebc5cefdd1b996f025dffd 100644
> --- a/drivers/iommu/intel-iommu.c
> +++ b/drivers/iommu/intel-iommu.c
> @@ -3734,8 +3734,11 @@ static void *intel_alloc_coherent(struct device *dev, size_t size,
>  		}
>  	}
>  
> -	if (!page)
> -		page = alloc_pages(flags, order);
> +	if (!page) {
> +		page = alloc_pages_node(dev_to_node(dev), flags, order);
> +		if (!page)
> +			page = alloc_pages(flags, order);

I'll send a V2 without the fallback to alloc_pages()

This seems not necessary at all.


> +	}
>  	if (!page)
>  		return NULL;
>  	memset(page_address(page), 0, size);

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] iommu/vt-d: add NUMA awareness to intel_alloc_coherent()
  2018-01-31 22:45 [PATCH] iommu/vt-d: add NUMA awareness to intel_alloc_coherent() Eric Dumazet
  2018-02-01  1:46 ` Eric Dumazet
@ 2018-02-01  6:33 ` Eric Dumazet
  2018-02-02 18:53 ` [PATCH] " Christoph Hellwig
  2 siblings, 0 replies; 7+ messages in thread
From: Eric Dumazet @ 2018-02-01  6:33 UTC (permalink / raw)
  To: linux-kernel
  Cc: Benjamin Serebrin, David Woodhouse, Joerg Roedel, iommu, netdev,
	Eric Dumazet

From: Eric Dumazet <edumazet@google.com>

Some devices (like mlx4) try hard to allocate memory on selected
NUMA node, but it turns out intel_alloc_coherent() is not NUMA
aware yet.

Note that dma_generic_alloc_coherent() in arch/x86/kernel/pci-dma.c
gets this right.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Benjamin Serebrin <serebrin@google.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Joerg Roedel <joro@8bytes.org>
---
v2: no fallback to alloc_pages(), this is not needed and might even
hurt in OOM cases.

 drivers/iommu/intel-iommu.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index a1373cf343269455808f66ad18dc0a2fb7aa73f2..3c538466a98bdb8fffdca688462b1350d536791b 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -3735,7 +3735,7 @@ static void *intel_alloc_coherent(struct device *dev, size_t size,
 	}
 
 	if (!page)
-		page = alloc_pages(flags, order);
+		page = alloc_pages_node(dev_to_node(dev), flags, order);
 	if (!page)
 		return NULL;
 	memset(page_address(page), 0, size);

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] iommu/vt-d: add NUMA awareness to intel_alloc_coherent()
  2018-01-31 22:45 [PATCH] iommu/vt-d: add NUMA awareness to intel_alloc_coherent() Eric Dumazet
  2018-02-01  1:46 ` Eric Dumazet
  2018-02-01  6:33 ` [PATCH v2] " Eric Dumazet
@ 2018-02-02 18:53 ` Christoph Hellwig
  2018-02-02 18:59   ` Eric Dumazet
  2 siblings, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2018-02-02 18:53 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: linux-kernel, Benjamin Serebrin, David Woodhouse, Joerg Roedel,
	iommu, netdev, Eric Dumazet

I've got patches pending to replace all that code with
dma_direct_alloc, which will do the right thing.  They were
submitted for 4.16, and I will resend them after -rc1.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] iommu/vt-d: add NUMA awareness to intel_alloc_coherent()
  2018-02-02 18:53 ` [PATCH] " Christoph Hellwig
@ 2018-02-02 18:59   ` Eric Dumazet
  2020-04-01 22:53     ` Eric Dumazet
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Dumazet @ 2018-02-02 18:59 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Eric Dumazet, linux-kernel, Benjamin Serebrin, David Woodhouse,
	Joerg Roedel, iommu, netdev

On Fri, Feb 2, 2018 at 10:53 AM, Christoph Hellwig <hch@infradead.org> wrote:
> I've got patches pending to replace all that code with
> dma_direct_alloc, which will do the right thing.  They were
> submitted for 4.16, and I will resend them after -rc1.

I see, thanks Christoph !

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] iommu/vt-d: add NUMA awareness to intel_alloc_coherent()
  2018-02-02 18:59   ` Eric Dumazet
@ 2020-04-01 22:53     ` Eric Dumazet
  2020-04-02  6:56       ` Christoph Hellwig
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Dumazet @ 2020-04-01 22:53 UTC (permalink / raw)
  To: Eric Dumazet, Christoph Hellwig
  Cc: linux-kernel, Benjamin Serebrin, David Woodhouse, Joerg Roedel,
	iommu, netdev



On 2/2/18 10:59 AM, Eric Dumazet wrote:
> On Fri, Feb 2, 2018 at 10:53 AM, Christoph Hellwig <hch@infradead.org> wrote:
>> I've got patches pending to replace all that code with
>> dma_direct_alloc, which will do the right thing.  They were
>> submitted for 4.16, and I will resend them after -rc1.
> 
> I see, thanks Christoph !
> 

Hi Christoph 

It seems 4.16 has shipped ( :) ) , and intel_alloc_coherent() still has no NUMA awareness.

Should I respin https://lore.kernel.org/patchwork/patch/884326/

Thanks !

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] iommu/vt-d: add NUMA awareness to intel_alloc_coherent()
  2020-04-01 22:53     ` Eric Dumazet
@ 2020-04-02  6:56       ` Christoph Hellwig
  0 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2020-04-02  6:56 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Eric Dumazet, Christoph Hellwig, linux-kernel, Benjamin Serebrin,
	David Woodhouse, Joerg Roedel, iommu, netdev

On Wed, Apr 01, 2020 at 03:53:38PM -0700, Eric Dumazet wrote:
> 
> 
> On 2/2/18 10:59 AM, Eric Dumazet wrote:
> > On Fri, Feb 2, 2018 at 10:53 AM, Christoph Hellwig <hch@infradead.org> wrote:
> >> I've got patches pending to replace all that code with
> >> dma_direct_alloc, which will do the right thing.  They were
> >> submitted for 4.16, and I will resend them after -rc1.
> > 
> > I see, thanks Christoph !
> > 
> 
> Hi Christoph 
> 
> It seems 4.16 has shipped ( :) ) , and intel_alloc_coherent() still has no NUMA awareness.

Actually, that code went in and then got reverted again..

> Should I respin https://lore.kernel.org/patchwork/patch/884326/

Maybe.  We are still hoping to convert intel-iommu to the dma-iommu
framework, but I'm not sure how long that is going to take, so maybe
just respin it for now.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-04-02  6:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-31 22:45 [PATCH] iommu/vt-d: add NUMA awareness to intel_alloc_coherent() Eric Dumazet
2018-02-01  1:46 ` Eric Dumazet
2018-02-01  6:33 ` [PATCH v2] " Eric Dumazet
2018-02-02 18:53 ` [PATCH] " Christoph Hellwig
2018-02-02 18:59   ` Eric Dumazet
2020-04-01 22:53     ` Eric Dumazet
2020-04-02  6:56       ` Christoph Hellwig

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).