From patchwork Thu Jan 26 00:30:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9538197 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 7D153604A7 for ; Thu, 26 Jan 2017 00:32:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 707D026B39 for ; Thu, 26 Jan 2017 00:32:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 651E927F85; Thu, 26 Jan 2017 00:32:32 +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 07C7B26B39 for ; Thu, 26 Jan 2017 00:32: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 1cWXxJ-0005qa-MC; Thu, 26 Jan 2017 00:30:25 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWXxI-0005pz-Lu for xen-devel@lists.xenproject.org; Thu, 26 Jan 2017 00:30:24 +0000 Received: from [193.109.254.147] by server-1.bemta-6.messagelabs.com id 7D/E3-27678-F1349885; Thu, 26 Jan 2017 00:30:23 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFIsWRWlGSWpSXmKPExsXiVRvkpCvv3Bl h0DFN3OL7lslMDowehz9cYQlgjGLNzEvKr0hgzdj9YzlzwVbJio/zNrA2MF4S6WLk4hASmMko 8WHhU3YQh0VgDavEuePzGUEcCYFLrBJbdl9i6WLkAHJiJHZOCe5i5AQyqyQerbvPBGILCahI3 Ny+igli0nQmiZVP/7OBJIQF9CSOHP3BDmH7SPR0bgBrYBMwkHizYy8riC0ioCRxb9VksDizQJ TEmeXNzCC7WARUJVb0FYCYvALeEn3fuUAqOIHMGZM/MIGEhQS8JKYdyAEJiwrISay83AI2kFd AUOLkzCdgBzMLaEqs36UPMVteYvvbOcwTGEVmIamahVA1C0nVAkbmVYzqxalFZalFuoZ6SUWZ 6RkluYmZObqGBmZ6uanFxYnpqTmJScV6yfm5mxiBYc8ABDsYdz53OsQoycGkJMp7U7szQogvK T+lMiOxOCO+qDQntfgQowYHh8CEs3OnM0mx5OXnpSpJ8No4AdUJFqWmp1akZeYAIxOmVIKDR0 mE1xMkzVtckJhbnJkOkTrFqMuxa9fll0xCYDOkxHntQIoEQIoySvPgRsCSxCVGWSlhXkagA4V 4ClKLcjNLUOVfMYpzMCoJ8050BJrCk5lXArfpFdARTEBHXGBuBzmiJBEhJdXA2HZM081WO3/v x9sc36pEZr4UfH000apOcF6q8M8bMru+drqLXHiWv+xvR/dRJcOrL1Xj3h7bfPac4Pt5VY+FL qgvlxI65OXSm9sc/WrBmjfNj3rm3ehg/dJ2bHH0mp5oR+lvP+1aJuYy6yl9r/720+25Jt+xf5 byx1d/frl3Lp/guupA3z37tZRYijMSDbWYi4oTAbORMZMNAwAA X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-2.tower-27.messagelabs.com!1485390623!31316056!1 X-Originating-IP: [74.125.82.66] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 5633 invoked from network); 26 Jan 2017 00:30:23 -0000 Received: from mail-wm0-f66.google.com (HELO mail-wm0-f66.google.com) (74.125.82.66) by server-2.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 26 Jan 2017 00:30:23 -0000 Received: by mail-wm0-f66.google.com with SMTP id r144so46496822wme.0 for ; Wed, 25 Jan 2017 16:30:23 -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=5OJi3xygaOzBnmCzjW3d3//3BXyR2eqQtdraGTrsw+Q=; b=OC5YMLlSE1i0Pex6MNNsA2KjdNv7OCLm1tr+mT/uISY93P3syfn+5Bh3JwtyO1mjzP n7oDnEVCkInU+9y7KiJKOyScOQdYaxAk4GLURM5cuhe0UMxelqWTA/tGbVZNtCALAzPH EdwuzEfiFE0NzyzdI59VBpTrHpW2Al9nPT5qP6oNNd4gRGZQ8aKenmsHtzb6t/DrbjgC b1Qr+d266ihPQPZF1gMS27vjaA48HHF8zxeDenftAv7MAoVOS0AmbCPm1T47JMKGkiq6 xBiWkp/jMkoRDeLJ0XlYndavz7w03JiohhUWiUVIDiEISLLtvhFSFZeJ0Ko+EC/hqHmu SHSg== 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=5OJi3xygaOzBnmCzjW3d3//3BXyR2eqQtdraGTrsw+Q=; b=MkAZ5LTLjer3aLn0sfjFPEUM5KeViKoRaLbJiQImAqNQA2NjMOoQnLg+ayyBSD/cgM CBUNmel1qm42Plz+m9aJ9JWtpxdFVRRkLGUj65/3ITCFmYm4eZLB8PZEzpu6DF3CkYfL pgr3Gpy8SVMZpxo/uOAg1ydK+oe3cmAtC7qB28kW0fsO3wQUzLAijFeRitraNhIQIWml tjxnsz/d9ksrSUIaNM2YPJ3lGRgjRXQG5Af+UtxGNIKtE5bsMgGOxmNAa5r6i2grSLk1 TmB2MfMvitm/jVzUh5OhShSQWDe+XdcAkWkqCAjomYlN9bEEzbyDrAOdaiT/1cuAL7QR xPtg== X-Gm-Message-State: AIkVDXJcUU6vsn6Plq1h1O9rxgg4xX8GoOr3nvECQFkXjSr1VqbEQctYj0tuaSagfubmNg== X-Received: by 10.223.178.243 with SMTP id g106mr121367wrd.32.1485390622960; Wed, 25 Jan 2017 16:30:22 -0800 (PST) Received: from Solace.fritz.box (58-209-66-80.hosts.abilene.it. [80.66.209.58]) by smtp.gmail.com with ESMTPSA id d29sm946635wmi.19.2017.01.25.16.30.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jan 2017 16:30:22 -0800 (PST) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Thu, 26 Jan 2017 01:30:21 +0100 Message-ID: <148539062127.5464.10925207754310543542.stgit@Solace.fritz.box> In-Reply-To: <148539008889.5464.5896389113741708672.stgit@Solace.fritz.box> References: <148539008889.5464.5896389113741708672.stgit@Solace.fritz.box> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: George Dunlap , Anshul Makkar Subject: [Xen-devel] [PATCH 5/9] 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 --- 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 f4c0ae4..bab9667 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); @@ -1494,7 +1504,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)); @@ -1817,8 +1829,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 {