Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2554611lqz; Wed, 3 Apr 2024 01:08:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXmAdjtKSFYAdP8jucVTk7/nQk2LCnaFgipWUT4f2gPcV5L7kz/OnKCIwBXYOyTvgFqqwd81pxFkzRfzvlh5JsrCbanLbbEtzRFsD7J9A== X-Google-Smtp-Source: AGHT+IGicMo6QrTa7mnCl6VEnAhavap+mel6vZ/8kClBvvptRW7HkIW3pvGD8vjBhnHrTf4+OEDa X-Received: by 2002:a05:6512:53a:b0:515:d1f9:983e with SMTP id o26-20020a056512053a00b00515d1f9983emr1189315lfc.12.1712131704724; Wed, 03 Apr 2024 01:08:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712131704; cv=pass; d=google.com; s=arc-20160816; b=OJjt6084ESQWtMrDTTQ6pRfKOvTNTFqp4dEMqHnBSFLfaEcquVowG42PdUOBn6MShf AtDLnNcL3W7CB9s8f8fTpF5+kbBATpR4R+0kdDjTo3eA49cAd07/N/0sVf9Ja5xer1C6 AM5kvqEVvDNZ0/RXx1uWvCv5DFTHj+WCCWEu1H0Zg+hWPSSvIHq5DfmQwZR4W4sGGOXL e0Ygmn9KmhI0TPbjorXlIChgtuyvOk1EY32uJLATu8ZqOijbKTBQvOuxSFuOqq0jSzX7 zvzcEWp03eYdu6CxExVDlQI3UEPxDCOiCEvqcmF+z1u0XmDEoyULV7qCl3tzhPsbJJi0 rI7w== ARC-Message-Signature: i=2; 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=oLadZMY/1E+aj61iqE390ie32fUnJXqsMN5cFXtebck=; fh=FLpiMa9kEn8Z97KGtNRYhSSd4Gdu2dBQ4yB81EkCLfM=; b=PvFzzD8B1ElEbAh7o5IbTIhxzlqTKyelIXDeTnodKiFxEhiIFw/BwtUnBwwgUf9i/x mBUBhyEj/LJLIjsTi5/6Ij1VG/U5T/nRjJPRdcO4uQSEzAjtvzOuTomkeF3oLVN6z0G2 u9XACL8UjdgCGEF/WhdlvKKoMVruYByWrT3XO/H5ySF4lP7hqjkoad4uqsqaO3OMEva7 Jsb0PGnnahEtJdqM8xDDl2AJTlmuTC1UnkwW01vsNv5jt7f2UUpxDcsj1j6LvOfsgsc7 fx8RnS5qPh8dwzVo2J9rtTvWyTiZpY0007/hvjF5tSPNiqCtDrxAMUOdqzokl4MCBT7D jhJA==; 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=LoaKepvw; 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-129250-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129250-linux.lists.archive=gmail.com@vger.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 m18-20020a50c192000000b0056bd5d042d6si6587293edf.33.2024.04.03.01.08.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 01:08:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-129250-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=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=LoaKepvw; 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-129250-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129250-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 5A5371F24EA6 for ; Wed, 3 Apr 2024 08:08:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0687083CDE; Wed, 3 Apr 2024 08:05:37 +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="LoaKepvw" Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (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 B74A182C7D for ; Wed, 3 Apr 2024 08:05:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712131536; cv=none; b=T0qbfAa63fLLdf8eU+8/Drt6WxqVbEOTfV8IbK494gPt2jGr9F5mjgexq+xY7zEU7Oxq8xoj98gq6L550TGPFSfQsfksih7//qq394Dw003AJCv31n7pktKwtLweg7/5zoWXfNOr9d5PRBLQw4ABVihSXCFp4dHxlZ3/kITcyqA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712131536; c=relaxed/simple; bh=+BS7mctHpN9iWLFPEwC2/74zIoWzY97OXSTjHAOIU1s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=o34/xEIVKVwRpYeF4+fVnxTsQICBJhIy+5wLhUJ5EWm6hpAegM3LXWP2/kkVxB1MiPUl6PW63qkPKBZZ8oiDBh3AFozERcxOoUg3QpGs1HxC+EFZwOuTJFPKb+uCOvaZh9Yh3/upmYfX7dGSl9j7rS4pUeaDL+1RwWqNHY98PqM= 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=LoaKepvw; arc=none smtp.client-ip=209.85.210.178 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-pf1-f178.google.com with SMTP id d2e1a72fcca58-6ea7f2d093aso5682243b3a.3 for ; Wed, 03 Apr 2024 01:05:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1712131533; x=1712736333; 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=oLadZMY/1E+aj61iqE390ie32fUnJXqsMN5cFXtebck=; b=LoaKepvwpIgMgTETh3kzvXiZiZwSk+B9o73db2yUsrHf0PeqmmT4O4FXUjdiF6lgH9 +SJTk8Gp6utJJzIeThkrwLJp0MkiycHvkrPfjfaUDYF9G0kuF2olWU0A9/MGQcI/1YHq ePSbSQa4NDp1GdSg5ozbKaFx6dny/viVqIQhIhfawKkC8GCzYZ86G/Np1ZnrHtrEdzFG Ia31qc9p6AvwgtLwXeT23pDuQCNoDayhHtGguhQ//jSZsvEW+nsWqQ8tNS7uMugcnWK2 0qApW4wFGj1MmdZNsRCk5LFO9sekAdwsTLJCTs9wmR3OsbpnYZmHXW5TFHHWYI76Z315 17Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712131533; x=1712736333; 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=oLadZMY/1E+aj61iqE390ie32fUnJXqsMN5cFXtebck=; b=NIeHzEP7OLh2l+0+ODQul6XTABgPdYjqZuAhli3nNJn8IuBk+zKLSBDS4t+DGosy/U B2t1Vq7QbwM9w4oJQ5rEKBkbnRKlvXssWNFFQ0GQ8R5ErGDCiP+EkEaXnYd1uQlwqDh9 qVgBo27sYbRa8vCsQxAlOT62BHXlMfftYqaUMR1XbmQYK+XAbr+Dtw2E3e4Ieq2w23W1 rnPnbQaOTcZuQwO+VXy1uiJJG3WVQ9f4z9DCgc8WjWl11gqoOVbegnZOBluhNL659tIo Q4/RUlwAcja/kiHhoj0hv6BeW3mVxuW8NDhK+mZNfXyYPVvUWA69RpQEAvEbm7zWNISi EKRA== X-Gm-Message-State: AOJu0YyyBG/TtUTy1KYJ24q63wzgGkthzkH6TrKi6+qkdBPtTJxVLVkl 4urP2HTOpdeKZXzmLLWoiw8SMaENFZAIN35fXpt9yfg1+UH8ZU9drGmlOUCqlx9TiB9BWxSxJ9q / X-Received: by 2002:a05:6a21:3294:b0:1a5:6a85:8ce9 with SMTP id yt20-20020a056a21329400b001a56a858ce9mr2619252pzb.12.1712131533285; Wed, 03 Apr 2024 01:05:33 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id c12-20020a170902d48c00b001e0b5d49fc7sm12557229plg.161.2024.04.03.01.05.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 01:05:32 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Anup Patel , Andrew Jones , Ajay Kaher , Alexandre Ghiti , Alexey Makhalov , Conor Dooley , Juergen Gross , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, Mark Rutland , Palmer Dabbelt , Paolo Bonzini , Paul Walmsley , Shuah Khan , virtualization@lists.linux.dev, VMware PV-Drivers Reviewers , Will Deacon , x86@kernel.org Subject: [PATCH v5 10/22] RISC-V: KVM: No need to update the counter value during reset Date: Wed, 3 Apr 2024 01:04:39 -0700 Message-Id: <20240403080452.1007601-11-atishp@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240403080452.1007601-1-atishp@rivosinc.com> References: <20240403080452.1007601-1-atishp@rivosinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Andrew Jones 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 cee1b9ca4ec4..b5159ce4592d 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; } -- 2.34.1