From patchwork Wed Jan 10 23:13:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 187109 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1110831dyi; Wed, 10 Jan 2024 15:17:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IF+GDcA25e+gVq7vobO9KqAl5qPKPZXt/P2jOkrREW5WpGsB3AG3Jt5YbSFYy7HcUz5gae0 X-Received: by 2002:a9d:674e:0:b0:6dd:e4bc:6353 with SMTP id w14-20020a9d674e000000b006dde4bc6353mr423734otm.71.1704928647477; Wed, 10 Jan 2024 15:17:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704928647; cv=none; d=google.com; s=arc-20160816; b=RJnrqW2pD7EiKtDh1vq9uegY78+9ePHfTt8qOjhGVy6dke8KekCy6oisnSn58Sx5rQ A/tFcEgLNg/rrhfhbhzxc09LqwsUsyZohw1JYgE52zE6o1c0KdItL5XrFHGtKDNwkCB6 zefO4SvwsZuVBKAM2uEN1+Y4veEuXAo22RnsYSYP4Odbm2JIqIr1uA355EvUmwQ7Krqk okmw3VjQhjmdzFWTs6ydrXVSMTKVaJluF+C6Dsy57HXGdjgQ1U+ialch32sb3Ybm0Ia+ JdglHsl5Q1fR4NcFyLXFatQCeap2N42lYwRSzP/KC8EzQ6GybxP1KbJIUt1Hj44mbPL4 xRxQ== 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=QezjoA6tUvS/5tHzC/r6igb3Gn0pDkI0esE0F/349nk=; fh=wAXPU3FcJaKyT/S431cGy/57pKkDY1VtUcX2OXS/8Xs=; b=G1GYmv5yVGfM1VR70qZEDdwOxgupK13/KKZkGj5IwD0UMatFjQQiWnMusdBKZ7SNAM ulyaBUvOQbtILAyiQlPIGH/A0c66hXHnQ5y6/RDhfe+gYk5aMfFZn9Z3M5Qd8W268ggE ieqZKCmoqMXOkzwx+fROTuhhxJLsKORoqzYu+PrVFtuhencqY6c777a6z9woYoxafQJw BBM4lWh9xMbT4cnLH77mjWxr8sggrvpgCTZSvB+ROZcI1FMm7FE8BJ+A3xB1G1vzy85w MgD5weLMC6WacMnRTo9G+MAtfW6lpzVt29VIZdMZYbWcIixmPCsWgUGBgoKNVo00yjew 0p+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=aJ1KB07B; spf=pass (google.com: domain of linux-kernel+bounces-22882-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22882-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id r10-20020a63ce4a000000b005cdab7a395asi4733519pgi.349.2024.01.10.15.17.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 15:17:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22882-ouuuleilei=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=aJ1KB07B; spf=pass (google.com: domain of linux-kernel+bounces-22882-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22882-ouuuleilei=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 27E20283BC7 for ; Wed, 10 Jan 2024 23:17:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0BF3855C32; Wed, 10 Jan 2024 23:14:53 +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="aJ1KB07B" Received: from mail-io1-f52.google.com (mail-io1-f52.google.com [209.85.166.52]) (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 1ACB2537F5 for ; Wed, 10 Jan 2024 23:14:48 +0000 (UTC) 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-io1-f52.google.com with SMTP id ca18e2360f4ac-7ba903342c2so297740139f.3 for ; Wed, 10 Jan 2024 15:14:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1704928487; x=1705533287; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QezjoA6tUvS/5tHzC/r6igb3Gn0pDkI0esE0F/349nk=; b=aJ1KB07B8xihJBHSJu4x2wtWXbNbhYGzAFZGya+OUrELM3nq3Eh9ov7hLGURIubBOQ UYKqK+jOqqrTbUsmKI9l8CXvfgBw8+8XEehKCQiH/hD6l7t4o5Ntko+7+ItTDOd6PsBp 0+7c3BwXyQu+dEj9dZ6l9eTHn3/DcFLlnn8uX0YUPQHo8ZneH9fIwhA3lFMIXeQSvLfH zJj0dvoNbYIHSXVZdOiyMEDIiNmZirnP0ao1w90AFeFIDbZ/A9xymJ6zNO8Z0A/zaAQJ IC2dt27Am5lZdmiABZoiC9jLsvIHVDxRKjp2kYhKcR0QbGct0Zc6K2d8mRlvByZamvR9 ptiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704928487; x=1705533287; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QezjoA6tUvS/5tHzC/r6igb3Gn0pDkI0esE0F/349nk=; b=udKt+jbGx0qGElXewwk2uAAx0hIybvNB8qkwDSv/KyN8vtwWRGmXhL/3lU8yDBoYLI c3DTp4mOQTV8bExU2IN/O13UaXKidYXJOpdbIicV6J6t22JatE3zr8S2ROVu0P6XkeKN FrgNM5/KrpnF/dlK+BeuOTxFfGxXoWTlP6DZ37X06uMABJHji2dVL4XtfFVMtmoI1aBl C2qfrYzeaV1B0fxazUhdQFnCQZvaciTLuWCo+xFwxwjYK1uKKYGvBe2uiU7QOl9B0+q6 z6PB7AqhsVJ9QnHmzNXBZVyB3ZjKvHVgrbvoj/uWLKi9n6Cj+EWAZzm+xlrl5BvoG6zS MEnA== X-Gm-Message-State: AOJu0YzX+qzTmnVQEVe26UnZsSJe42JZ8Q+LGeyL/xGGCB6CTurFFo4i 1uBNAtsyVGFYaq+o++s3JhVp1WFbLELmp4xcjHc8Hv4cRks= X-Received: by 2002:a5e:890c:0:b0:7bb:df90:6936 with SMTP id k12-20020a5e890c000000b007bbdf906936mr380036ioj.41.1704928487361; Wed, 10 Jan 2024 15:14:47 -0800 (PST) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id co13-20020a0566383e0d00b0046e3b925818sm1185503jab.37.2024.01.10.15.14.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 15:14:47 -0800 (PST) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Anup Patel , Alexandre Ghiti , Andrew Jones , Atish Patra , Conor Dooley , Guo Ren , Icenowy Zheng , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-riscv@lists.infradead.org, Mark Rutland , Palmer Dabbelt , Paul Walmsley , Will Deacon , Vladimir Isaev Subject: [v3 06/10] RISC-V: KVM: No need to update the counter value during reset Date: Wed, 10 Jan 2024 15:13:55 -0800 Message-Id: <20240110231359.1239367-7-atishp@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110231359.1239367-1-atishp@rivosinc.com> References: <20240110231359.1239367-1-atishp@rivosinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787747261650909948 X-GMAIL-MSGID: 1787747261650909948 The virtual counter value is updated during pmu_ctr_read. There is no need to update it in reset case. Otherwise, it will be counted twice which is incorrect. Fixes: 0cb74b65d2e5 ("RISC-V: KVM: Implement perf support without sampling") Reviewed-by: Anup Patel Signed-off-by: Atish Patra --- arch/riscv/kvm/vcpu_pmu.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/riscv/kvm/vcpu_pmu.c b/arch/riscv/kvm/vcpu_pmu.c index 86391a5061dd..b1574c043f77 100644 --- a/arch/riscv/kvm/vcpu_pmu.c +++ b/arch/riscv/kvm/vcpu_pmu.c @@ -397,7 +397,6 @@ int kvm_riscv_vcpu_pmu_ctr_stop(struct kvm_vcpu *vcpu, unsigned long ctr_base, { struct kvm_pmu *kvpmu = vcpu_to_pmu(vcpu); int i, pmc_index, sbiret = 0; - u64 enabled, running; struct kvm_pmc *pmc; int fevent_code; @@ -432,12 +431,9 @@ int kvm_riscv_vcpu_pmu_ctr_stop(struct kvm_vcpu *vcpu, unsigned long ctr_base, sbiret = SBI_ERR_ALREADY_STOPPED; } - if (flags & SBI_PMU_STOP_FLAG_RESET) { - /* Relase the counter if this is a reset request */ - pmc->counter_val += perf_event_read_value(pmc->perf_event, - &enabled, &running); + if (flags & SBI_PMU_STOP_FLAG_RESET) + /* Release the counter if this is a reset request */ kvm_pmu_release_perf_event(pmc); - } } else { sbiret = SBI_ERR_INVALID_PARAM; }