From patchwork Fri Mar 29 15:09:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 10877261 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 178D91708 for ; Fri, 29 Mar 2019 15:11:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 006602987F for ; Fri, 29 Mar 2019 15:11:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F22DA29888; Fri, 29 Mar 2019 15:11:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9ABC02987F for ; Fri, 29 Mar 2019 15:11:36 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1h9t93-0004VC-D4; Fri, 29 Mar 2019 15:10:13 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1h9t8k-0003m3-Ik for xen-devel@lists.xenproject.org; Fri, 29 Mar 2019 15:09:54 +0000 X-Inumbo-ID: b28bab65-5234-11e9-bc90-bc764e045a96 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id b28bab65-5234-11e9-bc90-bc764e045a96; Fri, 29 Mar 2019 15:09:50 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 8C62EB031; Fri, 29 Mar 2019 15:09:49 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Fri, 29 Mar 2019 16:09:20 +0100 Message-Id: <20190329150934.17694-36-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190329150934.17694-1-jgross@suse.com> References: <20190329150934.17694-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC 35/49] xen/sched: add runstate counters to struct sched_item 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: Juergen Gross , Tim Deegan , Stefano Stabellini , 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" X-Virus-Scanned: ClamAV using ClamSMTP Add counters to struct sched_item indicating how many vcpus are either running/runnable or blocked/paused. The counters are updated when a vcpu runstate is changed. Signed-off-by: Juergen Gross --- xen/common/schedule.c | 27 +++++++++++++++++++++++++++ xen/include/xen/sched-if.h | 4 ++++ 2 files changed, 31 insertions(+) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 5a12d9bdc7..0a94505b89 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -178,6 +178,7 @@ static inline void vcpu_runstate_change( struct vcpu *v, int new_state, s_time_t new_entry_time) { s_time_t delta; + bool old_run, new_run; ASSERT(v->runstate.state != new_state); ASSERT(spin_is_locked(per_cpu(sched_res, v->processor)->schedule_lock)); @@ -186,6 +187,26 @@ static inline void vcpu_runstate_change( trace_runstate_change(v, new_state); + old_run = (v->runstate.state == RUNSTATE_running || + v->runstate.state == RUNSTATE_runnable); + new_run = (new_state == RUNSTATE_running || new_state == RUNSTATE_runnable); + + if ( old_run != new_run ) + { + struct sched_item *item = v->sched_item; + + if ( old_run ) + { + item->run_cnt--; + item->idle_cnt++; + } + else + { + item->run_cnt++; + item->idle_cnt--; + } + } + delta = new_entry_time - v->runstate.state_entry_time; if ( delta > 0 ) { @@ -362,9 +383,15 @@ int sched_init_vcpu(struct vcpu *v) return 1; if ( is_idle_domain(d) ) + { processor = v->vcpu_id; + item->run_cnt++; + } else + { processor = sched_select_initial_cpu(v); + item->idle_cnt++; + } sched_set_res(item, per_cpu(sched_res, processor)); diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index 38b403dfbf..795b2fafe5 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -62,6 +62,10 @@ struct sched_item { /* Last time item got (de-)scheduled. */ uint64_t state_entry_time; + /* Vcpu state summary. */ + unsigned int run_cnt; /* vcpus running or runnable */ + unsigned int idle_cnt; /* vcpus blocked or offline */ + /* Currently running on a CPU? */ bool is_running; /* Item needs affinity restored */