Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [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

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