linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RT 7/6] include linux/interrupt.h in mm/bounce.c
       [not found] <20090807203939.GA19374@pengutronix.de>
@ 2009-08-09  9:36 ` Uwe Kleine-König
       [not found]   ` <1249810600-21946-2-git-send-email-u.kleine-koenig@pengutronix.de>
  0 siblings, 1 reply; 6+ messages in thread
From: Uwe Kleine-König @ 2009-08-09  9:36 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, rt-users, Jens Axboe, Ingo Molnar, Li Zefan, linux-mm,
	linux-arm-kernel

This fixes a a build failure for 2.6.31-rc4-rt1 (ARCH=arm,
mv78xx0_defconfig and others):

mm/bounce.c: In function 'bounce_copy_vec':
mm/bounce.c:52: error: implicit declaration of function 'local_irq_save_nort'
mm/bounce.c:56: error: implicit declaration of function 'local_irq_restore_nort'

Signed-off-by: Uwe Kleine-KA?nig <u.kleine-koenig@pengutronix.de>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-arm-kernel@lists.arm.linux.org.uk
---
 mm/bounce.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/mm/bounce.c b/mm/bounce.c
index 2fd099c..4a91eed 100644
--- a/mm/bounce.c
+++ b/mm/bounce.c
@@ -13,6 +13,7 @@
 #include <linux/init.h>
 #include <linux/hash.h>
 #include <linux/highmem.h>
+#include <linux/interrupt.h>
 #include <asm/tlbflush.h>
 
 #include <trace/events/block.h>
-- 
1.6.3.3

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

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

* [PATCH RT 9/6] [RFH] Build failure on 2.6.31-rc4-rt1 in mm/highmem.c
       [not found]   ` <1249810600-21946-2-git-send-email-u.kleine-koenig@pengutronix.de>
@ 2009-08-09  9:36     ` Uwe Kleine-König
  2009-08-13 21:34       ` [PATCH] [RFC, RT] fix kmap_high_get Uwe Kleine-König
  0 siblings, 1 reply; 6+ messages in thread
From: Uwe Kleine-König @ 2009-08-09  9:36 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, rt-users, Nicolas Pitre, MinChan Kim, Andrew Morton,
	Peter Zijlstra, Ingo Molnar, Li Zefan, Jens Axboe, linux-mm

The two commits

	b38cb5a (mm: remove kmap_lock)

and

	3297e76 (highmem: atomic highmem kmap page pinning)

conflict (without causing a text based conflict) because the latter
introduces a usage of kmap_lock.

The actual compiler output is (e.g. for ARCH=arm, stmp378x_defconfig):

	  CC      mm/highmem.o
	mm/highmem.c: In function 'pkmap_try_free':
	mm/highmem.c:116: warning: unused variable 'addr'
	mm/highmem.c: In function 'kmap_high_get':
	mm/highmem.c:372: error: 'kmap_lock' undeclared (first use in this function)
	mm/highmem.c:372: error: (Each undeclared identifier is reported only once
	mm/highmem.c:372: error: for each function it appears in.)
	mm/highmem.c:375: error: invalid operands to binary < (have 'atomic_t' and 'int')
	mm/highmem.c:376: error: wrong type argument to increment

The problems in lines 116 and 375f are resolved by the patch below, but
I don't know highmem enough to fix the remaining error.  Moreover I
don't have a machine that makes use of highmem.

Signed-off-by: Uwe Kleine-KA?nig <u.kleine-koenig@pengutronix.de>
Cc: Nicolas Pitre <nico@marvell.com>
Cc: MinChan Kim <minchan.kim@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
---
 mm/highmem.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/mm/highmem.c b/mm/highmem.c
index 66e915a..4aa9eea 100644
--- a/mm/highmem.c
+++ b/mm/highmem.c
@@ -113,10 +113,10 @@ static int pkmap_try_free(int pos)
 	 */
 	if (!pte_none(pkmap_page_table[pos])) {
 		struct page *page = pte_page(pkmap_page_table[pos]);
-		unsigned long addr = PKMAP_ADDR(pos);
 		pte_t *ptep = &pkmap_page_table[pos];
 
-		VM_BUG_ON(addr != (unsigned long)page_address(page));
+		VM_BUG_ON((unsigned long)PKMAP_ADDR(pos) !=
+				(unsigned long)page_address(page));
 
 		if (!__set_page_address(page, NULL, pos))
 			BUG();
@@ -372,8 +372,8 @@ void *kmap_high_get(struct page *page)
 	lock_kmap_any(flags);
 	vaddr = (unsigned long)page_address(page);
 	if (vaddr) {
-		BUG_ON(pkmap_count[PKMAP_NR(vaddr)] < 1);
-		pkmap_count[PKMAP_NR(vaddr)]++;
+		BUG_ON(atomic_read(&pkmap_count[PKMAP_NR(vaddr)]) < 1);
+		atomic_add(1, pkmap_count[PKMAP_NR(vaddr)]);
 	}
 	unlock_kmap_any(flags);
 	return (void*) vaddr;
-- 
1.6.3.3

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

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

* [PATCH] [RFC, RT] fix kmap_high_get
  2009-08-09  9:36     ` [PATCH RT 9/6] [RFH] Build failure on 2.6.31-rc4-rt1 in mm/highmem.c Uwe Kleine-König
