From patchwork Wed Mar 1 14:52:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9598523 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 8FFE9604DC for ; Wed, 1 Mar 2017 14:54:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 863E32856B for ; Wed, 1 Mar 2017 14:54:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 77AC828582; Wed, 1 Mar 2017 14:54:54 +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 F00AC2856B for ; Wed, 1 Mar 2017 14:54:53 +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 1cj5cZ-0005wn-Rh; Wed, 01 Mar 2017 14:52:51 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cj5cZ-0005wU-3Q for xen-devel@lists.xenproject.org; Wed, 01 Mar 2017 14:52:51 +0000 Received: from [85.158.143.35] by server-8.bemta-6.messagelabs.com id EC/95-21675-240E6B85; Wed, 01 Mar 2017 14:52:50 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrHIsWRWlGSWpSXmKPExsXiVRvkpOv4YFu EwfLzOhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aUVZMYC5ZIVdxs/M/SwLhatIuRi0NIYAaj xJQF85lAHBaBNawSD59cYANxJAQusUpsn9DE3MXICeTESGz9dxvKLpdo69jNBGILCahI3Ny+i gli1C9GiRO7poIVCQvoSRw5+oMdwg6QePBvOQuIzSZgIPFmx15WEFtEQEni3qrJYIOYBaIkzi xvButlEVCVWNpzHKyGV8Bbon/1czYQm1PAR+L0ysVANgfQMm+JP+tcQcKiAnISKy+3QJULSpy c+YQFpIRZQFNi/S59iOnyEtvfzmGewCgyC0nVLISqWUiqFjAyr2LUKE4tKkst0jU00EsqykzP KMlNzMwB8sz0clOLixPTU3MSk4r1kvNzNzECw58BCHYw3lsWcIhRkoNJSZR396ptEUJ8Sfkpl RmJxRnxRaU5qcWHGDU4OAQmnJ07nUmKJS8/L1VJgvfePaA6waLU9NSKtMwcYITClEpw8CiJ8L aBpHmLCxJzizPTIVKnGHU5PvQffsMkBDZDSpw3G6RIAKQoozQPbgQsWVxilJUS5mUEOlCIpyC 1KDezBFX+FaM4B6OSMO8xkCk8mXklcJteAR3BBHTEC5WtIEeUJCKkpBoYj+Smbnnhfe6sn+0E jbV7FXd+uJbpnR9QYDbP9Fp/Aqdmzo8bOzNW3DyRznWki3uyVdqv6f3cV7feedmvdYA/0HCV/ sOSvpdtSsd/Wu1LYdy9vbo++M0jk21dLgllf19LhfvLrNie67Jwe2XN9J+LdThlV96UYA5sVn j7OIm5vNMmId5g+fSjSizFGYmGWsxFxYkAr1GcOxEDAAA= X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-3.tower-21.messagelabs.com!1488379969!56631702!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.4.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 17147 invoked from network); 1 Mar 2017 14:52:49 -0000 Received: from mail-wm0-f66.google.com (HELO mail-wm0-f66.google.com) (74.125.82.66) by server-3.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 1 Mar 2017 14:52:49 -0000 Received: by mail-wm0-f66.google.com with SMTP id v190so1755304wme.3 for ; Wed, 01 Mar 2017 06:52:49 -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=eIoqfm4cvbsC+j7NVNmLcNYGg2I94Ia/REILfelLtHI=; b=a+5gTQVmcFd/k5FVontbkd0/bdT79+EE1sSRJ+bRQAeRvzmMGvvfQEn1Mqrtux+41c oJjdohIQNQcc8wciGN+n2deZZPhZkdcv7CIoVjXsz/2qYPLykee4X/DfuxfxkSlcc4JZ QU7bYz1abZt3D2fAPW3rxlExkGbYdM4tqcER4GlBXH5kOgx/VznCjZEIBh10skg8u/ik 1x8xmX08WU7AGdtEUGockvmNMwP7ynNYg4vC/mmQ83l45hQEKBTPAUc8erbPHu7QjXNu YQtRxDawZYaISWDCxmG+WVML8KpVf3FRzOTQGjctf+UQqSnlHrYcNuL64Wa9rvfUC9lO f2XQ== 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=eIoqfm4cvbsC+j7NVNmLcNYGg2I94Ia/REILfelLtHI=; b=pkhotuXCXK66E0hzw8kpTpmIJNmQprGyf/h7XzSXEfDOx2XvO/2VE0vG+kN7pAw9Mx SPHI6SK6ldDGeprt6V2P7TFU7CweQSnvm3CD+CiQPnEiflW71aW2Z0o11+UxNa858tpe mWIOAghd5CTYLscyAJEFzCXiIw6qKpj8dqsWOYKBFSrKW8DrPmAJ+boYitl5/FuuYogC TdUeT3vfMpXPhSQ85z+prANxeGzW+Awt9mjvOJOimE7vsubTEx/3KuECvg5CitfeuvfT Bh1/imM2ks+1IXcP3XYxdpyA4liGupT2iRkcxboyOdRJj/zQmN5S3jNMwJDexw808Lws QgZg== X-Gm-Message-State: AMke39km+uhf7GqseQAlk0HibfOcE/y32ThQMTAe8Vfc6N1CMWtbSISI6ugZ7Kknp4aqLw== X-Received: by 10.28.143.5 with SMTP id r5mr3787259wmd.141.1488379969369; Wed, 01 Mar 2017 06:52:49 -0800 (PST) Received: from Solace.fritz.box ([80.66.223.93]) by smtp.gmail.com with ESMTPSA id 186sm23069499wmw.24.2017.03.01.06.52.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Mar 2017 06:52:48 -0800 (PST) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Wed, 01 Mar 2017 15:52:47 +0100 Message-ID: <148837996684.11900.7458004309335265466.stgit@Solace.fritz.box> In-Reply-To: <148837861276.11900.8292677471375175885.stgit@Solace.fritz.box> References: <148837861276.11900.8292677471375175885.stgit@Solace.fritz.box> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: George Dunlap , Anshul Makkar Subject: [Xen-devel] [PATCH v4 1/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 v3: * moved at the top of the series. 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 b12d038..cfb783d 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -504,12 +504,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)); } /* @@ -913,6 +916,14 @@ __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: @@ -1080,9 +1091,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); @@ -1395,7 +1405,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 == RQD(ops, vc->processor)); @@ -1718,8 +1730,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 {