atom feed294 messages in org.kernel.vger.linux-rt-users[PATCH -rt] Fix kmap_high_get()
FromSent OnAttachments
150 earlier messages
Fernando Lopez-LezcanoJul 10, 2009 5:16 pm 
Jaswinder Singh RajputJul 14, 2009 2:12 am 
Thomas GleixnerJul 29, 2009 5:47 pm 
Tim BlechmannJul 30, 2009 2:56 am.patch
Darren HartJul 30, 2009 4:03 pm 
Clark WilliamsJul 31, 2009 7:12 am 
Frederic WeisbeckerJul 31, 2009 4:21 pm 
Darren HartJul 31, 2009 5:41 pm 
Frederic WeisbeckerJul 31, 2009 6:19 pm 
Thomas MeyerAug 1, 2009 2:48 am 
john stultzAug 4, 2009 6:29 pm 
gowrishankarAug 4, 2009 11:05 pm 
Clark WilliamsAug 5, 2009 6:32 am 
Will SchmidtAug 5, 2009 12:19 pm 
gowrishankarAug 5, 2009 11:45 pm 
Clark WilliamsAug 6, 2009 7:36 am 
Sven-Thorsten DietrichAug 6, 2009 7:46 am 
John KacurAug 6, 2009 7:54 am 
gowrishankarAug 6, 2009 9:39 am 
Sripathi KodiAug 6, 2009 9:25 pm 
Darren HartAug 7, 2009 7:29 am 
Uwe Kleine-KönigAug 7, 2009 1:39 pm 
Uwe Kleine-KönigAug 7, 2009 1:42 pm 
Uwe Kleine-KönigAug 7, 2009 1:42 pm 
Uwe Kleine-KönigAug 7, 2009 1:42 pm 
Uwe Kleine-KönigAug 7, 2009 1:42 pm 
Uwe Kleine-KönigAug 7, 2009 1:42 pm 
Uwe Kleine-KönigAug 7, 2009 1:42 pm 
Uwe Kleine-KönigAug 7, 2009 1:53 pm 
Uwe Kleine-KönigAug 7, 2009 1:54 pm 
Mark BrownAug 8, 2009 12:57 am 
Uwe Kleine-KönigAug 9, 2009 2:36 am 
Uwe Kleine-KönigAug 9, 2009 2:36 am 
Uwe Kleine-KönigAug 9, 2009 2:36 am 
Russell King - ARM LinuxAug 9, 2009 2:42 am 
David MillerAug 9, 2009 9:48 pm 
Uwe Kleine-KönigAug 10, 2009 2:40 am 
David MillerAug 10, 2009 8:00 am 
Kevin HilmanAug 10, 2009 9:47 am 
Russell King - ARM LinuxAug 10, 2009 10:26 am 
Kevin HilmanAug 10, 2009 2:03 pm 
Russell King - ARM LinuxAug 10, 2009 3:02 pm 
Jan EngelhardtAug 11, 2009 3:51 am 
Thomas GleixnerAug 11, 2009 11:08 am 
Will SchmidtAug 12, 2009 1:45 pm 
Thomas GleixnerAug 13, 2009 12:29 am 
Will SchmidtAug 13, 2009 8:04 am 
Kevin HilmanAug 13, 2009 8:05 am 
Uwe Kleine-KönigAug 13, 2009 2:33 pm 
Peter ZijlstraAug 14, 2009 7:02 am 
Nicolas PitreAug 14, 2009 8:58 am 
Uwe Kleine-KönigAug 14, 2009 1:12 pm 
Wim Van SebroeckAug 16, 2009 7:08 am 
Thomas GleixnerAug 16, 2009 1:41 pm 
Dale StimsonAug 17, 2009 9:07 am 
Thomas GleixnerAug 18, 2009 1:03 pm 
Will SchmidtAug 18, 2009 2:04 pm 
Thomas GleixnerAug 18, 2009 2:13 pm 
john stultzAug 18, 2009 3:30 pm 
john stultzAug 18, 2009 3:49 pm 
Will SchmidtAug 18, 2009 4:12 pm 
john stultzAug 18, 2009 5:17 pm.rt
Will SchmidtAug 19, 2009 10:11 am 
Thomas GleixnerAug 19, 2009 2:48 pm 
john stultzAug 19, 2009 7:18 pm 
Dinakar GuniguntalaAug 20, 2009 8:28 am 
Thomas GleixnerAug 21, 2009 2:26 pm 
Mark KnechtAug 21, 2009 3:57 pm 
Thomas GleixnerAug 26, 2009 10:23 am 
Kevin HilmanAug 27, 2009 4:02 am 
Thomas GleixnerAug 28, 2009 2:35 pm 
Wu ZhangjinSep 2, 2009 8:25 am 
Jan EngelhardtSep 12, 2009 2:44 am 
Thomas GleixnerSep 15, 2009 2:11 pm 
Thomas GleixnerSep 15, 2009 3:29 pm 
Thomas GleixnerSep 18, 2009 3:38 pm 
Jaswinder Singh RajputSep 18, 2009 9:34 pm 
Steven RostedtSep 19, 2009 6:37 am 
Jaswinder Singh RajputSep 19, 2009 8:01 am 
Jon MastersSep 20, 2009 4:22 pm 
Mark KnechtSep 20, 2009 4:34 pm 
Darren HartSep 22, 2009 11:31 am 
Clark WilliamsSep 22, 2009 12:00 pm 
Jan BlunckSep 23, 2009 8:39 am 
Darren HartSep 23, 2009 9:18 am 
Thomas GleixnerSep 23, 2009 9:24 am 
Will SchmidtSep 23, 2009 2:33 pm 
Jan BlunckSep 24, 2009 8:16 am 
Thomas GleixnerOct 6, 2009 3:15 am 
Remy BohmerOct 6, 2009 11:23 am 
Thomas GleixnerOct 6, 2009 12:22 pm 
Thomas GleixnerOct 6, 2009 1:07 pm 
Remy BohmerOct 7, 2009 12:13 am 
Remy BohmerOct 13, 2009 8:46 am 
Thomas GleixnerOct 13, 2009 10:10 am 
Thomas GleixnerOct 14, 2009 3:01 am 
Fernando Lopez-LezcanoNov 3, 2009 6:12 pm 
Uwe Kleine-KönigNov 4, 2009 12:37 am 
Fernando Lopez-LezcanoNov 5, 2009 11:33 am 
Thomas GleixnerNov 5, 2009 11:40 am 
44 later messages
Subject:[PATCH -rt] Fix kmap_high_get()
From:Peter Zijlstra (a.p.@chello.nl)
Date:Aug 14, 2009 7:02:30 am
List:org.kernel.vger.linux-rt-users

On Thu, 2009-08-13 at 23:34 +0200, Uwe Kleine-König wrote:

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

Signed-off-by: Uwe Kleine-König <u.kl@pengutronix.de> Cc: Nicolas Pitre <ni@marvell.com> Cc: MinChan Kim <minc@gmail.com> Cc: Andrew Morton <ak@linux-foundation.org> Cc: Peter Zijlstra <a.p.@chello.nl> Cc: Ingo Molnar <min@elte.hu> Cc: Thomas Gleixner <tg@linutronix.de> Cc: Li Zefan <li@cn.fujitsu.com> Cc: Jens Axboe <jens@oracle.com> Cc: linu@kvack.org Cc: linu@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.@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