@ 2009-08-13 21:34       ` Uwe Kleine-König
  2009-08-14 14:02         ` [PATCH -rt] Fix kmap_high_get() Peter Zijlstra
  0 siblings, 1 reply; 6+ messages in thread
From: Uwe Kleine-König @ 2009-08-13 21:34 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: rt-users, Nicolas Pitre, MinChan Kim, Andrew Morton,
	Peter Zijlstra, Ingo Molnar, Li Zefan, Jens Axboe, linux-mm,
	linux-kernel

This fixes the build failure with ARCH_NEEDS_KMAP_HIGH_GET.
This is only compile tested.

Signed-off-by: Uwe Kleine-KA?nig <u.kleine-koenig@pengutronix.de>
Cc: Nicolas Pitre <nico@marvell.com>
Cc: MinChan Kim <minchan.kim@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
---
Hello

this bases on the patch "[PATCH RT 9/6] [RFH] Build failure on
2.6.31-rc4-rt1 in mm/highmem.c" earlier in this thread.

I don't know if kmap_high_get() has to call kmap_account().  Anyone?

As I don't have any knowledge about highmem (or mm in general) I'll go into
hiding before tglx caughts me with his trout.

Best regards
Uwe

 mm/highmem.c |   79 ++++++++++++++++++++-------------------------------------
 1 files changed, 28 insertions(+), 51 deletions(-)

diff --git a/mm/highmem.c b/mm/highmem.c
index 4aa9eea..b5f5faf 100644
--- a/mm/highmem.c
+++ b/mm/highmem.c
@@ -75,26 +75,6 @@ pte_t * pkmap_page_table;
 
 static DECLARE_WAIT_QUEUE_HEAD(pkmap_wait);
 
