From patchwork Wed Jul 11 13:24:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongji Xie X-Patchwork-Id: 10519755 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 09A676028E for ; Wed, 11 Jul 2018 13:26:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0089228FBE for ; Wed, 11 Jul 2018 13:26:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E878228FCD; Wed, 11 Jul 2018 13:26:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7BFC728FBE for ; Wed, 11 Jul 2018 13:26:08 +0000 (UTC) Received: from localhost ([::1]:53739 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fdF8B-0007W4-30 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 11 Jul 2018 09:26:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50480) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fdF7W-0007Dc-Ev for qemu-devel@nongnu.org; Wed, 11 Jul 2018 09:25:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fdF7S-0004Zo-E8 for qemu-devel@nongnu.org; Wed, 11 Jul 2018 09:25:26 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:37223) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fdF7S-0004Yb-9I for qemu-devel@nongnu.org; Wed, 11 Jul 2018 09:25:22 -0400 Received: by mail-pf0-x242.google.com with SMTP id x10-v6so8554644pfm.4 for ; Wed, 11 Jul 2018 06:25:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=a0BVtXPz1WbRW59tFEBIR9oBgCe8dsGd6VR74QzSl7E=; b=BwuMN7UENulYXjvbJT7Py9Tz9d2bvaNrNrltMhwa54ytgOQKjeUbxNpR3Ew5R3AxCY jtn9vJndfuBZfjKUeNa0uA44r82uXYItsZzw4wWbb/CJapoIRi0qMIdvVcNTukY2scH0 r31tb8M+UlqOorzMWJPkONiVcxz1hY9Vb8U64sgow8W/5AuLVZl++UbG7aNS8uepDQXp oFZfNQWxi9MOhzjN28iMcSRZIOOSxr+eV333mzCP8taY2zNW1HuNrvvcJ+o9KyGjAP/W J0guNw+3+eKp8t8f036pmNj/b3avWrP+glcjJyCJ4LaTK67b/7tZnEjHaRvXAvzLExJ0 doVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=a0BVtXPz1WbRW59tFEBIR9oBgCe8dsGd6VR74QzSl7E=; b=PwIgdJNEo6Pa8hz9wOktTtcRE5ZZOtWOT4Z/3ZrrgZeaZvqV1EQgXKaUCJrYK8hsgF rQl214YaoJ9zuYONCXozNJN1oeyH2mwDyQFTVCXppd6kdoEgU/bTt7qJlwWRKR+6qCmh aehyr+nUIOKU9DMp+fczMiOwpAY6KdbQhSr74gho0YhFBHhR4i1KoT6NmcmmcIlMSLnO zutHHh6IDApOoS2mHihOBy6a4qsW3/5VUhz990MxibQbVMEdP+j5GQ9IBgdGZYs4WRGP SdSwTwCMsP8mRnfn8jOs3ueyJ5nEvSOq9vN2g8HGHky4aEF7o7htjTqd8kkJrdXgarMu ZHnA== X-Gm-Message-State: APt69E2dIKyAtQ0DSgUC9Ynuc5g91iBKZ2GtGVcdO19qmBhp5yVeQHNq M/BF+Ty8jtS7ZcbHcSYKEGI= X-Google-Smtp-Source: AAOMgpc9eYjMlIPuMJDctg3xbGd9emqahdOSKsLAmF6PsIUtGdKgzPNr8vkLoj6Gq+lXIYv1I2fYew== X-Received: by 2002:a62:9cd7:: with SMTP id u84-v6mr13296773pfk.90.1531315521418; Wed, 11 Jul 2018 06:25:21 -0700 (PDT) Received: from localhost ([101.93.255.41]) by smtp.gmail.com with ESMTPSA id n9-v6sm24440103pfg.21.2018.07.11.06.25.20 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 11 Jul 2018 06:25:20 -0700 (PDT) From: Yongji Xie X-Google-Original-From: Yongji Xie To: pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com Date: Wed, 11 Jul 2018 21:24:48 +0800 Message-Id: <1531315488-2590-1-git-send-email-xieyongji@baidu.com> X-Mailer: git-send-email 1.7.9.5 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH] kvmclock: run KVM_KVMCLOCK_CTRL ioctl in vcpu thread X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: elohimes@gmail.com, qemu-devel@nongnu.org, chaiwen@baidu.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP According to KVM API Documentation, we should only run vcpu ioctls from the same thread that was used to create the vcpu. This patch makes KVM_KVMCLOCK_CTRL ioctl consistent with the Documentation. No functional change. Signed-off-by: Yongji Xie Signed-off-by: Chai Wen --- hw/i386/kvm/clock.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c index 0bf1c60..25ea783 100644 --- a/hw/i386/kvm/clock.c +++ b/hw/i386/kvm/clock.c @@ -147,6 +147,15 @@ static void kvm_update_clock(KVMClockState *s) s->clock_is_reliable = kvm_has_adjust_clock_stable(); } +static void do_kvmclock_ctrl(CPUState *cpu, run_on_cpu_data data) +{ + int ret = kvm_vcpu_ioctl(cpu, KVM_KVMCLOCK_CTRL, 0); + + if (ret && ret != -EINVAL) { + fprintf(stderr, "%s: %s\n", __func__, strerror(-ret)); + } +} + static void kvmclock_vm_state_change(void *opaque, int running, RunState state) { @@ -183,13 +192,7 @@ static void kvmclock_vm_state_change(void *opaque, int running, return; } CPU_FOREACH(cpu) { - ret = kvm_vcpu_ioctl(cpu, KVM_KVMCLOCK_CTRL, 0); - if (ret) { - if (ret != -EINVAL) { - fprintf(stderr, "%s: %s\n", __func__, strerror(-ret)); - } - return; - } + run_on_cpu(cpu, do_kvmclock_ctrl, RUN_ON_CPU_NULL); } } else {