linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Anshuman Khandual <anshuman.khandual@arm.com>
To: Barry Song <21cnbao@gmail.com>
Cc: wangkefeng.wang@huawei.com, prime.zeng@hisilicon.com,
	linux-doc@vger.kernel.org, peterz@infradead.org,
	catalin.marinas@arm.com, yangyicong@hisilicon.com,
	linux-mm@kvack.org, Nadav Amit <namit@vmware.com>,
	guojian@oppo.com, linux-riscv@lists.infradead.org,
	will@kernel.org, linux-s390@vger.kernel.org,
	zhangshiming@oppo.com, lipeifeng@oppo.com, corbet@lwn.net,
	x86@kernel.org, Mel Gorman <mgorman@suse.de>,
	linux-mips@vger.kernel.org, arnd@arndb.de, realmz6@gmail.com,
	Barry Song <v-songbaohua@oppo.com>,
	openrisc@lists.librecores.org, darren@os.amperecomputing.com,
	linux-arm-kernel@lists.infradead.org, xhao@linux.alibaba.com,
	linux-kernel@vger.kernel.org, huzhanyuan@oppo.com,
	Yicong Yang <yangyicong@huawei.com>,
	akpm@linux-foundation.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v3 4/4] arm64: support batched/deferred tlb shootdown during page reclamation
Date: Wed, 21 Sep 2022 09:03:23 +0530	[thread overview]
Message-ID: <41b48f0a-c001-9a8c-3017-4b2e06b44e34@arm.com> (raw)
In-Reply-To: <CAGsJ_4y0HrWd90ApAn=eDpYrkCigM6MyH=3cYnSuunZ5QpsD3w@mail.gmail.com>



On 9/21/22 07:21, Barry Song wrote:
> On Wed, Sep 21, 2022 at 1:50 PM Barry Song <21cnbao@gmail.com> wrote:
>>
>> On Tue, Sep 20, 2022 at 8:45 PM Anshuman Khandual
>> <anshuman.khandual@arm.com> wrote:
>>>
>>>
>>>
>>> On 9/20/22 09:09, Barry Song wrote:
>>>> On Tue, Sep 20, 2022 at 3:00 PM Anshuman Khandual
>>>> <anshuman.khandual@arm.com> wrote:
>>>>>
>>>>>
>>>>> On 8/22/22 13:51, Yicong Yang wrote:
>>>>>> +static inline bool arch_tlbbatch_should_defer(struct mm_struct *mm)
>>>>>> +{
>>>>>> +     return true;
>>>>>> +}
>>>>>
>>>>> This needs to be conditional on systems, where there will be performance
>>>>> improvements, and should not just be enabled all the time on all systems.
>>>>> num_online_cpus() > X, which does not hold any cpu hotplug lock would be
>>>>> a good metric ?
>>>>
>>>> for a small system, i don't see how this patch will help, e.g. cpus <= 4;
>>>> so we can actually disable tlb-batch on small systems.
>>>
>>> Do not subscribe ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH based on NR_CPUS ?
>>> That might not help much as the default value is 256 for NR_CPUS.
>>>
>>> OR
>>>
>>> arch_tlbbatch_should_defer() checks on
>>>
>>> 1. online cpus                  (dont enable batched TLB if <= X)
>>> 2. ARM64_WORKAROUND_REPEAT_TLBI (dont enable batched TLB)
>>>
>>>> just need to check if we will have any race condition since hotplug will
>>>> make the condition true and false dynamically.
>>>
>>> If should_defer_flush() evaluate to be false, then ptep_clear_flush()
>>> clears and flushes the entry right away. This should not race with other
>>> queued up TLBI requests, which will be flushed separately. Wondering how
>>> there can be a race here !
>>
>> Right. How about we make something as below?
>>
>> static inline bool arch_tlbbatch_should_defer(struct mm_struct *mm)
>> {
>>     /* for a small system very small number of CPUs, TLB shootdown is cheap */
>>     if (num_online_cpus() <= 4 ||
>> unlikely(this_cpu_has_cap(ARM64_WORKAROUND_REPEAT_TLBI)))
>>           return false;
>>
>> #ifdef CONFIG_ARM64_WORKAROUND_REPEAT_TLBI
>>     if (unlikely(this_cpu_has_cap(ARM64_WORKAROUND_REPEAT_TLBI)))
>>          return false;
>> #endif
>>
>>     return true;
>> }
> 
> sorry, i mean
> 
> static inline bool arch_tlbbatch_should_defer(struct mm_struct *mm)
> {
>     /* for a small system very small number of CPUs, TLB shootdown is cheap */
>     if (num_online_cpus() <= 4)
>             return false;
> 
> #ifdef CONFIG_ARM64_WORKAROUND_REPEAT_TLBI
>     if (unlikely(this_cpu_has_cap(ARM64_WORKAROUND_REPEAT_TLBI)))
>             return false;
> #endif
> 
>     return true;
> }

