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


Groups > linux.kernel > #1734776 > unrolled thread

Re: [PATCH] iommu/amd: Use raw_cpu_ptr() instead of get_cpu_ptr() for ->flush_queue

Started byJoerg Roedel <joro@8bytes.org>
First post2017-09-19 11:50 +0200
Last post2017-09-21 17:30 +0200
Articles 2 — 2 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

  Re: [PATCH] iommu/amd: Use raw_cpu_ptr() instead of get_cpu_ptr()  for ->flush_queue Joerg Roedel <joro@8bytes.org> - 2017-09-19 11:50 +0200
    [PATCH v2] iommu/iova: Use raw_cpu_ptr() instead of get_cpu_ptr()  for ->fq Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2017-09-21 17:30 +0200

#1734776 — Re: [PATCH] iommu/amd: Use raw_cpu_ptr() instead of get_cpu_ptr() for ->flush_queue

FromJoerg Roedel <joro@8bytes.org>
Date2017-09-19 11:50 +0200
SubjectRe: [PATCH] iommu/amd: Use raw_cpu_ptr() instead of get_cpu_ptr() for ->flush_queue
Message-ID<urnkf-39c-33@gated-at.bofh.it>
Hi Sebastian,

On Wed, Sep 06, 2017 at 12:34:59PM +0200, Sebastian Andrzej Siewior wrote:
> get_cpu_ptr() disables preemption and returns the ->flush_queue object
> of the current CPU. raw_cpu_ptr() does the same except that it not
> disable preemption which means the scheduler can move it to another CPU
> after it obtained the per-CPU object.
> In this case this is not bad because the data structure itself is
> protected with a spin_lock. This change shouldn't matter in general
> but on RT it does because the sleeping lock can't be accessed with
> disabled preemption.

I moved the flushing to driver/iommu/iova.c to share it with the Intel
IOMMU and possibly other drivers too, so this patch does no longer apply
to v4.14-rc1. Can you update the patch to these changes?

Regards,

	Joerg

[toc] | [next] | [standalone]


#1736773 — [PATCH v2] iommu/iova: Use raw_cpu_ptr() instead of get_cpu_ptr() for ->fq

FromSebastian Andrzej Siewior <bigeasy@linutronix.de>
Date2017-09-21 17:30 +0200
Subject[PATCH v2] iommu/iova: Use raw_cpu_ptr() instead of get_cpu_ptr() for ->fq
Message-ID<usbAm-2Ne-11@gated-at.bofh.it>
In reply to#1734776
get_cpu_ptr() disabled preemption and returns the ->fq object of the
current CPU. raw_cpu_ptr() does the same except that it not disable
preemption which means the scheduler can move it to another CPU after it
obtained the per-CPU object.
In this case this is not bad because the data structure itself is
protected with a spin_lock. This change shouldn't matter however on RT
it does because the sleeping lock can't be accessed with disabled
preemption.

Cc: Joerg Roedel <joro@8bytes.org>
Cc: iommu@lists.linux-foundation.org
Reported-by: vinadhy@gmail.com
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
On 2017-09-19 11:41:19 [+0200], Joerg Roedel wrote:
> Hi Sebastian,
Hi Jörg,

> I moved the flushing to driver/iommu/iova.c to share it with the Intel
> IOMMU and possibly other drivers too, so this patch does no longer apply
> to v4.14-rc1. Can you update the patch to these changes?

Sure.

v1…v2: move the change from amd_iommu.c to iova.c

 drivers/iommu/iova.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
index 33edfa794ae9..b30900025c62 100644
--- a/drivers/iommu/iova.c
+++ b/drivers/iommu/iova.c
@@ -570,7 +570,7 @@ void queue_iova(struct iova_domain *iovad,
 		unsigned long pfn, unsigned long pages,
 		unsigned long data)
 {
-	struct iova_fq *fq = get_cpu_ptr(iovad->fq);
+	struct iova_fq *fq = raw_cpu_ptr(iovad->fq);
 	unsigned long flags;
 	unsigned idx;
 
@@ -600,8 +600,6 @@ void queue_iova(struct iova_domain *iovad,
 	if (atomic_cmpxchg(&iovad->fq_timer_on, 0, 1) == 0)
 		mod_timer(&iovad->fq_timer,
 			  jiffies + msecs_to_jiffies(IOVA_FQ_TIMEOUT));
-
-	put_cpu_ptr(iovad->fq);
 }
 EXPORT_SYMBOL_GPL(queue_iova);
 
-- 
2.14.1

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web