From patchwork Sat Sep 14 08:52:29 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: 11145627 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 6F1651800 for ; Sat, 14 Sep 2019 08:55:21 +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 55F1720830 for ; Sat, 14 Sep 2019 08:55:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 55F1720830 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.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 1i93ot-0000kb-G3; Sat, 14 Sep 2019 08:54:15 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i93or-0000gv-Ml for xen-devel@lists.xenproject.org; Sat, 14 Sep 2019 08:54:13 +0000 X-Inumbo-ID: 10284566-d6cd-11e9-95c1-12813bfff9fa Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 10284566-d6cd-11e9-95c1-12813bfff9fa; Sat, 14 Sep 2019 08:53:04 +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 78582B66F; Sat, 14 Sep 2019 08:53:02 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Sat, 14 Sep 2019 10:52:29 +0200 Message-Id: <20190914085251.18816-26-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190914085251.18816-1-jgross@suse.com> References: <20190914085251.18816-1-jgross@suse.com> Subject: [Xen-devel] [PATCH v3 25/47] xen/sched: add runstate counters to struct sched_unit 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" Add counters to struct sched_unit summing up runstates of associated vcpus. This allows doing quick checks whether a unit has any vcpu running or whether only a single vcpu of a unit is running. Signed-off-by: Juergen Gross --- RFC V2: add counters for each possible runstate --- xen/common/schedule.c | 8 +++++++- xen/include/xen/sched.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 7b37461db9..0bd9f0d278 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -239,6 +239,7 @@ static inline void vcpu_runstate_change( struct vcpu *v, int new_state, s_time_t new_entry_time) { s_time_t delta; + struct sched_unit *unit = v->sched_unit; ASSERT(v->runstate.state != new_state); ASSERT(spin_is_locked(get_sched_res(v->processor)->schedule_lock)); @@ -247,6 +248,9 @@ static inline void vcpu_runstate_change( trace_runstate_change(v, new_state); + unit->runstate_cnt[v->runstate.state]--; + unit->runstate_cnt[new_state]++; + delta = new_entry_time - v->runstate.state_entry_time; if ( delta > 0 ) { @@ -368,7 +372,7 @@ static struct sched_unit *sched_alloc_unit(struct vcpu *v) unit->vcpu_list = v; unit->unit_id = v->vcpu_id; unit->domain = d; - v->sched_unit = unit; + unit->runstate_cnt[v->runstate.state]++; for ( prev_unit = &d->sched_unit_list; *prev_unit; prev_unit = &(*prev_unit)->next_in_list ) @@ -384,6 +388,8 @@ static struct sched_unit *sched_alloc_unit(struct vcpu *v) !zalloc_cpumask_var(&unit->cpu_soft_affinity) ) goto fail; + v->sched_unit = unit; + return unit; fail: diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 56ed863b08..36257a06fe 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -277,6 +277,8 @@ struct sched_unit { /* Last time unit got (de-)scheduled. */ uint64_t state_entry_time; + /* Vcpu state summary. */ + unsigned int runstate_cnt[4]; /* Bitmask of CPUs on which this VCPU may run. */ cpumask_var_t cpu_hard_affinity;