Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2746054rdb; Mon, 12 Feb 2024 15:36:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVHT9yNsYJr3V/Iuc3tvGINJmlKVuQzXgZY/OJV2VVJupc3wAPGpie4x8+7owh3nX8i2g++9CFTo5n99a1vxxW0qC3PDh4y802VVWinTg== X-Google-Smtp-Source: AGHT+IHOEAj0bQVO1vAa+G7wGiT+qVNNmscDeA8sPWkuwn5XoOtQsopWbeC7gVjji8zqvp4eUnDK X-Received: by 2002:a17:902:e9cc:b0:1d7:4b27:4ac3 with SMTP id 12-20020a170902e9cc00b001d74b274ac3mr8573532plk.31.1707781005176; Mon, 12 Feb 2024 15:36:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707781005; cv=pass; d=google.com; s=arc-20160816; b=nh7BTxJdWxSHhMx5gmOJ4Ai44r5HvaFTgR4Wiu6jAWaCrQV6bNCUycwERrxNDQiPG7 NnabV6KxTLh/xGMNyqDM2/6MkR0pCF+OQ/IYx5RJIbICRSOj/jLrxLl9hDPC6+8KXtHc /aSMGh/TIkJLHnxj+stL0uasyt1mlVC/kv/Wcz6+cJJBy1XwL8tWHDRWyssnzoNHmwh4 j14hFQ2r2PQEYPCcKdvmeJVa3JYyOl1wi9vHjU7GutvD/HAEFwAKbf+yecauf1g+HXsD AM9+FDl5N/hUy41SxjqWkPtVCAwY9uE8cv3DcUNXdPY8WKd3oRP8Up1L4skMjvewBOlc BLBQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:from :dkim-signature; bh=oNioNdguCz5tyqf3w8SAJg3WWFu/ZpF1hV12mYbLuZw=; fh=HRphVwWg1yewYpoL1FjVLqQFj2p2HKZo9o4Fd/3UA7k=; b=f5E5WL1LX24BN8+LatVPD9Zm9mkrakDXA4fPvFn7WWKo+HdG/jBYYlBU8AbHr4xYcP mTdTdDJpCXhT5+JDTG3iD2gKHT+tzscW4dx9/4NesA9QA253am2+cfR2ZJlQnk3mlGQI nruONb3gBCxGAuSC+DMVvpR+UhJbDVbaQ9zcAIfRNeyAF1ms+MoADUKR/fTUorN4SjRQ R+EHkxJ9/yGU0COpv+8umambeL6WsQ4Wso199/sAliLBhx+F7XTvE72YVLPKKObweK2p I7TXUD6F8mo8432QriWFBdMyry4XgqN+dik9fYq4TsAoSW0Ng6Tf4/bH8SMvvrjyKLlV snNg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=M3nABIb8; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-62543-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62543-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCUx7SEIRnunc/uZTAz5hNTubEKgBqCASldnghzv0OQCGV5cfAuqV2gnHCeHL74p0aPmSf4rgCrSIkgEMkeOH3i9mwVtHs/3EnF2OSRETg== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q15-20020a170902eb8f00b001d70fef0d09si982758plg.52.2024.02.12.15.36.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 15:36:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62543-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=M3nABIb8; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-62543-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62543-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9E25C2847E1 for ; Mon, 12 Feb 2024 23:36:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DFADF5027B; Mon, 12 Feb 2024 23:36:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="M3nABIb8" Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0528C4F611 for ; Mon, 12 Feb 2024 23:36:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707780994; cv=none; b=nL1c36eZ7KmsmLeh3fShrkmWOCm5W2mML2j0G96kVpqA3w8QFxmySo+QvhLHYy8JGM0lLlA7jEIrsj9KuzsnAQxuWLqbfzSgMURt6jwcSj2NpzOjdAJ9cRDDk7LIoyt6UBWgu2tmTpUKgC5irDQPoBur8rc3CfQ006X8BGguN7I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707780994; c=relaxed/simple; bh=pUkJcJN2rctCyQ0hK/qiJS411FCsdKiJii0pjIPLWbg=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=lyWsfMTXW44g4juzS90IUlgKEETynj6iu4h0n++cdQzOzwZSCrqhL8Hw58vdHfhmeQSwOMZtnqIMnIn4kU1CPFa5x2+l/KuKtf2zq+vm2svUVQcf3MfIbdhQuNfG9hQ/LILg3cUl0bdkbfoG3qwaAFcqhjkZIYa7McKrIEosAJ4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=M3nABIb8; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1d780a392fdso31488755ad.3 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=vger.kernel.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=M3nABIb8Duqd1/WqTQLCDTwxg+B5jxrOMCM13OuQ6X23HAea/NPLKfEUtTITKl9omP Uq0BBS9EazJ9EUgNwwRIXhXU1yEO8EdObHVoVdX+EVs2Csqln6APqSx9Ote7dDmgvRMc G62DiHTNe7YkhRuBuyaLgdEzd56pMZpHtftQcRDfPwTnI1M458pxlQeHExvZq/yu6Hg6 BiMzBTvDtA1yKEW9S801lDi8t9oQE1HiBqrtuia6wnYP1zzge75zxYfVCBxaNj+DAsZ5 IexEU6twYcCZ506jEYh4UyQbg9m40IVi8RWforSrnW9ASDi1/vGDW8lFCoO3qT/u7Jkp 70tw== 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=FSrLlfb7sXdUY2Urr5Fja6CYd9Y6fRhATISI48ljTk8NbHCh1LE5nQAbBIIgy9Y98d idVDsgVy90q5Ah4LAV4jeBNBqxWFIQxxYjGMvoVXMVli+gJ1Y7PijAcdzG8GIAkvrkT4 4FxvKok8rNlc76M+45vqOqeXefaubeuFO50denFb3dabZ47e2wo/dS2Yq5714oSWutd6 avQ1pj6XpbbrW0ezQGaSOqyhHr3IO11Hu34A3Cp4czG2QzenUTpSBTXkcrMt+HZfYaeO S4RfIWUmkpILMK5ZaQ3lDFsC4uHeZW5jBfTbIDJRq3g6eGSjqIqVO51RkeZz2FrwrQ9E zfiQ== X-Forwarded-Encrypted: i=1; AJvYcCWUyNBvqQPHl6J1Ml/Djc/BoemGaW6K1RBSGFMxFEj+AJhx8TCxOgY8SLzg7lxKoyR66Kbt9Y9AWmIb+ZZovjTaQaF17QvJViTmfHaY X-Gm-Message-State: AOJu0YykEYtFgMRkqV+C7/jtmZj6DqauVGmYrAAmQzseCwNg8cZeoNhU yk8c28Wl7oGPmubh1UdyNbKZuXYjdStHXlR0/TqvPf8tReig64CtM9asbLjeYwU= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit 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?q?Cl=C3=A9ment_L=C3=A9ger?= , 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= 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 -- - Charlie