Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Hanjun Guo <guohanjun@huawei.com>
To: Will Deacon <will.deacon@arm.com>
Cc: "wangxiongfeng \(C\)" <wangxiongfeng2@huawei.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Linuxarm <linuxarm@huawei.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"Zhouguanghui \(OS Kernel\)" <zhouguanghui1@huawei.com>
Subject: Re: [RFC] munmap(64k) is much slower with patch set reduce synchronous TLB invalidation on ARM64 merged
Date: Tue, 7 May 2019 11:15:46 +0800	[thread overview]
Message-ID: <17eeae5a-dcc0-7e7f-154d-664a8e83ccf5@huawei.com> (raw)
In-Reply-To: <20190506184714.GE2875@brain-police>

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

      reply	other threads:[~2019-05-07  3:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=17eeae5a-dcc0-7e7f-154d-664a8e83ccf5@huawei.com \
    --to=guohanjun@huawei.com \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linuxarm@huawei.com \
    --cc=wangxiongfeng2@huawei.com \
    --cc=will.deacon@arm.com \
    --cc=zhouguanghui1@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox