* [RFC] munmap(64k) is much slower with patch set reduce synchronous TLB invalidation on ARM64 merged
@ 2019-05-04 11:44 Hanjun Guo
2019-05-06 18:47 ` Will Deacon
0 siblings, 1 reply; 3+ messages in thread
From: Hanjun Guo @ 2019-05-04 11:44 UTC (permalink / raw)
To: Will Deacon
Cc: wangxiongfeng (C), Catalin Marinas, Linuxarm,
linux-arm-kernel@lists.infradead.org, Zhouguanghui (OS Kernel)
Hi Will,
With patch set "Avoid synchronous TLB invalidation for intermediate
page-table entries on arm64" was merged, munmap() for hugepage such as
2M will be much faster, but with following case, munmap(64k) will take
much longer time than before:
#define MEM_LEN_TEST (0x10000UL)
#define MEM_ADD_START (0x8000fffef000UL)
#define MEM1_ADD_START (0x800000090000UL)
mem = (unsigned char *)mmap((void *)MEM_ADD_START, MEM_LEN_TEST, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
mem1 = (unsigned char *)mmap((void *)MEM1_ADD_START, MEM_LEN_TEST, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
munmap(mem, MEM_LEN_TEST); // will take much longer time (from 50us to 230us on A55) than before
munmap(mem1, MEM_LEN_TEST);
munmap(mem, MEM_LEN_TEST) will finally call unmap_region() in the kernel,
and in free_pgtables() will adjust the start and end in mmu_gather, so when
running to __flush_tlb_range(), the (end - start) will more that 1G but less
than 2G in this case, on the other hand, (MAX_TLBI_OPS * stride) will be 2G
as the stride is 2M.
So in the end if ((end - start) > (MAX_TLBI_OPS * stride)) will not valid,
and will take loops to invalidate the TLB for many times which is time consuming.
Can we make the (MAX_TLBI_OPS * stride) as constant such as 4M (which is the
value before "Avoid synchronous TLB invalidation for intermediate page-table
entries on arm64" merged)? or a smaller value for MAX_TLBI_OPS?
Looking forward your insight on this.
Best regards
Hanjun
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] munmap(64k) is much slower with patch set reduce synchronous TLB invalidation on ARM64 merged
2019-05-04 11:44 [RFC] munmap(64k) is much slower with patch set reduce synchronous TLB invalidation on ARM64 merged Hanjun Guo
@ 2019-05-06 18:47 ` Will Deacon
2019-05-07 3:15 ` Hanjun Guo
0 siblings, 1 reply; 3+ messages in thread
From: Will Deacon @ 2019-05-06 18:47 UTC (permalink / raw)
To: Hanjun Guo
Cc: wangxiongfeng (C), Catalin Marinas, Linuxarm,
linux-arm-kernel@lists.infradead.org, Zhouguanghui (OS Kernel)
On Sat, May 04, 2019 at 07:44:59PM +0800, Hanjun Guo wrote:
> With patch set "Avoid synchronous TLB invalidation for intermediate
> page-table entries on arm64" was merged, munmap() for hugepage such as
> 2M will be much faster, but with following case, munmap(64k) will take
> much longer time than before:
I didn't find anything grepping for that subject. Could you provide a commit
ID instead, please?
> #define MEM_LEN_TEST (0x10000UL)
> #define MEM_ADD_START (0x8000fffef000UL)
> #define MEM1_ADD_START (0x800000090000UL)
>
> mem = (unsigned char *)mmap((void *)MEM_ADD_START, MEM_LEN_TEST, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
>
> mem1 = (unsigned char *)mmap((void *)MEM1_ADD_START, MEM_LEN_TEST, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
>
> munmap(mem, MEM_LEN_TEST); // will take much longer time (from 50us to 230us on A55) than before
>
> munmap(mem1, MEM_LEN_TEST);
>
> munmap(mem, MEM_LEN_TEST) will finally call unmap_region() in the kernel,
> and in free_pgtables() will adjust the start and end in mmu_gather, so when
> running to __flush_tlb_range(), the (end - start) will more that 1G but less
> than 2G in this case, on the other hand, (MAX_TLBI_OPS * stride) will be 2G
> as the stride is 2M.
>
> So in the end if ((end - start) > (MAX_TLBI_OPS * stride)) will not valid,
> and will take loops to invalidate the TLB for many times which is time consuming.
>
> Can we make the (MAX_TLBI_OPS * stride) as constant such as 4M (which is the
> value before "Avoid synchronous TLB invalidation for intermediate page-table
> entries on arm64" merged)? or a smaller value for MAX_TLBI_OPS?
Changing MAX_TLBI_OPS will hurt the common case when tearing down PMD tables
with 4k pages, so I'm hesitant to change that again.
Will
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] munmap(64k) is much slower with patch set reduce synchronous TLB invalidation on ARM64 merged
2019-05-06 18:47 ` Will Deacon
@ 2019-05-07 3:15 ` Hanjun Guo
0 siblings, 0 replies; 3+ messages in thread
From: Hanjun Guo @ 2019-05-07 3:15 UTC (permalink / raw)
To: Will Deacon
Cc: wangxiongfeng (C), Catalin Marinas, Linuxarm,
linux-arm-kernel@lists.infradead.org, Zhouguanghui (OS Kernel)
On 2019/5/7 2:47, Will Deacon wrote:
> On Sat, May 04, 2019 at 07:44:59PM +0800, Hanjun Guo wrote:
>> With patch set "Avoid synchronous TLB invalidation for intermediate
>> page-table entries on arm64" was merged, munmap() for hugepage such as
>> 2M will be much faster, but with following case, munmap(64k) will take
>> much longer time than before:
>
> I didn't find anything grepping for that subject. Could you provide a commit
> ID instead, please?
Sorry for not clear, this is a patch set:
https://lkml.org/lkml/2018/8/30/751
And for specific commit IDs,
f270ab8 arm64: tlb: Adjust stride and type of TLBI according to mmu_gather
67a902a arm64: tlbflush: Allow stride to be specified for __flush_tlb_range()
>
>> #define MEM_LEN_TEST (0x10000UL)
>> #define MEM_ADD_START (0x8000fffef000UL)
>> #define MEM1_ADD_START (0x800000090000UL)
>>
>> mem = (unsigned char *)mmap((void *)MEM_ADD_START, MEM_LEN_TEST, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
>>
>> mem1 = (unsigned char *)mmap((void *)MEM1_ADD_START, MEM_LEN_TEST, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
>>
>> munmap(mem, MEM_LEN_TEST); // will take much longer time (from 50us to 230us on A55) than before
>>
>> munmap(mem1, MEM_LEN_TEST);
>>
>> munmap(mem, MEM_LEN_TEST) will finally call unmap_region() in the kernel,
>> and in free_pgtables() will adjust the start and end in mmu_gather, so when
>> running to __flush_tlb_range(), the (end - start) will more that 1G but less
>> than 2G in this case, on the other hand, (MAX_TLBI_OPS * stride) will be 2G
>> as the stride is 2M.
>>
>> So in the end if ((end - start) > (MAX_TLBI_OPS * stride)) will not valid,
>> and will take loops to invalidate the TLB for many times which is time consuming.
>>
>> Can we make the (MAX_TLBI_OPS * stride) as constant such as 4M (which is the
>> value before "Avoid synchronous TLB invalidation for intermediate page-table
>> entries on arm64" merged)? or a smaller value for MAX_TLBI_OPS?
>
> Changing MAX_TLBI_OPS will hurt the common case when tearing down PMD tables
> with 4k pages, so I'm hesitant to change that again.
It's true, but MAX_TLBI_OPS(1024) seems not an objective value fits all needs.
Is it reasonable to update the algorithm of adjusting the start and end in mmu_gather
in function free_pgtables()?
Thanks
Hanjun
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-05-07 3:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-04 11:44 [RFC] munmap(64k) is much slower with patch set reduce synchronous TLB invalidation on ARM64 merged Hanjun Guo
2019-05-06 18:47 ` Will Deacon
2019-05-07 3:15 ` Hanjun Guo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox