Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp420985ybt; Mon, 6 Jul 2020 12:36:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+fMRJh9Rqg8a3/ZkaKzwCqd/++U2eZz8MyNZvHhhce/zBLPv8Dpj/3Ip+gW81yd1vCdW+ X-Received: by 2002:a17:906:b74e:: with SMTP id fx14mr42795940ejb.202.1594064194520; Mon, 06 Jul 2020 12:36:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594064194; cv=none; d=google.com; s=arc-20160816; b=AaUMdD/WR23/Z1BOfOFbKFtc5jDz7s4ShAAEdA5bvp0i6c26jQgDDHaNWM+hu22LoF c4zViVKxTpeBi3E7qWQbqq95+8PcScXFTJzmaBiJsbkW5UVkN/jV9B7R1qnSMEATpKRz HSkg98RwC5shFxHMq1auyDYtw6/5bpUYDirOWWR1yJ8YaxNdKVZMByXollFGoyQza9LB YveE6Sh64f5A0xU7B3Jt4UJRj4mkjYLgi1RJ/H3mmBQGEKr8sU/BVg5psF14lrnlX9RB mpTyEyFhuFFppzTyJ93RZreI0m1M/yRNXI2GP82qyGz4KT+ju+qg1fkjxkdTpg0jV+3R rAAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:ironport-sdr:ironport-sdr; bh=EW3aoAHPpElwxgtNo86V/uu5M2tZemGbspMgPmIErx8=; b=f17i4CLrdLOJKKPRuWKpLoYCtNAz69oxfQygWhZsLliEtHORLaNHAxCPw7KTJByEM7 4qRDH/XlrI0aeO8JIto0PybfWN3OlTtQYlcbaytSVKE0cxjPbRBpnDLD2dXdZWh/s34b VrNFNqAflHEBYyFZ1OBoxrrY5xTBvuyWCJ1G8jIrOKOBCOAZdJNK5HEcNLCbWHbMf4pF ufuP0TXgbTek17WtfqoobS9Y0eUWY11II7P9HSIoCIYw24n8ESN4c4V6nMuc+F+ZavjW 1qGO/jFHAUK8BxDk1Ef/QZzHMKcHvTziartA4t5tr0gA1ZRHFDO6A7rXeg+cc6MCf+4L TZjQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h21si13395089ejb.246.2020.07.06.12.36.11; Mon, 06 Jul 2020 12:36:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726634AbgGFTfd (ORCPT + 99 others); Mon, 6 Jul 2020 15:35:33 -0400 Received: from mga07.intel.com ([134.134.136.100]:61214 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725860AbgGFTfd (ORCPT ); Mon, 6 Jul 2020 15:35:33 -0400 IronPort-SDR: Cw7307QVQ4ewAOVMEyoiGMa1RK/0fJ9PsQrUjJBSBMdFAmfegzih4I8AFdGWi5lc6zEhq0iWk7 OGhebs40zXuA== X-IronPort-AV: E=McAfee;i="6000,8403,9674"; a="212469587" X-IronPort-AV: E=Sophos;i="5.75,320,1589266800"; d="scan'208";a="212469587" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2020 12:35:33 -0700 IronPort-SDR: BV3MTMeSa7ZSVfIrR1qQpNJ01pAY/1saVEuR6QjRfRtE+w9Lc5meCdJlYKaPB/4ZtzFPvI6x76 1MNGGF3Yf1aA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,320,1589266800"; d="scan'208";a="482805193" Received: from chenyu-office.sh.intel.com ([10.239.158.173]) by fmsmga006.fm.intel.com with ESMTP; 06 Jul 2020 12:35:30 -0700 From: Chen Yu To: Peter Zijlstra , Valentin Schneider Cc: Vincent Guittot , Ingo Molnar , Juri Lelli , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , linux-kernel@vger.kernel.org, Chen Yu Subject: [PATCH 1/2][RFC] sched/topology: Add update_domain_cpu() Date: Tue, 7 Jul 2020 03:36:41 +0800 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce update_domain_cpu(), which is a wrapper of update_top_cache_domain(). In update_domain_cpu() the cpu hotplug lock is to protect against the rebuild of sched domain, and the rcu read lock is to protect against the dereference of domain tree(rq->sd) in update_top_cache_domain(). This patch is to prepare for the next patch to update the flags of sched domain via sysctl. No intentional functional impact. Signed-off-by: Chen Yu --- include/linux/sched/topology.h | 5 +++++ kernel/sched/topology.c | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h index fb11091129b3..dc81736090e3 100644 --- a/include/linux/sched/topology.h +++ b/include/linux/sched/topology.h @@ -161,6 +161,7 @@ cpumask_var_t *alloc_sched_domains(unsigned int ndoms); void free_sched_domains(cpumask_var_t doms[], unsigned int ndoms); bool cpus_share_cache(int this_cpu, int that_cpu); +void update_domain_cpu(int cpu); typedef const struct cpumask *(*sched_domain_mask_f)(int cpu); typedef int (*sched_domain_flags_f)(void); @@ -214,6 +215,10 @@ static inline bool cpus_share_cache(int this_cpu, int that_cpu) return true; } +static inline void update_domain_cpu(int cpu) +{ +} + #endif /* !CONFIG_SMP */ #ifndef arch_scale_cpu_capacity diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index ba81187bb7af..495b65367a12 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -651,6 +651,17 @@ static void update_top_cache_domain(int cpu) rcu_assign_pointer(per_cpu(sd_asym_cpucapacity, cpu), sd); } +void update_domain_cpu(int cpu) +{ + /* Protect against sched domain rebuild. */ + get_online_cpus(); + /* Guard read-side sched domain dereference. */ + rcu_read_lock(); + update_top_cache_domain(cpu); + rcu_read_unlock(); + put_online_cpus(); +} + /* * Attach the domain 'sd' to 'cpu' as its base domain. Callers must * hold the hotplug lock. -- 2.17.1