From patchwork Mon Jan 20 12:39:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dietmar Eggemann X-Patchwork-Id: 23386 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f198.google.com (mail-yk0-f198.google.com [209.85.160.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C3E482107B for ; Mon, 20 Jan 2014 12:41:57 +0000 (UTC) Received: by mail-yk0-f198.google.com with SMTP id 131sf4129264ykp.1 for ; Mon, 20 Jan 2014 04:41:56 -0800 (PST) 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:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=slCRw3tdKE0Cz8jSG/hmJzhiE6zUnIsFDsO0Zpdw4tY=; b=NcFuyB6QJQwwNpn4MDBT4FsTWfNV3pbMG8AjFq8uNcaAVxwmkKZnQ/ko7VZFhQM8Wi E6xWaVlXL1v3X3kikAtUMxlgbH788EWushJz3BdTSv7SDDXvUKy+1OZxSXvqry8AXVna pAE96bU5rqa82zj5LcbCiRR7FhPcykY/VXweXpD54n9/Dy8eWV+MIMLWedtXU3s7zL3q LaH7LzlC4m6Yp3updc106KE1IO48J1JLK8fFpGu1lN71AbhF0r04nUi3zyeZ3Xq2Eu/L 0jWNL70nzvhnK3zPBC3vVDuQ3mX4qIFAs7pgClslPQJpSOICgmKkRK0/d1+aWOmouZuq 5kxQ== X-Gm-Message-State: ALoCoQkUXIM/HcmKSOrh/mLNhLm69H5Wj37ENiqwNTUkN8vzIpt0WB2XKos0aGjimXjoTVdKTK/f X-Received: by 10.236.36.39 with SMTP id v27mr6166557yha.5.1390221716976; Mon, 20 Jan 2014 04:41:56 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.87.8 with SMTP id t8ls1765414qez.60.gmail; Mon, 20 Jan 2014 04:41:56 -0800 (PST) X-Received: by 10.52.31.227 with SMTP id d3mr57746vdi.38.1390221716862; Mon, 20 Jan 2014 04:41:56 -0800 (PST) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by mx.google.com with ESMTPS id fb12si290378veb.128.2014.01.20.04.41.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 Jan 2014 04:41:56 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.177; Received: by mail-ve0-f177.google.com with SMTP id jz11so804414veb.22 for ; Mon, 20 Jan 2014 04:41:56 -0800 (PST) X-Received: by 10.52.30.230 with SMTP id v6mr3594598vdh.6.1390221716777; Mon, 20 Jan 2014 04:41:56 -0800 (PST) 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.220.174.196 with SMTP id u4csp55924vcz; Mon, 20 Jan 2014 04:41:56 -0800 (PST) X-Received: by 10.66.164.70 with SMTP id yo6mr18549425pab.85.1390221715691; Mon, 20 Jan 2014 04:41:55 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bq5si1351022pbb.198.2014.01.20.04.41.54; Mon, 20 Jan 2014 04:41:54 -0800 (PST) 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 S1753830AbaATMlt (ORCPT + 26 others); Mon, 20 Jan 2014 07:41:49 -0500 Received: from service87.mimecast.com ([91.220.42.44]:51745 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752869AbaATMkH (ORCPT ); Mon, 20 Jan 2014 07:40:07 -0500 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Mon, 20 Jan 2014 12:40:06 +0000 Received: from e103711-lin.cambridge.arm.com ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 20 Jan 2014 12:40:05 +0000 From: dietmar.eggemann@arm.com To: peterz@infradead.org, mingo@redhat.com, vincent.guittot@linaro.org, morten.rasmussen@arm.com, chris.redpath@arm.com Cc: linux-kernel@vger.kernel.org, dietmar.eggemann@arm.com Subject: [RFC v2 PATCH 08/11] sched: introduce a func ptr for sd topology flags Date: Mon, 20 Jan 2014 12:39:45 +0000 Message-Id: <1390221588-20473-9-git-send-email-dietmar.eggemann@arm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1390221588-20473-1-git-send-email-dietmar.eggemann@arm.com> References: <1390221588-20473-1-git-send-email-dietmar.eggemann@arm.com> X-OriginalArrivalTime: 20 Jan 2014 12:40:05.0176 (UTC) FILETIME=[BE999B80:01CF15DC] X-MC-Unique: 114012012400604801 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: dietmar.eggemann@arm.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org 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: Dietmar Eggemann To be able to set sd topology flags via the topology_info[] table dependent on runtime information (cpu feature or per cpu), this patch changes the provision of the sd topology flags from a simple int to a func ptr. The default flags func ptr for SMT and MC level are defined in include/linux/sched.h. Since there are no sd topology flags for BOOK and CPU level in the default topology info table, no default flags func ptr for these level are defined. The function sd_init() can handle the fact that there is no sd devel flags func ptr defined. The sd topology flags func ptr definition has an int cpu argument which is only necessary when we start to set up sd topology flags differently for different sched groups. Signed-off-by: Dietmar Eggemann --- include/linux/sched.h | 15 ++++++++++++++- kernel/sched/core.c | 19 +++++++++++++------ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index f79a0d5041fb..055d79e594ef 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -2781,10 +2781,11 @@ static inline unsigned long rlimit_max(unsigned int limit) } typedef const struct cpumask *(*sched_domain_mask_f)(int cpu); +typedef int (*sched_domain_flags_f)(int cpu); struct sched_domain_topology_info { sched_domain_mask_f mask; - int flags; + sched_domain_flags_f flags; #ifdef CONFIG_SCHED_DEBUG char *name; #endif @@ -2799,4 +2800,16 @@ struct sched_domain_topology_info { extern void set_sd_topology_info(struct sched_domain_topology_info *ti, unsigned int s); +#ifdef CONFIG_SCHED_SMT +static inline int cpu_smt_flags(int cpu) +{ + return SD_SHARE_CPUPOWER | SD_SHARE_PKG_RESOURCES; +} +#endif + +static inline int cpu_coregroup_flags(int cpu) +{ + return SD_SHARE_PKG_RESOURCES; +} + #endif diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 9edd1d511f3c..79f34cc5f547 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -5335,10 +5335,10 @@ static void claim_allocations(int cpu, struct sched_domain *sd) */ static struct sched_domain_topology_info default_topology_info[] = { #ifdef CONFIG_SCHED_SMT - { cpu_smt_mask, SD_SHARE_CPUPOWER | SD_SHARE_PKG_RESOURCES, SD_NAME(SIBLING) }, + { cpu_smt_mask, cpu_smt_flags, SD_NAME(SIBLING) }, #endif #ifdef CONFIG_SCHED_MC - { cpu_coregroup_mask, SD_SHARE_PKG_RESOURCES, SD_NAME(MC) }, + { cpu_coregroup_mask, cpu_coregroup_flags, SD_NAME(MC) }, #endif #ifdef CONFIG_SCHED_BOOK { cpu_book_mask, SD_NAME(BOOK) }, @@ -5374,6 +5374,11 @@ static const struct cpumask *sd_numa_mask(int cpu) return sched_domains_numa_masks[sched_domains_curr_level][cpu_to_node(cpu)]; } +static int sd_numa_flags(int cpu) +{ + return SD_NUMA; +} + static void sched_numa_warn(const char *str) { static int done = false; @@ -5598,7 +5603,7 @@ static void sched_init_topology(void) for (j = 0; j < level; i++, j++) { tl[i] = (struct sched_domain_topology_level){ .info.mask = sd_numa_mask, - .info.flags = SD_NUMA, + .info.flags = sd_numa_flags, .flags = SDTL_OVERLAP, .numa_level = j, }; @@ -5613,6 +5618,7 @@ sd_init(struct sched_domain_topology_level *tl, int cpu) { struct sched_domain *sd = *per_cpu_ptr(tl->data.sd, cpu); int sd_weight; + int flags; #ifdef CONFIG_NUMA /* @@ -5622,10 +5628,11 @@ sd_init(struct sched_domain_topology_level *tl, int cpu) #endif sd_weight = cpumask_weight(tl->info.mask(cpu)); + flags = tl->info.flags ? tl->info.flags(cpu) : 0; - if (WARN_ONCE(tl->info.flags & ~TOPOLOGY_SD_FLAGS, + if (WARN_ONCE(flags & ~TOPOLOGY_SD_FLAGS, "wrong flags in topology info\n")) - tl->info.flags &= ~TOPOLOGY_SD_FLAGS; + flags &= ~TOPOLOGY_SD_FLAGS; *sd = (struct sched_domain){ .min_interval = sd_weight, @@ -5638,7 +5645,7 @@ sd_init(struct sched_domain_topology_level *tl, int cpu) | 1*SD_BALANCE_EXEC | 1*SD_BALANCE_FORK | 1*SD_WAKE_AFFINE - | tl->info.flags + | flags , .last_balance = jiffies,