From patchwork Thu Jul 18 09:54:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrii Anisov X-Patchwork-Id: 11048747 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 23EF46C5 for ; Thu, 18 Jul 2019 09:55:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0561F287AE for ; Thu, 18 Jul 2019 09:55:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E969C279E0; Thu, 18 Jul 2019 09:55:45 +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=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8EBAC279E0 for ; Thu, 18 Jul 2019 09:55:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ho37G-0000Hx-SX; Thu, 18 Jul 2019 09:54:22 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ho37F-0000Hs-6I for xen-devel@lists.xenproject.org; Thu, 18 Jul 2019 09:54:21 +0000 X-Inumbo-ID: 026d5d3b-a942-11e9-8980-bc764e045a96 Received: from mail-lj1-x244.google.com (unknown [2a00:1450:4864:20::244]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 026d5d3b-a942-11e9-8980-bc764e045a96; Thu, 18 Jul 2019 09:54:19 +0000 (UTC) Received: by mail-lj1-x244.google.com with SMTP id v24so26715223ljg.13 for ; Thu, 18 Jul 2019 02:54:19 -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=+4o2+eFFhgbwp5ihS5Vdct+p+xXhdL8cUpHmebzUVZM=; b=RNWemrYyp5z18795E7UqFT9QFpmXZ3dSimkb2NXCCROjl36Px8IxBhiojjezGFmtIr C5eL8am7S3AwdvQGPql9tmIj7AEC3BQ9CiLzh8m4Yapd6Xl9/2E6+Ou+HZKEAyj7if4n 0BuOBKY2o7xL9yM/zVkEtXQH55K9jD9sWSbWN3XJXmU1mLQnuWHaCQOcOiXFrm2uQs6k E2EnurKacuFDQgTa79+utnX3Y3OYBTMN4lCojWlApN9+uKecwaJMPFfDvKBYNssBY7/a L+U+pYKP2m+FAVXWdkR44IjPe9EQcDcXDNV0ch5AQDG3nNE/3RqCiMjT2/VnpnE01JJO ULEQ== 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=+4o2+eFFhgbwp5ihS5Vdct+p+xXhdL8cUpHmebzUVZM=; b=GzI/vEnXBqFyt1yCMOLdqE77aC4VKQgFtADsXSVUeKrPGHRLaDI7Y/k/r2MSkNsgaA RTHU+aO+8nPlf6Gfusyz8vYnF4mjJyFHweR4u43W0Joz3QZ/ZZmGJTj5SgQ8tEh+LMxg DzdazzuyekyqlO7P3AX6ZibgpJ9/mKykEEEG1QEIh7W1scEYYZcSdIVe58Ud6wg1gAPY CgER3iwdZFDAtdHdw3M8XfRmqBNU1mWj8af6Aq8anNadc4PlUuVfGCqxVC3VnApwehNz q9GYViEuMU6jiZHPGV7iLXBiMpZBxusYY7jhXEIjSKjY+AN6sbIbFMA5AKEB2pwcgjiy s33A== X-Gm-Message-State: APjAAAXyCFk/0KstIwLVyir6oiRHwd1Tmlqk/gffj77/5b+lG6NwuNV1 ItEe+34tblxdMGkDDE0StG3M5BGd X-Google-Smtp-Source: APXvYqxB/18ntNyzFl74fAFKNmX1OUXuOPHJbNcPN/3bmh44Oci2zQIavzoBqZ8B8bkRd4K344l5Ug== X-Received: by 2002:a2e:9685:: with SMTP id q5mr9960252lji.227.1563443657504; Thu, 18 Jul 2019 02:54:17 -0700 (PDT) Received: from aanisov-work.kyiv.epam.com (ll-22.209.223.85.sovam.net.ua. [85.223.209.22]) by smtp.gmail.com with ESMTPSA id k27sm4308280lfm.90.2019.07.18.02.54.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Jul 2019 02:54:16 -0700 (PDT) From: Andrii Anisov To: xen-devel@lists.xenproject.org Date: Thu, 18 Jul 2019 12:54:15 +0300 Message-Id: <1563443655-15802-1-git-send-email-andrii.anisov@gmail.com> X-Mailer: git-send-email 2.7.4 Subject: [Xen-devel] [PATCH] schedule: mask out XEN_RUNSTATE_UPDATE from state entry time X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: George Dunlap , Andrii Anisov , Dario Faggioli MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Andrii Anisov Using XEN_RUNSTATE_UPDATE mask during the process of copying runstate values to guest causes runstate entry time to be eventually considered negative on a calculation of the time delta. So the XEN_RUNSTATE_UPDATE should be masked out during the calculation of the time spent in the particular runstate. Signed-off-by: Andrii Anisov --- xen/common/schedule.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 25f6ab3..f4f1a81 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -182,7 +182,9 @@ static inline void vcpu_runstate_change( trace_runstate_change(v, new_state); - delta = new_entry_time - v->runstate.state_entry_time; + delta = new_entry_time - + (v->runstate.state_entry_time & ~XEN_RUNSTATE_UPDATE); + if ( delta > 0 ) { v->runstate.time[v->runstate.state] += delta;