From nobody Thu Apr 25 04:39:09 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1568198027; cv=none; d=zoho.com; s=zohoarc; b=JxcDbfZcklP0X3XICL2TjGrSKFxTvkFgv6HisfMfcgBEtZEIEkZCQb7ue6DYLqdCGWil7ESs/7/rneyGp/4JCEezy4R4gn6opddkc9Wl2A70ENOp55R6iW2I+piVnC21XjKbemxsHJY03aLwz8gCya4N9roog+zCRAbuwmnY+NQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568198027; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=6xg8i6SQMskfwhzMKn2bhBbh/HcjV7mwcblvLUs+gjc=; b=Xssg5ou+ELhVsg8xPCwBAFNNXl+CqBEAKbvZo/CfMgdBHtB8jvP8CybMGuFOaOdl3RKsWE73Uyr3C+hK6h7tjPj4sspXagoXyWl7dg/9xxgeVtq6hGrM5C1/2rq+WFxtwA+UDRNhKr34iAsWXj4J390FA3FBoIDcJ4rml/DzT8Y= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1568198027714643.5432278208774; Wed, 11 Sep 2019 03:33:47 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i7zvO-00006J-9a; Wed, 11 Sep 2019 10:32:34 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i7zvN-000064-8V for xen-devel@lists.xenproject.org; Wed, 11 Sep 2019 10:32:33 +0000 Received: from mail-lf1-x142.google.com (unknown [2a00:1450:4864:20::142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 742a4384-d47f-11e9-978d-bc764e2007e4; Wed, 11 Sep 2019 10:32:29 +0000 (UTC) Received: by mail-lf1-x142.google.com with SMTP id t8so15988225lfc.13 for ; Wed, 11 Sep 2019 03:32:29 -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.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Sep 2019 03:32:26 -0700 (PDT) X-Inumbo-ID: 742a4384-d47f-11e9-978d-bc764e2007e4 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=wjAeCZij2Xw6xoNlfZ2Z1Stlf0K5I20sXHD+nMPhkoI=; b=A21Wk5W0TFKbr1uHis+Qk7ZnFcg5HeHxrLmEOi8sRCxC9G9zToYSwqLvQKqGSM5oWN AZgweoS/81b0sSsJN+gDCbLhz06Vnd7vyrf7fS1qaCh8Z+/KcCN8erihO8PolKfDANYz 1T9sNmAsC3yJqP/CRA3XfD3K9hn1nxtq43IAbycKBMbgnwQIsZG/PTRES+/yF/Q1r9DF 9EuxQYsJQLbFdfdn3dcedfCkBvFI5HAgdhSdM5/WEE6VsSF+gaREOaWsS46s3EvsnMV2 AYmgrvpqdsjrheD5gBgvo3Ge5yj0jWgBMdaH86YEiO+t6PeoJL9qKjQ58ZzUsHvtsG00 nysQ== 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=wjAeCZij2Xw6xoNlfZ2Z1Stlf0K5I20sXHD+nMPhkoI=; b=cGyaDEMk8Rkawf0Le/WCBDnjJxMJXf6DUiBCH4+NHR2pQwaEuInvy1efB8nw5n7QHP ZJxP5Jyl2fCbZbtw2c8KIJOUpwAmpZYA4EboDNsB5PeqxtbEQMsmG0jY7unhymc+M4Zb b5bOoYUnop/Jmh3U6Ic7rdUaR8pOTPgnI+yf9HK2o0+eMMzEs3MXdyzUwxM4LqhfQ2o0 wcIt4bxpaEhye573FBq+EzzZY45LeFu0KNEKgsm0FtcfskRvRvkU3MJrLBJyqQ+49Yih HLOy9qYVA/ibGCIRGvkUNN+GfZG8UknuShk/byMgOimowZ/yRTgAHi70AeVbMMhiqb7n y3gA== X-Gm-Message-State: APjAAAWOOG6ADwYEQcmDLlaRItZ/IXdQOFFBFIw0lXFQSmYh8R391dm4 rkyQ17QiXQ48exsHklrlZ1qQpwqXkNY= X-Google-Smtp-Source: APXvYqwYktQJELQC55+1f3aWu6a8jxZrzr8GcXcq/hSCeKYctx4MxDcLYm+pOCcoIGjMxfg93iTcCA== X-Received: by 2002:ac2:5203:: with SMTP id a3mr340474lfl.151.1568197947575; Wed, 11 Sep 2019 03:32:27 -0700 (PDT) From: Andrii Anisov To: xen-devel@lists.xenproject.org Date: Wed, 11 Sep 2019 13:32:14 +0300 Message-Id: <1568197942-15374-2-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 1/9] schedule: Introduce per-pcpu time accounting 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Andrii Anisov Introduce per-pcpu time accounting what includes the following states: TACC_HYP - the pcpu executes hypervisor code like softirq processing (including scheduling), tasklets and context switches TACC_GUEST - the pcpu executes guests code TACC_IDLE - the low-power state of the pcpu TACC_IRQ - the pcpu performs interrupts processing, without separation to guest or hypervisor interrupts TACC_GSYNC - the pcpu executes hypervisor code to process synchronous trap from the guest. E.g. hypercall processing or io emulation. Currently, the only reenterant state is TACC_IRQ. It is assumed, no changes to state other than TACC_IRQ could happen until we return from nested interrupts. IRQ time is accounted in a distinct way comparing to other stat= es. It is acumulated between other states transition moments, and is substracted from the old state on states transion calculation. Signed-off-by: Andrii Anisov --- xen/common/schedule.c | 81 +++++++++++++++++++++++++++++++++++++++++++++= ++++ xen/include/xen/sched.h | 27 +++++++++++++++++ 2 files changed, 108 insertions(+) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 7b71581..6dd6603 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -1539,6 +1539,87 @@ static void schedule(void) context_switch(prev, next); } =20 +DEFINE_PER_CPU(struct tacc, tacc); + +static void tacc_state_change(enum TACC_STATES new_state) +{ + s_time_t now, delta; + struct tacc* tacc =3D &this_cpu(tacc); + unsigned long flags; + + local_irq_save(flags); + + now =3D NOW(); + delta =3D now - tacc->state_entry_time; + + /* We do not expect states reenterability (at least through this funct= ion)*/ + ASSERT(new_state !=3D tacc->state); + + tacc->state_time[tacc->state] +=3D delta - tacc->irq_time; + tacc->state_time[TACC_IRQ] +=3D tacc->irq_time; + tacc->irq_time =3D 0; + tacc->state =3D new_state; + tacc->state_entry_time =3D now; + + local_irq_restore(flags); +} + +void tacc_hyp(int place) +{ +// printk("\ttacc_hyp %u, place %d\n", smp_processor_id(), place); + tacc_state_change(TACC_HYP); +} + +void tacc_guest(int place) +{ +// printk("\ttacc_guest %u, place %d\n", smp_processor_id(), place); + tacc_state_change(TACC_GUEST); +} + +void tacc_idle(int place) +{ +// printk("\tidle cpu %u, place %d\n", smp_processor_id(), place); + tacc_state_change(TACC_IDLE); +} + +void tacc_gsync(int place) +{ +// printk("\ttacc_gsync %u, place %d\n", smp_processor_id(), place); + tacc_state_change(TACC_GSYNC); +} + +void tacc_irq_enter(int place) +{ + struct tacc* tacc =3D &this_cpu(tacc); + +// printk("\ttacc_irq_enter %u, place %d, cnt %d\n", smp_processor_id()= , place, this_cpu(tacc).irq_cnt); + ASSERT(!local_irq_is_enabled()); + ASSERT(tacc->irq_cnt >=3D 0); + + if ( tacc->irq_cnt =3D=3D 0 ) + { + tacc->irq_enter_time =3D NOW(); + } + + tacc->irq_cnt++; +} + +void tacc_irq_exit(int place) +{ + struct tacc* tacc =3D &this_cpu(tacc); + +// printk("\ttacc_irq_exit %u, place %d, cnt %d\n", smp_processor_id(),= place, tacc->irq_cnt); + ASSERT(!local_irq_is_enabled()); + ASSERT(tacc->irq_cnt > 0); + if ( tacc->irq_cnt =3D=3D 1 ) + { + tacc->irq_time =3D NOW() - tacc->irq_enter_time; + tacc->irq_enter_time =3D 0; + } + + tacc->irq_cnt--; +} + 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 e3601c1..04a8724 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -1002,6 +1002,33 @@ extern void dump_runq(unsigned char key); =20 void arch_do_physinfo(struct xen_sysctl_physinfo *pi); =20 +enum TACC_STATES { + TACC_HYP =3D 0, + TACC_GUEST =3D 1, + TACC_IDLE =3D 2, + TACC_IRQ =3D 3, + TACC_GSYNC =3D 4, + TACC_STATES_MAX +}; + +struct tacc +{ + s_time_t state_time[TACC_STATES_MAX]; + s_time_t state_entry_time; + int state; + + s_time_t guest_time; + + s_time_t irq_enter_time; + s_time_t irq_time; + int irq_cnt; +}; + +DECLARE_PER_CPU(struct tacc, tacc); + +void tacc_hyp(int place); +void tacc_idle(int place); + #endif /* __SCHED_H__ */ =20 /* --=20 2.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu Apr 25 04:39:09 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1568198028; cv=none; d=zoho.com; s=zohoarc; b=grAuQDxZweAWAp2857BX6gzeoIcMFip3Xf4f8lFuCteP+mXh/5fK60mmFZ6rW7/quXUOxItZDbYv5STN8fl/tvzZaqjeg3GG96Q2p3AA0NoMFrt09xDQxrnuw2toojmHeIe2FC6ZAuQwY3LBiFeaa8IPlD9bBQkFiY/vRD+VvBg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568198028; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=uBdzL211Ece7PgrTgXbxOBukDMkUw9sOYHPJ1fhOFbw=; b=ONQQJtj3r6pcZvgsXGuGxGJTl9n1U416i8qSsqMadxaT6wWuAt7MSvWF3obOGH12SPLjj84A1jnk2sWY0wzCoSPhHUTK9DVVkyAl4kdX1XQL0Uk/gl7Fsmf1e9sLqYtxDwdHO1y3rkgfKpxFk8HclwjQ7GYGMLGFsMtMRphWr+A= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1568198028463981.4972899392666; Wed, 11 Sep 2019 03:33:48 -0700 (PDT) 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 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) 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) X-Inumbo-ID: 74df8a82-d47f-11e9-b299-bc764e2007e4 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) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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_ru= nstate_info *runstate) =20 uint64_t get_cpu_idle_time(unsigned int cpu) { - struct vcpu_runstate_info state =3D { 0 }; - struct vcpu *v =3D idle_vcpu[cpu]; + struct tacc *tacc =3D &per_cpu(tacc, cpu); =20 - 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 =3D &per_cpu(tacc, cpu); + + return tacc->state_time[TACC_GUEST]; +} + +uint64_t get_cpu_hyp_time(unsigned int cpu) +{ + struct tacc *tacc =3D &per_cpu(tacc, cpu); + + return tacc->state_time[TACC_HYP]; +} + +uint64_t get_cpu_irq_time(unsigned int cpu) +{ + struct tacc *tacc =3D &per_cpu(tacc, cpu); + + return tacc->state_time[TACC_IRQ]; +} +uint64_t get_cpu_gsync_time(unsigned int cpu) +{ + struct tacc *tacc =3D &per_cpu(tacc, cpu); =20 - return state.time[RUNSTATE_running]; + return tacc->state_time[TACC_GSYNC]; } =20 /* 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 =3D 0; i < nr_cpus; i++ ) { cpuinfo.idletime =3D get_cpu_idle_time(i); + cpuinfo.guesttime =3D get_cpu_guest_time(i); + cpuinfo.hyptime =3D get_cpu_hyp_time(i); + cpuinfo.gsynctime =3D get_cpu_gsync_time(i); + cpuinfo.irqtime =3D get_cpu_irq_time(i); =20 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); =20 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); =20 /* * Used by idle loop to decide whether there is work to do: --=20 2.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu Apr 25 04:39:09 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1568198033; cv=none; d=zoho.com; s=zohoarc; b=HUTWcyBdsrsKTck8Sb5cMuk7YMWGnpf6RJ+J+e8mJpMb2zJopknA6NHRbMJwlp9+ZlpyXiz+6CFpigZgVtYf+3BCcBiR+sr5wjuY1ppHneywZsBPrbGcpplASrOMuQZbPV7zRYdB7P0r1SlIhpnNLnuOgb8dmJp36lOeIFzgoS4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568198033; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=K74GCwsYfh7vPfh/TzJPORFUwSZSeODSacr4d6Op5lw=; b=beb17eSlwcCZ1WY7QInLeSMfrWWuAd5AlUgfOJlykA0BTrgXiJ6cOM64Q3+OZEURZntNRYYwOEihm9t3SiblEbu8Q/kVdx2Zqsd44694ylXQl8KshkTFImbu4WRohn1UrBsQCBLw4TmzWS4SiVLkM2ocR25mq+g4JG+078apPkA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 156819803304818.16673524654766; Wed, 11 Sep 2019 03:33:53 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i7zvY-00009s-VW; Wed, 11 Sep 2019 10:32:44 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i7zvX-00009C-9Q for xen-devel@lists.xenproject.org; Wed, 11 Sep 2019 10:32:43 +0000 Received: from mail-lj1-x244.google.com (unknown [2a00:1450:4864:20::244]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 75f7655c-d47f-11e9-a337-bc764e2007e4; Wed, 11 Sep 2019 10:32:32 +0000 (UTC) Received: by mail-lj1-x244.google.com with SMTP id u14so19450462ljj.11 for ; Wed, 11 Sep 2019 03:32:32 -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.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Sep 2019 03:32:30 -0700 (PDT) X-Inumbo-ID: 75f7655c-d47f-11e9-a337-bc764e2007e4 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=AC9kNkmArPC3CzG+J65Zgd+nHkAn9+JKqJkWk1/eavM=; b=fRMTOSwJNbVaQuzqiIUP2BxsXXEOPY35/+4BhqAAYesK6QvtpW7qJYOOel8W6OK9mb H6pYZiaPM/5FtLOmukohyjNEcnKN+nqlyBHvCASq2li02l9iI2a67mwd6oppFu2pyOci FnZVgIwa91FTLb3tO7xOj75GB1UV0YNliifzVhIB+0GwMRTokC4yBK7eNQ/+I/bphYjs e5fpt1bYOx9OimcQ4RXs38vpiozBLGwUQ4f4SYHDl7oL9tOGXqTEVnD7QS6m8RpaGIJT rjiiZpqYkZ3xlptInbh6paUW9BNUs/E2OQ/pYepQLdxu2iA+b8/yOhKu+wcLFplvt3xQ EiSw== 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=AC9kNkmArPC3CzG+J65Zgd+nHkAn9+JKqJkWk1/eavM=; b=g7nXkAROIwEeB/N+iAlBiJ4s6Ql0m70B6zs0vQGDbVojUN8/CXr1YM4IQFuigtVgOI CBKeNo2nElqXBdw0pMaKh1WlFIcQ0emXofcg9aC8CZGkGNBa2vdghHuZGyiJv65q3LbA Ek0LpNjbpLefT0ItTODiGnZl5XLWdmRBs/Q0rdUsYr9JO59YaqbnAjMHw1p+2z4HZ2Ll p5F0ziTwH/SwcYgxscRUtsTIA0h1MKy2xJOHiTJv/cgoNjL/kX80PynrK4BCA6xmVbPT 3+iSVz0fPnKakI20Kc8NYbfPImsBBc9UNr+wYfd074GpKDHZPL5LQjPA+8dbhR+3yq0X YX/w== X-Gm-Message-State: APjAAAXNA4RL3PaZUDPDaWvqYfSXpmk+ISVJIbV26YPxMvA7Oj4isJYW xvYFmRd1m+tZlovCiUPvgp3qKgun4mE= X-Google-Smtp-Source: APXvYqzks7WvwhsxPXamr1i/FvYqbuwkN9K8Ylqe93xKrQE6r7f1nYgJpT93k1dnj/RYpmNZdd9+Jg== X-Received: by 2002:a2e:9586:: with SMTP id w6mr21889348ljh.47.1568197950711; Wed, 11 Sep 2019 03:32:30 -0700 (PDT) From: Andrii Anisov To: xen-devel@lists.xenproject.org Date: Wed, 11 Sep 2019 13:32:16 +0300 Message-Id: <1568197942-15374-4-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 3/9] xentop: show CPU load information 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: Ian Jackson , Andrii Anisov , Wei Liu MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Andrii Anisov Let xentop request and show information about CPU load provided by new time accounting infrastructure. Signed-off-by: Andrii Anisov --- tools/xenstat/libxenstat/src/xenstat.c | 50 +++++++++++++++++++++++++= ++++ tools/xenstat/libxenstat/src/xenstat.h | 15 +++++++++ tools/xenstat/libxenstat/src/xenstat_priv.h | 5 +++ tools/xenstat/xentop/xentop.c | 36 +++++++++++++++++++++ 4 files changed, 106 insertions(+) diff --git a/tools/xenstat/libxenstat/src/xenstat.c b/tools/xenstat/libxens= tat/src/xenstat.c index 6f93d4e..cfb6504 100644 --- a/tools/xenstat/libxenstat/src/xenstat.c +++ b/tools/xenstat/libxenstat/src/xenstat.c @@ -134,6 +134,9 @@ void xenstat_uninit(xenstat_handle * handle) xenstat_node *xenstat_get_node(xenstat_handle * handle, unsigned int flags) { #define DOMAIN_CHUNK_SIZE 256 + xc_cpuinfo_t *cpuinfo; + int max_cpus, nr_cpus; + xenstat_node *node; xc_physinfo_t physinfo =3D { 0 }; xc_domaininfo_t domaininfo[DOMAIN_CHUNK_SIZE]; @@ -163,6 +166,28 @@ xenstat_node *xenstat_get_node(xenstat_handle * handle= , unsigned int flags) * handle->page_size; =20 node->freeable_mb =3D 0; + + max_cpus =3D node->num_cpus; + + cpuinfo =3D calloc(max_cpus, sizeof(xc_cpuinfo_t)); + if (!cpuinfo) + return NULL; + + if (xc_getcpuinfo(handle->xc_handle, max_cpus, cpuinfo, &nr_cpus) < 0) { + free(cpuinfo); + return NULL; + } + + for ( i =3D 0; i < nr_cpus; i++) { + node->idle_time +=3D cpuinfo[i].idletime; + node->hyp_time +=3D cpuinfo[i].hyptime; + node->guest_time +=3D cpuinfo[i].guesttime; + node->gsync_time +=3D cpuinfo[i].gsynctime; + node->irq_time +=3D cpuinfo[i].irqtime; + } + + free(cpuinfo); + /* malloc(0) is not portable, so allocate a single domain. This will * be resized below. */ node->domains =3D malloc(sizeof(xenstat_domain)); @@ -332,6 +357,31 @@ unsigned long long xenstat_node_cpu_hz(xenstat_node * = node) return node->cpu_hz; } =20 +unsigned long long xenstat_node_idle_time(xenstat_node * node) +{ + return node->idle_time; +} + +unsigned long long xenstat_node_guest_time(xenstat_node * node) +{ + return node->guest_time; +} + +unsigned long long xenstat_node_hyp_time(xenstat_node * node) +{ + return node->hyp_time; +} + +unsigned long long xenstat_node_gsync_time(xenstat_node * node) +{ + return node->gsync_time; +} + +unsigned long long xenstat_node_irq_time(xenstat_node * node) +{ + return node->irq_time; +} + /* Get the domain ID for this domain */ unsigned xenstat_domain_id(xenstat_domain * domain) { diff --git a/tools/xenstat/libxenstat/src/xenstat.h b/tools/xenstat/libxens= tat/src/xenstat.h index 76a660f..9881ce5 100644 --- a/tools/xenstat/libxenstat/src/xenstat.h +++ b/tools/xenstat/libxenstat/src/xenstat.h @@ -80,6 +80,21 @@ unsigned int xenstat_node_num_cpus(xenstat_node * node); /* Get information about the CPU speed */ unsigned long long xenstat_node_cpu_hz(xenstat_node * node); =20 +/* Get information about the CPU idle time */ +unsigned long long xenstat_node_idle_time(xenstat_node * node); + +/* Get information about the CPU guest execution time */ +unsigned long long xenstat_node_guest_time(xenstat_node * node); + +/* Get information about the CPU hypervisor execution time */ +unsigned long long xenstat_node_hyp_time(xenstat_node * node); + +/* Get information about the CPU guest syncronous trap execution time */ +unsigned long long xenstat_node_gsync_time(xenstat_node * node); + +/* Get information about the CPU IRQ serving time */ +unsigned long long xenstat_node_irq_time(xenstat_node * node); + /* * Domain functions - extract information from a xenstat_domain */ diff --git a/tools/xenstat/libxenstat/src/xenstat_priv.h b/tools/xenstat/li= bxenstat/src/xenstat_priv.h index 4eb44a8..64387cd 100644 --- a/tools/xenstat/libxenstat/src/xenstat_priv.h +++ b/tools/xenstat/libxenstat/src/xenstat_priv.h @@ -45,6 +45,11 @@ struct xenstat_node { unsigned int flags; unsigned long long cpu_hz; unsigned int num_cpus; + unsigned long long hyp_time; + unsigned long long guest_time; + unsigned long long idle_time; + unsigned long long gsync_time; + unsigned long long irq_time; unsigned long long tot_mem; unsigned long long free_mem; unsigned int num_domains; diff --git a/tools/xenstat/xentop/xentop.c b/tools/xenstat/xentop/xentop.c index af11ebf..7514559 100644 --- a/tools/xenstat/xentop/xentop.c +++ b/tools/xenstat/xentop/xentop.c @@ -930,6 +930,40 @@ void adjust_field_widths(xenstat_domain *domain) fields[FIELD_VBD_WSECT-1].default_width =3D length; } =20 +void do_utilization(void) +{ + double us_elapsed =3D 0.0, + us_hyp =3D 0.0, + us_guest =3D 0.0, + us_idle =3D 0.0, + us_gsync =3D 0.0, + us_irq =3D 0.0; + + /* Can't calculate CPU percentage without a current and a previous sample= .*/ + if(prev_node !=3D NULL && cur_node !=3D NULL) { + + /* Calculate the time elapsed in microseconds */ + us_elapsed =3D ((curtime.tv_sec-oldtime.tv_sec)*1000000.0 + +(curtime.tv_usec - oldtime.tv_usec)); + + /* In the following, nanoseconds must be multiplied by 1000.0 to + * convert to microseconds, then divided by 100.0 to get a percentage, + * resulting in a multiplication by 10.0 */ + us_idle =3D ((xenstat_node_idle_time(cur_node) - + xenstat_node_idle_time(prev_node))/10.0)/us_elapsed; + us_guest =3D ((xenstat_node_guest_time(cur_node) - + xenstat_node_guest_time(prev_node))/10.0)/us_elapsed; + us_hyp =3D ((xenstat_node_hyp_time(cur_node) - + xenstat_node_hyp_time(prev_node))/10.0)/us_elapsed; + us_gsync =3D ((xenstat_node_gsync_time(cur_node) - + xenstat_node_gsync_time(prev_node))/10.0)/us_elapsed; + us_irq =3D ((xenstat_node_irq_time(cur_node) - + xenstat_node_irq_time(prev_node))/10.0)/us_elapsed; + } + + print("%%CPU(s): %6.1f gu, %6.1f gs, %6.1f ir, %6.1f hy, %6.1f id \n", + us_guest, us_gsync, us_irq, us_hyp, us_idle); +} =20 /* Section printing functions */ /* Prints the top summary, above the domain table */ @@ -972,6 +1006,8 @@ void do_summary(void) used =3D xenstat_node_tot_mem(cur_node); freeable_mb =3D 0; =20 + do_utilization(); + /* Dump node memory and cpu information */ if ( freeable_mb <=3D 0 ) print("Mem: %lluk total, %lluk used, %lluk free ", --=20 2.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu Apr 25 04:39:09 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1568198035; cv=none; d=zoho.com; s=zohoarc; b=WJiKifJZ/Xuz42dQ7zNijz3/RApjfery28cwwAgIOPmJeO4KqHeoLRJLevEq+evtamDpDW7GC8MMbEkXoUK69d0t6RPR2z2MRAI6OYwU0/QjIYmpKNyZTdAFSySyyUd0wC845Vgp9+AzWUx3CvtCZY42LubjN+R8vGNOLTVSnr0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568198035; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=3FC/mfjFig9yXFAXRX4BQU1tSPeK1VJqThSyUcddVVQ=; b=ktuamYhId8El/C2JRKU7V6Ab3Q+8Ih5GXoq7X/VuNN4cxVuHSehrOyfCqeF/fI+zFW8wwqp/cK0qTyXfWruoFDdA4MJAztFhbuw122cC6uwwCZCRGSN25Rt7AlitsNI0t/oAwb51qoVQz+0pMJ9FOndD4TtvQyZjdi+GRB5SEoQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1568198035213828.7862842007303; Wed, 11 Sep 2019 03:33:55 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i7zvd-0000Bk-B7; Wed, 11 Sep 2019 10:32:49 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i7zvc-0000BL-A9 for xen-devel@lists.xenproject.org; Wed, 11 Sep 2019 10:32:48 +0000 Received: from mail-lj1-x243.google.com (unknown [2a00:1450:4864:20::243]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 76e7155c-d47f-11e9-b299-bc764e2007e4; Wed, 11 Sep 2019 10:32:33 +0000 (UTC) Received: by mail-lj1-x243.google.com with SMTP id q64so8938613ljb.12 for ; 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.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Sep 2019 03:32:31 -0700 (PDT) X-Inumbo-ID: 76e7155c-d47f-11e9-b299-bc764e2007e4 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=FeNrC6ayJRxDhm8dZguxagsFl4ax8cTGLoDLGNor5EU=; b=C9Y2hzfU687HJuQP7Y3fi8qDQl9xytXyv9Kyrme6dgV4Xs/WHWxV6XmP7oasg8VfO6 SJJvsPpb20s4iOcVESxN/NvoBjs78eXLiQ0+RzENMu9W2LZ3gcb5Mk5M5Eyxyo0AoKZk lnVlmJW40/0Lf+arcy74Gkj2/vgnabYiuCBcGVZs1akW60WVOsJfmimJHWHNr/GsW8F9 PNr25QvQAkqBGvheRa9rhIwY3EecSrT3pn2cR8yT3xdjPoE5LWhMbIgQCHWqen8Jg/dn OYUokLg9GskhtC99lkwbDYAUuA5kJmWWHI4AsJcsT5wTiehHXDmVlWH+Bgwhi2N2blie L7wA== 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=FeNrC6ayJRxDhm8dZguxagsFl4ax8cTGLoDLGNor5EU=; b=HtEQJneMhHVv+PMKfX5s+z+FnYgEFHCyTUJKmELKpdk0eppVlfpGA6jTMus8sRVR2O scbFRSE0LG+rUhq8ID58x2zkHgzowzG8NkkfzSvbk0NKa5lvKDkGkvPO0UT8WC5a7xw/ 3Pc7IiYIXG4Ib9vidrfAQy8POKA/3znxdqZjoV16Dg0X0le1nstO6l83OJXSxmAiqbAJ kwOyWcgqQD/kdH4Uo31E97hPItooAvMPHLXQ4nmwhl3bZO9V6EoTtCHD+SV/ZmySh5bD CUYumcuZMkznid6uuDFeqDkfPPFV9hMsr4D1SfmUdjPDAojdNzSQJa702XJ6xi+ZoN+e Z2wA== X-Gm-Message-State: APjAAAWrWgMp+AY95EB8ocvxcu1Mb811b+yV0xgEtCp1b7k0OjIKLtHi kIo/vA+W/Mw7myT0hXN96RbGoXSZo4A= X-Google-Smtp-Source: APXvYqz5iVXjde/moak1Zqnzh85/RxP2W4dXNPHLLSW6UjD/1QSFoiU471ZYRqoCaWuOqP1lM0sDyQ== X-Received: by 2002:a2e:9882:: with SMTP id b2mr23024769ljj.225.1568197952337; Wed, 11 Sep 2019 03:32:32 -0700 (PDT) From: Andrii Anisov To: xen-devel@lists.xenproject.org Date: Wed, 11 Sep 2019 13:32:17 +0300 Message-Id: <1568197942-15374-5-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 4/9] arm64: utilize time accounting 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: Volodymyr Babchuk , Julien Grall , Stefano Stabellini , Andrii Anisov MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Andrii Anisov Call time accounting hooks from appropriate transition points of the ARM64 code. Signed-off-by: Andrii Anisov --- xen/arch/arm/arm64/entry.S | 39 ++++++++++++++++++++++++++++++++++++--- xen/arch/arm/domain.c | 2 ++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/arm64/entry.S b/xen/arch/arm/arm64/entry.S index 2d9a271..6fb2fa9 100644 --- a/xen/arch/arm/arm64/entry.S +++ b/xen/arch/arm/arm64/entry.S @@ -143,12 +143,21 @@ =20 .endm =20 - .macro exit, hyp, compat + .macro exit, hyp, compat, tacc=3D1 =20 .if \hyp =3D=3D 0 /* Guest mode */ =20 + .if \tacc =3D=3D 1 + + mov x0, #1 + bl tacc_hyp + + .endif + bl leave_hypervisor_tail /* Disables interrupts on return */ =20 + mov x0, #1 + bl tacc_guest exit_guest \compat =20 .endif @@ -205,9 +214,15 @@ hyp_sync: =20 hyp_irq: entry hyp=3D1 + mov x0,#5 + bl tacc_irq_enter msr daifclr, #4 mov x0, sp bl do_trap_irq + + mov x0,#5 + bl tacc_irq_exit + exit hyp=3D1 =20 guest_sync: @@ -291,6 +306,9 @@ guest_sync_slowpath: * to save them. */ entry hyp=3D0, compat=3D0, save_x0_x1=3D0 + =20 + mov x0,#1 + bl tacc_gsync /* * The vSError will be checked while SKIP_SYNCHRONIZE_SERROR_ENTRY= _EXIT * is not set. If a vSError took place, the initial exception will= be @@ -307,6 +325,10 @@ guest_sync_slowpath: =20 guest_irq: entry hyp=3D0, compat=3D0 + + mov x0,#6 + bl tacc_irq_enter + /* * The vSError will be checked while SKIP_SYNCHRONIZE_SERROR_ENTRY= _EXIT * is not set. If a vSError took place, the initial exception will= be @@ -319,6 +341,8 @@ guest_irq: mov x0, sp bl do_trap_irq 1: + mov x0,#6 + bl tacc_irq_exit exit hyp=3D0, compat=3D0 =20 guest_fiq_invalid: @@ -334,6 +358,9 @@ guest_error: =20 guest_sync_compat: entry hyp=3D0, compat=3D1 + + mov x0,#2 + bl tacc_gsync /* * The vSError will be checked while SKIP_SYNCHRONIZE_SERROR_ENTRY= _EXIT * is not set. If a vSError took place, the initial exception will= be @@ -350,6 +377,10 @@ guest_sync_compat: =20 guest_irq_compat: entry hyp=3D0, compat=3D1 + + mov x0,#7 + bl tacc_irq_enter + /* * The vSError will be checked while SKIP_SYNCHRONIZE_SERROR_ENTRY= _EXIT * is not set. If a vSError took place, the initial exception will= be @@ -362,6 +393,8 @@ guest_irq_compat: mov x0, sp bl do_trap_irq 1: + mov x0,#7 + bl tacc_irq_exit exit hyp=3D0, compat=3D1 =20 guest_fiq_invalid_compat: @@ -376,9 +409,9 @@ guest_error_compat: exit hyp=3D0, compat=3D1 =20 ENTRY(return_to_new_vcpu32) - exit hyp=3D0, compat=3D1 + exit hyp=3D0, compat=3D1, tacc=3D0 ENTRY(return_to_new_vcpu64) - exit hyp=3D0, compat=3D0 + exit hyp=3D0, compat=3D0, tacc=3D0 =20 return_from_trap: msr daifset, #2 /* Mask interrupts */ diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index a9c4113..53ef630 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -51,11 +51,13 @@ static void do_idle(void) process_pending_softirqs(); =20 local_irq_disable(); + tacc_idle(1); if ( cpu_is_haltable(cpu) ) { dsb(sy); wfi(); } + tacc_hyp(2); local_irq_enable(); =20 sched_tick_resume(); --=20 2.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu Apr 25 04:39:09 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1568198040; cv=none; d=zoho.com; s=zohoarc; b=dF3RuHlu8x4ruKC0wbcNTcAL/wa6NZMK8toUK9u+PbRmehRIRqgltCnAv70aCw0DxgSO9W4ZBgwk2h2aA/HDWMijATKwUlUyLkcJy9NRSsLuur4NmYAVfh6+y+bxah1FAb2l+7NNOb2TkDePkmn5oni4HLnuQZN+KLudshCc7+M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568198040; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=LIv33cW2CctnQNdWx4B/AnSAyLUEDzYkAZQ7VMQMjAQ=; b=GkXonFywaNuJ7JjCoX3LHFoODdbgkjoysbM5WFH7EuX1kftnziuWcM7nxfyudmFJ/JqgezqSbccEzdukzcofkrGur4CLBQE/uRLI3drwkHSqlhkYcHxTqJXpuVC+BPJEp0L1AYqpKaYbMuUGusffawT6jT6rZz0NkOvsdxSCcKk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1568198040588504.8567647276443; Wed, 11 Sep 2019 03:34:00 -0700 (PDT) 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 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) 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) X-Inumbo-ID: 77adbebe-d47f-11e9-a337-bc764e2007e4 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) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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--; } =20 +s_time_t tacc_get_guest_time(struct tacc *tacc) +{ + s_time_t guest_time; + + guest_time =3D tacc->state_time[TACC_GUEST]; + guest_time +=3D 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 =20 struct evtchn_fifo_vcpu *evtchn_fifo; =20 + s_time_t pcpu_guest_time; + /* vPCI per-vCPU area, used to store data for long running operations.= */ struct vpci_vcpu vpci; =20 @@ -1033,6 +1035,12 @@ DECLARE_PER_CPU(struct tacc, tacc); void tacc_hyp(int place); void tacc_idle(int place); =20 +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__ */ =20 /* --=20 2.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu Apr 25 04:39:09 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1568198042; cv=none; d=zoho.com; s=zohoarc; b=HeAWZi7jszmCYvWloV8geIAZEtmYrSe/INCQJTpe5kzPB3voJlCYffeCF01iUztGv3kQeliMFKvCuCdF5t8FDhINYqImGzyEH2pYL+XkCAzjyaZOtkq3o2WwReOTvC7mfB1X1ObZsY32sDj3Qr7ozLSx4XAsyOJR1d464L14ZkM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568198042; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=mtZgySk6FE5bDUFfO8kgrUBq4bNrTb0Obi2DLn6lkL8=; b=c+cblYdDW+1tt99+nEKDTxd6boUTOGYK9PXWJTWXjoKebSEu6qTnOlqgcwRIXPwPi6tyvCSR552C8NGDrl2mzrAr1Ubo5E0LTj27yuBdbrHy4J1NBSdQ7/hVxEAWS4+ZAB1V/Ye2J4e6wJzmM60E0CsFfeBKmf2QYdDFH7TIlNw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1568198042645441.9378459233243; Wed, 11 Sep 2019 03:34:02 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i7zvo-0000Ib-74; Wed, 11 Sep 2019 10:33:00 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i7zvm-0000HO-9T for xen-devel@lists.xenproject.org; Wed, 11 Sep 2019 10:32:58 +0000 Received: from mail-lf1-x141.google.com (unknown [2a00:1450:4864:20::141]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7872d6ea-d47f-11e9-978d-bc764e2007e4; Wed, 11 Sep 2019 10:32:36 +0000 (UTC) Received: by mail-lf1-x141.google.com with SMTP id t8so15988533lfc.13 for ; Wed, 11 Sep 2019 03:32:36 -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.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Sep 2019 03:32:34 -0700 (PDT) X-Inumbo-ID: 7872d6ea-d47f-11e9-978d-bc764e2007e4 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=08Tfqlh32NonuTtd2lAC2CC6l3pp2R7W8WbzNwGVHbA=; b=BqXnLW68Bh5QTW0Ew/mCLYKCqvWmb/YPGKeQEAPTGOZotGTFSmw4ATOHcollF/TsBB dEmF2tOGjYrMh//MMdu5usIUo8L9tqGjIba0zOCC06Ms/OkdEWdcLPHcGfE9riHEqTnF abJV9QX3hUB9bLo7HYKTMZj3m5oGTFDSCg7w5rscLcLc6atTZVm6ht5vf3n7+9mD//ui Q2+RbmY3R7syxHPVzRUfFdtogEHRYFUtf+uOeSJ/124fdQPDiRPOCxqRjqdA+pQYk1gM Bbl4Br0klvYTWCrITEvr7uTMm68chLWkiF6+4adXGk8rgxqXeIu3Y/m42iA2hpoCCShr zR8w== 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=08Tfqlh32NonuTtd2lAC2CC6l3pp2R7W8WbzNwGVHbA=; b=pQYRWFk2FuLWOqW3WPXQF/uA56tmXV+93BcbFsjNdvjZAOhfwxh8L0nov5wOxmdS7y BHQh82JIfkIjrap1snWC2Cjx3oUhp0R0TeZF2jBHPkPHFEhsw3drgI1Jxsb46iTE7PHc e5PkB2Rr16m4jWV7AuNbJfZ7StYWFatES6QaWs0zVX3hjhNYPY5LdJ5Cs8VGV0RBQlPw p5zT6daBkOoIlLzKq1+ktwjvzBzCy7JRXQBTnn3zUl5AYhBNiWxQGET+8acPHJeDIytq tMhOXa4Rb6RFTsxngqDX4Luddia8URx3WHdHFMR32BTxIB2L6qLoHEsyY8sTI8e3MeIG 6BtA== X-Gm-Message-State: APjAAAXRKMw+lrvsOxPZvXTlvVzIkftFIZ/6Q1H1BR5fQdsS0JOAzGN0 VekeGwObxnwj001mQ67Cqro3V7C1NgU= X-Google-Smtp-Source: APXvYqx0Y2MLLMusealu4mWXiRk+PuMbEJzgqM8TyJJ/YqX67dWzFfUWbRs8DaLxD53ZYt1aCG9+1Q== X-Received: by 2002:ac2:4a69:: with SMTP id q9mr22552432lfp.86.1568197954984; Wed, 11 Sep 2019 03:32:34 -0700 (PDT) From: Andrii Anisov To: xen-devel@lists.xenproject.org Date: Wed, 11 Sep 2019 13:32:19 +0300 Message-Id: <1568197942-15374-7-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 6/9] sched:rtds: get guest time from time accounting code 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 , Meng Xu , Dario Faggioli MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Andrii Anisov While the RTDS scheduler code does not use guest time from the other pcpu, we are free to go with lockless time accounting. Signed-off-by: Andrii Anisov --- xen/common/sched_rt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index e0e350b..2ce200b 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -945,8 +945,9 @@ burn_budget(const struct scheduler *ops, struct rt_vcpu= *svc, s_time_t now) if ( is_idle_vcpu(svc->vcpu) ) return; =20 + ASSERT(svc->vcpu =3D=3D current); /* burn at nanoseconds level */ - delta =3D now - svc->last_start; + delta =3D tacc_get_guest_time_delta(); /* * delta < 0 only happens in nested virtualization; * TODO: how should we handle delta < 0 in a better way? @@ -960,7 +961,6 @@ burn_budget(const struct scheduler *ops, struct rt_vcpu= *svc, s_time_t now) } =20 svc->cur_budget -=3D delta; - svc->last_start =3D now; =20 if ( svc->cur_budget <=3D 0 ) { --=20 2.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu Apr 25 04:39:09 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1568198062; cv=none; d=zoho.com; s=zohoarc; b=Fvh/EXjvCcQhWk/3oRrDTMRqjswPMJHOWq6sqoHb1emcDsQ23upYgY5+5RweAnSYa5dRIvfT3BlRFRTimwu8ml8vDAbMp4pxKCuXgZprb729RFkEXRv6fMPRYfUvIc7a4KjErGQDcrbOhVaX92ydBl85V+2kXhifmBO/LeincJ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568198062; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=vupEKNeYgEByKkpV2YmWbSKugrELyssvA5NpXrUfDBM=; b=lnbh9nmtvoqv2HtdXG7B8opWwS/6JyFTXjiT6oFGjVYZfN/qs2eIl31mm6vhKVUlug+NZfG/8X5kiWAe6D0ldbpjJOmbi+egqscC3+6KpfhlphADKy6T1Odng7khC8Bhp+q6ZLMQA3gg+SPHl18uOEbUYfwm5ssBUrpp8xn8428= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 15681980624121018.2483663098606; Wed, 11 Sep 2019 03:34:22 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i7zvs-0000Lb-IZ; Wed, 11 Sep 2019 10:33:04 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i7zvr-0000Ks-AR for xen-devel@lists.xenproject.org; Wed, 11 Sep 2019 10:33:03 +0000 Received: from mail-lf1-x144.google.com (unknown [2a00:1450:4864:20::144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 793ed45c-d47f-11e9-a337-bc764e2007e4; Wed, 11 Sep 2019 10:32:37 +0000 (UTC) Received: by mail-lf1-x144.google.com with SMTP id r134so16000689lff.12 for ; Wed, 11 Sep 2019 03:32:37 -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.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Sep 2019 03:32:35 -0700 (PDT) X-Inumbo-ID: 793ed45c-d47f-11e9-a337-bc764e2007e4 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=Pe9dvRwPhdT31/9Du9G7/kjBTUkLjLa2MmB2iXYgZwg=; b=NyaNagQ/0rkjRnn2FpInVnjY6JHRRjh3OlJ2NA6KLGo0THcH9KEsNCS3XJoEetGs3i jHeXHwXYN0mmcEAV/e8k7MQV+Bs9uJjxCR5E4KAnqFn5vIMeb007oQ/PTa9smFPDExi/ MkmA1Rqp7Dx3a4mXaaYwRr5ZoIpVXkwx9ds/4J3FsgxzPXM0afijlkND4+1wbzorl2R2 3Bs44QgGvJuFNT1yy2nEk50e/DfTPaX9jmVifXshFJQ8KsqKdyoo8r9uqFJq+qjuxdba 0CnEbXapbcmEFt5KmYl8ycUTI5UtFUWwoMHMqPHxjSUR8OWa3wjI3s1b5RS45HFW6Xp4 stsg== 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=Pe9dvRwPhdT31/9Du9G7/kjBTUkLjLa2MmB2iXYgZwg=; b=sIWJkYr30bDQ6M1ZHY2modvncPAGBOgF+SvdXuyqwRdksu9TnnSgr1tAduBXKK/3YS fPoNWPVanoK3QmEgZysDQzh50RhHXv+LNXuNcAURXKwsYW3tGdh3oBRriBptk/RQur3X 7sA2nhMP8ZbKMzkfOiXFwNYrzEhxYyTBtg712q+lTqAG6Ap/Fr5O6VCI6TRoLraNoo0P uOKLlretouJ5i/li7KEpv+G7wW1Ck01D79vU7zNzI5ePiH6uktbdkn9X64kZDLzzDa2I sUwXF2iiY1EZw8P7yWFUh71vVjXA+/2dhu/pMnZ+P6fopGYl/yOYpLjEBzT7eIRBElEP DaEA== X-Gm-Message-State: APjAAAWleSZdA6A1UFRA+bZvVJDwyfyDASiv5dF7Kng9uzAS3DyGObFN lJyIto2oJDbxP6AudOfQFdtBpI+4l0k= X-Google-Smtp-Source: APXvYqxjejrhFx/4g2irDO7w4Gg156RQ5cKIophC9kg0Yr2AE0r6OpyXiLm4oNq1tXRpJjIv/+EvCQ== X-Received: by 2002:ac2:4adb:: with SMTP id m27mr5227384lfp.1.1568197956313; Wed, 11 Sep 2019 03:32:36 -0700 (PDT) From: Andrii Anisov To: xen-devel@lists.xenproject.org Date: Wed, 11 Sep 2019 13:32:20 +0300 Message-Id: <1568197942-15374-8-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 7/9] tacc: Introduce a locked 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: Stefano Stabellini , Andrii Anisov , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , Dario Faggioli MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Andrii Anisov The locked interface to acquire guest time by scheduling code is introduced. It can be used by schedulers what do require guest time from a different pcpu to take scheduling decission. Signed-off-by: Andrii Anisov --- xen/common/Kconfig | 3 +++ xen/common/schedule.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ xen/include/xen/sched.h | 11 +++++++++++ 3 files changed, 58 insertions(+) diff --git a/xen/common/Kconfig b/xen/common/Kconfig index 16829f6..c1748dd 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -221,6 +221,9 @@ config ARGO menu "Schedulers" visible if EXPERT =3D "y" =20 +config TACC_NEEDS_LOCK + bool + config SCHED_CREDIT bool "Credit scheduler support" default y diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 62df77e..98b739f 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -1562,6 +1562,14 @@ static void schedule(void) context_switch(prev, next); } =20 +#ifdef CONFIG_TACC_NEEDS_LOCK +#define tacc_lock(tacc) spin_lock(&tacc->tacc_lock) +#define tacc_unlock(tacc) spin_unlock(&tacc->tacc_lock) +#else +#define tacc_lock(tacc) +#define tacc_unlock(tacc) +#endif + DEFINE_PER_CPU(struct tacc, tacc); =20 static void tacc_state_change(enum TACC_STATES new_state) @@ -1571,6 +1579,7 @@ static void tacc_state_change(enum TACC_STATES new_st= ate) unsigned long flags; =20 local_irq_save(flags); + tacc_lock(tacc); =20 now =3D NOW(); delta =3D now - tacc->state_entry_time; @@ -1584,6 +1593,7 @@ static void tacc_state_change(enum TACC_STATES new_st= ate) tacc->state =3D new_state; tacc->state_entry_time =3D now; =20 + tacc_unlock(tacc); local_irq_restore(flags); } =20 @@ -1621,7 +1631,9 @@ void tacc_irq_enter(int place) =20 if ( tacc->irq_cnt =3D=3D 0 ) { + tacc_lock(tacc); tacc->irq_enter_time =3D NOW(); + tacc_unlock(tacc); } =20 tacc->irq_cnt++; @@ -1636,8 +1648,10 @@ void tacc_irq_exit(int place) ASSERT(tacc->irq_cnt > 0); if ( tacc->irq_cnt =3D=3D 1 ) { + tacc_lock(tacc); tacc->irq_time =3D NOW() - tacc->irq_enter_time; tacc->irq_enter_time =3D 0; + tacc_unlock(tacc); } =20 tacc->irq_cnt--; @@ -1653,6 +1667,36 @@ s_time_t tacc_get_guest_time(struct tacc *tacc) return guest_time; } =20 +#ifdef CONFIG_TACC_NEEDS_LOCK +s_time_t tacc_get_guest_time_cpu(int cpu) +{ + struct tacc* tacc =3D &per_cpu(tacc, cpu); + s_time_t guest_time; + s_time_t now; + + tacc_lock(tacc); + + now =3D NOW(); + guest_time =3D tacc_get_guest_time(tacc); + if (tacc->state =3D=3D TACC_GUEST || tacc->state =3D=3D TACC_GSYNC) + { + guest_time +=3D NOW() - tacc->state_entry_time; + } + + if (tacc->irq_enter_time) + { + guest_time -=3D NOW() - tacc->irq_enter_time; + } + + guest_time -=3D tacc->irq_time; + + tacc_unlock(tacc); + + return guest_time; +} +#endif + + 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 5b41805..a649d1f 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -1028,6 +1028,9 @@ struct tacc s_time_t irq_enter_time; s_time_t irq_time; int irq_cnt; +#ifdef CONFIG_TACC_NEEDS_LOCK + spinlock_t tacc_lock; +#endif }; =20 DECLARE_PER_CPU(struct tacc, tacc); @@ -1041,6 +1044,14 @@ inline s_time_t tacc_get_guest_time_delta(void) return tacc_get_guest_time(&this_cpu(tacc)) - current->pcpu_guest_time; } =20 +#ifdef CONFIG_TACC_NEEDS_LOCK +s_time_t tacc_get_guest_time_cpu(int cpu); +inline s_time_t tacc_get_guest_time_delta_vcpu(struct vcpu* vcpu) +{ + return tacc_get_guest_time_cpu(vcpu->processor) - vcpu->pcpu_guest_tim= e; +} +#endif + #endif /* __SCHED_H__ */ =20 /* --=20 2.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu Apr 25 04:39:09 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1568198046; cv=none; d=zoho.com; s=zohoarc; b=LimDtAT8q6GY61gA4GoFHAPAn3bRU2ouh1zyFDMAvgnfWpqkvu30Wom0VNjNnNGDRnmijk2tHuEoBmV7ZXmuAJE1ECr3l5EE1lc6ZvWaaaDUZSTkY+0Dtv+FgQt9WEzRhEhf9amLW3yA4bMP62ej73NAQcMhR4kfWAzoTqqc4Xs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568198046; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=WOTRTleAxDNNUCZzt1aKf7zuM+ZvERH4y1Ayl0d4tEg=; b=D0NOWdobYFxfCWKpULTWY3x+tiOY66JFDb+cf3r28owinNKpdpEKzCdTq/F4U1xFcC1KNiz95LK6jeSy+c8S00UJrTwZpvaR5/FYoSebWE8nXgX0pWvLRSCGhk1eA1HSVRCB0+TXK4OeXCTK2WpZnBLCedQVgO+WHiZZwM1ENIg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1568198046648534.6329977678579; Wed, 11 Sep 2019 03:34:06 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i7zvx-0000Q7-Ta; Wed, 11 Sep 2019 10:33:09 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i7zvw-0000P1-AV for xen-devel@lists.xenproject.org; Wed, 11 Sep 2019 10:33:08 +0000 Received: from mail-lj1-x244.google.com (unknown [2a00:1450:4864:20::244]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7a46ec36-d47f-11e9-b299-bc764e2007e4; Wed, 11 Sep 2019 10:32:39 +0000 (UTC) Received: by mail-lj1-x244.google.com with SMTP id u14so19450744ljj.11 for ; Wed, 11 Sep 2019 03:32:39 -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.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Sep 2019 03:32:37 -0700 (PDT) X-Inumbo-ID: 7a46ec36-d47f-11e9-b299-bc764e2007e4 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=D1tmQx4QQQTXiGm/taYp9ljWrLsYP/6Sdp2V1mTvY5Q=; b=mkSkUftQESBwTE4pIFjxK9nOfDpujozkVjuwu1pLch7xAXRF/bECdIU1TZyHk5wChg UOWQlOXQPb+UjPLj1fcfEKamv9s8PynMB/StH3U1vRP3AVaxbIt6pFCra/d5IR0oaQ7N y1dARxwpsAU8HA4wOmcyUrXnodrkPo2Z2BlzebyvDBGOSb5pOKWcckzW0t2j7WZ1hVT7 R0m8q0eaAzywezFAe9j1YCCFj/MzugvLzL2bEl1hD7r+TQXlb1Z6aydmgpSAnAFAVSFH 4ybJJfc3bCZccsg+w7QQKvZRgQdFcaChtvEEeXHp1GLQq+AB+t2h01uvp+cZrj+uefcl dLTQ== 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=D1tmQx4QQQTXiGm/taYp9ljWrLsYP/6Sdp2V1mTvY5Q=; b=Gi0uxWIXJRxiLsFeowNR8QaCk/ZcT1BtiEG0h9rrZLOUU8AtRKatA5tq85Y/B457TX GSAEGcWY6QaHXIn52YV45MESDIi6t9t589qYFQunRgHe/5lMYFuqrPiw6TGQCQUURhN4 dk84kLfOtbKFMUU6oF+JqELdjN/UP8cYBrvJT99dmF2eI47erFfP2buIWNwjR+jDV+iI 9H9yU+V2/D8ZSDA4NEDvsjbdUSKCSVbqMWNMBnBBaFW5DShDKhh8gcHiwiJClCpdnXvC vmX8mXh2R3rjThzcxUC9eYjF14RBiZfqk6dSW8YvVi+ZXCyAsWO2wX+Ut2YdNuKOSJpG Ur3w== X-Gm-Message-State: APjAAAUNA9baGP0Pw155WKcVU6WkOAm9+rc2Lp4h3KsxRqPw4WdNmUXY R1d+k5tH2c9GYhBGHP8r6zkenr/m40U= X-Google-Smtp-Source: APXvYqzHZOS70e5XAk+zkJW0cCEdc6izNMK3UieVBImeIDCwGtsLRl0Oq/AKUp5DG3TGajQ0KAUjAw== X-Received: by 2002:a2e:504f:: with SMTP id v15mr23161379ljd.67.1568197957942; Wed, 11 Sep 2019 03:32:37 -0700 (PDT) From: Andrii Anisov To: xen-devel@lists.xenproject.org Date: Wed, 11 Sep 2019 13:32:21 +0300 Message-Id: <1568197942-15374-9-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 8/9] sched:credit: get guest time from time accounting code 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: Stefano Stabellini , Andrii Anisov , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , Dario Faggioli MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Andrii Anisov While the Credit scheduler code uses guest time from the other pcpu, we have to use locked time accounting. Signed-off-by: Andrii Anisov --- xen/common/Kconfig | 1 + xen/common/sched_credit.c | 12 +++++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/xen/common/Kconfig b/xen/common/Kconfig index c1748dd..d17a8b4 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -227,6 +227,7 @@ config TACC_NEEDS_LOCK config SCHED_CREDIT bool "Credit scheduler support" default y + select TACC_NEEDS_LOCK ---help--- The traditional credit scheduler is a general purpose scheduler. =20 diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 81dee5e..ac6b9e6 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -324,16 +324,15 @@ runq_remove(struct csched_vcpu *svc) __runq_remove(svc); } =20 -static void burn_credits(struct csched_vcpu *svc, s_time_t now) +static void burn_credits(struct csched_vcpu *svc, s_time_t delta) { - s_time_t delta; uint64_t val; unsigned int credits; =20 /* Assert svc is current */ ASSERT( svc =3D=3D CSCHED_VCPU(curr_on_cpu(svc->vcpu->processor)) ); =20 - if ( (delta =3D now - svc->start_time) <=3D 0 ) + if ( delta <=3D 0 ) return; =20 val =3D delta * CSCHED_CREDITS_PER_MSEC + svc->residual; @@ -341,7 +340,6 @@ static void burn_credits(struct csched_vcpu *svc, s_tim= e_t now) credits =3D val; ASSERT(credits =3D=3D val); /* make sure we haven't truncated val */ atomic_sub(credits, &svc->credit); - svc->start_time +=3D (credits * MILLISECS(1)) / CSCHED_CREDITS_PER_MSE= C; } =20 static bool_t __read_mostly opt_tickle_one_idle =3D 1; @@ -956,7 +954,7 @@ csched_vcpu_acct(struct csched_private *prv, unsigned i= nt cpu) /* * Update credits */ - burn_credits(svc, NOW()); + burn_credits(svc, tacc_get_guest_time_delta_vcpu(svc->vcpu)); =20 /* * Put this VCPU and domain back on the active list if it was @@ -1856,14 +1854,14 @@ csched_schedule( (unsigned char *)&d); } =20 - runtime =3D now - current->runstate.state_entry_time; + runtime =3D tacc_get_guest_time_delta(); if ( runtime < 0 ) /* Does this ever happen? */ runtime =3D 0; =20 if ( !is_idle_vcpu(scurr->vcpu) ) { /* Update credits of a non-idle VCPU. */ - burn_credits(scurr, now); + burn_credits(scurr, runtime); scurr->start_time -=3D now; scurr->last_sched_time =3D now; } --=20 2.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu Apr 25 04:39:09 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1568198056; cv=none; d=zoho.com; s=zohoarc; b=PoSCZW/xdnDLJdqB2D3+cNSPt6fAS4Lo+SvCrI0dKV2v1O4B1kM7FWGtWcrtPIIe4GskI5Hc+opBMGM9owdsOybBDhauI6L3DEM62RcaGYOS13GQNqVWBa+7S6XQrIvX8IpqXcE1Nem7vEmepBf/KL9HNYnZLPFuYkHJ3Oi7+uQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568198056; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=GSs93aNowSNdkmogCRWbnEP82FDoCyvH8SjkD9kf9MM=; b=RFuV8g+Y//21dY8WgdmgxK2meCc+DXD4sekVaPLxTTL53B1GZ0LxS1Rz9MyLv+xAQ7s7gs1CD8KS5k58Sh6cH8d/2JtOPUO/Ufj2l2JGISVWvknSYgPCEx81HjCXr0dffqDt38gM50NsguGDZtMKXphtkDYEh91QtuXdXeTuOE0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 15681980565031023.1742293684288; Wed, 11 Sep 2019 03:34:16 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i7zw3-0000UL-8N; Wed, 11 Sep 2019 10:33:15 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i7zw1-0000T0-AK for xen-devel@lists.xenproject.org; Wed, 11 Sep 2019 10:33:13 +0000 Received: from mail-lj1-x244.google.com (unknown [2a00:1450:4864:20::244]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7b29eefa-d47f-11e9-b76c-bc764e2007e4; Wed, 11 Sep 2019 10:32:41 +0000 (UTC) Received: by mail-lj1-x244.google.com with SMTP id y23so19132831ljn.5 for ; Wed, 11 Sep 2019 03:32:41 -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.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Sep 2019 03:32:38 -0700 (PDT) X-Inumbo-ID: 7b29eefa-d47f-11e9-b76c-bc764e2007e4 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=nTxSIglmusaJTq+slsHa0UgJ/0RrGOlxtblHgFLIsZ4=; b=uj8hwhqHEt/YuJweovSp6KjRqgNBJw149U13EqsUdElkHyDRWKs2ERrR5JC3TyROTE pETd614g2kxfVzS2TX2Vf6MtN+l7zm0DRFgilUicOfsCz4rR5uOVstSqCdZqkcqgfIsr QoiOZHxg6Tr/hdRRqvateyzO2vF39//gz/tdd2nUu62ZQWMdgYCdE5sUjC8mT8LTCj8P aQ3KPkkHQtWLiV6FUWAQD6ChOFGbQTVQxtNfR64FPVy9vYc+HdGOo3JkWyTLh75FnQmD yWh1aIKOG97JEiYgnavoWAG9ZG6loIVH1mV2J2fN/7uBUD3GjHSy7aI5MtDMiy5DW9vC gYbg== 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=nTxSIglmusaJTq+slsHa0UgJ/0RrGOlxtblHgFLIsZ4=; b=WdheIRjDD0cjz2fiJxKthDRXZsrwfd+lH2TuLJmmejaOsAsiQdGY0iyFO7zJrn0AEK StmnRtXNqPNXrwI8xIvFbvK76R2HUpOvHOyRnH2sLX3TiK7jR/sgFuCKswb1EYCxZWGg dxeMCHmFcMVZru+mhM/1JoGY+SJZYdTK6YlXfj8IjILTy54i+azrxvSc7NOo7DedLEvI RMfpSURHo+Fq1wcwZFI+/PfqSAV1MVPe+SDdEHjwZ5e2f/04FGpA8vJYl4qbeGs5byiC mGfDcTbQyMi1LUM6CoQVRwRWsIEUx8TAoyGrzbtuyXXg+s58wRSeGekdeHh0MF2hQLLv 1Xug== X-Gm-Message-State: APjAAAUWnbSHnfvHo/izFNwB60MDU88vRGLJ/OaaZdlxxI7KxkboLKRW w4r/BiU7JvlA9OXt02sLa8gXxTYJKYQ= X-Google-Smtp-Source: APXvYqw7Zpe3MGMlHtgBgNuE9VQf7Mufhx7GHZJO8jeINlKDc+9rZNrgrh9XUoy2yHDqq24BiZzGIA== X-Received: by 2002:a2e:88c6:: with SMTP id a6mr23164351ljk.39.1568197959507; Wed, 11 Sep 2019 03:32:39 -0700 (PDT) From: Andrii Anisov To: xen-devel@lists.xenproject.org Date: Wed, 11 Sep 2019 13:32:22 +0300 Message-Id: <1568197942-15374-10-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 9/9] sched:credit2: get guest time from time accounting code 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: Stefano Stabellini , Andrii Anisov , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , Dario Faggioli MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Andrii Anisov While the Credit2 scheduler code uses guest time from the other pcpu, we have to use locked time accounting. Signed-off-by: Andrii Anisov --- xen/common/Kconfig | 1 + xen/common/sched_credit2.c | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/xen/common/Kconfig b/xen/common/Kconfig index d17a8b4..6408c18 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -234,6 +234,7 @@ config SCHED_CREDIT config SCHED_CREDIT2 bool "Credit2 scheduler support" default y + select TACC_NEEDS_LOCK ---help--- The credit2 scheduler is a general purpose scheduler that is optimized for lower latency and higher VM density. diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index 6b77da7..3b3888b 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -1342,7 +1342,7 @@ static inline bool is_preemptable(const struct csched= 2_vcpu *svc, return true; =20 ASSERT(svc->vcpu->is_running); - return now - svc->vcpu->runstate.state_entry_time > + return tacc_get_guest_time_delta_vcpu(svc->vcpu)> ratelimit - CSCHED2_RATELIMIT_TICKLE_TOLERANCE; } =20 @@ -1722,7 +1722,7 @@ void burn_credits(struct csched2_runqueue_data *rqd, return; } =20 - delta =3D now - svc->start_time; + delta =3D tacc_get_guest_time_delta_vcpu(svc->vcpu); =20 if ( unlikely(delta <=3D 0) ) { @@ -1739,7 +1739,7 @@ void burn_credits(struct csched2_runqueue_data *rqd, if ( has_cap(svc) ) svc->budget -=3D delta; =20 - svc->start_time =3D now; + svc->vcpu->pcpu_guest_time +=3D delta; =20 out: if ( unlikely(tb_init_done) ) @@ -3189,8 +3189,8 @@ csched2_runtime(const struct scheduler *ops, int cpu, { s_time_t ratelimit_min =3D MICROSECS(prv->ratelimit_us); if ( snext->vcpu->is_running ) - ratelimit_min =3D snext->vcpu->runstate.state_entry_time + - MICROSECS(prv->ratelimit_us) - now; + ratelimit_min =3D tacc_get_guest_time_delta_vcpu(snext->vcpu) + + MICROSECS(prv->ratelimit_us); if ( ratelimit_min > min_time ) min_time =3D ratelimit_min; } @@ -3265,6 +3265,7 @@ runq_candidate(struct csched2_runqueue_data *rqd, struct csched2_vcpu *snext =3D NULL; struct csched2_private *prv =3D csched2_priv(per_cpu(scheduler, cpu)); bool yield =3D false, soft_aff_preempt =3D false; + s_time_t guest_time; =20 *skipped =3D 0; =20 @@ -3286,8 +3287,8 @@ runq_candidate(struct csched2_runqueue_data *rqd, * no point forcing it to do so until rate limiting expires. */ if ( !yield && prv->ratelimit_us && vcpu_runnable(scurr->vcpu) && - (now - scurr->vcpu->runstate.state_entry_time) < - MICROSECS(prv->ratelimit_us) ) + ((guest_time =3D tacc_get_guest_time_delta_vcpu(scurr->vcpu)) < + MICROSECS(prv->ratelimit_us))) { if ( unlikely(tb_init_done) ) { @@ -3297,7 +3298,7 @@ runq_candidate(struct csched2_runqueue_data *rqd, } d; d.dom =3D scurr->vcpu->domain->domain_id; d.vcpu =3D scurr->vcpu->vcpu_id; - d.runtime =3D now - scurr->vcpu->runstate.state_entry_time; + d.runtime =3D guest_time; __trace_var(TRC_CSCHED2_RATELIMIT, 1, sizeof(d), (unsigned char *)&d); --=20 2.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel