* [PATCH vmalloc] reduce purge_lock range and hold time of
@ 2016-10-15 14:12 zhouxianrong
2016-10-15 16:55 ` Christoph Hellwig
2016-10-18 2:25 ` [PATCH vmalloc] reduce purge_lock range and hold time of vmap_area_lock zhouxianrong
0 siblings, 2 replies; 4+ messages in thread
From: zhouxianrong @ 2016-10-15 14:12 UTC (permalink / raw)
To: linux-mm
Cc: linux-kernel, akpm, rientjes, hannes, chris, vdavydov.dev,
mgorman, joe, shawn.lin, iamjoonsoo.kim, kuleshovmail,
zhouxianrong, zhouxiyu, zhangshiming5, won.ho.park, tuxiaobing
From: z00281421 <z00281421@notesmail.huawei.com>
i think no need to place __free_vmap_area loop in purge_lock;
_free_vmap_area could be non-atomic operations with flushing tlb
but must be done after flush tlb. and the whole__free_vmap_area loops
also could be non-atomic operations. if so we could improve realtime
because the loop times sometimes is larg and spend a few time.
Signed-off-by: z00281421 <z00281421@notesmail.huawei.com>
---
mm/vmalloc.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 91f44e7..9d9154d 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -661,13 +661,23 @@ static void __purge_vmap_area_lazy(unsigned long *start, unsigned long *end,
if (nr || force_flush)
flush_tlb_kernel_range(*start, *end);
+ spin_unlock(&purge_lock);
+
if (nr) {
+ /* the batch count should not be too small
+ ** because if vmalloc space is few free is first than alloc.
+ */
+ unsigned char batch = -1;
spin_lock(&vmap_area_lock);
- llist_for_each_entry_safe(va, n_va, valist, purge_list)
+ llist_for_each_entry_safe(va, n_va, valist, purge_list) {
__free_vmap_area(va);
+ if (!batch--) {
+ spin_unlock(&vmap_area_lock);
+ spin_lock(&vmap_area_lock);
+ }
+ }
spin_unlock(&vmap_area_lock);
}
- spin_unlock(&purge_lock);
}
/*
--
1.7.9.5
--
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 related [flat|nested] 4+ messages in thread
* Re: [PATCH vmalloc] reduce purge_lock range and hold time of
2016-10-15 14:12 [PATCH vmalloc] reduce purge_lock range and hold time of zhouxianrong
@ 2016-10-15 16:55 ` Christoph Hellwig
2016-10-18 2:55 ` zhouxianrong
2016-10-18 2:25 ` [PATCH vmalloc] reduce purge_lock range and hold time of vmap_area_lock zhouxianrong
1 sibling, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2016-10-15 16:55 UTC (permalink / raw)
To: zhouxianrong
Cc: linux-mm, linux-kernel, akpm, rientjes, hannes, chris,
vdavydov.dev, mgorman, joe, shawn.lin, iamjoonsoo.kim,
kuleshovmail, zhouxiyu, zhangshiming5, won.ho.park, tuxiaobing
On Sat, Oct 15, 2016 at 10:12:48PM +0800, zhouxianrong@huawei.com wrote:
> From: z00281421 <z00281421@notesmail.huawei.com>
>
> i think no need to place __free_vmap_area loop in purge_lock;
> _free_vmap_area could be non-atomic operations with flushing tlb
> but must be done after flush tlb. and the whole__free_vmap_area loops
> also could be non-atomic operations. if so we could improve realtime
> because the loop times sometimes is larg and spend a few time.
Right, see the previous patch in reply to Joel that drops purge_lock
entirely.
Instead of your open coded batch counter you probably want to add
a cond_resched_lock after the call to __free_vmap_area.
--
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] 4+ messages in thread
* [PATCH vmalloc] reduce purge_lock range and hold time of vmap_area_lock
2016-10-15 14:12 [PATCH vmalloc] reduce purge_lock range and hold time of zhouxianrong
2016-10-15 16:55 ` Christoph Hellwig
@ 2016-10-18 2:25 ` zhouxianrong
1 sibling, 0 replies; 4+ messages in thread
From: zhouxianrong @ 2016-10-18 2:25 UTC (permalink / raw)
To: linux-mm
Cc: linux-kernel, akpm, rientjes, hannes, chris, vdavydov.dev,
mgorman, joe, shawn.lin, iamjoonsoo.kim, kuleshovmail,
zhouxianrong, zhouxiyu, zhangshiming5, won.ho.park, tuxiaobing
From: z00281421 <z00281421@notesmail.huawei.com>
Signed-off-by: z00281421 <z00281421@notesmail.huawei.com>
---
mm/vmalloc.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 91f44e7..e9c9c04 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -661,13 +661,18 @@ static void __purge_vmap_area_lazy(unsigned long *start, unsigned long *end,
if (nr || force_flush)
flush_tlb_kernel_range(*start, *end);
+ spin_unlock(&purge_lock);
+
if (nr) {
+ unsigned char batch = 0;
spin_lock(&vmap_area_lock);
- llist_for_each_entry_safe(va, n_va, valist, purge_list)
+ llist_for_each_entry_safe(va, n_va, valist, purge_list) {
__free_vmap_area(va);
+ if (!batch++)
+ cond_resched_lock(&vmap_area_lock);
+ }
spin_unlock(&vmap_area_lock);
}
- spin_unlock(&purge_lock);
}
/*
--
1.7.9.5
--
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 related [flat|nested] 4+ messages in thread
* Re: [PATCH vmalloc] reduce purge_lock range and hold time of
2016-10-15 16:55 ` Christoph Hellwig
@ 2016-10-18 2:55 ` zhouxianrong
0 siblings, 0 replies; 4+ messages in thread
From: zhouxianrong @ 2016-10-18 2:55 UTC (permalink / raw)
To: Christoph Hellwig
Cc: linux-mm, linux-kernel, akpm, rientjes, hannes, chris,
vdavydov.dev, mgorman, joe, shawn.lin, iamjoonsoo.kim,
kuleshovmail, zhouxiyu, zhangshiming5, won.ho.park, tuxiaobing
hey Hellwig:
cond_resched_lock is a good choice. i mixed the cond_resched_lock and batch to balance of
realtime and performance and resubmit this patch.
On 2016/10/16 0:55, Christoph Hellwig wrote:
> On Sat, Oct 15, 2016 at 10:12:48PM +0800, zhouxianrong@huawei.com wrote:
>> From: z00281421 <z00281421@notesmail.huawei.com>
>>
>> i think no need to place __free_vmap_area loop in purge_lock;
>> _free_vmap_area could be non-atomic operations with flushing tlb
>> but must be done after flush tlb. and the whole__free_vmap_area loops
>> also could be non-atomic operations. if so we could improve realtime
>> because the loop times sometimes is larg and spend a few time.
>
> Right, see the previous patch in reply to Joel that drops purge_lock
> entirely.
>
> Instead of your open coded batch counter you probably want to add
> a cond_resched_lock after the call to __free_vmap_area.
>
> .
>
--
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] 4+ messages in thread
end of thread, other threads:[~2016-10-18 2:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-15 14:12 [PATCH vmalloc] reduce purge_lock range and hold time of zhouxianrong
2016-10-15 16:55 ` Christoph Hellwig
2016-10-18 2:55 ` zhouxianrong
2016-10-18 2:25 ` [PATCH vmalloc] reduce purge_lock range and hold time of vmap_area_lock zhouxianrong
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).