From patchwork Wed Sep 11 10:32: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: 11140873 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 D0A4414E5 for ; Wed, 11 Sep 2019 10:34:28 +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 ABEDD2087E for ; Wed, 11 Sep 2019 10:34:28 +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="Q/90VE4Z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ABEDD2087E 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 1i7zvT-00007Z-K9; Wed, 11 Sep 2019 10:32:39 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i7zvS-00007G-AS for xen-devel@lists.xenproject.org; Wed, 11 Sep 2019 10:32:38 +0000 X-Inumbo-ID: 74df8a82-d47f-11e9-b299-bc764e2007e4 Received: from mail-lf1-x143.google.com (unknown [2a00:1450:4864:20::143]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 74df8a82-d47f-11e9-b299-bc764e2007e4; Wed, 11 Sep 2019 10:32:30 +0000 (UTC) Received: by mail-lf1-x143.google.com with SMTP id w67so16009003lff.4 for ; Wed, 11 Sep 2019 03:32:30 -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=aqXFQn3KxWtsIDGkNKwWIgnyKzS5VXO95uQ8ju2Spbk=; b=Q/90VE4ZsQYdXaQZj0SMpAOryuSI4oLF014698oCBwgip3cEhFWFwdgsHd2Z5hP2Af 5s0EbjXov/zOjTok7I7AMBfPe9OyiuNt+pWBnb9AXea0L92tiMW+nO9pNCcr4ZPtq2f+ Z0fdxxeLEWsPNvTQNe8xnMz1JMa/1UU+M0Lso3czkFew5EO1ajQr6RkH76tRjrnfaT+u AmW8SzEkCNyMZJtkPsJn4W4T0EUwILs+I6AeiOSzIY3DwX+npRDWD0q5/ZxcLDlMxRay 164vu7VAwvPEqImM+vus132RB7w4Fsjy+Te7LwOwWVCH+tDSM1FxoeNIKysP+WjNtic9 N7gA== 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=aqXFQn3KxWtsIDGkNKwWIgnyKzS5VXO95uQ8ju2Spbk=; b=j6c18ILiyX5zKU43/wSGRIKnQbjbzY+6nICPG+DmLvTbIxmocZ5Hp8xZhPp9nlUmWx Nf01AjSWNou7snkF3CJweKVqZhv++qSKxMKIiZMdchql75Ijw9SkiRcLLqJYda30J5bA gRzjR27AxYrqImu3PMmJrWKrNN1gYh0ouqaSOS3FEXrqMgr6e8y+Qj3kYqWQT8CELOwG kormlF5S1CjkW8TWjJmjFtJZdCo0qOJ9rhG/BNwP5eUtbOChRg0SzvPasIkOXF9WTrQY 0nf4ntuTmv75cEMTp97HvcjaD3mN9nvBfAoNFZPOUzQZmV+efSUnucMpUgZHGi+IarCm gl3A== X-Gm-Message-State: APjAAAUNWZSQaRkV/5HbhQ1aIZFWHIt2sqzpHomdzN47rMyDwsOwc2U9 J9Jjea0F6wrXwS5dx6WlCc2rlfPde38= X-Google-Smtp-Source: APXvYqxwhq4bqGgpmK+m18qIu6USIpEwLeSuAJRw7jtd6RNL/NRsYXdybm/xkxz6mT9NmS7BUwRXJA== X-Received: by 2002:a05:6512:6c:: with SMTP id i12mr23753466lfo.40.1568197948968; Wed, 11 Sep 2019 03:32:28 -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.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Sep 2019 03:32:28 -0700 (PDT) From: Andrii Anisov To: xen-devel@lists.xenproject.org Date: Wed, 11 Sep 2019 13:32:15 +0300 Message-Id: <1568197942-15374-3-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 2/9] sysctl: extend XEN_SYSCTL_getcpuinfo interface 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 Extend XEN_SYSCTL_getcpuinfo interface with timing information provided by introduced time accounting infrastructure. Signed-off-by: Andrii Anisov --- xen/common/schedule.c | 33 ++++++++++++++++++++++++++++----- xen/common/sysctl.c | 4 ++++ xen/include/public/sysctl.h | 4 ++++ xen/include/xen/sched.h | 4 ++++ 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 6dd6603..2007034 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -208,13 +208,36 @@ void vcpu_runstate_get(struct vcpu *v, struct vcpu_runstate_info *runstate) uint64_t get_cpu_idle_time(unsigned int cpu) { - struct vcpu_runstate_info state = { 0 }; - struct vcpu *v = idle_vcpu[cpu]; + struct tacc *tacc = &per_cpu(tacc, cpu); - if ( cpu_online(cpu) && v ) - vcpu_runstate_get(v, &state); + return tacc->state_time[TACC_IDLE]; +} + +uint64_t get_cpu_guest_time(unsigned int cpu) +{ + struct tacc *tacc = &per_cpu(tacc, cpu); + + return tacc->state_time[TACC_GUEST]; +} + +uint64_t get_cpu_hyp_time(unsigned int cpu) +{ + struct tacc *tacc = &per_cpu(tacc, cpu); + + return tacc->state_time[TACC_HYP]; +} + +uint64_t get_cpu_irq_time(unsigned int cpu) +{ + struct tacc *tacc = &per_cpu(tacc, cpu); + + return tacc->state_time[TACC_IRQ]; +} +uint64_t get_cpu_gsync_time(unsigned int cpu) +{ + struct tacc *tacc = &per_cpu(tacc, cpu); - return state.time[RUNSTATE_running]; + return tacc->state_time[TACC_GSYNC]; } /* diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c index 92b4ea0..b63083c 100644 --- a/xen/common/sysctl.c +++ b/xen/common/sysctl.c @@ -152,6 +152,10 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) for ( i = 0; i < nr_cpus; i++ ) { cpuinfo.idletime = get_cpu_idle_time(i); + cpuinfo.guesttime = get_cpu_guest_time(i); + cpuinfo.hyptime = get_cpu_hyp_time(i); + cpuinfo.gsynctime = get_cpu_gsync_time(i); + cpuinfo.irqtime = get_cpu_irq_time(i); if ( copy_to_guest_offset(op->u.getcpuinfo.info, i, &cpuinfo, 1) ) goto out; diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index 5401f9c..cdada1f 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -168,6 +168,10 @@ struct xen_sysctl_debug_keys { /* XEN_SYSCTL_getcpuinfo */ struct xen_sysctl_cpuinfo { uint64_aligned_t idletime; + uint64_aligned_t hyptime; + uint64_aligned_t guesttime; + uint64_aligned_t irqtime; + uint64_aligned_t gsynctime; }; typedef struct xen_sysctl_cpuinfo xen_sysctl_cpuinfo_t; DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpuinfo_t); diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 04a8724..8167608 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -876,6 +876,10 @@ void restore_vcpu_affinity(struct domain *d); void vcpu_runstate_get(struct vcpu *v, struct vcpu_runstate_info *runstate); uint64_t get_cpu_idle_time(unsigned int cpu); +uint64_t get_cpu_hyp_time(unsigned int cpu); +uint64_t get_cpu_guest_time(unsigned int cpu); +uint64_t get_cpu_gsync_time(unsigned int cpu); +uint64_t get_cpu_irq_time(unsigned int cpu); /* * Used by idle loop to decide whether there is work to do: