From patchwork Wed Nov 22 01:07:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13463787 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 90370C61D97 for ; Wed, 22 Nov 2023 01:08:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E331E6B0522; Tue, 21 Nov 2023 20:08:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DE2C76B0523; Tue, 21 Nov 2023 20:08:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CAA8F6B0525; Tue, 21 Nov 2023 20:08:19 -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 BC8AD6B0522 for ; Tue, 21 Nov 2023 20:08:19 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 8B08B1CB7F3 for ; Wed, 22 Nov 2023 01:08:19 +0000 (UTC) X-FDA: 81483804318.03.1FBF182 Received: from mail-oa1-f53.google.com (mail-oa1-f53.google.com [209.85.160.53]) by imf05.hostedemail.com (Postfix) with ESMTP id D353310000E for ; Wed, 22 Nov 2023 01:08:17 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=sifive.com header.s=google header.b=kSgzRTgr; dmarc=pass (policy=reject) header.from=sifive.com; spf=pass (imf05.hostedemail.com: domain of samuel.holland@sifive.com designates 209.85.160.53 as permitted sender) smtp.mailfrom=samuel.holland@sifive.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700615297; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=5K3acMXD355Dnu5c/0LgKAwcyMlLGIb9WZpaCFq6NtI=; b=CXxfpvMByZP7bl8eUpTyweka4+ReROGw4XBvBf63d3m+o8ovfrXNlOSC3dogu8+eHX71QC BhTfcKEsx9wB1PQhh9qiwJYnwmigmMi3jMqfHUBT9+HCLGH2lvoa39rnHTyOMfl8//PsIO /ktjbQ7AA2xp12bhiyLYiKZvmcMCz78= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=sifive.com header.s=google header.b=kSgzRTgr; dmarc=pass (policy=reject) header.from=sifive.com; spf=pass (imf05.hostedemail.com: domain of samuel.holland@sifive.com designates 209.85.160.53 as permitted sender) smtp.mailfrom=samuel.holland@sifive.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700615297; a=rsa-sha256; cv=none; b=iCvDd35XtqvUnGEy1IF+7NtcIMJ8kv8h8EB6y4pynBFY3xouMbBSnV3QZJ+WSU5aLOMlxc S+GqZNGghmUeTzf7D/3e1H4ewVs8AswwGuUvxF9n5TESxVWCCFmTWlriZy4miSBuQSdAv9 Y/rS7r1CbAnMIVcTtg4TqWFqe8kOI08= Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-1f066fc2a28so3776499fac.0 for ; Tue, 21 Nov 2023 17:08:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1700615297; x=1701220097; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=5K3acMXD355Dnu5c/0LgKAwcyMlLGIb9WZpaCFq6NtI=; b=kSgzRTgruS3XN+/adOsPWmfS/EjyBGImsadvxy5JE7qvXKk+7c49dVOpZosVMGqacT EYFiWeVUiOXc8+FLrbhAzLHawAWsSRPWcezSP1aL1EcNT0g0jDL5pVvxJlWUNj2/tjP6 O6B1buqNHe2BojjdMkBhk/L+JBxdwqPzi01MvpMbNEYoAOl/LwHi2Nv8WlUTPDaVHeW7 NCpTJwdh/8USY6mIJNXY84pzyJUZ63fDCF2B28avPKd/mjuEa4bYp2tSaenrM2vwKMWf s9TDGqromLx9BsMBoPL8UCRj+du3B06n9GiDSGkOe3+nSzQVw1r8W6u2MJ+Pe6eDJur2 LAKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700615297; x=1701220097; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5K3acMXD355Dnu5c/0LgKAwcyMlLGIb9WZpaCFq6NtI=; b=Vv9lWv4DFIJSjmQCQn6ci1zVdludMapusewTZME9TXk1fnvQD4ESdPh0IpVMgbt9cI ZRXj1sSBDVP4moTxlLXx91rFUrSKkJwiUDiWdFfMguirmQZwhcRQCqCP7sBJPbGB7OYb 2sTueZUZ1QomHo0cKeD02aoLZSvz04xZqShlNY5XUD3v5BA650KN1Hk6TnHosPY7AvyU MUj1w/K8gdzTm8wt6COsjL5VPU883A4gRtIixb1I4ImWP9FvZGct3Vf20qA6eJXRoZwa p5xIFXZc0v5C1624jLtygTiujMIkJG+ERz3HN0ZvrbHnKQvzFuiDiZyIGNBtF/dNf9sq w/jQ== X-Gm-Message-State: AOJu0YyHOJ8UkJuZlJwMRlIMYiS8/SeCu6Y5Dekdz8U5OlrasfIYuoox l7DKDmph2oUBVesP+uHUzZz4+A== X-Google-Smtp-Source: AGHT+IH6/NUuwGldOP1aJCDWjPm+XWVk8E4Msjy4/jNiAvoh03MIiSiJCBFz4I47qP2HX2IfskLVbg== X-Received: by 2002:a05:6870:816:b0:1f0:1c00:d860 with SMTP id fw22-20020a056870081600b001f01c00d860mr1172251oab.51.1700615297034; Tue, 21 Nov 2023 17:08:17 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id bn5-20020a056a00324500b006be047268d5sm8713961pfb.174.2023.11.21.17.08.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 17:08:16 -0800 (PST) From: Samuel Holland To: Palmer Dabbelt , linux-riscv@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexandre Ghiti , Samuel Holland Subject: [PATCH v3 0/8] riscv: ASID-related and UP-related TLB flush enhancements Date: Tue, 21 Nov 2023 17:07:11 -0800 Message-ID: <20231122010815.3545294-1-samuel.holland@sifive.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Rspamd-Queue-Id: D353310000E X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 6h7ofcenegyrg8rn7umw6uogcgj37egr X-HE-Tag: 1700615297-510082 X-HE-Meta: U2FsdGVkX192YE6noGG/+TyjSH8zw46mfsp03PCixGEQl5rHwBW13R5SZ0nWpccR7pXW3qVztVOCYh9sPsPXJ8e5B+vie1A0P40bCIJm1j6nu83t6l6Ap5alATegrU3jOEpFEHC52QA9+dCdWRQRBBu3pzdY7ayNODY/oql3KE1HxBnHLiQCcMJjfptaTg3GdYoYRpjwiU4wVE95RadjhlVCIxWkNI1JuWwrwPtt9F6Eitd94JlOcHkg9WLQb/qjUzCM6tLsM6gQCDQ3HSFn09jFKoJXaij+l9do2NpRDc6v3yug0uZrmktl0IX/1Q/dZd09h4fyrtJ+0Y8MI1czr0oYPGHQht47pz55wcXICiUaMCs7qlF7M6AymFqQAsPLp635sULFMVWrYGFiE1KANAep3tAV+bcLJZoFDh77/2kSzv7gnf8zbEMsB8W/166c8EqrjB8VgKNTN2AA/h6v9oiI4X01QN+JLWMJvpAYreK/4BYVC+JfTjvhYVnyttwGJ5yEpll4Va38MoLihayNvdEd8GwhhJAT/oWeP73UBH6XsKVsZZOyaRv4wDGKYgCgudMZAQizAdgxuBP1VDd2VCbdHHQdIoaZOKOAaY2pzAsdVWcVVnd688Sa+7ZwHdDDytbQQcYxe14sbBouwMxrJsFgAoRKOr0cpEkMPd2UAjGpvbPi3Isq+ZW0grUSyp57R1YVcJRGHTVnLF2eQJDgqHVidLoG29AdbCIHWPOVGkdTFrDhohX5RqspFL3NbY0oCpSoutWO+od7qoEzkxr4lGWZFqJZxC2XdR8QMikZdHAqaHCSHYwppABCy5e7nz4IsCZbvndW6MDGtNUF7jqhHsBQSbGWjieOnz/z79vvMZlMFCHePlbdXiiAxkI/lmPRaF/3GdQ1tOEHkQg2Q3nhmcPXYr3Qh3U6/soiUvVMCY8EBdcwKgBqMT9iOVCnHCpvjU334QfrwvzHkdQnpr9 YB4HjBp9 0L56GDvShsgeFDg05KPtoTyrwfzez9pEfNQXriRPetepEsEMjKOpSC+R6557+OqSc4AB5i2yntE0wXuxu0316vWXMBm8dmUVyZBEBOQAS/8eEHhF5txEQvH8clR2EXW+oq//8HL3jzWk3sbbcMlxjJpZ4JwmD3Uqc9oN8JTfYLwmBfPU7WUnGQzaFQWPB0vCESlcY1huy698M2xyMFvjrUKU5yKjvpm9ZhedWvFhUjNzQpzILc5kBr72ku9CmOWYgDNTL4GmrWJ00054Wo/fSc6uBoXEfh3O1UzxPFoz2br5WXxT1wjglegi35R2ktCiPvHqwnf7Fd0CYrYVCKI9WPH13Nu568FWB0jfXrjgApF4b/elyqOriHWf1qxRQScPT0yv9FQua4Ss+oekNbNUndc0tsYNVqMIGLxLV/MQZKEHgV67M1FPy8Ub/tvY2Oi7uswVa9EfBYiKw0LU= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000420, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: While reviewing Alexandre Ghiti's "riscv: tlb flush improvements" series[1], I noticed that most TLB flush functions end up as a call to local_flush_tlb_all() when SMP is disabled. This series resolves that. Along the way, I realized that we should be using single-ASID flushes wherever possible, so I implemented that as well. [1]: https://lore.kernel.org/linux-riscv/20231030133027.19542-1-alexghiti@rivosinc.com/ Changes in v3: - Fixed a performance regression caused by executing sfence.vma in a loop on implementations affected by SiFive CIP-1200 - Rebased on v6.7-rc1 Changes in v2: - Move the SMP/UP merge earlier in the series to avoid build issues - Make a copy of __flush_tlb_range() instead of adding ifdefs inside - local_flush_tlb_all() is the only function used on !MMU (smpboot.c) Samuel Holland (8): riscv: mm: Combine the SMP and UP TLB flush code riscv: Apply SiFive CIP-1200 workaround to single-ASID sfence.vma riscv: Avoid TLB flush loops when affected by SiFive CIP-1200 riscv: mm: Introduce cntx2asid/cntx2version helper macros riscv: mm: Use a fixed layout for the MM context ID riscv: mm: Make asid_bits a local variable riscv: mm: Preserve global TLB entries when switching contexts riscv: mm: Always use ASID to flush MM contexts arch/riscv/errata/sifive/errata.c | 3 ++ arch/riscv/include/asm/errata_list.h | 12 ++++++- arch/riscv/include/asm/mmu.h | 3 ++ arch/riscv/include/asm/mmu_context.h | 2 -- arch/riscv/include/asm/tlbflush.h | 54 ++++++++++++++-------------- arch/riscv/mm/Makefile | 5 +-- arch/riscv/mm/context.c | 26 ++++++-------- arch/riscv/mm/tlbflush.c | 41 ++++++++------------- 8 files changed, 70 insertions(+), 76 deletions(-)