From patchwork Thu Feb 9 13:59:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9564633 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 8CF5A601C3 for ; Thu, 9 Feb 2017 14:01:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 78CE128499 for ; Thu, 9 Feb 2017 14:01:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6DE532849B; Thu, 9 Feb 2017 14:01:35 +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 16B77284EB for ; Thu, 9 Feb 2017 14:01:35 +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 1cbpFj-00046s-2I; Thu, 09 Feb 2017 13:59:15 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cbpFh-000468-KF for xen-devel@lists.xenproject.org; Thu, 09 Feb 2017 13:59:13 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id 2C/F5-22349-0B57C985; Thu, 09 Feb 2017 13:59:12 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmleJIrShJLcpLzFFi42K5GNpwUHdd6Zw Ig/3NUhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bLk+9ZCrZKVvRN+M/ewHhJpIuRk0NIYCaj xOqXUl2MXBwsAmtYJTbP3cwI4kgIXGKVWPzvHzNIlYRAjMSuwx+ZIOxqiS3XzzJDdKtI3Ny+i gmkQUjgJ6PEn2ub2EASwgJ6EkeO/mCHsIMk1rWeYQGx2QQMJN7s2MsKYosIKEncWzUZbCizQJ TEmeXNYENZBFQlmo60gtXwCnhJnHrWAVbDKeAt8f7eWnaIxV4Sy/4uBZspKiAnsfJyC1S9oMT JmU+A4hxAMzUl1u/ShxgvL7H97RzmCYwis5BUzUKomoWkagEj8ypG9eLUorLUIl1LvaSizPSM ktzEzBxdQwMzvdzU4uLE9NScxKRiveT83E2MwOBnAIIdjHc3BRxilORgUhLllS2YEyHEl5SfU pmRWJwRX1Sak1p8iFGDg0Ngwtm505mkWPLy81KVJHgFSoDqBItS01Mr0jJzgPEJUyrBwaMkwj sFJM1bXJCYW5yZDpE6xWjM0dN1+iUTx55dl18yCYFNkhLnrQIpFQApzSjNgxsESxuXGGWlhHk Zgc4U4ilILcrNLEGVf8UozsGoJMxbCDKFJzOvBG7fK6BTmIBOuX56FsgpJYkIKakGxoxiw6Z2 EUtux657nqKO/JNnpL9iEbDg3H65TcPBJXJtS8nlsusNwa0Wop7yzUXnMs9MdnTqO8ZiJtZ46 xqjazXvqZh36xzedeo+MLr+QmS+ShqDzHcOgdUbVt/Pcm9SWLaG2eRAw1tBTSPeHFv2N1MfN7 315jbbffciu67jhuQrlS+W6OcrsRRnJBpqMRcVJwIAesjCXRYDAAA= X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-9.tower-21.messagelabs.com!1486648750!56814676!1 X-Originating-IP: [209.85.128.193] 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 42297 invoked from network); 9 Feb 2017 13:59:10 -0000 Received: from mail-wr0-f193.google.com (HELO mail-wr0-f193.google.com) (209.85.128.193) by server-9.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 9 Feb 2017 13:59:10 -0000 Received: by mail-wr0-f193.google.com with SMTP id k90so11990231wrc.3 for ; Thu, 09 Feb 2017 05:59:10 -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=N04++azD3txsLr+L7Nta0nhMYLmV3Sauw6lSEnf94Q0=; b=HaMK0p6XmJ+tJiHf/9dnw7lpHjI7yM1O9gdVesDwLFkhkxIZ2MMWE5mvOSfQqbSlaO eCPuRxW9jXVFqDyS+3nC21l/mFOnHhw9Mm4oaLjfB14VvIkeU5tXA18sxTFGZF+10zEF B6fL/bhPch6318Id1uU+phkbRj/swQRaGh3HiMRl+RxSBjscd8pBp6PH3kZuj4tRoDTA 1zvHhoweOrjvylLv1qvuoB5Vbws7WXuPtAJDRKypImoOrkMNEn0d/F1qrL+6uE5NaI1r 3CxOUKoW1+bQpBEZVCFfLKSiGC7Qvus5ARAkz6AFBy83jAAgCJqewWlE5cufO3/J4LPx MQEw== 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=N04++azD3txsLr+L7Nta0nhMYLmV3Sauw6lSEnf94Q0=; b=B7/QiplWcp42ZzJC1JBYN5N25sPmN/PldBLGv21MkflA4T5hrw8JfQQ0/Lce+NzBt9 p+HcN57AOSq9hh5fvjKPUxXwdO9Pupugp6tj2aTOc8KxXjoirwCjYUvSyMn6lYS9DGkE cx/E82mpK5nv1FXH/LJbYP6Wjy6Vc0A7lrXYLxL5wOx9GRqmhrhelCOiekLKyPBXln8o +xEBhzBQ2xAFwLTNz7zT93+ORlEB8/JC7nCoMtByUCta+JM2v7Cs05lsCnL7N6MhWyvX +OaWPi3ALOYoyVGF/pzv5F3iJI6hJ7HTtelvLtg5iSXMSYLl3Y4Ia24qopZsbG6u4jbL AXTw== X-Gm-Message-State: AMke39l2iZbMujj629pknE9ddn2wQDhVPGfGOY353/cfDsWA5b2vBQul3FV7d7UdqreJSA== X-Received: by 10.223.169.164 with SMTP id b33mr3292082wrd.132.1486648750042; Thu, 09 Feb 2017 05:59:10 -0800 (PST) Received: from Solace.fritz.box ([80.66.223.139]) by smtp.gmail.com with ESMTPSA id l67sm9018712wmf.1.2017.02.09.05.59.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Feb 2017 05:59:09 -0800 (PST) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Thu, 09 Feb 2017 14:59:08 +0100 Message-ID: <148664874799.595.17524826454909514715.stgit@Solace.fritz.box> In-Reply-To: <148664844741.595.10506268024432565895.stgit@Solace.fritz.box> References: <148664844741.595.10506268024432565895.stgit@Solace.fritz.box> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: George Dunlap , Anshul Makkar Subject: [Xen-devel] [PATCH v2 07/10] 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: George Dunlap Cc: Anshul Makkar --- 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 addee7b..bfb4891 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -470,12 +470,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)); } /* @@ -1122,6 +1125,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: @@ -1289,9 +1300,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(cpu, rqd); if ( unlikely(new->tickled_cpu != -1) ) SCHED_STAT_CRANK(tickled_cpu_overwritten); @@ -1493,7 +1503,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)); @@ -1816,8 +1828,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 {