From patchwork Mon Feb 19 06:04:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungchul Park X-Patchwork-Id: 13562180 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 EDD36C5475B for ; Mon, 19 Feb 2024 06:04:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8ED866B008A; Mon, 19 Feb 2024 01:04:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 89D6D6B0089; Mon, 19 Feb 2024 01:04:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 660BC6B0088; Mon, 19 Feb 2024 01:04:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 454E96B0085 for ; Mon, 19 Feb 2024 01:04:25 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1EB731C01AA for ; Mon, 19 Feb 2024 06:04:25 +0000 (UTC) X-FDA: 81807513690.27.74065C8 Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by imf18.hostedemail.com (Postfix) with ESMTP id 65EB21C0009 for ; Mon, 19 Feb 2024 06:04:22 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of byungchul@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=byungchul@sk.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708322663; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=eRD1/8o+qtEOTAKMY7ucioDJJtMI3+WpTL+ASvHX4To=; b=d4/2KlhlVP/xl2N0Q2QCQ5z9UIvXuDpzbYCJqw6G8h7RGJrBbm06vbp+4IPCUHjD0CCXVp E/NwlmmNAEh1GWHEiOuN6ZfxCV9ToxGcyxGN/zeEf9OBWDezLf6MI8hZzmX5Y39S2G7ktE a0RDqrpqSk1RCRUGorr+FSQhpreIhic= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708322663; a=rsa-sha256; cv=none; b=z7nSiZZ0mgxpntV/nhQImvXTVG3XVTwZ6xUAnALTvGoPpDxMpa1vMq0KHcKqTvZ/hAyzSo kuiyQBttZBRbvApo0kTQPWMGmX3x7N/gYOQhBOdAQrz+23Ovd+i4ULVtrd0RlOQVEC8QNa 60msAnDdJaxY3/+u1xOoS2pJQv7fgjY= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of byungchul@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=byungchul@sk.com; dmarc=none X-AuditID: a67dfc5b-d6dff70000001748-bd-65d2ef615024 From: Byungchul Park To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: kernel_team@skhynix.com, akpm@linux-foundation.org, ying.huang@intel.com, namit@vmware.com, vernhao@tencent.com, mgorman@techsingularity.net, hughd@google.com, willy@infradead.org, david@redhat.com, peterz@infradead.org, luto@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, rjgolo@gmail.com Subject: [PATCH v8 1/8] x86/tlb: Add APIs manipulating tlb batch's arch data Date: Mon, 19 Feb 2024 15:04:00 +0900 Message-Id: <20240219060407.25254-2-byungchul@sk.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240219060407.25254-1-byungchul@sk.com> References: <20240219060407.25254-1-byungchul@sk.com> X-Brightmail-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u8eCTaUem1doeSze 85LJY9OqTjaPTZ8msXu8O3eO3ePEjN8sHvNOBnq833eVzWPxiw9MHlt/2Xk0Tr3G5vF5k5zH u/lv2QIEorhsUlJzMstSi/TtErgybt9+yVSwiq9iyY92tgbGaTxdjJwcEgImEueuH2ADsdkE 1CVu3PjJDGKLCJhJHGz9w97FyMXBLPCRSWL19w4WkISwgI/E4vv/wGwWAVWJ7pnvmEBsXgFT iVPTNrBADJWXWL3hANAgDg5OoEG7DwqBhIWASk5cncw0gZFrASPDKkaRzLyy3MTMHFO94uyM yrzMCr3k/NxNjMDgXlb7Z+IOxi+X3Q8xCnAwKvHwZohcShViTSwrrsw9xCjBwawkwuvedCFV iDclsbIqtSg/vqg0J7X4EKM0B4uSOK9XeGqCkEB6YklqdmpqQWoRTJaJg1OqgdHK2n/Sdu7V /xe/iok3ct0vt4ZJpKPoyqFNhhYaFd6TWU5/dn/l+ObD9QxrvaN3Z2S4VmhcMhZ8uNh1OZPF +tiAU83Hln/jTmg6bfLN66XQtfu7VkQd4vyxcIPwk+UvT1VHrNiVrfz8zdUHSuvnP128TV9B L1eKZX+k3f8PxRppdi5Vaz3SlfuUWIozEg21mIuKEwGcMv88agIAAA== X-CFilter-Loop: Reflected X-Stat-Signature: meg9nh391ji37zpqywim59ux4yx6ggzg X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 65EB21C0009 X-Rspam-User: X-HE-Tag: 1708322662-991155 X-HE-Meta: U2FsdGVkX1/xYZq/j2Q9BGUTNwLbdbypm+P8nX0KAXBxNUJQcqd7WNaA0tyBmVLCSsPcXT4HbS1pJQR2vOenmNnTo8/vfVf1TEm3SLjadr6JBx2ReexIfHYRmPbfWWBQ1dzzICB4eLmGQ24qIc3HQ2Vls/r24Ui3Oainpas/Q/vsY6G1MoM7SqiRVWBXNPnUCAeL/L9kH34ptobG41h2N72vLB2EPxKiJCNXAOlO4nSedR2WUuJdARWEWUaOmt1vK3HiVIJ2HCU+qf47IMMxC+Od4WJyhWJffpvJOV0LnEw2p9CqlohZIdsit7flo3otKhJQiTBqeDgAfC/JLra8358xNXt4gaynRluuV2GbSQrSqoE6GZBQtfAfrPFeSlM8uO57GiOYg4+aMcM0lnWdoP6Qbcg15OiuRIJjPLBtYKk3WZJmroOy9thNgCAYVx5IKjFBoIeCHODlMoxKEqCzlGToMp4PfbJnb2mlM9lpJzHPqq2abfS0Q58O7Mb+U6aipLKZ71jC1iJ7vH8UKbOeAmd6Z89mebOkSPcHJl9Ih3F1qToIG7S79F8QrVdZYpvNvHdkeY3nnqPmmCuqIA1jUFIZ8daGoFvBLnkadErAqmUTCYJLESFbbw7hG51ScFaYxMosIrKvXZVnEepc4NDfmn0gOSe6ebtsf4K9fXS5I4moBGgrzvi8dY+7vWArmS2zrOPc/2yugDan50v8SbmLhw== 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: List-Subscribe: List-Unsubscribe: This is a preparation for migrc mechanism that needs to recognize read-only TLB entries during batched TLB flush by separating tlb batch's arch data into two, one is for read-only entries and the other is for writable ones, and merging those two when needed. Migrc also needs to optimize CPUs to flush by clearing ones that have already performed TLB flush needed. To support it, added APIs manipulating arch data for x86. Signed-off-by: Byungchul Park --- arch/x86/include/asm/tlbflush.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h index 25726893c6f4..fa7e16dbeb44 100644 --- a/arch/x86/include/asm/tlbflush.h +++ b/arch/x86/include/asm/tlbflush.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -293,6 +294,23 @@ static inline void arch_flush_tlb_batched_pending(struct mm_struct *mm) extern void arch_tlbbatch_flush(struct arch_tlbflush_unmap_batch *batch); +static inline void arch_tlbbatch_clear(struct arch_tlbflush_unmap_batch *batch) +{ + cpumask_clear(&batch->cpumask); +} + +static inline void arch_tlbbatch_fold(struct arch_tlbflush_unmap_batch *bdst, + struct arch_tlbflush_unmap_batch *bsrc) +{ + cpumask_or(&bdst->cpumask, &bdst->cpumask, &bsrc->cpumask); +} + +static inline bool arch_tlbbatch_done(struct arch_tlbflush_unmap_batch *bdst, + struct arch_tlbflush_unmap_batch *bsrc) +{ + return cpumask_andnot(&bdst->cpumask, &bdst->cpumask, &bsrc->cpumask); +} + static inline bool pte_flags_need_flush(unsigned long oldflags, unsigned long newflags, bool ignore_access)