From patchwork Wed Sep 11 10:32:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrii Anisov X-Patchwork-Id: 11140869 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 221FA184E for ; Wed, 11 Sep 2019 10:34:11 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F1AAA20CC7 for ; Wed, 11 Sep 2019 10:34:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BnFZb4zk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F1AAA20CC7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i7zvi-0000FK-Sw; Wed, 11 Sep 2019 10:32:54 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i7zvh-0000EQ-9u for xen-devel@lists.xenproject.org; Wed, 11 Sep 2019 10:32:53 +0000 X-Inumbo-ID: 77adbebe-d47f-11e9-a337-bc764e2007e4 Received: from mail-lj1-x244.google.com (unknown [2a00:1450:4864:20::244]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 77adbebe-d47f-11e9-a337-bc764e2007e4; Wed, 11 Sep 2019 10:32:35 +0000 (UTC) Received: by mail-lj1-x244.google.com with SMTP id a22so19511223ljd.0 for ; Wed, 11 Sep 2019 03:32:35 -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:in-reply-to:references; bh=MxYXirbw6xPemib9KGe3LPit2WCpm5IHJxLF3QhMyss=; b=BnFZb4zkh2Vi/LyxIKfqWpTOqMoIEu6BHvmnds1YYCeXR64vHew35ijMfBsIGEzmXP +94/wYp2b/jE0XhgoFUl/6yOW7M79jWSYp2wiNCMuIjtJEDcLUrsL1nJmTeCfejTNxNk U3T57S6i/IWTHn/g3ttVmcKarb3g/iVbFdN+0EdnqvqfL4aoX1zr0/LxV7MSJR1boohY ySFnEmsTwFTT+Ferk//eheLkr7IY68wLd+M3EE64UfEnMrs7M90HFtulddvJn4o8VTLd ba9So8Tnad1hokXfYS8ty7VdNF+e3hJd9wN+DTWjar/syQmk4rUUc37PKwkQE88I6oNW nyuA== 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:in-reply-to :references; bh=MxYXirbw6xPemib9KGe3LPit2WCpm5IHJxLF3QhMyss=; b=ZKjeQz4XJmBsNp4RZet1MbNg4ppfELST+z/l2N8jSqizSzmhLhquSIwEW6ANfBR88h iFZOEUeBF0NDeh9ZJyLTJUeiii8la2Ho6O6e+XPivEdaKFQiMI5SWD73CwnEIiZY5D7W LQqGzWgbpGFkp9tHaCxDnyCtVM6xpCyZ2OKCJ8fziygeGdMkLwWXpxdFmRsheAWhPAT+ 12tVOtW4tYL0Z8WC4N24j4spS8REJrYuMAxRvFfr7vl4hgAnxDmTUb7LCuEHHb+TIvEj q79znxQdj98KO+RO5wJWpgWhrA9QU6k2lAGzT3lkfQ2vpycaKQCQKNmF+jy6U0nTjpwp rspA== X-Gm-Message-State: APjAAAXf+MqjyGgoeTRBsQzSDA+f5/U6n8TajcGPwUbQKFOA7v8Ixjg3 50yT+j/4n68dz5LI8jr/1Icjk+tf04M= X-Google-Smtp-Source: APXvYqxHC/9oq3VXTPaJPxfA6HiwbnCV8O4kfZcimSKZ+5co849oMuU2HcoQhHVnUa59R9x7sdW4KQ== X-Received: by 2002:a2e:7a03:: with SMTP id v3mr9291670ljc.138.1568197953676; Wed, 11 Sep 2019 03:32:33 -0700 (PDT) Received: from aanisov-work.kyiv.epam.com (ll-74.141.223.85.sovam.net.ua. [85.223.141.74]) by smtp.gmail.com with ESMTPSA id w27sm4585275ljd.55.2019.09.11.03.32.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Sep 2019 03:32:33 -0700 (PDT) From: Andrii Anisov To: xen-devel@lists.xenproject.org Date: Wed, 11 Sep 2019 13:32:18 +0300 Message-Id: <1568197942-15374-6-git-send-email-andrii.anisov@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1568197942-15374-1-git-send-email-andrii.anisov@gmail.com> References: <1568197942-15374-1-git-send-email-andrii.anisov@gmail.com> Subject: [Xen-devel] [RFC 5/9] tacc: Introduce a lockless interface for guest 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: Tim Deegan , Stefano Stabellini , Andrii Anisov , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Dario Faggioli , Julien Grall , Jan Beulich MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Andrii Anisov The lockless interface to acquire guest time by scheduling code is introduced. It can be used by schedulers what do not require guest time from a different pcpu to take scheduling decission. Signed-off-by: Andrii Anisov --- xen/common/schedule.c | 10 ++++++++++ xen/include/xen/sched.h | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 2007034..62df77e 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -1643,6 +1643,16 @@ void tacc_irq_exit(int place) tacc->irq_cnt--; } +s_time_t tacc_get_guest_time(struct tacc *tacc) +{ + s_time_t guest_time; + + guest_time = tacc->state_time[TACC_GUEST]; + guest_time += tacc->state_time[TACC_GSYNC]; + + return guest_time; +} + void context_saved(struct vcpu *prev) { /* Clear running flag /after/ writing context to memory. */ diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 8167608..5b41805 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -266,6 +266,8 @@ struct vcpu struct evtchn_fifo_vcpu *evtchn_fifo; + s_time_t pcpu_guest_time; + /* vPCI per-vCPU area, used to store data for long running operations. */ struct vpci_vcpu vpci; @@ -1033,6 +1035,12 @@ DECLARE_PER_CPU(struct tacc, tacc); void tacc_hyp(int place); void tacc_idle(int place); +s_time_t tacc_get_guest_time(struct tacc *tacc); +inline s_time_t tacc_get_guest_time_delta(void) +{ + return tacc_get_guest_time(&this_cpu(tacc)) - current->pcpu_guest_time; +} + #endif /* __SCHED_H__ */ /*