Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp2297699rdb; Mon, 25 Dec 2023 05:03:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IEzqRFSdy8nTebKaaGUFbFC+IfRIFIv3P6MaOX3E+bOP7XdyYkZxzKG+e+xsUQjo4J+y8su X-Received: by 2002:a50:c342:0:b0:54b:17c:d001 with SMTP id q2-20020a50c342000000b0054b017cd001mr3746823edb.29.1703509419007; Mon, 25 Dec 2023 05:03:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703509418; cv=none; d=google.com; s=arc-20160816; b=Ve28bvjghjewsCijhV/w9ZD4TyfNKLMVB+mqlrxN8f5zp9N8g+IbMycl938MoJ62cw ZdDpU6yVI7cRB7bt5/Lhz881KVsPn6r69Qhv+pjRmR8JHHKaCAHEgZ2CSezvfuRp+r0G zf4zCpvcc4L9vCY5ydxWTcAUbU1tRC3HNC1MO5D1c7+zuLTJLK5tG/+oU8YwaR9LiQSo 1Izd3ql47AC6Bu51Y8ap2f6CsbyF4EsirGaWVpn7WpDsxvIsSZQuXgqKXgZzr40ZyE3k H35VsD8ENQpneYxBOrYi3pN8FoSdyFZMkFDxpm3sMY1312DL7Frn2lf/K59C6xdLd74Z ptRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=q+iWkrut1EblBc/094DgkH0tUg2g8JSUJDaWosgKAvE=; fh=aos4oD+Llfsos2DBOalqQJ69U2YLuKYcVP3FbCBwZDg=; b=hzAzsc+uRqD3l9d6GDUBGbQkrQbBLGtcstkJ3Ew+85c+k204WHWrEOTCWyT4JHLkeB +2EKQnR4/1PcCbBwnpgQPF/EiogMxq8bng3vT8VDWrWoLn8U8lnmFTnj28AOExTnbi97 0ewOrr/UCjE9UQQB5Arku8p1O0En+JOPBMSyurBPzHgFzqNwIw44XjEmVIywha82LNyZ FrqZ7g2J+FY1DgIRR3uvdgfDZVPGjDariMspSb5rchhTQcQLypbyY/c+OvHyEH5hujnQ 1vPaX8SiPlmBjvAK9RFC6qPGzEhq/dFf0WubwpY6/YbauKkiZyjwjK7NI3AJJEU4fjrY Hxhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HHLBBAnp; spf=pass (google.com: domain of linux-kernel+bounces-11054-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11054-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id f10-20020a056402354a00b005536e351556si4661083edd.359.2023.12.25.05.03.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Dec 2023 05:03:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-11054-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HHLBBAnp; spf=pass (google.com: domain of linux-kernel+bounces-11054-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11054-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 am.mirrors.kernel.org (Postfix) with ESMTPS id BE7EE1F21227 for ; Mon, 25 Dec 2023 13:03:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8ADA155C22; Mon, 25 Dec 2023 13:00:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HHLBBAnp" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C028E55C00; Mon, 25 Dec 2023 13:00:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F47EC433C9; Mon, 25 Dec 2023 12:59:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703509200; bh=ODSRlqemB7gRQiZhfDlWrTaT1uOIIWzSdyDrN4uUjz0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HHLBBAnppN8o1pDLvfunhLB3Lt7KIVadT3NnTcn5SeCKjvTRQgM4K4iXQOFErew9F ndXJaJGkSxgn856NCf4OewK7dyrSqkDQlE54srL+wIlNRs7pOZODCz4VUwGa6Xmf6+ bp+vPyCJJZYfGRt569xm7px0kHlXZOtgnipq7eozxtZM4ImLOAEwbhMAAXaRmPEzNq Rki4RUiNkCK0vHj8j0j1huJYkDKcuGN0Q1v2LP/OGvHeytt2O+/tvNuF2pd6AeGDdb St1pQ7BXZ7AreXCvnoA6IBJWYdBdFLfdHkFqR/ZEYRAToqSyeIX1YenPa9Dz0T1bpf NZ6YmbH9G5kTg== From: guoren@kernel.org To: paul.walmsley@sifive.com, palmer@dabbelt.com, guoren@kernel.org, panqinglin2020@iscas.ac.cn, bjorn@rivosinc.com, conor.dooley@microchip.com, leobras@redhat.com, peterz@infradead.org, anup@brainfault.org, keescook@chromium.org, wuwei2016@iscas.ac.cn, xiaoguang.xing@sophgo.com, chao.wei@sophgo.com, unicorn_wang@outlook.com, uwu@icenowy.me, jszhang@kernel.org, wefu@redhat.com, atishp@atishpatra.org Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, Guo Ren Subject: [PATCH V12 12/14] RISC-V: paravirt: pvqspinlock: Add nopvspin kernel parameter Date: Mon, 25 Dec 2023 07:58:45 -0500 Message-Id: <20231225125847.2778638-13-guoren@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231225125847.2778638-1-guoren@kernel.org> References: <20231225125847.2778638-1-guoren@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Guo Ren Disables the qspinlock slow path using PV optimizations which allow the hypervisor to 'idle' the guest on lock contention. Reviewed-by: Leonardo Bras Signed-off-by: Guo Ren Signed-off-by: Guo Ren --- Documentation/admin-guide/kernel-parameters.txt | 2 +- arch/riscv/kernel/qspinlock_paravirt.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index b7794c96d91e..4aff81d741e2 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -3927,7 +3927,7 @@ as generic guest with no PV drivers. Currently support XEN HVM, KVM, HYPER_V and VMWARE guest. - nopvspin [X86,XEN,KVM] + nopvspin [X86,XEN,KVM,RISC-V] Disables the qspinlock slow path using PV optimizations which allow the hypervisor to 'idle' the guest on lock contention. diff --git a/arch/riscv/kernel/qspinlock_paravirt.c b/arch/riscv/kernel/qspinlock_paravirt.c index 7d1b99412222..4b04c93c4b9b 100644 --- a/arch/riscv/kernel/qspinlock_paravirt.c +++ b/arch/riscv/kernel/qspinlock_paravirt.c @@ -43,8 +43,21 @@ EXPORT_STATIC_CALL(pv_queued_spin_lock_slowpath); DEFINE_STATIC_CALL(pv_queued_spin_unlock, native_queued_spin_unlock); EXPORT_STATIC_CALL(pv_queued_spin_unlock); +static bool nopvspin __initdata; +static __init int parse_nopvspin(char *arg) +{ + nopvspin = true; + return 0; +} +early_param("nopvspin", parse_nopvspin); + void __init pv_qspinlock_init(void) { + if (nopvspin) { + pr_info("PV qspinlocks disabled\n"); + return; + } + if (num_possible_cpus() == 1) return; -- 2.40.1