From patchwork Tue Nov 22 20:35:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Neri X-Patchwork-Id: 24549 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2425056wrr; Tue, 22 Nov 2022 12:30:35 -0800 (PST) X-Google-Smtp-Source: AA0mqf6+iRSDjPzdmXMw969XFqvFh2T7wrl/8YeBCKpHpMTx+D741FbUQAgAG2TR+sYw97eDbVKi X-Received: by 2002:a05:6402:1a2e:b0:461:2915:e41d with SMTP id be14-20020a0564021a2e00b004612915e41dmr22301700edb.184.1669149035320; Tue, 22 Nov 2022 12:30:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669149035; cv=none; d=google.com; s=arc-20160816; b=MRBf2tVJB7JRlmnpwLadhN/saTOKW/VhL6++HjJDbIANFxTwghqeTXJ2y3MfiWFgT8 w2CXFcVafDb2sv4Q2HDxJh/Rs62O8i83PBiai4v1Jv9dBTPU6mx4D3qB0fUd3fTbRYU8 Fk2RiKDUjiACxl3j6iwo7h8LKpOQH/cN7x8fCGWspuZccbQq1v4/PrMLns6VNmaVACsh 0znZQJQ5wyLH3rM7OiXAynUFbLHc8SkX91TElBa0LsWXd68thXAknmtTQAIq95GhSDHM D89KNz/nrrTEtIpMaU/7WBK5ghjTXDeCzhV+hB4EfeMPr2SsZGalvB6EASdMRb1eWTKp YByQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=+hZ/T+LG2SEQUHOc50V28ZpAG9z7f3Qnk7J/1+X9MBw=; b=i6dJtMhgIcfQZZsj9sMzMlASU6tpMzQU2Z5MPfOrzVT3RDD7tI3GZ1dHqLeB4l59v0 Z1h7EDguWpLhI0y/jKcsPbpn+Fwvf1Uspp3pBgQr2W9YVhheerDX3SFUMNoD2uq8VoG8 Z7aitWWF6wlKDeegUkkP/Woc2U5eTmSsV4ea5pMNX8M24+csITW++0S2GOAGgS7hjO3t lLaSoUpkn7Wyzif9LOOxhC90RLbYpS35nH0fhOsm3CZhtSXYW+Vpsz7l2VliWyNgnXUT OtzArmEHlHTapmFHiPzn11UouzOc5SxpKts08o4sf/GcCjPmSc8OPNIcvj9GupX97MQE tS6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YO5abYmc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i21-20020a170906251500b007ae52a5707bsi9192881ejb.95.2022.11.22.12.30.11; Tue, 22 Nov 2022 12:30:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YO5abYmc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234880AbiKVU2h (ORCPT + 99 others); Tue, 22 Nov 2022 15:28:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234402AbiKVU2P (ORCPT ); Tue, 22 Nov 2022 15:28:15 -0500 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC03C1B1D8 for ; Tue, 22 Nov 2022 12:28:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669148894; x=1700684894; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=ZxiRvtsJwz9dFNPg5MHP4zjCzO9YSRx6bjDINyhvJ5o=; b=YO5abYmcCWkxOVmwE0RoQ8gdQ02Gl9vS8d2LzhQcaNrhIaclRTjZDDva w5ZimWTsceDPCaNUq56YuyLrJ8tzVeStPDv6caiGQTFbfd2pNFRc6Zy2D reQHuqADcqYYODzbEyaRuUVGxwJiw7DSV7WqyPBLunxBEVkDHmPrcLA1I UUY3hn5dNJFqTXvHa/SUhP3KGvaJaV4b1fi2wwDzyIm8bhFTnUresYOk5 j2whgaklJBIUugC1QQ6HyQ9yf+en30WsRKYO3LyW8ReX5RPzsZGvzdgp0 5SJWvlE6+5jr2zf4Ay+e+/CIo4vLXHms8hlce/MztAlwoGMTNeqowluFK g==; X-IronPort-AV: E=McAfee;i="6500,9779,10539"; a="293616509" X-IronPort-AV: E=Sophos;i="5.96,185,1665471600"; d="scan'208";a="293616509" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2022 12:28:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10539"; a="816228136" X-IronPort-AV: E=Sophos;i="5.96,185,1665471600"; d="scan'208";a="816228136" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by orsmga005.jf.intel.com with ESMTP; 22 Nov 2022 12:28:14 -0800 From: Ricardo Neri To: "Peter Zijlstra (Intel)" , Juri Lelli , Vincent Guittot Cc: Ricardo Neri , "Ravi V. Shankar" , Ben Segall , Daniel Bristot de Oliveira , Dietmar Eggemann , Len Brown , Mel Gorman , "Rafael J. Wysocki" , Srinivas Pandruvada , Steven Rostedt , Tim Chen , Valentin Schneider , x86@kernel.org, linux-kernel@vger.kernel.org, Ricardo Neri , "Tim C . Chen" Subject: [PATCH v2 4/7] sched/fair: Introduce sched_smt_siblings_idle() Date: Tue, 22 Nov 2022 12:35:29 -0800 Message-Id: <20221122203532.15013-5-ricardo.neri-calderon@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221122203532.15013-1-ricardo.neri-calderon@linux.intel.com> References: <20221122203532.15013-1-ricardo.neri-calderon@linux.intel.com> X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750229618591661866?= X-GMAIL-MSGID: =?utf-8?q?1750229618591661866?= Architectures that implement arch_asym_cpu_priority() may need to know the idle state of the SMT siblings of a CPU. The scheduler has this information and functionality. Expose it. Move the existing functionality outside of the NUMA code. Cc: Ben Segall Cc: Daniel Bristot de Oliveira Cc: Dietmar Eggemann Cc: Len Brown Cc: Mel Gorman Cc: Rafael J. Wysocki Cc: Srinivas Pandruvada Cc: Steven Rostedt Cc: Tim C. Chen Cc: Valentin Schneider Cc: x86@kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Ricardo Neri --- Changes since v1: * Introduced this patch. --- include/linux/sched.h | 2 ++ kernel/sched/fair.c | 39 ++++++++++++++++++++++----------------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index ffb6eb55cd13..0d01c64ac737 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -2426,4 +2426,6 @@ static inline void sched_core_fork(struct task_struct *p) { } extern void sched_set_stop_task(int cpu, struct task_struct *stop); +extern bool sched_smt_siblings_idle(int cpu); + #endif diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 0e4251f83807..9517c48df50e 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1052,6 +1052,28 @@ update_stats_curr_start(struct cfs_rq *cfs_rq, struct sched_entity *se) * Scheduling class queueing methods: */ +static inline bool is_core_idle(int cpu) +{ +#ifdef CONFIG_SCHED_SMT + int sibling; + + for_each_cpu(sibling, cpu_smt_mask(cpu)) { + if (cpu == sibling) + continue; + + if (!idle_cpu(sibling)) + return false; + } +#endif + + return true; +} + +bool sched_smt_siblings_idle(int cpu) +{ + return is_core_idle(cpu); +} + #ifdef CONFIG_NUMA #define NUMA_IMBALANCE_MIN 2 @@ -1691,23 +1713,6 @@ struct numa_stats { int idle_cpu; }; -static inline bool is_core_idle(int cpu) -{ -#ifdef CONFIG_SCHED_SMT - int sibling; - - for_each_cpu(sibling, cpu_smt_mask(cpu)) { - if (cpu == sibling) - continue; - - if (!idle_cpu(sibling)) - return false; - } -#endif - - return true; -} - struct task_numa_env { struct task_struct *p;