This is a good starting point.

  reply	other threads:[~2022-09-21  3:34 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-22  8:21 [PATCH v3 0/4] mm: arm64: bring up BATCHED_UNMAP_TLB_FLUSH Yicong Yang
2022-08-22  8:21 ` [PATCH v3 1/4] Revert "Documentation/features: mark BATCHED_UNMAP_TLB_FLUSH doesn't apply to ARM64" Yicong Yang
2022-09-09  4:26   ` Anshuman Khandual
2022-09-09  4:40     ` Barry Song
2022-08-22  8:21 ` [PATCH v3 2/4] mm/tlbbatch: Introduce arch_tlbbatch_should_defer() Yicong Yang
2022-08-24  9:40   ` Kefeng Wang
2022-09-09  4:16   ` Anshuman Khandual
2022-08-22  8:21 ` [PATCH v3 3/4] mm: rmap: Extend tlbbatch APIs to fit new platforms Yicong Yang
2022-08-24  9:43   ` Kefeng Wang
2022-09-09  4:51   ` Anshuman Khandual
2022-09-09  5:25     ` Barry Song
2022-08-22  8:21 ` [PATCH v3 4/4] arm64: support batched/deferred tlb shootdown during page reclamation Yicong Yang
2022-08-24  9:46   ` Kefeng Wang
2022-09-09  5:24   ` Anshuman Khandual
2022-09-09  5:35     ` Barry Song
2022-09-09  6:32       ` Yicong Yang
2022-09-15  6:07       ` Anshuman Khandual
2022-09-15  6:42         ` Barry Song
2022-09-15 14:31           ` Nadav Amit
2022-09-19  2:46             ` Anshuman Khandual
2022-09-19  4:24           ` Anshuman Khandual
2022-09-19  4:53             ` Barry Song
2022-09-19  5:08               ` Barry Song
2022-09-20  3:00   ` Anshuman Khandual
2022-09-20  3:39     ` Barry Song
2022-09-20  8:45       ` Anshuman Khandual
2022-09-21  1:50         ` Barry Song
2022-09-21  1:51           ` Barry Song
2022-09-21  3:33             ` Anshuman Khandual [this message]
2022-09-21  6:53   ` Anshuman Khandual
2022-09-21  7:15     ` Barry Song
2022-09-21  7:17     ` Nadav Amit
2022-09-22  3:15       ` Anshuman Khandual
2022-09-06  8:53 ` [PATCH v3 0/4] mm: arm64: bring up BATCHED_UNMAP_TLB_FLUSH Yicong Yang

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=41b48f0a-c001-9a8c-3017-4b2e06b44e34@arm.com \
    --to=anshuman.khandual@arm.com \
    --cc=21cnbao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=catalin.marinas@arm.com \
    --cc=corbet@lwn.net \
    --cc=darren@os.amperecomputing.com \
    --cc=guojian@oppo.com \
    --cc=huzhanyuan@oppo.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=lipeifeng@oppo.com \
    --cc=mgorman@suse.de \
    --cc=namit@vmware.com \
    --cc=openrisc@lists.librecores.org \
    --cc=peterz@infradead.org \
    --cc=prime.zeng@hisilicon.com \
    --cc=realmz6@gmail.com \
    --cc=v-songbaohua@oppo.com \
    --cc=wangkefeng.wang@huawei.com \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    --cc=xhao@linux.alibaba.com \
    --cc=yangyicong@hisilicon.com \
    --cc=yangyicong@huawei.com \
    --cc=zhangshiming@oppo.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;
as well as URLs for NNTP newsgroup(s).