From patchwork Thu Jan 25 04:23:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13529991 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 13474C47258 for ; Thu, 25 Jan 2024 04:23:28 +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=gOS8amINxkFNjWxgfT5+De0GGA/bkDcg9smlRWfytSY=; b=nCAqj/hwA4Qe+U 6rAHhrn1PUX1HlMEoyQJLxTBkJ3MdCpFacQMCYoo73OaLiEydZ/k2+Hkh42HnGNoGbsFfQ/i1a/Z9 L1KgjBNuhCVn1DPk3MMMcPLgtXsE7JBml6QqR3TmfnS61dEHnF9OdDz1/PAsx5phHgd5T3hGS6DTg WG3KZPwk8pOKalMzF8co+Qy4vEhR7/bXDhAhK0AMM6vuefhaiwHB5fZ+NlD6swa1IKB9MNYDQ2PUm 7IBQr77Rn8OOnQYbnws9O69rhAzRj7/K+q9hHPM0MK04F1bkWkyh1OTHzWfOwHsnVJuVLxzEUXbQz 9XZblLDmmEQaXMGPImQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rSrGn-006FQx-2g; Thu, 25 Jan 2024 04:23:17 +0000 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rSrGh-006FOr-1A for linux-riscv@lists.infradead.org; Thu, 25 Jan 2024 04:23:16 +0000 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-5ce74ea4bf2so251399a12.0 for ; Wed, 24 Jan 2024 20:23:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1706156590; x=1706761390; 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=bdsnxFeLDc7O+tsMX6XHeSkZFgA7YsQDvmpx17WI4kI=; b=eLDVQ3EnLyLHKVWN0YO17CmlHSMApaEBc2eaIU54Y1Wb+QqjEWf4RECADUbK/xc0hx fOArLsQ6myZpUWix5QAu/hfaqXrtt9sxqyhOg0U7nW6BjbKn7h37/pgG5You+lMO25yt SBP7EdZbfSJov0Pq3xyLfe84pRwjDrs8QCxw/VzMCfpcZ45WXyog8hAuVf3Ivo3am9Gw XJS2n0f/a/2XPfej1Up1OuVQ5tbhZjQO1efjbmmKqBTnB7G9mKyzRj6XA8FsfvvDEs7Z 3DI1UHWVri5xLcQ3yy1WZFabR2NcEFZPpMdBrDe3Qj3q29ibdV4fm4Yzwe5SnhFROQUT q5iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706156590; x=1706761390; 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=bdsnxFeLDc7O+tsMX6XHeSkZFgA7YsQDvmpx17WI4kI=; b=oEA74A04SMBJgfEa07Ll3xiTMVq1pC/rfUqN7g+PR//kSVmTkBvnxw9aDjRkJwGcR7 C4flZsY22mesHIz3PNSJcbgn8OiLT0FqFLjBZs1O2yj82xR/BLCDDRNQFiYKnMH1xERq 6Xcaco03KGcof6g5OyQxRPIVsm5SVh8xB6XL6RD5TOgPoNyo2Hb2wGylc4nKj6i6axve Tgdz33vsfWZu6D9xRnH4E7rnX0JBQqkE6rPRnGEvF5uzJm0iY3Ds4tQ2Z8ZTGUhr0bJ2 2vY0admZlrfgSQSfDgI/kmzxvc5hQbbGuksL0u6JDqn7Es1ALMdLWlOdC9dbrpSnn2Bx V19A== X-Gm-Message-State: AOJu0YwEdVMgdTGou/ErEXw270Ecn6lInNGGQjnKMXVFczCGN4v+qGve d40sAhfBv3RuQHEFbjEeQ2mW3zSqjIZl3hAF9VOBwMhIOxk3giM7ANaq7tCUE4g= X-Google-Smtp-Source: AGHT+IG0c3KHNOYvKXWZKGA877PW8294s0ljZp87IKGqkduZuQ+JPtDg7C2fQbUVQ11GAN+QWsDGOA== X-Received: by 2002:a05:6a20:9f03:b0:19a:fbfa:b16a with SMTP id mk3-20020a056a209f0300b0019afbfab16amr468801pzb.30.1706156590009; Wed, 24 Jan 2024 20:23:10 -0800 (PST) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id ko9-20020a056a00460900b006dab36287bfsm14549743pfb.207.2024.01.24.20.23.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 20:23:09 -0800 (PST) From: Charlie Jenkins Subject: [PATCH v10 0/2] riscv: Create and document PR_RISCV_SET_ICACHE_FLUSH_CTX prctl Date: Wed, 24 Jan 2024 20:23:07 -0800 Message-Id: <20240124-fencei-v10-0-a25971f4301d@rivosinc.com> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIACvisWUC/23QS07EMAwG4KuMsqbIdp5lxT0Qi+bFZEE7alEEG vXuuCOmU6EsbeX77fgqljSXtIiX01XMqZalTCMXCE8nEc7D+JG6ErkhCEgiou1yGkMqXe6zgWi dygMIfnyZUy7ft6S3d67PZfma5p9bcMWt+xdBdI+o2EHnUwCHGDwhvc6lTksZw3OYPsWWUukgJ eySWFLwhuTg0WNuSPmQhHKXcptpNWpH0iVvG1LdpQKE/cNVsYwqZMq+Bx1lQ+qjdLvULIcBk8Z oiai1rTnKfpeGJShEw1YpHRrSHiQ+bmtZWpfBoEoYPTSkO0qzS8dSyUHx1VQGwobsD5Iet+23m cjr+pxctP/luq6/EfVc/3ACAAA= 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 X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706156588; l=2933; i=charlie@rivosinc.com; s=20231120; h=from:subject:message-id; bh=Fp/Nsdcth0hMGV4QFLJyIHW6clYIcFNJ6WEMI/uUbQg=; b=SvtUbRzRCSPcDsyKUxxcadxQoBxxmIhU4504F5DxcJ1phzCTxqjQPG4L5ty+vMNgQswrEoK5x HlIebRpycAvDGysjIrrNQ3pIhmMKVTQ3CdAEmLCsQkAYHOsQyG0xTtr 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-20240124_202311_653369_DE193534 X-CRM114-Status: GOOD ( 10.04 ) 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 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 (2): riscv: Include riscv_set_icache_flush_ctx prctl documentation: Document PR_RISCV_SET_ICACHE_FLUSH_CTX prctl Documentation/arch/riscv/cmodx.rst | 96 ++++++++++++++++++++++++++++++++++++++ Documentation/arch/riscv/index.rst | 1 + arch/riscv/include/asm/mmu.h | 2 + arch/riscv/include/asm/processor.h | 7 +++ arch/riscv/include/asm/switch_to.h | 13 ++++++ arch/riscv/mm/cacheflush.c | 67 ++++++++++++++++++++++++++ arch/riscv/mm/context.c | 13 ++++-- include/uapi/linux/prctl.h | 6 +++ kernel/sys.c | 6 +++ 9 files changed, 208 insertions(+), 3 deletions(-) --- base-commit: 6613476e225e090cc9aad49be7fa504e290dd33d change-id: 20231117-fencei-f9f60d784fa0