From nobody Mon Feb 9 17:59:04 2026 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=1564137548; cv=none; d=zoho.com; s=zohoarc; b=Fjv5PkSbaG9W86q/7/jpOfAg3ypLJfWf61ofUU9Bvtf0HgVHtJElHyI3w+GshXSEk6RoN4tZ963ZVQ+01xixDb2WROnqIhHbKPzdtxgRtQJQlxE+Xd0xfDkbK/EVcfPKdLAft7diL2zVj2ZeeA9NtN30dTW6SG4Bo5heAVs5L1Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564137548; 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=EYZL3iJm5/RdIWC5PinzYR+HZ59HZakiQApxuR8lmNQ=; b=KiZ0Vw4YXArhuXc6uFEOiG8F+uIOPL369es99sNjVTAMpfx1OE5moqFLslygoddFcRvKXHZIVo01BXx9pclSPl1zILyASTuJfCbVgP0/8kY23lVvgCsLvcZZ2VJOjJ1oPHvY8XaZur/lP8ar8lrlXmnaAqealZOc1bqln6UPsZM= 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 1564137548415207.83794595285644; Fri, 26 Jul 2019 03:39:08 -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 1hqxbj-0006YT-2P; Fri, 26 Jul 2019 10:37:51 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hqxbh-0006YG-Oi for xen-devel@lists.xenproject.org; Fri, 26 Jul 2019 10:37:49 +0000 Received: from mail-lj1-x243.google.com (unknown [2a00:1450:4864:20::243]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 6890b12e-af91-11e9-8980-bc764e045a96; Fri, 26 Jul 2019 10:37:48 +0000 (UTC) Received: by mail-lj1-x243.google.com with SMTP id t28so51004234lje.9 for ; Fri, 26 Jul 2019 03:37:47 -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 m4sm9938274ljc.56.2019.07.26.03.37.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Jul 2019 03:37:45 -0700 (PDT) X-Inumbo-ID: 6890b12e-af91-11e9-8980-bc764e045a96 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=r+8JnlZestTVxlER6RMuaC2epWUTI/v8WDaAeYWwhA0=; b=RErUSs4OfOW/pF16O1aJVbU3Hhci+OMHYQPUk2SEsqu4CYSMr9MwQIgkWyIIPO/yvp qGPQOfBQFNHUiuojaa2stI9YYWn7ptUKN7+6Xisdjrzlv6L5DtPy+qD15r3hpHWGNqRw MyH9te2o+rJVHwlsKBzYnHNAJ/qEPaImQEB+cz0ozfInPKstUj+m5gS4RofLWvphvdJy p1/zSAvhBDeFosLUoqdt7AU7w1JxbdBw0CxwJyo4m6gjUUXqBFgjujvS88TmqIb4EucG eY0hfn8R/bYIeBvpj+DvmG4uZO0AQPY4CyZrBw0/MY6gZ5XTM7Z2vCDm5eAbgbbRBk0U FUYg== 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=r+8JnlZestTVxlER6RMuaC2epWUTI/v8WDaAeYWwhA0=; b=Q2nzZhVjBZ4Rf3kBXs+7iVLDAT3YrRL2/1FFnDtX8KU0vyoZCQdpHokwPDQKjBiw6x hTj5YtEH7FtUGAQTaXdvVmFtSIDiEX8idYP3fzb9rjEuP1AKKSBn3bd6kkHJfLhV5tcP zZtCmrZqGGS336VbgrH0dD2ZWgM2qo0YPC/r9NGSiLn7fftvpP0RY3fg23By4S9TQdxf O4wwcmpttAeKB4qrEv5UHejxLgJVyP8xdfcaX86UmVnwZJlO7pazEcSn0pV4+onUqEQ6 qsFwNtrOq37IDczzv9O37bff0aCfcVB9gkpPVtpIAtjbdkY9R6b+9iyN1tA5bLJfKTGb u//Q== X-Gm-Message-State: APjAAAW1E3qgZyRi7yK8BkflNCatvLTFCPHhGC4Lu5qLaI1CAtrXboh6 +C4qpgGfmDN0Zio6x+uygZbxBxWO X-Google-Smtp-Source: APXvYqzHH/Xa7A2eRVemlcQHIS8r9ZHsUY98TbT8rBeFeaJFRSzBtBgMe01uVPHjzTX70sZs9qqx3g== X-Received: by 2002:a2e:9117:: with SMTP id m23mr49167542ljg.134.1564137466198; Fri, 26 Jul 2019 03:37:46 -0700 (PDT) From: Andrii Anisov To: xen-devel@lists.xenproject.org Date: Fri, 26 Jul 2019 13:37:35 +0300 Message-Id: <1564137460-25629-3-git-send-email-andrii.anisov@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1564137460-25629-1-git-send-email-andrii.anisov@gmail.com> References: <1564137460-25629-1-git-send-email-andrii.anisov@gmail.com> Subject: [Xen-devel] [RFC 2/6] schedule: account true system idle 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 , George Dunlap , Dario Faggioli , Julien Grall , Volodymyr Babchuk 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 Currently the idle time is being accounted as a idle vcpu runtime. This is not entirely correct, because the entity named idle vcpu is in fact a hypervisor tasks worker. E.g. some softirqs are processed by the idle vcpu. So lets change idle vcpu time accounting and specify system idle time as a idle vcpu blocked time. For this we should appropriately change idle vcpu runstates around the real processor idle entry. Signed-off-by: Andrii Anisov --- xen/arch/arm/domain.c | 24 ++++++++++++++++++++++++ xen/common/schedule.c | 4 +++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 941bbff..a4e0fd7 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -19,6 +19,7 @@ #include #include #include +#include =20 #include #include @@ -42,6 +43,27 @@ =20 DEFINE_PER_CPU(struct vcpu *, curr_vcpu); =20 +static inline void idle_vcpu_runstate_change( + unsigned int cpu, int new_state, s_time_t new_entry_time) +{ + s_time_t delta; + struct vcpu *v =3D idle_vcpu[cpu]; + spinlock_t *lock =3D vcpu_schedule_lock(v); + + ASSERT(v =3D=3D current); + ASSERT(v->runstate.state !=3D new_state); + + delta =3D new_entry_time - v->runstate.state_entry_time; + if ( delta > 0 ) + { + v->runstate.time[v->runstate.state] +=3D delta; + v->runstate.state_entry_time =3D new_entry_time; + } + + v->runstate.state =3D new_state; + vcpu_schedule_unlock(lock, v); +} + static void do_idle(void) { unsigned int cpu =3D smp_processor_id(); @@ -51,11 +73,13 @@ static void do_idle(void) process_pending_softirqs(); =20 local_irq_disable(); + idle_vcpu_runstate_change(cpu, RUNSTATE_blocked, NOW()); if ( cpu_is_haltable(cpu) ) { dsb(sy); wfi(); } + idle_vcpu_runstate_change(cpu, RUNSTATE_running, NOW()); local_irq_enable(); =20 sched_tick_resume(); diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 349f962..0a38d4a 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -214,7 +214,7 @@ uint64_t get_cpu_idle_time(unsigned int cpu) if ( cpu_online(cpu) && v ) vcpu_runstate_get(v, &state); =20 - return state.time[RUNSTATE_running]; + return state.time[RUNSTATE_blocked]; } =20 /* @@ -922,6 +922,8 @@ void vcpu_block(void) { struct vcpu *v =3D current; =20 + ASSERT(!is_idle_vcpu(v)); + set_bit(_VPF_blocked, &v->pause_flags); =20 arch_vcpu_block(v); --=20 2.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel