From patchwork Mon Feb 12 23:36:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13554163 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0A2FDC4829D for ; Mon, 12 Feb 2024 23:36:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:MIME-Version:Message-Id:Date: Subject:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=zNIiTW8MFMqCJOXoHrvglx7VFakpLi+WZHdE0TxFiMk=; b=MvEd3PdYNsIv5z GgrX0eZ+uIYrypQrQDpDckKuYmuMmITqv/Wb73TvSRy5MKUKusLK35sjXejeWFFbdMvO5r/X8s+Tn Fq4/ZdG6y1vnd98fW9FUqkYI9cPu+srnMzO0GkpufCUUluhVPNP6qpOVfNXlbXXIBU0JVEkOXaeEP HvM8FSrvnm673WKd2cCeaDAWZNfRRPsDThHjp1n3Zb47o0oVfxs5cD4K/4RMe0QM4O3lcNiRsid/I zH+9UPqhur3tc7m300+qsfZKDmdi3SiAi7SH/cbfJIZozw8r4qgKrFQIkC8CQg4Da30Hbl4NQgXtg GY3JNgd5D926hqtGgy7w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZfqo-00000007Ia6-2TCj; Mon, 12 Feb 2024 23:36:38 +0000 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZfqi-00000007IVO-4AVi for linux-riscv@lists.infradead.org; Mon, 12 Feb 2024 23:36:35 +0000 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1d953fa3286so29277225ad.2 for ; Mon, 12 Feb 2024 15:36:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1707780991; x=1708385791; darn=lists.infradead.org; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:from:to:cc:subject:date:message-id:reply-to; bh=oNioNdguCz5tyqf3w8SAJg3WWFu/ZpF1hV12mYbLuZw=; b=DDE60NKdPhS4TAnWKXfDT4Hwt6CfulwGKrd5NXVXvP+wmb3+YE5sLqREZr/VEHtcl/ stsVcFc9F34EHRHz9gpQEGrzUP9UqbLLriXjP6Gvzd0BB/jfbNRWKG8RFYmlH4RT1MUj g5nNGUG7BIqao5i4K4HF2kvV7LTGMh0IdN8a4bu7t6gWEjSoSlcDxsaA6qWgDRPSbInc zig6VzKBNzl+7Xl6kWihRSJEXJdSjtrkqcg/LPieLhKfEyGIHq8JTDM9NpWPfrBZpfIh T/cDQx+T1iALs6ZUKvcLerj668ek1q3trwZsMJyh9umJX9yFZxRC9FBmSns02oyBN1Da oMvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707780991; x=1708385791; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=oNioNdguCz5tyqf3w8SAJg3WWFu/ZpF1hV12mYbLuZw=; b=LoyCEjQHqvLh8ikWZkQLJNe06BydRNPCpsISikIPL8aBTDx8l8Vi0G2sxRFhvvlKru NgpSizNHIX4tZj8k9DgLFDoMuPF++uDykj5UpJylSfKs007R3djXREfEhntvn5kvZ/YF K3zWodnSNYNO0guT+76kFZZxS2jpfVrlHNxQAd8zauhk9+TSqvCGvaTzjTBjJtDFWzUb Kmwtm2n/0m+v6VzkNbuFWxXXIPgAzew1I4j3yOBr9wi/c2nyG0tVwoVie8GAHOn5bfPn bb8PP5p7Xboi5oRR1ATvcM17XecCJrFD4+6O/7N+udmDOaFbI+83pFldyICA0fnJXHRy XI+Q== X-Gm-Message-State: AOJu0Yz5/Bp2F0SE0OhvlOPb5cIQG8YA2Lu4ohO6tB8KGlhyXsgkkbnJ xgCgjeQPYUiPzvisGxt1ilUlIg/AKpkgIC2mZMnuCLz7iyakO4vFSm7tLF7pVKE= X-Google-Smtp-Source: AGHT+IGlzxazBjxv9RA941+ZHFC2kAe0rM4VKTlBx4LwX5kenDzB6/KnJLHG3CbaBKLMEuWgOEr4pg== X-Received: by 2002:a17:902:e5ca:b0:1d9:a5ec:30d2 with SMTP id u10-20020a170902e5ca00b001d9a5ec30d2mr11052876plf.12.1707780991294; Mon, 12 Feb 2024 15:36:31 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXpvQ/bifwy33zc0j7hfXTIrBarDTDQRSnG6jYoRxhctuzyMpZB6R4vMI76zxbUXHW0cs3V8WLKORH+/uwFPaweDLNxZ7qbduxPCHHp0g7FFkebRIRxtn2bizXbAPcSXa8QVUUu97cm7VTqO4JHVM283X7nKupleVBuXX3tbwbUi8IlEBnYoLbiSp+JhOnGD8VzLBXHn3gVtZ98YrtIhUVagP8HgaUEES4xH8F+9CuDEpfjLP+N/q2901jsLZ9+4IZmDRonnYLIENZ54LTACnJQ9/BheuZoViYtxjyRimNQJyM4fxmdG+920Nh0ZHC0kiYnoZPYtLsiKBcKkrRgH39F49cjZ9FbEyrWwykOK+ncNr596z6qNw24o1R3+Yuu80MZg+QWKMUcCTADenpd1O/lte6A4HetVbCQKl2Byf3z4eDJhGCHuVB6E/Dt08bDCsftsF0= Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id b5-20020a170902650500b001da153682c5sm888693plk.261.2024.02.12.15.36.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 15:36:30 -0800 (PST) From: Charlie Jenkins Subject: [PATCH v11 0/4] riscv: Create and document PR_RISCV_SET_ICACHE_FLUSH_CTX prctl Date: Mon, 12 Feb 2024 15:36:25 -0800 Message-Id: <20240212-fencei-v11-0-e1327f25fe10@rivosinc.com> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAHmrymUC/23SS07EMAwG4KuMsqbIdpxHWXEPxKJ5MVnQjlpUg UZzd9IR00Yoy1j5fjtWrmKJc46LeDldxRzXvORpLAfEp5Pw52H8iF0OpSAISCKi6VIcfcxd6pO GYCynAUS5fJljyt/3pLf3cj7n5Wuaf+7BK27VvwiiR8SKHXQuerCI3hHS65zXacmjf/bTp9hSV qqkhF1SkeSdJjk4dJgaUh6SUO5Sbj2NQmVJ2uhMQ/JDMiDsD165yMA+UXI9qCAbUtXS7lIVOQw YFQZDRK1pdS37XeoigRF1sczKN6SpJB67NUUam0AjRwwOGtLWUu/SFsly4LI1TkDYkH0l6dhtv /XEMq5L0QbTkgg15eMrwLYjUr3BxBIw/LO32+0XwJEEjKwCAAA= To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Jonathan Corbet , Conor Dooley , =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= , Atish Patra , Randy Dunlap , Alexandre Ghiti Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Charlie Jenkins , Atish Patra , Alexandre Ghiti X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1707780989; l=3458; i=charlie@rivosinc.com; s=20231120; h=from:subject:message-id; bh=pUkJcJN2rctCyQ0hK/qiJS411FCsdKiJii0pjIPLWbg=; b=MPwj9l2ctTE9U5PMrkcabg29HVx1LnyHJJ9FmdT2NRt6a6jiZmF+27/ABOvnKjANPSgri2Nzk yny/fD+G20bBSrkLd6AMgL81mkbhViWypSaZGxhLbhPl1JRHJHuVKKM X-Developer-Key: i=charlie@rivosinc.com; a=ed25519; pk=t4RSWpMV1q5lf/NWIeR9z58bcje60/dbtxxmoSfBEcs= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240212_153633_244291_4A104B0C X-CRM114-Status: GOOD ( 10.44 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Improve the performance of icache flushing by creating a new prctl flag PR_RISCV_SET_ICACHE_FLUSH_CTX. The interface is left generic to allow for future expansions such as with the proposed J extension [1]. Documentation is also provided to explain the use case. Patch sent to add PR_RISCV_SET_ICACHE_FLUSH_CTX to man-pages [2]. [1] https://github.com/riscv/riscv-j-extension [2] https://lore.kernel.org/linux-man/20240124-fencei_prctl-v1-1-0bddafcef331@rivosinc.com Signed-off-by: Charlie Jenkins --- Changes in v11: - Add back PR_RISCV_CTX_SW_FENCEI_OFF (Samuel) - Fix under nosmp (Samuel) - Change set_prev_cpu (Samuel) - Fixup example testcase in docs - Change wording of documentation slightly (Alejandor Colomar) - Link to v10: https://lore.kernel.org/r/20240124-fencei-v10-0-a25971f4301d@rivosinc.com Changes in v10: - Fix fence.i condition to properly only flush on migration (Alex) - Fix documentation wording (Alex) - Link to v9: https://lore.kernel.org/r/20240123-fencei-v9-0-71411bfe8d71@rivosinc.com Changes in v9: - Remove prev_cpu from mm (Alex) - Link to v8: https://lore.kernel.org/r/20240116-fencei-v8-0-43a42134f021@rivosinc.com Changes in v8: - Only flush icache if migrated to different cpu (Alex) - Move flushing to switch_to to catch per-thread flushing properly - Link to v7: https://lore.kernel.org/r/20240112-fencei-v7-0-78f0614e1db0@rivosinc.com Changes in v7: - Change "per_thread" parameter to "scope" and provide constants for the parameter. - Link to v6: https://lore.kernel.org/r/20240109-fencei-v6-0-04116e51445c@rivosinc.com Changes in v6: - Fixup documentation formatting - Link to v5: https://lore.kernel.org/r/20240108-fencei-v5-0-aa1e51d7222f@rivosinc.com Changes in v5: - Minor documentation changes (Randy) - Link to v4: https://lore.kernel.org/r/20240107-fencei-v4-0-d4cf2fb905d3@rivosinc.com Changes in v4: - Add OFF flag to disallow fence.i in userspace (Atish) - Fix documentation issues (Atish) - Link to v3: https://lore.kernel.org/r/20231213-fencei-v3-0-b75158238eb7@rivosinc.com Changes in v3: - Check if value force_icache_flush set on thread, rather than in mm twice (Clément) - Link to v2: https://lore.kernel.org/r/20231130-fencei-v2-0-2cb623ab1b1f@rivosinc.com Changes in v2: - Fix kernel-doc comment (Conor) - Link to v1: https://lore.kernel.org/r/20231122-fencei-v1-0-bec0811cb212@rivosinc.com --- Charlie Jenkins (4): riscv: Remove unnecessary irqflags processor.h include riscv: Include riscv_set_icache_flush_ctx prctl documentation: Document PR_RISCV_SET_ICACHE_FLUSH_CTX prctl cpumask: Add assign cpu Documentation/arch/riscv/cmodx.rst | 98 ++++++++++++++++++++++++++++++++++ Documentation/arch/riscv/index.rst | 1 + arch/riscv/include/asm/irqflags.h | 1 - arch/riscv/include/asm/mmu.h | 2 + arch/riscv/include/asm/processor.h | 12 +++++ arch/riscv/include/asm/switch_to.h | 23 ++++++++ arch/riscv/mm/cacheflush.c | 105 +++++++++++++++++++++++++++++++++++++ arch/riscv/mm/context.c | 18 +++++-- include/linux/cpumask.h | 16 ++++++ include/uapi/linux/prctl.h | 6 +++ kernel/sys.c | 6 +++ 11 files changed, 282 insertions(+), 6 deletions(-) --- base-commit: 6613476e225e090cc9aad49be7fa504e290dd33d change-id: 20231117-fencei-f9f60d784fa0