minor clean-up and optimize highmem related code
Subsystems (2)
cover minor clean-up and optimize highmem related code
This patchset clean-up and optimize highmem related code.
[1] is just clean-up and doesn't introduce any functional change. [2-3] are for clean-up and optimization.
These eliminate an useless lock opearation and list management. [4-5] is for optimization related to flush_all_zero_pkmaps().
Joonsoo Kim (5):
mm, highmem: use PKMAP_NR() to calculate an index of pkmap mm, highmem: remove useless pool_lock
mm, highmem: remove page_address_pool list
mm, highmem: makes flush_all_zero_pkmaps() return index of last
flushed entry
mm, highmem: get virtual address of the page using PKMAP_ADDR()
include/linux/highmem.h | 1 + mm/highmem.c | 102 ++++++++++++++++++++--------------------------- 2 files changed, 45 insertions(+), 58 deletions(-)
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/5 mm, highmem: use PKMAP_NR() to calculate an index of pkmap
To calculate an index of pkmap, using PKMAP_NR() is more understandable and maintainable, So change it.
mm/highmem.c +1 -1
@@ -99,7 +99,7 @@ struct page *kmap_to_page(void *vaddr)unsigned long addr = (unsigned long )vaddr;if (addr >=PKMAP_ADDR (0 ) && addr <=PKMAP_ADDR (LAST_PKMAP )) { -int i = (addr -PKMAP_ADDR (0 )) >>PAGE_SHIFT ; +int i =PKMAP_NR (addr);return pte_page (pkmap_page_table[i]); }
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 2/5 mm, highmem: remove useless pool_lock
In reply to Joonsoo KimThe pool_lock protects the page_address_pool from concurrent access. But, access to the page_address_pool is already protected by kmap_lock. So remove it.
mm/highmem.c +0 -6
@@ -328,7 +328,6 @@ struct page_address_map {* page_address_map freelist, allocated from page_address_maps. */ static struct list_head page_address_pool;/* freelist */ -static spinlock_t pool_lock;/* protects page_address_pool */ /* * Hash table bucket
@@ -395,11 +394,9 @@ void set_page_address(struct page *page, void *virtual)if (virtual) {/* Add */ BUG_ON (list_empty (&page_address_pool)); -spin_lock_irqsave (&pool_lock, flags); pam =list_entry (page_address_pool.next, struct page_address_map, list);list_del (&pam->list); -spin_unlock_irqrestore (&pool_lock, flags); pam->page = page; pam->virtual = virtual;
@@ -413,9 +410,7 @@ void set_page_address(struct page *page, void *virtual)if (pam->page == page) {list_del (&pam->list);spin_unlock_irqrestore (&pas->lock, flags); -spin_lock_irqsave (&pool_lock, flags);list_add_tail (&pam->list, &page_address_pool); -spin_unlock_irqrestore (&pool_lock, flags); goto done; } }
@@ -438,7 +433,6 @@ void __init page_address_init(void)INIT_LIST_HEAD (&page_address_htable[i].lh); spin_lock_init(&page_address_htable[i].lock); } -spin_lock_init (&pool_lock); }#endif /* defined(CONFIG_HIGHMEM) && !defined(WANT_PAGE_VIRTUAL) */
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 3/5 mm, highmem: remove page_address_pool list
In reply to Joonsoo KimWe can find free page_address_map instance without the page_address_pool. So remove it.
mm/highmem.c +2 -17
@@ -323,11 +323,7 @@ struct page_address_map {void *virtual;struct list_head list; }; - -/* -* page_address_map freelist, allocated from page_address_maps. -*/ -static struct list_head page_address_pool;/* freelist */ +static struct page_address_map page_address_maps[LAST_PKMAP ];/* * Hash table bucket
@@ -392,12 +388,7 @@ void set_page_address(struct page *page, void *virtual) pas =page_slot (page);if (virtual) {/* Add */ -BUG_ON (list_empty (&page_address_pool)); - - pam =list_entry (page_address_pool.next, - struct page_address_map, list); -list_del (&pam->list); - + pam = &page_address_maps[PKMAP_NR ((unsigned long )virtual)]; pam->page = page; pam->virtual = virtual;
@@ -410,7 +401,6 @@ void set_page_address(struct page *page, void *virtual)if (pam->page == page) {list_del (&pam->list);spin_unlock_irqrestore (&pas->lock, flags); -list_add_tail (&pam->list, &page_address_pool); goto done; } }
@@ -420,15 +410,10 @@ done:return ; } -static struct page_address_map page_address_maps[LAST_PKMAP ]; -void __init page_address_init (void ) {int i; -INIT_LIST_HEAD (&page_address_pool); -for (i =0 ; i <ARRAY_SIZE (page_address_maps); i++) -list_add (&page_address_maps[i].list, &page_address_pool);for (i =0 ; i <ARRAY_SIZE (page_address_htable); i++) {INIT_LIST_HEAD (&page_address_htable[i].lh);spin_lock_init (&page_address_htable[i].lock);
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 4/5 mm, highmem: makes flush_all_zero_pkmaps() return index of last flushed entry
In reply to Joonsoo KimIn current code, after flush_all_zero_pkmaps() is invoked,
then re-iterate all pkmaps. It can be optimized if flush_all_zero_pkmaps() return index of flushed entry. With this index,
we can immediately map highmem page to virtual address represented by index. So change return type of flush_all_zero_pkmaps()
and return index of last flushed entry.
include/linux/highmem.h +1 -0
@@ -32,6 +32,7 @@ static inline void invalidate_kernel_vmap_range(void *vaddr, int size)#ifdef CONFIG_HIGHMEM #include <asm/highmem.h> +#define PKMAP_INDEX_INVAL (-1)/* declarations for linux/mm/highmem.c */ unsigned int nr_free_highpages (void );
mm/highmem.c +40 -32
106 lines not on this page · raw message
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 5/5 mm, highmem: get virtual address of the page using PKMAP_ADDR()
In reply to Joonsoo KimIn flush_all_zero_pkmaps(), we have an index of the pkmap associated the page. Using this index, we can simply get virtual address of the page. So change it.
mm/highmem.c +1 -2
@@ -137,8 +137,7 @@ static int flush_all_zero_pkmaps(void)* So no dangers, even with speculative execution. */ page =pte_page (pkmap_page_table[i]); -pte_clear (&init_mm, (unsigned long )page_address (page), - &pkmap_page_table[i]); +pte_clear (&init_mm,PKMAP_ADDR (i), &pkmap_page_table[i]);set_page_address (page,NULL ); index = i;
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 1/5] mm, highmem: use PKMAP_NR() to calculate an index of pkmap
In reply to Joonsoo KimQuoted 5 lines · Joonsoo Kim
To calculate an index of pkmap, using
PKMAP_NR()is more understandable and maintainable, So change it.Cc Mel Gorman <[email protected]>Signed-off-by Joonsoo Kim <[email protected]>
Signature · 8 lines
Kind regards, Minchan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 2/5] mm, highmem: remove useless pool_lock
In reply to Joonsoo KimQuoted 5 lines · Joonsoo Kim
The
pool_lockprotects thepage_address_poolfrom concurrent access. But, access to thepage_address_poolis already protected bykmap_lock. So remove it.Signed-off-by Joonsoo Kim <[email protected]>
Looks good to me.
Just a nitpick.
Please write comment about locking rule like below.
mm/highmem.c struct page_address_map { · line 329
Quoted 8 lines
mm/highmem.c +0
-0@@ -328,7 +328,6 @@ struct page_address_map {* page_address_map freelist, allocated from page_address_maps. */
/* page_address_pool is protected by kmap_lock */
Quoted 3 lines
mm/highmem.c +0
-1static struct list_head page_address_pool;/* freelist */ -static spinlock_t pool_lock;/* protects page_address_pool */
Signature · 8 lines
Kind regards, Minchan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 3/5] mm, highmem: remove page_address_pool list
In reply to Joonsoo KimQuoted 4 lines · Joonsoo Kim
We can find free
page_address_mapinstance without thepage_address_pool. So remove it.Signed-off-by Joonsoo Kim <[email protected]>
See below a nitpick. :)
mm/highmem.c struct page_address_map { · line 326
Quoted 10 lines
mm/highmem.c +0
-1@@ -323,11 +323,7 @@ struct page_address_map {void *virtual;struct list_head list; }; -
Let's leave a blank line.
Signature · 8 lines
Kind regards, Minchan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 4/5] mm, highmem: makes flush_all_zero_pkmaps() return index of last flushed entry
In reply to Joonsoo KimQuoted 14 lines · Joonsoo Kim
In current code, after
flush_all_zero_pkmaps()is invoked,
then re-iterate all pkmaps. It can be optimized ifflush_all_zero_pkmaps()return index of flushed entry. With this index,
we can immediately map highmem page to virtual address represented by index. So change return type offlush_all_zero_pkmaps()
and return index of last flushed entry.Signed-off-by Joonsoo Kim <[email protected]>include/linux/highmem.h +0
-0
include/linux/highmem.h static inline void invalidate_kernel_vmap_range(void *vaddr, int size) · line 35
Quoted 4 lines
include/linux/highmem.h +1
-0@@ -32,6 +32,7 @@ static inline void invalidate_kernel_vmap_range(void *vaddr, int size)#ifdef CONFIG_HIGHMEM #include <asm/highmem.h> +#define PKMAP_INDEX_INVAL (-1)
How about this?
#define PKMAP_INVALID_INDEX (-1)
Quoted 21 lines
include/linux/highmem.h +0
-0/* declarations for linux/mm/highmem.c */ unsigned int nr_free_highpages (void );mm/highmem.c +2
-2@@ -106,10 +106,10 @@ struct page *kmap_to_page(void *vaddr)return virt_to_page (addr); } -static void flush_all_zero_pkmaps (void ) +static int flush_all_zero_pkmaps (void ) {int i; -int need_flush =0 ; +int index =PKMAP_INDEX_INVAL ;flush_cache_kmaps ();
mm/highmem.c static void flush_all_zero_pkmaps(void) · line 144
Quoted 5 lines
mm/highmem.c +1
-1@@ -141,10 +141,12 @@ static void flush_all_zero_pkmaps(void) &pkmap_page_table[i]);set_page_address (page,NULL ); - need_flush =1 ; + index = i;
How about returning first free index instead of last one? and update last_pkmap_nr to it.
Quoted 99 lines
mm/highmem.c +37
-29} -if (need_flush) +if (index !=PKMAP_INDEX_INVAL )flush_tlb_kernel_range (PKMAP_ADDR (0 ),PKMAP_ADDR (LAST_PKMAP )); + +return index; }/** @@ -160,6 +162,7 @@ void kmap_flush_unused(void)static inline unsigned long map_new_virtual (struct page *page) {unsigned long vaddr; +int index =PKMAP_INDEX_INVAL ;int count; start:@@ -168,40 +171,45 @@ start:for (;;) { last_pkmap_nr = (last_pkmap_nr +1 ) &LAST_PKMAP_MASK ;if (!last_pkmap_nr) { -flush_all_zero_pkmaps (); - count =LAST_PKMAP ; + index =flush_all_zero_pkmaps (); +if (index !=PKMAP_INDEX_INVAL ) +break ;/* Found a usable entry */ } -if (!pkmap_count[last_pkmap_nr]) +if (!pkmap_count[last_pkmap_nr]) { + index = last_pkmap_nr;break ;/* Found a usable entry */ -if (--count) -continue ; - -/* -* Sleep for somebody else to unmap their entries -*/ - { -DECLARE_WAITQUEUE (wait, current); - -__set_current_state (TASK_UNINTERRUPTIBLE ); -add_wait_queue (&pkmap_map_wait, &wait); -unlock_kmap (); -schedule (); -remove_wait_queue (&pkmap_map_wait, &wait); -lock_kmap (); - -/* Somebody else might have mapped it while we slept */ -if (page_address (page)) -return (unsigned long )page_address (page); - -/* Re-start */ - goto start; } +if (--count ==0 ) +break ; } - vaddr =PKMAP_ADDR (last_pkmap_nr); + +/* +* Sleep for somebody else to unmap their entries +*/ +if (index ==PKMAP_INDEX_INVAL ) { +DECLARE_WAITQUEUE (wait, current); + +__set_current_state (TASK_UNINTERRUPTIBLE ); +add_wait_queue (&pkmap_map_wait, &wait); +unlock_kmap (); +schedule (); +remove_wait_queue (&pkmap_map_wait, &wait); +lock_kmap (); + +/* Somebody else might have mapped it while we slept */ + vaddr = (unsigned long )page_address (page); +if (vaddr) +return vaddr; + +/* Re-start */ + goto start; + } + + vaddr =PKMAP_ADDR (index);set_pte_at (&init_mm, vaddr, - &(pkmap_page_table[last_pkmap_nr]),mk_pte (page, kmap_prot)); + &(pkmap_page_table[index]),mk_pte (page, kmap_prot)); - pkmap_count[last_pkmap_nr] =1 ; + pkmap_count[index] =1 ;set_page_address (page, (void *)vaddr);return vaddr;Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Signature · 8 lines
Kind regards, Minchan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 5/5] mm, highmem: get virtual address of the page using PKMAP_ADDR()
In reply to Joonsoo KimQuoted 5 lines · Joonsoo Kim
In
flush_all_zero_pkmaps(), we have an index of the pkmap associated the page. Using this index, we can simply get virtual address of the page. So change it.Signed-off-by Joonsoo Kim <[email protected]>
Signature · 8 lines
Kind regards, Minchan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Hi Joonsoo,
Quoted 7 lines · Joonsoo Kim
This patchset clean-up and optimize highmem related code.
[1] is just clean-up and doesn't introduce any functional change. [2-3] are for clean-up and optimization.
These eliminate an useless lock opearation and list management. [4-5] is for optimization related toflush_all_zero_pkmaps().
Quoted 7 lines
Joonsoo Kim (5):
mm, highmem: usePKMAP_NR()to calculate an index of pkmap mm, highmem: remove uselesspool_lock
mm, highmem: removepage_address_poollist
mm, highmem: makesflush_all_zero_pkmaps()return index of last
flushed entry
mm, highmem: get virtual address of the page usingPKMAP_ADDR()
This patchset looks awesome to me.
If you have a plan to respin, please CCed Peter.
Signature · 8 lines
Kind regards, Minchan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 4/5] mm, highmem: makes flush_all_zero_pkmaps() return index of last flushed entry
In reply to Minchan Kim2012/10/29 Minchan Kim <[email protected]>:
Quoted 16 lines · Joonsoo Kim
Quoted 15 lines
In current code, after
flush_all_zero_pkmaps()is invoked,
then re-iterate all pkmaps. It can be optimized ifflush_all_zero_pkmaps()return index of flushed entry. With this index,
we can immediately map highmem page to virtual address represented by index. So change return type offlush_all_zero_pkmaps()
and return index of last flushed entry.Signed-off-by Joonsoo Kim <[email protected]>include/linux/highmem.h +0
-0@@ -32,6 +32,7 @@ static inline void invalidate_kernel_vmap_range(void *vaddr, int size)
Quoted 7 lines
include/linux/highmem.h static inline void invalidate_kernel_vmap_range(void *vaddr, int size) · line 35
Quoted 3 lines
include/linux/highmem.h +1
-0#ifdef CONFIG_HIGHMEM #include <asm/highmem.h> +#define PKMAP_INDEX_INVAL (-1)How about this?
#define
PKMAP_INVALID_INDEX(-1)
Okay.
Quoted 23 lines
Quoted 23 lines
include/linux/highmem.h +0
-0/* declarations for linux/mm/highmem.c */ unsigned int nr_free_highpages (void );mm/highmem.c +2
-2@@ -106,10 +106,10 @@ struct page *kmap_to_page(void *vaddr)return virt_to_page (addr); } -static void flush_all_zero_pkmaps (void ) +static int flush_all_zero_pkmaps (void ) {int i; -int need_flush =0 ; +int index =PKMAP_INDEX_INVAL ;flush_cache_kmaps ();@@ -141,10 +141,12 @@ static void flush_all_zero_pkmaps(void) &pkmap_page_table[i]);
Quoted 6 lines
mm/highmem.c static void flush_all_zero_pkmaps(void) · line 144
Quoted 3 lines
mm/highmem.c +1
-1set_page_address (page,NULL ); - need_flush =1 ; + index = i;How about returning first free index instead of last one? and update
last_pkmap_nrto it.
Okay. It will be more good.
Thanks.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Hi, Minchan.
2012/10/29 Minchan Kim <[email protected]>:
Quoted 18 lines
Hi Joonsoo,
Quoted 7 lines · Joonsoo Kim
This patchset clean-up and optimize highmem related code.
[1] is just clean-up and doesn't introduce any functional change. [2-3] are for clean-up and optimization.
These eliminate an useless lock opearation and list management. [4-5] is for optimization related toflush_all_zero_pkmaps().Quoted 7 lines
Joonsoo Kim (5):
mm, highmem: usePKMAP_NR()to calculate an index of pkmap mm, highmem: remove uselesspool_lock
mm, highmem: removepage_address_poollist
mm, highmem: makesflush_all_zero_pkmaps()return index of last
flushed entry
mm, highmem: get virtual address of the page usingPKMAP_ADDR()
Quoted 2 lines
This patchset looks awesome to me.
If you have a plan to respin, please CCed Peter.
Thanks for review.
I will wait more review and respin, the day after tomorrow. Version 2 will include fix about your comment.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerRe: [PATCH 2/5] mm, highmem: remove useless pool_lock
In reply to Joonsoo KimQuoted 3 lines · On Mon, 29 Oct 2012 04:12:53 +0900 Joonsoo Kim <[email protected]> wrote:
The
pool_lockprotects thepage_address_poolfrom concurrent access. But, access to thepage_address_poolis already protected bykmap_lock. So remove it.
Well, there's a set_page_address() call in mm/page_alloc.c which doesn't have lock_kmap(). it doesn't *need* lock_kmap() because it's init-time code and we're running single-threaded there. I hope!
But this exception should be double-checked and mentioned in the changelog, please. And it's a reason why we can't add assert_spin_locked(&kmap_lock) to set_page_address(), which is unfortunate.
The irq-disabling in this code is odd. If ARCH_NEEDS_KMAP_HIGH_GET=n, we didn't need irq-safe locking in set_page_address(). I guess we'll need to retain it in page_address() - I expect some callers have IRQs disabled.
ARCH_NEEDS_KMAP_HIGH_GET is a nasty looking thing. It's ARM:
/*
* The reason for kmap_high_get() is to ensure that the currently kmap'd
* page usage count does not decrease to zero while we're using its
* existing virtual mapping in an atomic context. With a VIVT cache this
* is essential to do, but with a VIPT cache this is only an optimization
* so not to pay the price of establishing a second mapping if an existing
* one can be used. However, on platforms without hardware TLB maintenance
* broadcast, we simply cannot use ARCH_NEEDS_KMAP_HIGH_GET at all since
* the locking involved must also disable IRQs which is incompatible with
* the IPI mechanism used by global TLB operations.
*/
#define ARCH_NEEDS_KMAP_HIGH_GET
#if defined(CONFIG_SMP) && defined(CONFIG_CPU_TLB_V6)
#undef ARCH_NEEDS_KMAP_HIGH_GET
#if defined(CONFIG_HIGHMEM) && defined(CONFIG_CPU_CACHE_VIVT) #error "The sum of features in your kernel config cannot be supported together" #endif
#endif
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 2/5] mm, highmem: remove useless pool_lock
Hi Andrew,
Quoted 7 lines · Andrew Morton
Quoted 3 lines · On Mon, 29 Oct 2012 04:12:53 +0900 Joonsoo Kim <[email protected]> wrote:
The
pool_lockprotects thepage_address_poolfrom concurrent access. But, access to thepage_address_poolis already protected bykmap_lock. So remove it.
Quoted 9 lines
Well, there's a
set_page_address()call inmm/page_alloc.cwhich doesn't havelock_kmap(). it doesn't *need*lock_kmap()because it's init-time code and we're running single-threaded there. I hope!But this exception should be double-checked and mentioned in the changelog, please. And it's a reason why we can't add
assert_spin_locked(&kmap_lock)toset_page_address(), which is unfortunate.
The exception is vaild only in m68k and sparc and they will use not set_page_address of highmem.c but page->virtual. So I think we can add such lock check in set_page_address in highmem.c.
But I'm not sure we really need it because set_page_address is used in few places so isn't it enough adding a just wording to avoid unnecessary overhead?
/* NOTE : Caller should hold kmap_lock by lock_kmap() */
Quoted 3 lines
The irq-disabling in this code is odd. If ARCH_NEEDS_KMAP_HIGH_GET=n, we didn't need irq-safe locking in
set_page_address(). I guess we'll
What lock you mean in set_page_address?
We have two locks in there, pool_lock and pas->lock. By this patchset, we don't need pool_lock any more. Remained thing is pas->lock.
If we make the lock irq-unsafe, it would be deadlock with page_addresss if it is called in irq context. Currenntly, page_address is used lots of places and not sure it's called only process context. Was there any rule that we have to use page_addresss in only process context?
Quoted 30 lines
need to retain it in
page_address()- I expect some callers have IRQs disabled.
ARCH_NEEDS_KMAP_HIGH_GETis a nasty looking thing. It's ARM:/*
* The reason forkmap_high_get()is to ensure that the currently kmap'd
* page usage count does not decrease to zero while we're using its
* existing virtual mapping in an atomic context. With a VIVT cache this
* is essential to do, but with a VIPT cache this is only an optimization
* so not to pay the price of establishing a second mapping if an existing
* one can be used. However, on platforms without hardware TLB maintenance
* broadcast, we simply cannot useARCH_NEEDS_KMAP_HIGH_GETat all since
* the locking involved must also disable IRQs which is incompatible with
* the IPI mechanism used by global TLB operations.
*/
#defineARCH_NEEDS_KMAP_HIGH_GET
#ifdefined(CONFIG_SMP)&&defined(CONFIG_CPU_TLB_V6)
#undefARCH_NEEDS_KMAP_HIGH_GET
#ifdefined(CONFIG_HIGHMEM)&&defined(CONFIG_CPU_CACHE_VIVT)#error "The sum of features in your kernel config cannot be supported together" #endif
#endif--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Signature · 8 lines
Kind regards, Minchan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 2/5] mm, highmem: remove useless pool_lock
In reply to Andrew MortonHello, Andrew.
2012/10/31 Andrew Morton <[email protected]>:
Quoted 7 lines
Quoted 3 lines · On Mon, 29 Oct 2012 04:12:53 +0900 Joonsoo Kim <[email protected]> wrote:
The
pool_lockprotects thepage_address_poolfrom concurrent access. But, access to thepage_address_poolis already protected bykmap_lock. So remove it.
Quoted 8 lines
Well, there's a
set_page_address()call inmm/page_alloc.cwhich doesn't havelock_kmap(). it doesn't *need*lock_kmap()because it's init-time code and we're running single-threaded there. I hope!But this exception should be double-checked and mentioned in the changelog, please. And it's a reason why we can't add
assert_spin_locked(&kmap_lock)toset_page_address(), which is unfortunate.
set_page_address() in mm/page_alloc.c is invoked only when WANT_PAGE_VIRTUAL is defined.
And in this case, set_page_address()'s definition is not in highmem.c, but in include/linux/mm.h.
So, we don't need to worry about set_page_address() call in mm/page_alloc.c
Quoted 4 lines
The irq-disabling in this code is odd. If ARCH_NEEDS_KMAP_HIGH_GET=n, we didn't need irq-safe locking in
set_page_address(). I guess we'll need to retain it inpage_address()- I expect some callers have IRQs disabled.
As Minchan described, if we don't disable irq when we take a lock for pas->lock, it would be deadlock with page_address().
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Hello, Andrew.
2012/10/29 JoonSoo Kim <[email protected]>:
Quoted 21 lines
Hi, Minchan.
2012/10/29 Minchan Kim <[email protected]>:
Quoted 18 lines
Hi Joonsoo,
Quoted 14 lines · Joonsoo Kim
This patchset clean-up and optimize highmem related code.
[1] is just clean-up and doesn't introduce any functional change. [2-3] are for clean-up and optimization.
These eliminate an useless lock opearation and list management. [4-5] is for optimization related toflush_all_zero_pkmaps().Joonsoo Kim (5):
mm, highmem: usePKMAP_NR()to calculate an index of pkmap mm, highmem: remove uselesspool_lock
mm, highmem: removepage_address_poollist
mm, highmem: makesflush_all_zero_pkmaps()return index of last
flushed entry
mm, highmem: get virtual address of the page usingPKMAP_ADDR()
Quoted 6 lines
Quoted 2 lines
This patchset looks awesome to me.
If you have a plan to respin, please CCed Peter.Thanks for review.
I will wait more review and respin, the day after tomorrow. Version 2 will include fix about your comment.
Could you pick up second version of this patchset?
[3] is changed to leave one blank line.
[4] is changed in order to further optimize according to Minchan's comment. It return first index of flushed entry, instead of last index. Others doesn't changed.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>