Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3007770rdb; Wed, 15 Nov 2023 18:33:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IH5bdlOzYk2bikF/jufU3A5CwkJ4ozR/kwFfnelqWKQGbbBvGBFXjiRZ/5eyt9SLUAmxVJg X-Received: by 2002:a05:6a20:440d:b0:186:3f74:d628 with SMTP id ce13-20020a056a20440d00b001863f74d628mr12552722pzb.44.1700102014097; Wed, 15 Nov 2023 18:33:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700102014; cv=none; d=google.com; s=arc-20160816; b=YW/pLyCg2rn0G1sNTNO007nqORjfwro89Wee/Yl/7tOEinopktn5XhfYPAtIj6h7TH QCM0bPk3i3NZyEq1CF9nxNUWl5x7VWCz2WU6+m7t/bLJssixAOWraMx1Zwn1Yvuc6Clh OdadgZIcKnuOOLF+M/YzQSQymxFN59VnIaxPfdWkaIaDM71o/oKzR79jsEgNzO9pBUGB n3ZqyOXazSflMzzAXUxnfbnN41yElHeD4EWk4umIKvzTuZJAUC7VnqaUAVRWuNwabJIN AwobS8XVz1MbJXtINt14hYL2WacRPTMRKyqh4KbUM3pkpOdlMou0vFYnYdDbBF4uDJzf Zdmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=XwQ5j1530hVdDJcqmTv9ng5h8/fI8dT5+gJjXUzYdZc=; fh=JOrDXAv7dX9lqUsWenmIinruxsV5NNS7FV+l4Q4onAY=; b=kGlu2cR27t5NGMeJyBcR78UMJAOpHkgxp0ZHTqjxxGguvj6yzJ0/sQS1x9Lk/JaY5+ HL6rJ5/gdnhBChMgmIrrhaoEuQIz4YTsm6tCS4/s0x/3v+QTbBTTj+ka+MrQEGjQaZW0 RZ+DDcg4GyQfuwL1hqOadVHum605tk0oQIYZC2VTLXPUh75Pl06LfGZrAzmntGbFTWIF 3KbAmDtX5VR6IHloU5uOpJ8uCpvsh57WjU3fd18bdHPfHR0YC80j+zB641RCd+2z/d03 TWr+wJ84/9PXppDF1dpfof8+gtPMLcJ61S2wKgnYoBrrFynRZYnqD1InyQXvzTP4uuzt RVZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id n2-20020a1709026a8200b001ce1605fcb9si10712613plk.540.2023.11.15.18.33.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 18:33:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 8BC77801E747; Wed, 15 Nov 2023 18:33:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344286AbjKPCdL (ORCPT + 99 others); Wed, 15 Nov 2023 21:33:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232310AbjKPCdK (ORCPT ); Wed, 15 Nov 2023 21:33:10 -0500 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 95C42199; Wed, 15 Nov 2023 18:33:05 -0800 (PST) Received: from loongson.cn (unknown [10.2.5.213]) by gateway (Coremail) with SMTP id _____8BxHOtff1Vll3A6AA--.45150S3; Thu, 16 Nov 2023 10:33:03 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.213]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Dxnd5df1Vl9p9DAA--.18774S2; Thu, 16 Nov 2023 10:33:01 +0800 (CST) From: Bibo Mao To: Tianrui Zhao , Huacai Chen Cc: WANG Xuerui , kvm@vger.kernel.org, loongarch@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v4 0/3] LoongArch: KVM: Remove SW timer switch when vcpu is halt polling Date: Thu, 16 Nov 2023 10:30:33 +0800 Message-Id: <20231116023036.2324371-1-maobibo@loongson.cn> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8Dxnd5df1Vl9p9DAA--.18774S2 X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBj93XoW7AF4rZryDJry3Gw48Kw4xKrX_yoW8XF47pr ZIkrnxXr40kr4Yg3Waqa1DXr97W3yxKFWxJrnxAFy8Ar17AF1YqFW8Kr95XFy3A393AryI vryrt3W5ua4UA3cCm3ZEXasCq-sJn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUk0b4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVWxJVW8Jr1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6r4j6r4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI0UMc 02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUGVWUXwAv7VC2z280aVAF wI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7V AKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCj r7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6x IIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAI w20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x 0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjxU70PfDUUUU X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 15 Nov 2023 18:33:31 -0800 (PST) This patches removes SW timer switch during vcpu block stage. VM uses HW timer rather than SW PV timer on LoongArch system, it can check pending HW timer interrupt status directly, rather than switch to SW timer and check injected SW timer interrupt. When SW timer is not used in vcpu halt-polling mode, the relative SW timer handling before entering guest can be removed also. Timer emulation is simpler than before, SW timer emuation is only used in vcpu thread context switch. --- Changes in v4: If vcpu is scheduled out since there is no pending event, and timer is fired during sched-out period. SW hrtimer is used to wake up vcpu thread in time, rather than inject pending timer irq. Changes in v3: Add kvm_arch_vcpu_runnable checking before kvm_vcpu_halt. Changes in v2: Add halt polling support for idle instruction emulation, using api kvm_vcpu_halt rather than kvm_vcpu_block in function kvm_emu_idle. --- Bibo Mao (3): LoongArch: KVM: Remove SW timer switch when vcpu is halt polling LoongArch: KVM: Allow to access HW timer CSR registers always LoongArch: KVM: Remove kvm_acquire_timer before entering guest arch/loongarch/include/asm/kvm_vcpu.h | 1 - arch/loongarch/kvm/exit.c | 13 +----- arch/loongarch/kvm/main.c | 1 - arch/loongarch/kvm/timer.c | 62 ++++++++++----------------- arch/loongarch/kvm/vcpu.c | 38 ++++------------ 5 files changed, 32 insertions(+), 83 deletions(-) base-commit: c42d9eeef8e5ba9292eda36fd8e3c11f35ee065c -- 2.39.3