-
-/*
- * Most architectures have no use for kmap_high_get(), so let's abstract
- * the disabling of IRQ out of the locking in that case to save on a
- * potential useless overhead.
- */
-#ifdef ARCH_NEEDS_KMAP_HIGH_GET
-#define lock_kmap()             spin_lock_irq(&kmap_lock)
-#define unlock_kmap()           spin_unlock_irq(&kmap_lock)
-#define lock_kmap_any(flags)    spin_lock_irqsave(&kmap_lock, flags)
-#define unlock_kmap_any(flags)  spin_unlock_irqrestore(&kmap_lock, flags)
-#else
-#define lock_kmap()             spin_lock(&kmap_lock)
-#define unlock_kmap()           spin_unlock(&kmap_lock)
-#define lock_kmap_any(flags)    \
-		do { spin_lock(&kmap_lock); (void)(flags); } while (0)
-#define unlock_kmap_any(flags)  \
-		do { spin_unlock(&kmap_lock); (void)(flags); } while (0)
-#endif
-
 /*
  * Try to free a given kmap slot.
  *
@@ -313,22 +293,32 @@ static void kunmap_account(void)
 	wake_up(&pkmap_wait);
 }
 
-void *kmap_high(struct page *page)
+/**
+ * kmap_high_get - pin a highmem page into memory
+ * @page: &struct page to pin
+ *
+ * Returns the page's current virtual memory address, or NULL if no mapping
+ * exists.  When and only when a non null address is returned then a
+ * matching call to kunmap_high() is necessary.
+ *
+ * This can be called from any context.
+ */
+void *kmap_high_get(struct page *page)
 {
 	unsigned long vaddr;
 
-
-	kmap_account();
 again:
 	vaddr = (unsigned long)page_address(page);
 	if (vaddr) {
 		atomic_t *counter = &pkmap_count[PKMAP_NR(vaddr)];
 		if (atomic_inc_not_zero(counter)) {
 			/*
-			 * atomic_inc_not_zero implies a (memory) barrier on success
-			 * so page address will be reloaded.
+			 * atomic_inc_not_zero implies a (memory) barrier on
+			 * success, so page address will be reloaded.
 			 */
-			unsigned long vaddr2 = (unsigned long)page_address(page);
+			unsigned long vaddr2 =
+				(unsigned long)page_address(page);
+
 			if (likely(vaddr == vaddr2))
 				return (void *)vaddr;
 
@@ -344,6 +334,18 @@ again:
 			goto again;
 		}
 	}
+	return NULL;
+}
+
+void *kmap_high(struct page *page)
+{
+	unsigned long vaddr;
+
+	kmap_account();
+again:
+	vaddr = (unsigned long)kmap_high_get(page);
+	if (vaddr)
+		return (void *)vaddr;
 
 	vaddr = pkmap_insert(page);
 	if (!vaddr)
@@ -354,31 +356,6 @@ again:
 
 EXPORT_SYMBOL(kmap_high);
 
-#ifdef ARCH_NEEDS_KMAP_HIGH_GET
-/**
- * kmap_high_get - pin a highmem page into memory
- * @page: &struct page to pin
- *
- * Returns the page's current virtual memory address, or NULL if no mapping
- * exists.  When and only when a non null address is returned then a
- * matching call to kunmap_high() is necessary.
- *
- * This can be called from any context.
- */
-void *kmap_high_get(struct page *page)
-{
-	unsigned long vaddr, flags;
-
-	lock_kmap_any(flags);
-	vaddr = (unsigned long)page_address(page);
-	if (vaddr) {
-		BUG_ON(atomic_read(&pkmap_count[PKMAP_NR(vaddr)]) < 1);
-		atomic_add(1, pkmap_count[PKMAP_NR(vaddr)]);
-	}
-	unlock_kmap_any(flags);
-	return (void*) vaddr;
-}
-#endif
 
  void kunmap_high(struct page *page)
 {
-- 
1.6.3.3

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

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

* [PATCH -rt] Fix kmap_high_get()
  2009-08-13 21:34       ` [PATCH] [RFC, RT] fix kmap_high_get Uwe Kleine-König
@ 2009-08-14 14:02         ` Peter Zijlstra
  2009-08-14 15:58           ` Nicolas Pitre
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Zijlstra @ 2009-08-14 14:02 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Thomas Gleixner, rt-users, Nicolas Pitre, MinChan Kim,
	Andrew Morton, Ingo Molnar, Li Zefan, Jens Axboe, linux-mm,
	linux-kernel

On Thu, 2009-08-13 at 23:34 +0200, Uwe Kleine-KA?nig wrote:
> This fixes the build failure with ARCH_NEEDS_KMAP_HIGH_GET.
> This is only compile tested.
> 
> Signed-off-by: Uwe Kleine-KA?nig <u.kleine-koenig@pengutronix.de>
> Cc: Nicolas Pitre <nico@marvell.com>
> Cc: MinChan Kim <minchan.kim@gmail.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Cc: Ingo Molnar <mingo@elte.hu>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Li Zefan <lizf@cn.fujitsu.com>
> Cc: Jens Axboe <jens.axboe@oracle.com>
> Cc: linux-mm@kvack.org
> Cc: linux-kernel@vger.kernel.org
> ---
> Hello
> 
> this bases on the patch "[PATCH RT 9/6] [RFH] Build failure on
> 2.6.31-rc4-rt1 in mm/highmem.c" earlier in this thread.
> 
> I don't know if kmap_high_get() has to call kmap_account().  Anyone?

I think it should, since it uses kunmap_high() to undo whatever
kmap_high_get() did. Now, if there'd been a kmap_high_put()... :-)

As to the patch, its not quite right.

>From what I understand kmap_high_get() is used to pin a page's kmap iff
it has one, whereas the result of your patch seems to be that it'll
actually create one if its not found.

Something like the below ought to do I guess.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 arch/arm/include/asm/highmem.h |    1 +
 arch/arm/mm/dma-mapping.c      |    2 +-
 mm/highmem.c                   |   50 ++++++++++++++++++---------------------
 3 files changed, 25 insertions(+), 28 deletions(-)

diff --git a/arch/arm/include/asm/highmem.h b/arch/arm/include/asm/highmem.h
index 7f36d00..4d9573b 100644
--- a/arch/arm/include/asm/highmem.h
+++ b/arch/arm/include/asm/highmem.h
@@ -19,6 +19,7 @@ extern pte_t *pkmap_page_table;
 
 extern void *kmap_high(struct page *page);
 extern void *kmap_high_get(struct page *page);
+extern void *kmap_high_put(struct page *page);
 extern void kunmap_high(struct page *page);
 
 extern void *kmap(struct page *page);
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 1576176..4a166d9 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -551,7 +551,7 @@ static void dma_cache_maint_contiguous(struct page *page, unsigned long offset,
 		if (vaddr) {
 			vaddr += offset;
 			inner_op(vaddr, vaddr + size);
-			kunmap_high(page);
+			kmap_high_put(page);
 		}
 	}
 
diff --git a/mm/highmem.c b/mm/highmem.c
index 66e915a..b2eaefe 100644
--- a/mm/highmem.c
+++ b/mm/highmem.c
@@ -75,26 +75,6 @@ pte_t * pkmap_page_table;
 
 static DECLARE_WAIT_QUEUE_HEAD(pkmap_wait);
 
-
-/*
- * Most architectures have no use for kmap_high_get(), so let's abstract
- * the disabling of IRQ out of the locking in that case to save on a
- * potential useless overhead.
- */
-#ifdef ARCH_NEEDS_KMAP_HIGH_GET
-#define lock_kmap()             spin_lock_irq(&kmap_lock)
-#define unlock_kmap()           spin_unlock_irq(&kmap_lock)
-#define lock_kmap_any(flags)    spin_lock_irqsave(&kmap_lock, flags)
-#define unlock_kmap_any(flags)  spin_unlock_irqrestore(&kmap_lock, flags)
-#else
-#define lock_kmap()             spin_lock(&kmap_lock)
-#define unlock_kmap()           spin_unlock(&kmap_lock)
-#define lock_kmap_any(flags)    \
-		do { spin_lock(&kmap_lock); (void)(flags); } while (0)
-#define unlock_kmap_any(flags)  \
-		do { spin_unlock(&kmap_lock); (void)(flags); } while (0)
-#endif
-
 /*
  * Try to free a given kmap slot.
  *
@@ -361,22 +341,38 @@ EXPORT_SYMBOL(kmap_high);
  *
  * Returns the page's current virtual memory address, or NULL if no mapping
  * exists.  When and only when a non null address is returned then a
- * matching call to kunmap_high() is necessary.
+ * matching call to kmap_high_put() is necessary.
  *
  * This can be called from any context.
  */
 void *kmap_high_get(struct page *page)
 {
-	unsigned long vaddr, flags;
+	unsigned long vaddr;
 
-	lock_kmap_any(flags);
+again:
 	vaddr = (unsigned long)page_address(page);
 	if (vaddr) {
-		BUG_ON(pkmap_count[PKMAP_NR(vaddr)] < 1);
-		pkmap_count[PKMAP_NR(vaddr)]++;
+		atomic_t *counter = &pkmap_count[PKMAP_NR(vaddr)];
+		if (atomic_inc_not_zero(counter)) {
+			unsigned long vaddr2 = (unsigned long)page_address(page);
+
+			if (likely(vaddr == vaddr2))
+				return (void *)vaddr;
+
+			pkmap_put(counter);
+			goto again;
+		}
 	}
-	unlock_kmap_any(flags);
-	return (void*) vaddr;
+
+	return NULL;
+}
+
+void kmap_high_put(struct page *page)
+{
+	unsigned long vaddr = (unsigned long)page_address(page);
+
+	BUG_ON(!vaddr);
+	pkmap_put(&pkmap_count[PKMAP_NR(vaddr)]);
 }
 #endif
 


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

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

* Re: [PATCH -rt] Fix kmap_high_get()
  2009-08-14 14:02         ` [PATCH -rt] Fix kmap_high_get() Peter Zijlstra
@ 2009-08-14 15:58           ` Nicolas Pitre
  2009-08-14 20:13             ` Uwe Kleine-König
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Pitre @ 2009-08-14 15:58 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Uwe Kleine-König, Thomas Gleixner, rt-users, MinChan Kim,
	Andrew Morton, Ingo Molnar, Li Zefan, Jens Axboe, linux-mm,
	linux-kernel

On Fri, 14 Aug 2009, Peter Zijlstra wrote:

> As to the patch, its not quite right.
> 
> From what I understand kmap_high_get() is used to pin a page's kmap iff
> it has one, whereas the result of your patch seems to be that it'll
> actually create one if its not found.

I don't have enough context to review this patch, but your understanding 
of the kmap_high_get() purpose is right.


Nicolas

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

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

* Re: [PATCH -rt] Fix kmap_high_get()
  2009-08-14 15:58           ` Nicolas Pitre
@ 2009-08-14 20:13             ` Uwe Kleine-König
  0 siblings, 0 replies; 6+ messages in thread
From: Uwe Kleine-König @ 2009-08-14 20:13 UTC (permalink / raw)
  To: Nicolas Pitre
  Cc: Peter Zijlstra, Thomas Gleixner, rt-users, MinChan Kim,
	Andrew Morton, Ingo Molnar, Li Zefan, Jens Axboe, linux-mm,
	linux-kernel

Hello,

On Fri, Aug 14, 2009 at 11:58:59AM -0400, Nicolas Pitre wrote:
> On Fri, 14 Aug 2009, Peter Zijlstra wrote:
> 
> > As to the patch, its not quite right.
... on irc Peter and me agreed it's not that wrong :-)  Anyhow, I merged
the two patches to get the benefits from both.  See below.

> > From what I understand kmap_high_get() is used to pin a page's kmap iff
> > it has one, whereas the result of your patch seems to be that it'll
> > actually create one if its not found.
> 
> I don't have enough context to review this patch, but your understanding 
> of the kmap_high_get() purpose is right.
The patch with all it's dependencies based on -rc6 is available on

	git://git.pengutronix.de/git/ukl/linux-2.6.git kmap-testing

Niko:  Your review would be very welcome because neither Peter nor me
have a machine with highmem.

Best regards
Uwe

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

end of thread, other threads:[~2009-08-14 20:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20090807203939.GA19374@pengutronix.de>
2009-08-09  9:36 ` [PATCH RT 7/6] include linux/interrupt.h in mm/bounce.c Uwe Kleine-König
     [not found]   ` <1249810600-21946-2-git-send-email-u.kleine-koenig@pengutronix.de>
2009-08-09  9:36     ` [PATCH RT 9/6] [RFH] Build failure on 2.6.31-rc4-rt1 in mm/highmem.c Uwe Kleine-König
2009-08-13 21:34       ` [PATCH] [RFC, RT] fix kmap_high_get Uwe Kleine-König
2009-08-14 14:02         ` [PATCH -rt] Fix kmap_high_get() Peter Zijlstra
2009-08-14 15:58           ` Nicolas Pitre
2009-08-14 20:13             ` Uwe Kleine-König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox