From patchwork Tue Feb 28 11:52:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9595297 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5198B601D7 for ; Tue, 28 Feb 2017 11:54:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FA8C27816 for ; Tue, 28 Feb 2017 11:54:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3459627CAF; Tue, 28 Feb 2017 11:54:33 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C661127816 for ; Tue, 28 Feb 2017 11:54:32 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cigKT-00018Y-Gp; Tue, 28 Feb 2017 11:52:29 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cigKS-000185-Nn for xen-devel@lists.xenproject.org; Tue, 28 Feb 2017 11:52:28 +0000 Received: from [85.158.139.211] by server-3.bemta-5.messagelabs.com id 2F/57-01926-C7465B85; Tue, 28 Feb 2017 11:52:28 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDIsWRWlGSWpSXmKPExsXiVRvkqFudsjX C4OEnOYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNaPr72TGgmapip5H89kaGCeLdjFycQgJTGeU WHi7ha2LkZODRWANq8SGvcYgCQmBS6wSfT83MYIkJARiJF5/PcYCYVdKXLy/lh3EFhJQkbi5f RUTxKSfjBJXfq1jAkkIC+hJHDn6gx3CDpDo3P0WzGYTMJB4s2MvK4gtIqAkcW/VZLB6ZoEoiT PLm5khrlCVmNKyHmwxr4C3xKb2hUC9HBycAj4Sy29YgJhCQOFtj2NBKkQF5CRWXm5hhagWlDg 58wkLSAmzgKbE+l36EMPlJba/ncM8gVFkFpKqWQhVs5BULWBkXsWoUZxaVJZapGtkqZdUlJme UZKbmJmja2hgqpebWlycmJ6ak5hUrJecn7uJERj69QwMjDsYL2/xO8QoycGkJMqblbw1QogvK T+lMiOxOCO+qDQntfgQowYHh8CEs3OnM0mx5OXnpSpJ8E4GqRMsSk1PrUjLzAFGJ0ypBAePkg jvC5A0b3FBYm5xZjpE6hSjLseH/sNvmITAZkiJ814HKRIAKcoozYMbAUsUlxhlpYR5GRkYGIR 4ClKLcjNLUOVfMYpzMCoJ854EmcKTmVcCt+kV0BFMIEeogB1RkoiQkmpgTErOrL2Z3c8/STk+ Zapqse8id9MC9b5Q+6vxZrZHLxbsMpnra+oQcCJV1+mQTOHkU21Zh8/vFp2Ye37/pHi9LtYJJ xbO7NnE/Fft7r2X32L4UoSfzJpsmKd5gtl1B+evlDXdP1ekx4ZLzvq76Nico1dbP/aySAkYpW mtcGsw9ThWKpB18nmDEktxRqKhFnNRcSIAQGEwUg8DAAA= X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-7.tower-206.messagelabs.com!1488282747!84222318!1 X-Originating-IP: [74.125.82.65] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 33639 invoked from network); 28 Feb 2017 11:52:27 -0000 Received: from mail-wm0-f65.google.com (HELO mail-wm0-f65.google.com) (74.125.82.65) by server-7.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Feb 2017 11:52:27 -0000 Received: by mail-wm0-f65.google.com with SMTP id m70so1961134wma.1 for ; Tue, 28 Feb 2017 03:52:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=F3x9wUj8UeNBLXEWwDf7UEX9TmwkAEqYsnl0pw7XwLE=; b=K6RB39/fXrSIxvKfv1+ChDF0XsM4IUKvoLcGDMoqHF5K4B5GH5PQ0y0coPGkl5a8U+ vhZ0ed0Gx/UgVFr1nkmQColYPCw+PBKels8f/3FMt7zRRDABUWx+o29c82W1wtQQ5aTN k9L1C9SWHzVm13o+7j+N2iuN5sS8sbUUw70+KwVbXeqNW/i/JtS2GhJYEkoAUedayi9U IMYnw39oWc0SpOLYI2r9HFBcJdm61jR8mZc/dkVgXwaYtNGb/vwl7BVIo8B0FqsdQATz sYzgPRMSHzLks0j8CYK28l/2Y6U1Rtdklz+YfCBwXS5u6usUyo4i94te2i3OJrifN/qh L8+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:cc:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=F3x9wUj8UeNBLXEWwDf7UEX9TmwkAEqYsnl0pw7XwLE=; b=mW+r2GleFSwzSul1zQwSyYyl4ow839xbRpgl5n59goy6mnqGOICadvaryPS31Bi8QB CQK3B1wz5zbJ49vO8VlhT+zRhBCBUPzIF7iz1wMLTZ2sNP2vqq8nRt1iYWLXa5+KyGbu p4UFTDgI7c/Mpe5QWSau0ovfC1N2LBnjbcFBuE784mc6/xNKRzvvc6BPyEtu+4ehfTwH IveHKsPp80mbFJ74rvacxGTBiCxlLhK/t2zvj6zYISyuFcLp3dSVS5VeWA1paXWCEYnW 0m3qq2B6BNo70XevQdHkUphTgeYNLqc3FcpxnElHioRptzqKzDdoJaPvNZe1NXoubi6F 6cKQ== X-Gm-Message-State: AMke39lqM3IdOxjRvxwEQtDm+IsGTRumWZTcfMhUAO7Zx4VCIjX2kmBgVz5aQ5sqgjQsyA== X-Received: by 10.28.74.221 with SMTP id n90mr2021942wmi.114.1488282747139; Tue, 28 Feb 2017 03:52:27 -0800 (PST) Received: from Solace.fritz.box ([80.66.223.93]) by smtp.gmail.com with ESMTPSA id g23sm2349667wme.27.2017.02.28.03.52.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Feb 2017 03:52:26 -0800 (PST) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Tue, 28 Feb 2017 12:52:25 +0100 Message-ID: <148828274464.26730.9460898039870001654.stgit@Solace.fritz.box> In-Reply-To: <148828109243.26730.2771577013485070217.stgit@Solace.fritz.box> References: <148828109243.26730.2771577013485070217.stgit@Solace.fritz.box> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: George Dunlap , Anshul Makkar Subject: [Xen-devel] [PATCH v3 4/7] xen: credit2: always mark a tickled pCPU as... tickled! X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP In fact, whether or not a pCPU has been tickled, and is therefore about to re-schedule, is something we look at and base decisions on in various places. So, let's make sure that we do that basing on accurate information. While there, also tweak a little bit smt_idle_mask_clear() (used for implementing SMT support), so that it only alter the relevant cpumask when there is the actual need for this. (This is only for reduced overhead, behavior remains the same). Signed-off-by: Dario Faggioli Reviewed-by: George Dunlap --- Cc: Anshul Makkar --- Changes from v2: * fixed a bug I found myself in runq_tickle(). --- xen/common/sched_credit2.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index b0ec5f8..feb0f83 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -523,12 +523,15 @@ void smt_idle_mask_set(unsigned int cpu, const cpumask_t *idlers, } /* - * Clear the bits of all the siblings of cpu from mask. + * Clear the bits of all the siblings of cpu from mask (if necessary). */ static inline void smt_idle_mask_clear(unsigned int cpu, cpumask_t *mask) { - cpumask_andnot(mask, mask, per_cpu(cpu_sibling_mask, cpu)); + const cpumask_t *cpu_siblings = per_cpu(cpu_sibling_mask, cpu); + + if ( cpumask_subset(cpu_siblings, mask) ) + cpumask_andnot(mask, mask, per_cpu(cpu_sibling_mask, cpu)); } /* @@ -1118,6 +1121,14 @@ static inline void runq_remove(struct csched2_vcpu *svc) void burn_credits(struct csched2_runqueue_data *rqd, struct csched2_vcpu *, s_time_t); +static inline void +tickle_cpu(unsigned int cpu, struct csched2_runqueue_data *rqd) +{ + __cpumask_set_cpu(cpu, &rqd->tickled); + smt_idle_mask_clear(cpu, &rqd->smt_idle); + cpu_raise_softirq(cpu, SCHEDULE_SOFTIRQ); +} + /* * Check what processor it is best to 'wake', for picking up a vcpu that has * just been put (back) in the runqueue. Logic is as follows: @@ -1285,9 +1296,8 @@ runq_tickle(const struct scheduler *ops, struct csched2_vcpu *new, s_time_t now) sizeof(d), (unsigned char *)&d); } - __cpumask_set_cpu(ipid, &rqd->tickled); - smt_idle_mask_clear(ipid, &rqd->smt_idle); - cpu_raise_softirq(ipid, SCHEDULE_SOFTIRQ); + + tickle_cpu(ipid, rqd); if ( unlikely(new->tickled_cpu != -1) ) SCHED_STAT_CRANK(tickled_cpu_overwritten); @@ -1489,7 +1499,9 @@ csched2_vcpu_sleep(const struct scheduler *ops, struct vcpu *vc) SCHED_STAT_CRANK(vcpu_sleep); if ( curr_on_cpu(vc->processor) == vc ) - cpu_raise_softirq(vc->processor, SCHEDULE_SOFTIRQ); + { + tickle_cpu(vc->processor, svc->rqd); + } else if ( vcpu_on_runq(svc) ) { ASSERT(svc->rqd == c2rqd(ops, vc->processor)); @@ -1812,8 +1824,8 @@ static void migrate(const struct scheduler *ops, svc->migrate_rqd = trqd; __set_bit(_VPF_migrating, &svc->vcpu->pause_flags); __set_bit(__CSFLAG_runq_migrate_request, &svc->flags); - cpu_raise_softirq(cpu, SCHEDULE_SOFTIRQ); SCHED_STAT_CRANK(migrate_requested); + tickle_cpu(cpu, svc->rqd); } else {