From patchwork Wed Jul 11 13:22:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongji Xie X-Patchwork-Id: 10519751 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 2BE7A603D7 for ; Wed, 11 Jul 2018 13:24:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2010928F5A for ; Wed, 11 Jul 2018 13:24:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 144F928F73; Wed, 11 Jul 2018 13:24:27 +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 BABE928FB6 for ; Wed, 11 Jul 2018 13:24:26 +0000 (UTC) Received: from localhost ([::1]:53730 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fdF6V-0006P9-W2 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 11 Jul 2018 09:24:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50212) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fdF5t-00065u-KV for qemu-devel@nongnu.org; Wed, 11 Jul 2018 09:23:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fdF5p-0003vW-GW for qemu-devel@nongnu.org; Wed, 11 Jul 2018 09:23:45 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:36061) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fdF5p-0003vP-AF for qemu-devel@nongnu.org; Wed, 11 Jul 2018 09:23:41 -0400 Received: by mail-pf0-x243.google.com with SMTP id u16-v6so18410480pfh.3 for ; Wed, 11 Jul 2018 06:23:41 -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=C7YncMA4/t8tPDaDFOkq0+XzCL8yyPWPnkrnYKGzbPO5EL78BrtcRjWXWssusGUdCl V95egU3z7c+gySCxUuXnuBzzc5QLflBDm5+Cb2gy3uQxCUC/7V+lr80eX/hOmPi61n70 9/msDxUkNRH5eepxXUomwg40TFy9lUh9hHFwdvT00vFZ2DJub/PDxCCU4+0tJEfIcNaK CJSXmq4Ezqb71GaiOC2yzhcxmSzsPJ06EEY2zZ5WKfa8TuVEqEujpa1DVTVvW9VrKZxi Nz6IiyTkMW5M8A/Y7SXhHkYll+qC80EFy4DoR7IOPVuxDhLHlEtO6LjCEeY/0t7H/THG Z0mQ== 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=K34Q+UzkpXaf/tH5+vpv9PCYAwbluYpMEzarS/CK5NpSPIbI6RKSmsH6KZCSXO2ERR lcxY3euDT85ot2jwNK8XCB1xqPRw4SqxHtNM5sILUd7nHNz4Rx73wRh6eLlgjPFJkUHH +b+MwncrCT9CYehhTUSdionpFnoB52DXL0TAwLpxniC3dNueWC90s1RgWKOvjlJuJ2vZ gJj5YaBp2SsjxzjnlN06dcCNGDyFOlbNcztiqg6D1scRKTeHlA4tvHwI2dmS0ZZJtX9Q 26V8bGf54bZp8Fg6Inz7644kc7UOp9iCxWbMUTMBCY+H+f923MalmXPcp8VI4H7T63+5 tvCA== X-Gm-Message-State: APt69E2dphuqQWq0qTKasP9MboOxgRIE/XX7YFGB4ioX6xh0i/rY3gjr hikztFTZ2ZImHZaYwjGM1Fg= X-Google-Smtp-Source: AAOMgpessHM89auRUYWVqbAuyIBjiyjjrz3qQ/8vikmGEOI52wi5AMj8SjSmkrk9pxERfs4MLssEgQ== X-Received: by 2002:a62:4add:: with SMTP id c90-v6mr28334254pfj.23.1531315420239; Wed, 11 Jul 2018 06:23:40 -0700 (PDT) Received: from localhost ([101.93.255.41]) by smtp.gmail.com with ESMTPSA id b23-v6sm10953061pfc.49.2018.07.11.06.23.34 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 11 Jul 2018 06:23:39 -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:22:44 +0800 Message-Id: <1531315364-2551-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::243 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 {