From patchwork Tue Jan 30 07:22:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: maobibo X-Patchwork-Id: 193864 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1050676dyb; Mon, 29 Jan 2024 23:23:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IHfAYgfhNFE5/foxMCD0kEKIPWMyEOmcbkfJ7STVnwROfyWmkFND60nHCeoVCtjF0AsSUVU X-Received: by 2002:a05:6214:ac4:b0:68c:44d9:4d6b with SMTP id g4-20020a0562140ac400b0068c44d94d6bmr7052808qvi.20.1706599404033; Mon, 29 Jan 2024 23:23:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706599404; cv=pass; d=google.com; s=arc-20160816; b=MR5HrOUTazxHiirn86V3gimBTd8tFXVHyt0A4Ic881JIgozFRYWn3Pd9QMMvDz5yBT HG2jgfUPPrjL0WyuzKleCsznPKyxweO/mc4SQ+B3yX/X9do/calZGz7Y156RlzFO7o2G hLuk+c9YmsxG07VY1zb4M5d7rbF7RAHeFD7iRNo8rbaidbi5g6i6s4x2XDg07F3UwnPZ U7blg0tf8UTO+PT4qc31QUI59uwqTFCC7llp8IhmwBGymR3TIyiF/0obMB+LYGLBKL0a O8Jj2tweYZY96pZ1GyVVbz8tiGeyc33ldgGB0Ur5HRO/FP/ZwSX0PjSBG08TWIdYYr3Z 0jWA== 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; bh=S1rIoQDrlZPzKFHNYqD9GFcZ5J3FT/QN6guvCClpuNU=; fh=x/Bt1aIM1r3EQAi+gC/DzSsKR75c0gIQCHo4YyJmMCE=; b=FEvD/MDckV+oGcCUzS68cV/GpTwq0NEBz7w8I8aSk213E9TolGO6lW02+/cJj2z5hQ AXtWtI1bWcIWkpJ99sMiHE//KobsVqi5cEhuPLXKs9+JqNe5/+Fyfpgfavs4ypmhldgU pnxO8+X6Xq132S3DJX/ppYU1HMkrxNIRIs+jjtiE+76q0Yahctp9ECwyv8uAU+npXnpJ ju21PIJU/ILujWKc2fVF+cqHiVqaKFJhq5U6laQhumQMhDLUEsA6tJkC2Lk6nE7aF5Xb 4Hx9udQOWyIGRhQQvuOqFr/+/mSrBCgjcTyxJbE2bc9fPgU8q20Ib2jPNq9ADLAO5ggW NNyg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=loongson.cn); spf=pass (google.com: domain of linux-kernel+bounces-44037-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44037-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id iw7-20020a0562140f2700b0068c4088317dsi6635925qvb.49.2024.01.29.23.23.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 23:23:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44037-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=loongson.cn); spf=pass (google.com: domain of linux-kernel+bounces-44037-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44037-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id CFE071C255D3 for ; Tue, 30 Jan 2024 07:23:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 75A3153E07; Tue, 30 Jan 2024 07:22:46 +0000 (UTC) Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 49D8951C38; Tue, 30 Jan 2024 07:22:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706599364; cv=none; b=CJv3DQmdJchOfoW3u7DBmj8CnLCYJ/bPaP0mGdj+SOu/D4NSFg9vDwjU8CjiJTpDyStocv937SeKqc2ifeIlCAnrOYSQvZ5XcgvAaT5jfJx7D0LlTo0mOc2U+dO1YUKcSxU6HSaWFbKM+Q184yW6Xv+j5tmFWrgZYSpZpHwvt50= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706599364; c=relaxed/simple; bh=Yusrw8yR1q3K2wILNjHvC0KO/QfZjjXjrb6GyWBsDVI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BVBnY71kqcbw0WFIZXFRk1Dyg59JJQXeeC1dTKXjTQpOeW4R5dB2fVlrVBINuo3dJ+wZDWxHHeOiuIwphjdp3EH5JWhPHTXbh8zdp84seFIyC/oGSOWhievOMHPCCWztH2HVbiCEzLU3QLOviHeJaJ4nsOZ+ssLxHNXMMGtTo0I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn; spf=pass smtp.mailfrom=loongson.cn; arc=none smtp.client-ip=114.242.206.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [10.2.5.213]) by gateway (Coremail) with SMTP id _____8AxeejAo7hlojoIAA--.5850S3; Tue, 30 Jan 2024 15:22:40 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.213]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxXs2+o7hlPo4nAA--.20587S3; Tue, 30 Jan 2024 15:22:39 +0800 (CST) From: Bibo Mao To: Tianrui Zhao , Huacai Chen Cc: kvm@vger.kernel.org, loongarch@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] LoongArch: KVM: Start SW timer only when vcpu is blocking Date: Tue, 30 Jan 2024 15:22:37 +0800 Message-Id: <20240130072238.2829831-2-maobibo@loongson.cn> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240130072238.2829831-1-maobibo@loongson.cn> References: <20240130072238.2829831-1-maobibo@loongson.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: AQAAf8BxXs2+o7hlPo4nAA--.20587S3 X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBj93XoW7Aw1xCw4DGrWUZF1UuryUArc_yoW8tFyrpF Wxuwn2gr4rJ3yUX3WjqFs8urn8K3ykKrn7WFy7Ca4xAwnxXr15XFW0kayfXFW3Aaykur1S vr95tr13ZF48A3cCm3ZEXasCq-sJn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUvab4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Jr0_Gr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx 1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r126r1DMcIj6I8E87Iv 67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2 Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1l4IxYO2xFxVAFwI0_Jrv_JF1lx2IqxVAq x4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r 1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF 7I0E14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxV W8JVWxJwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxU 2nYFDUUUU X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789499176624541279 X-GMAIL-MSGID: 1789499176624541279 SW timer is enabled when vcpu thread is scheduled out, and it is to wake up vcpu from blocked queue. If vcpu thread is scheduled out however is not blocked, such as it is preempted by other threads, it is not necessary to enable SW timer. Since vcpu thread is still on running queue if preempted and SW timer is only to wake up vcpu on blocking queue, so SW timer is not useful in this situation. This patch enables SW timer only when vcpu is scheduled out and is blocking. Signed-off-by: Bibo Mao --- arch/loongarch/kvm/timer.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/arch/loongarch/kvm/timer.c b/arch/loongarch/kvm/timer.c index 111328f60872..a9125f0a12d1 100644 --- a/arch/loongarch/kvm/timer.c +++ b/arch/loongarch/kvm/timer.c @@ -93,7 +93,8 @@ void kvm_restore_timer(struct kvm_vcpu *vcpu) /* * Freeze the soft-timer and sync the guest stable timer with it. */ - hrtimer_cancel(&vcpu->arch.swtimer); + if (kvm_vcpu_is_blocking(vcpu)) + hrtimer_cancel(&vcpu->arch.swtimer); /* * From LoongArch Reference Manual Volume 1 Chapter 7.6.2 @@ -168,26 +169,19 @@ static void _kvm_save_timer(struct kvm_vcpu *vcpu) * Here judge one-shot timer fired by checking whether TVAL is larger * than TCFG */ - if (ticks < cfg) { + if (ticks < cfg) delta = tick_to_ns(vcpu, ticks); - expire = ktime_add_ns(ktime_get(), delta); - vcpu->arch.expire = expire; + else + delta = 0; + expire = ktime_add_ns(ktime_get(), delta); + vcpu->arch.expire = expire; + if (kvm_vcpu_is_blocking(vcpu)) { /* * HRTIMER_MODE_PINNED is suggested since vcpu may run in * the same physical cpu in next time */ hrtimer_start(&vcpu->arch.swtimer, expire, HRTIMER_MODE_ABS_PINNED); - } else if (vcpu->stat.generic.blocking) { - /* - * Inject timer interrupt so that halt polling can dectect and exit. - * VCPU is scheduled out already and sleeps in rcuwait queue and - * will not poll pending events again. kvm_queue_irq() is not enough, - * hrtimer swtimer should be used here. - */ - expire = ktime_add_ns(ktime_get(), 10); - vcpu->arch.expire = expire; - hrtimer_start(&vcpu->arch.swtimer, expire, HRTIMER_MODE_ABS_PINNED); } } From patchwork Tue Jan 30 07:22:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: maobibo X-Patchwork-Id: 193865 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1050760dyb; Mon, 29 Jan 2024 23:23:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IFyosvmfC5wSURf/COElZfWcPpIIJR748uhU37itT5khpSBks9b8RT8HuA1uhqNkqiFIl/Q X-Received: by 2002:a17:906:29d9:b0:a31:13e5:8fb3 with SMTP id y25-20020a17090629d900b00a3113e58fb3mr6081949eje.38.1706599420998; Mon, 29 Jan 2024 23:23:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706599420; cv=pass; d=google.com; s=arc-20160816; b=hbe4DHAHXwq9+72VvYxqCufwZHtXVxWLM8Xd0Pn4M1+l3i7DCDX/F+KvoNPmebDgyI 1zjDxAW+5evh2EPQkUmqGW2WQ1IBUeNWU2fXzeHk2gjQu/Zg9CVBIsgLQuZN14h5sLlk u+9yFdDQxKp0omsKjnbeCEfObB/ewKoaK3XWunYiGmWocp4S1m3BRszB8FT0oS/rS+fx 4Zgzx+cESex6mfoDdr+1okdxr4gt/2KwMNoAdE9H5KOe5axvRcjDYVASDbMJs+U/vdjN RkNncnhqKyi0Tx+cCouf2ZL4/KfpCKwk8kfc6YAmjJwUxuK+6qinJz1R94ka4pId/3dx IxiA== 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; bh=Wefg7VNTMjBZn4em3lD/oDATnJiYRQdwjgMqz98mdRA=; fh=x/Bt1aIM1r3EQAi+gC/DzSsKR75c0gIQCHo4YyJmMCE=; b=xKgueYEfwtfnGVRxDzFLvwB50D5ntvzJxFnhfHXjM5JIQCBX+DpbKR5kg7ZjgPopZy p/itRoDyPHqSHt6aVzWNIKv3d4obs/MYZocxLUkf9/shkoEzRUyg4i6IGX1Mb/pH4A98 reFeSs2k0Oj1wO/Ap19O/Mdk/HlbX7ZS9z0OW9NpFNHTqY65JJi090E6MRLeJHlSUhKK 8gh3Dowkh0rSKzBQZYfuInxs/6irgUHzN39p4fJ78TfbM2kyuKOnkUAue/kaRNzpaR/2 WrTWt59SlSi/GX+TirXJArPrpW4PdQS7RpoO7nHRFrshp0NuzkzJQG5j84P9pKKWEW6r i8rw== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=loongson.cn); spf=pass (google.com: domain of linux-kernel+bounces-44038-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44038-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gw18-20020a170906f15200b00a361abbdbbasi436117ejb.943.2024.01.29.23.23.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 23:23:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44038-ouuuleilei=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; arc=pass (i=1 spf=pass spfdomain=loongson.cn); spf=pass (google.com: domain of linux-kernel+bounces-44038-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44038-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 9BA951F263AF for ; Tue, 30 Jan 2024 07:23:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C044956B94; Tue, 30 Jan 2024 07:22:47 +0000 (UTC) Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 00646524D1; Tue, 30 Jan 2024 07:22:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706599366; cv=none; b=uQX6L2jV5W41zSss8OKZVXPCkTi3wcUzyQjUhbEWz8VWUq1o2xxGJiQa5HQpEeG2D5Gkh2futFOdlM3d/Z21jbUdHp9g3R2Gcy1OaCY4fIHMYqm/pvuNdlnFUVMGiI4XDLMZOWM93nBY7zwn+Fv1pO83VWUExlnCF5zBBiPTnZQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706599366; c=relaxed/simple; bh=5t/MLIYK4bbQZ2ZQSJsYvzr+aXUvmNa0VBuiVYLdr+A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fSmqJpPuC9NsmeAYY0kgNV5uML0cIz8k344iFNt1RRTz9dQawedjyQxZz7xBnoS4xA4TGqLmwsvmdLMvcdy1I/66sS1bckfHjZtvuNKQj2feyzmMUaPNECNEgOTOVg4VXlgJ9HOirCK/A6P/m+W9rC4YRaCk6STjzAXwmViqom8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn; spf=pass smtp.mailfrom=loongson.cn; arc=none smtp.client-ip=114.242.206.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [10.2.5.213]) by gateway (Coremail) with SMTP id _____8Cx77vCo7hlpToIAA--.5797S3; Tue, 30 Jan 2024 15:22:42 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.213]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxXs2+o7hlPo4nAA--.20587S4; Tue, 30 Jan 2024 15:22:40 +0800 (CST) From: Bibo Mao To: Tianrui Zhao , Huacai Chen Cc: kvm@vger.kernel.org, loongarch@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] LoongArch: KVM: Do not restart SW timer when it is expired Date: Tue, 30 Jan 2024 15:22:38 +0800 Message-Id: <20240130072238.2829831-3-maobibo@loongson.cn> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240130072238.2829831-1-maobibo@loongson.cn> References: <20240130072238.2829831-1-maobibo@loongson.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: AQAAf8BxXs2+o7hlPo4nAA--.20587S4 X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBj93XoWxJF1UZFyrAFykXFWkXF4rCrX_yoW8Cr47pr WSkwn7Jw1rury8Wa4DJan5urn8A347t3W7WFW7G3y0yFnFyw15JF48XFykJFWft3y8ZrWS vr1Fyry5Ca1DX3XCm3ZEXasCq-sJn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUk2b4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx 1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1q6rW5McIj6I8E87Iv 67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2 Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s02 6x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0x vE2Ix0cI8IcVAFwI0_JFI_Gr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE 42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJwCI42IY6I8E87Iv6x kF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxU2T5lUUUUU X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789499194490682962 X-GMAIL-MSGID: 1789499194490682962 LoongArch guest has separate hw timer, SW timer is to wake up blocked vcpu thread, rather than HW timer emulation. When blocking vcpu schedules out, SW timer is used to wakeup blocked vcpu thread and injects timer interrupt. It does not care about whether guest timer is in period mode or oneshot mode, and SW timer needs not be restarted since vcpu has been woken. This patch does not restart sw timer when it is expired. Signed-off-by: Bibo Mao --- arch/loongarch/kvm/timer.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/arch/loongarch/kvm/timer.c b/arch/loongarch/kvm/timer.c index a9125f0a12d1..d3282f01d4d9 100644 --- a/arch/loongarch/kvm/timer.c +++ b/arch/loongarch/kvm/timer.c @@ -23,24 +23,6 @@ static inline u64 tick_to_ns(struct kvm_vcpu *vcpu, u64 tick) return div_u64(tick * MNSEC_PER_SEC, vcpu->arch.timer_mhz); } -/* - * Push timer forward on timeout. - * Handle an hrtimer event by push the hrtimer forward a period. - */ -static enum hrtimer_restart kvm_count_timeout(struct kvm_vcpu *vcpu) -{ - unsigned long cfg, period; - - /* Add periodic tick to current expire time */ - cfg = kvm_read_sw_gcsr(vcpu->arch.csr, LOONGARCH_CSR_TCFG); - if (cfg & CSR_TCFG_PERIOD) { - period = tick_to_ns(vcpu, cfg & CSR_TCFG_VAL); - hrtimer_add_expires_ns(&vcpu->arch.swtimer, period); - return HRTIMER_RESTART; - } else - return HRTIMER_NORESTART; -} - /* Low level hrtimer wake routine */ enum hrtimer_restart kvm_swtimer_wakeup(struct hrtimer *timer) { @@ -50,7 +32,7 @@ enum hrtimer_restart kvm_swtimer_wakeup(struct hrtimer *timer) kvm_queue_irq(vcpu, INT_TI); rcuwait_wake_up(&vcpu->wait); - return kvm_count_timeout(vcpu); + return HRTIMER_NORESTART; } /*