From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E870C32771 for ; Wed, 21 Sep 2022 03:33:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D35B1940007; Tue, 20 Sep 2022 23:33:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CE5A16B0073; Tue, 20 Sep 2022 23:33:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BAC8F940007; Tue, 20 Sep 2022 23:33:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id AC17F6B0072 for ; Tue, 20 Sep 2022 23:33:37 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 85329C099B for ; Wed, 21 Sep 2022 03:33:37 +0000 (UTC) X-FDA: 79934672874.28.EC1E8AD Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf27.hostedemail.com (Postfix) with ESMTP id B431540002 for ; Wed, 21 Sep 2022 03:33:36 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4AB9513D5; Tue, 20 Sep 2022 20:33:42 -0700 (PDT) Received: from [10.162.41.8] (unknown [10.162.41.8]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9A77B3F5A1; Tue, 20 Sep 2022 20:33:26 -0700 (PDT) Message-ID: <41b48f0a-c001-9a8c-3017-4b2e06b44e34@arm.com> Date: Wed, 21 Sep 2022 09:03:23 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v3 4/4] arm64: support batched/deferred tlb shootdown during page reclamation Content-Language: en-US To: Barry Song <21cnbao@gmail.com> Cc: Yicong Yang , akpm@linux-foundation.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, catalin.marinas@arm.com, will@kernel.org, linux-doc@vger.kernel.org, corbet@lwn.net, peterz@infradead.org, arnd@arndb.de, linux-kernel@vger.kernel.org, darren@os.amperecomputing.com, yangyicong@hisilicon.com, huzhanyuan@oppo.com, lipeifeng@oppo.com, zhangshiming@oppo.com, guojian@oppo.com, realmz6@gmail.com, linux-mips@vger.kernel.org, openrisc@lists.librecores.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, wangkefeng.wang@huawei.com, xhao@linux.alibaba.com, prime.zeng@hisilicon.com, Barry Song , Nadav Amit , Mel Gorman References: <20220822082120.8347-1-yangyicong@huawei.com> <20220822082120.8347-5-yangyicong@huawei.com> <302febae-508c-d73e-8676-d51752946645@arm.com> <8c4f103b-8f04-d0ad-b30a-2db7e52b36a3@arm.com> From: Anshuman Khandual In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663731217; a=rsa-sha256; cv=none; b=I8Wq1JlUslpeVVk7jP3Zd11MDNATox5lYW+NlfNUuJJY0NTYseuHArQVaxARDL/nkRh4Zo 0tbMwro3jrieSOQsQ4Q79fpVrFxlvL/qUJa/lFFh4RnFD4s6aQ06eGJIFb4YT8FFnMHIbE XyoMK2l/7UYWHymvuABeDy+6O8uOppg= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663731217; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SxAC9phDzT5Jha77yrzyGO/hxk2tim87eqA7/gMppj0=; b=b5ViWnALY6r/XAEbIR2NSyLG453vwufnjD7dx12xOwA8UTYwMeyV8dJXkJ2EAtJDJbGNeY 4FafWvKrjveaxoIq7d9HlxFFdsQDXuVZANK7FCGWdkkE1W+k4bjQLXwqxecVJWrFShtG87 6SsS455NEYq9DhzBdBFtqyMwLKdgakk= X-Rspamd-Queue-Id: B431540002 X-Rspam-User: Authentication-Results: imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com; dmarc=pass (policy=none) header.from=arm.com X-Rspamd-Server: rspam11 X-Stat-Signature: 31ddz6fqgf15z5sia5yodzuasmzqzbbj X-HE-Tag: 1663731216-312237 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 >> wrote: >>> >>> >>> >>> On 9/20/22 09:09, Barry Song wrote: >>>> On Tue, Sep 20, 2022 at 3:00 PM Anshuman Khandual >>>> 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.