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 898C6C4332F for ; Mon, 14 Nov 2022 08:46:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F246A6B0074; Mon, 14 Nov 2022 03:46:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ED2D26B0075; Mon, 14 Nov 2022 03:46:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE84E8E0001; Mon, 14 Nov 2022 03:46:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D01476B0074 for ; Mon, 14 Nov 2022 03:46:19 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 93B80160DDA for ; Mon, 14 Nov 2022 08:46:19 +0000 (UTC) X-FDA: 80131416078.07.2B76FFD Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf25.hostedemail.com (Postfix) with ESMTP id 63F12A000B for ; Mon, 14 Nov 2022 08:46:16 +0000 (UTC) Received: from canpemm500009.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4N9jZS4TZcz15Md3; Mon, 14 Nov 2022 16:45:52 +0800 (CST) Received: from [10.67.102.169] (10.67.102.169) by canpemm500009.china.huawei.com (7.192.105.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 14 Nov 2022 16:46:11 +0800 CC: , , , , , , , , , , , , , , , , , Barry Song <21cnbao@gmail.com>, , , , Barry Song , Nadav Amit , Mel Gorman Subject: Re: [PATCH v5 2/2] arm64: support batched/deferred tlb shootdown during page reclamation To: Anshuman Khandual , , , , , , , References: <20221028081255.19157-1-yangyicong@huawei.com> <20221028081255.19157-3-yangyicong@huawei.com> <86fbdc8c-0dcb-9b8f-d843-63460d8b1d6a@arm.com> From: Yicong Yang Message-ID: <9982dac0-9f2e-112a-d440-467c8e8f8aa4@huawei.com> Date: Mon, 14 Nov 2022 16:46:10 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: <86fbdc8c-0dcb-9b8f-d843-63460d8b1d6a@arm.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.102.169] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500009.china.huawei.com (7.192.105.203) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668415579; a=rsa-sha256; cv=none; b=Pj8mEy9hh6Rr7C5sXSrEF++eqCLEANFkrCzX2BAOahmX+WrhSTYAwLjq56QD+iGmUOpJA5 i3e8FWOsfH0Y144v5cVb1io6Mtz6wVgwjD0s9NeQyyvA9tKdhs7dLQQ37yjpV47z+6/5/K N64IcBxy4B3Cs3BayKBbpZlwHFjTnTU= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf25.hostedemail.com: domain of yangyicong@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=yangyicong@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668415579; 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=QmSTbgbP3LgyHnTxH2t6wXf7THD8cD/D/uQd4mSben8=; b=EMiI4ctqs73GRXS5jj8j3ndN0b6/3S4FTCV4NFPysaDRFIkUClTRYd2KoGSWcbmd+PV52q S9pk9wb+K5QTcRQMzJZX8o9iPZW0V4vN1BBp527xHr/IRJHL0v9fOl2FjatOxbz7PrsZMc lK7kaLIzYIhN4YT75C2/sMDww9RfNy0= X-Rspamd-Queue-Id: 63F12A000B Authentication-Results: imf25.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf25.hostedemail.com: domain of yangyicong@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=yangyicong@huawei.com X-Rspam-User: X-Rspamd-Server: rspam01 X-Stat-Signature: xmqrigb8an489rgzo6npk4wyswtib7oa X-HE-Tag: 1668415576-412333 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 2022/11/14 11:29, Anshuman Khandual wrote: > > > 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 ? > ok. Checked cpus_have_const_cap() I think it matches your words. > 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. > The workaround for the errata mentioned the affected platforms need the tlbi+dsb to be done twice, so I'm not sure if we defer the final dsb will cause any problem so I think the judgement here is used for safety. I have no such platform to test if it's ok to defer the last dsb. >> + >> + 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); >> +} > . >