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 936B5C43217 for ; Mon, 14 Nov 2022 03:29:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B035B6B0074; Sun, 13 Nov 2022 22:29:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AB2826B0075; Sun, 13 Nov 2022 22:29:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 97A1A8E0001; Sun, 13 Nov 2022 22:29:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 8513A6B0074 for ; Sun, 13 Nov 2022 22:29:26 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4FBAF14063F for ; Mon, 14 Nov 2022 03:29:26 +0000 (UTC) X-FDA: 80130617532.04.2ABB282 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf29.hostedemail.com (Postfix) with ESMTP id 87DAC120009 for ; Mon, 14 Nov 2022 03:29:25 +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 AC24B23A; Sun, 13 Nov 2022 19:29:30 -0800 (PST) Received: from [10.162.40.16] (unknown [10.162.40.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 76BB43F534; Sun, 13 Nov 2022 19:29:14 -0800 (PST) Message-ID: <86fbdc8c-0dcb-9b8f-d843-63460d8b1d6a@arm.com> Date: Mon, 14 Nov 2022 08:59:11 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH v5 2/2] arm64: support batched/deferred tlb shootdown during page reclamation Content-Language: en-US To: 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 Cc: corbet@lwn.net, peterz@infradead.org, arnd@arndb.de, punit.agrawal@bytedance.com, 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, Barry Song <21cnbao@gmail.com>, wangkefeng.wang@huawei.com, xhao@linux.alibaba.com, prime.zeng@hisilicon.com, Barry Song , Nadav Amit , Mel Gorman References: <20221028081255.19157-1-yangyicong@huawei.com> <20221028081255.19157-3-yangyicong@huawei.com> From: Anshuman Khandual In-Reply-To: <20221028081255.19157-3-yangyicong@huawei.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668396565; a=rsa-sha256; cv=none; b=xMaSsiFn+FjM7kU0ExNQSXsc7N1Uqw86jG60UKN5OWPjqyTsgp5IjsRYDdkPC31xvL4jNc SGGQOLjCzkGgxoyjsOuKpsWHXvsgBpqD3nylwSEwp3x/3+Rx3nbGBHt5wl0luwxgngYGeT 2fEzhxu3bvv+9gAy4T6qUP2No/u0uIM= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf29.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668396565; 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=cvxzwqbW7+zRqMPz4lVX3o6jYWZ4zs3nPJQL6El61+o=; b=A06bHPyfG2xlHUpt/hkIcJ3ON0nBqkLPGcU2uEZhZK5/KKWuTcmpIpumJnoOJ3rDNFqnoB YgasptmkMiYLW/9kljAwUxmWilXrhekk4mZ8DtyNxogfFmop5f0Q0ttBHnBnDrOvqDpw+J HXZVBi4Fz62TPHmm+IYyrel2xw1LyDA= X-Rspamd-Queue-Id: 87DAC120009 X-Rspam-User: Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf29.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com X-Rspamd-Server: rspam06 X-Stat-Signature: io7q98twecyb64yb97ishxgq5bw1ur5s X-HE-Tag: 1668396565-987062 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 10/28/22 13:42, Yicong Yang wrote: > +static inline bool arch_tlbbatch_should_defer(struct mm_struct *mm) > +{ > + /* > + * TLB batched flush is proved to be beneficial for systems with large > + * number of CPUs, especially system with more than 8 CPUs. TLB shutdown > + * is cheap on small systems which may not need this feature. So use > + * a threshold for enabling this to avoid potential side effects on > + * these platforms. > + */ > + if (num_online_cpus() <= CONFIG_ARM64_NR_CPUS_FOR_BATCHED_TLB) > + return false; > + > +#ifdef CONFIG_ARM64_WORKAROUND_REPEAT_TLBI > + if (unlikely(this_cpu_has_cap(ARM64_WORKAROUND_REPEAT_TLBI))) > + return false; > +#endif should_defer_flush() is immediately followed by set_tlb_ubc_flush_pending() which calls arch_tlbbatch_add_mm(), triggering the actual TLBI flush via __flush_tlb_page_nosync(). It should be okay to check capability with this_cpu_has_cap() as the entire call chain here is executed on the same cpu. But just wondering if cpus_have_const_cap() would be simpler, consistent, and also cost effective ? Regardless, a comment is needed before the #ifdef block explaining why it does not make sense to defer/batch when __tlbi()/__tlbi_user() implementation will execute 'dsb(ish)' between two TLBI instructions to workaround the errata. > + > + return true; > +} > + > +static inline void arch_tlbbatch_add_mm(struct arch_tlbflush_unmap_batch *batch, > + struct mm_struct *mm, > + unsigned long uaddr) > +{ > + __flush_tlb_page_nosync(mm, uaddr); > +} > + > +static inline void arch_tlbbatch_flush(struct arch_tlbflush_unmap_batch *batch) > +{ > + dsb(ish); > +}