From patchwork Fri Jul 17 08:03:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xunlei Pang X-Patchwork-Id: 51227 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DF93622A8D for ; Fri, 17 Jul 2015 08:06:45 +0000 (UTC) Received: by wizo10 with SMTP id o10sf10077033wiz.0 for ; Fri, 17 Jul 2015 01:06:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=8D9c7voezCLOVMrIfIfiUj5pn5LFOT9a5h7GihFHFrk=; b=eAvG5eLXN0kz1qFkuC5ayZ+kGvlkH4TOYYNR7PPIc6VayyvIr+dJJtKyg+qshaVw5C MRpWpWMmeoKCyWGMyVs5RudS+hHohJZK3ORaf8zqT1eRy/vOaGI32hC7MPZflXmwbMGl SxVC+FNNfZ3752olcEfIedZ0a1FMFQeBWr0BwmJybRJn+/krqCgUVPQxd4sq3FcqDsNl S95FGZy0GolXSGe019fBl4I51fI3mGEDSJEYLvKIxHTwE+gOEPZvcwMgU55qaglTVkD9 fJgJTDk/e8n0GJdxd6WqSulNObjS6atMcUsU/ObWedTgEW5qvKYCRZHbVqIVuQVLetir TWqA== X-Gm-Message-State: ALoCoQnUJuE92B2vlFReCxISZ+WpJJFD2qhcKNh4btw7agD1AfrBmLoQWn+gCczu059SMHH0QQiH X-Received: by 10.112.54.166 with SMTP id k6mr6963450lbp.0.1437120405190; Fri, 17 Jul 2015 01:06:45 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.88.7 with SMTP id bc7ls481999lab.74.gmail; Fri, 17 Jul 2015 01:06:44 -0700 (PDT) X-Received: by 10.152.27.197 with SMTP id v5mr13331306lag.64.1437120404808; Fri, 17 Jul 2015 01:06:44 -0700 (PDT) Received: from mail-la0-x22c.google.com (mail-la0-x22c.google.com. [2a00:1450:4010:c03::22c]) by mx.google.com with ESMTPS id j10si9248270lbp.23.2015.07.17.01.06.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Jul 2015 01:06:44 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::22c as permitted sender) client-ip=2a00:1450:4010:c03::22c; Received: by lahh5 with SMTP id h5so56864613lah.2 for ; Fri, 17 Jul 2015 01:06:44 -0700 (PDT) X-Received: by 10.152.18.162 with SMTP id x2mr13393190lad.73.1437120404671; Fri, 17 Jul 2015 01:06:44 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp740437lbb; Fri, 17 Jul 2015 01:06:43 -0700 (PDT) X-Received: by 10.70.91.206 with SMTP id cg14mr27379935pdb.158.1437120402591; Fri, 17 Jul 2015 01:06:42 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ms1si17297878pbb.162.2015.07.17.01.06.41; Fri, 17 Jul 2015 01:06:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757265AbbGQIGi (ORCPT + 28 others); Fri, 17 Jul 2015 04:06:38 -0400 Received: from m50-110.126.com ([123.125.50.110]:47415 "EHLO m50-110.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752334AbbGQIGe (ORCPT ); Fri, 17 Jul 2015 04:06:34 -0400 Received: from localhost.localdomain (unknown [210.21.223.3]) by smtp4 (Coremail) with SMTP id jdKowAA3HiMEt6hVaeRDAA--.6903S3; Fri, 17 Jul 2015 16:04:34 +0800 (CST) From: Xunlei Pang To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Ingo Molnar , Xunlei Pang Subject: [PATCH] sched: Avoid sched domain rebuilding when hotplugging an isolate cpu Date: Fri, 17 Jul 2015 16:03:45 +0800 Message-Id: <1437120225-16466-1-git-send-email-xlpang@126.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: jdKowAA3HiMEt6hVaeRDAA--.6903S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxZw1xCr13tryrXrW3XFyfCrg_yoW5WFW7pF srWFWrWrWUt3WfJFWakr4fWF15Ga97Ja1jg3WkCr1rJrn8GF1IgF1FqF47tayj9ry8Jry2 yFnxK39xWFWqy3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jk8n5UUUUU= X-Originating-IP: [210.21.223.3] X-CM-SenderInfo: p0ost0bj6rjloofrz/1tbiXBI6v1R0Xam3+AAAsQ Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Original-Sender: xlpang@126.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::22c as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@126.com; dmarc=fail (p=NONE dis=NONE) header.from=126.com Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Xunlei Pang The sched domain is always rebuilt when hotplugging an isolate cpu, as we can see in partition_sched_domains() with the NULL doms_new, current sched domain is destroyed, then rebuilt. Worse still, the rebuilding will reset all the parameters of the sched_domain. This makes no sense and contradicts the isloate concept. The patch avoids the rebuilding if the hotplug cpu is an isolate one. Signed-off-by: Xunlei Pang --- kernel/sched/core.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index bb8f3ad..bae817e 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6862,9 +6862,12 @@ error: } static cpumask_var_t *doms_cur; /* current sched domains */ -static int ndoms_cur; /* number of sched domains in 'doms_cur' */ +/* effective number of sched domains in 'doms_cur' */ +static int ndoms_cur; +/* original number of sched domains in 'doms_cur' */ +static int ndoms_orig; +/* attribues of custom domains in 'doms_cur' */ static struct sched_domain_attr *dattr_cur; - /* attribues of custom domains in 'doms_cur' */ /* * Special case: If a kmalloc of a doms_cur partition (array of @@ -6918,6 +6921,7 @@ static int init_sched_domains(const struct cpumask *cpu_map) int err; arch_update_cpu_topology(); + ndoms_orig = 1; ndoms_cur = 1; doms_cur = alloc_sched_domains(ndoms_cur); if (!doms_cur) @@ -6990,6 +6994,7 @@ void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[], { int i, j, n; int new_topology; + bool borrow_needed = false; mutex_lock(&sched_domains_mutex); @@ -6999,6 +7004,13 @@ void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[], /* Let architecture update cpu core mappings. */ new_topology = arch_update_cpu_topology(); + if (doms_new == NULL && doms_cur != &fallback_doms) { + doms_new = &fallback_doms; + cpumask_andnot(doms_new[0], cpu_active_mask, cpu_isolated_map); + borrow_needed = true; + WARN_ON_ONCE(dattr_new); + } + n = doms_new ? ndoms_new : 0; /* Destroy deleted domains */ @@ -7036,10 +7048,22 @@ match2: } /* Remember the new sched domains */ - if (doms_cur != &fallback_doms) - free_sched_domains(doms_cur, ndoms_cur); + if (doms_cur != &fallback_doms && !borrow_needed) + free_sched_domains(doms_cur, ndoms_orig); kfree(dattr_cur); /* kfree(NULL) is safe */ - doms_cur = doms_new; + + if (borrow_needed) { + /* + * Borrow previous doms_cur as new storage, so that + * fallback_doms can be used as the temporal storage + * in the future rebuilding. + */ + cpumask_copy(doms_cur[0], doms_new[0]); + } else { + doms_cur = doms_new; + ndoms_orig = ndoms_new; + } + dattr_cur = dattr_new; ndoms_cur = ndoms_new;