From patchwork Tue Nov 22 20:35:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Neri X-Patchwork-Id: 24547 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2424812wrr; Tue, 22 Nov 2022 12:30:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf4jw3VM9XGltc32Huq/2ahLbr3xnUs4ywuB2EH/uYr/uRPlX9j9Ekj10K8UYSdsu/bCrKB7 X-Received: by 2002:aa7:cd8d:0:b0:463:19ca:a573 with SMTP id x13-20020aa7cd8d000000b0046319caa573mr22490675edv.31.1669149003849; Tue, 22 Nov 2022 12:30:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669149003; cv=none; d=google.com; s=arc-20160816; b=UHVbdfXF35J5ZbH80qXT8qdx7ba7Pq/V1GUWAdnnqCJQ0hUTgy3+ypq7sX6xTeLyKT JNUPtXQuxI5CXvIyZYJfooyGN3uCpGQ0oAETsNnG1slxyemcIjhxwPP/dJDrSx+ep+tB tUbv5gc4BuZ2U6P2RVnUHtjT14YVzu13d/q+WwnsjdO7eXBBaIRjZLLdKCXmUI/sFsg0 setRsMjeOCdizhaAUs482u2W2S6FFzJ4ldxv4qKjBBFUPPHUrdar7RTxVHBueHXq7SiE TquE1KfIYy267Q4xfBmzuJciumEmbR9VR91GGe+r7jeDTtTCBCWZqNud8HUT0bVCvksn i3Bw== 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=qfdLMp6C2mQQHbjZslPrJ3feswPbF4MER/ytrchrErw=; b=sf5M0T3XaqPStNegI9HgnMpllx9Deb63lRLDzZKQAjFGDxPf2Yjvz6yflMvRPMuplW X9MaZr5vEDhKNmR2BRJ7ForZWUAVOGStmK0XjXW7Dbwje7oEQ2f3KoU9ZMWo9eY+wXXc AhJ0wWx4mCnQ+DMQmFBXfI0HQiijBRV3jXNmOSefbdJVLsdIIyNMpQ7Le0CwEtnpcd+x m2UDp4wjUqzbY6aT3lNlu0N840Y3eEGO3v4dpXPQ/x5CfrM8SC1lgXt83/9n4zdafDgV L7JryFeupV+0AoWfe8VkM5mOi6m0QhV22oVShxNLcshVo16N1HNHRpyVH3o70OHFWTms HVWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="YptDn/a3"; 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 n11-20020a170906118b00b0077e04f856a2si6140945eja.541.2022.11.22.12.29.40; Tue, 22 Nov 2022 12:30:03 -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="YptDn/a3"; 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 S234853AbiKVU2a (ORCPT + 99 others); Tue, 22 Nov 2022 15:28:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234457AbiKVU2P (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 A3B1F1ADB9 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=Tu8yb4rTFtiG5/ROXb+qs9Ym1yY05u5ArJRxVYfGmFo=; b=YptDn/a3/nVFOVtzeQfSQeV98c6tT1NwvCbizeZq55KsOlAwv4ge4FUe 8aIQAfVMfwBhZo3q+3Kh+36152bdNfkn2358g6SNsOcKl0wFhO0MzZGS5 qFrKDTXl5sg4/VMENHGAbzwUkLOT/gYLSP2rI2etx8Swn9cFru1tBsoMC zqD6sAD2A7EdQyhKrAdJCGqjzX0DyPQNG1Ak5v700hb6Y7V/RJb0deiGZ EZQiAKhcVC9NscnX/CG3ZuQudCv4pcAukhWC3ya5FxmaHKfIWcMVXWdNj IU8PDE03v+VaojhDTTG908ULMkBDBPBDmlVPjY+6mo8aF6kMTARamaUYn Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10539"; a="293616507" X-IronPort-AV: E=Sophos;i="5.96,185,1665471600"; d="scan'208";a="293616507" 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="816228132" X-IronPort-AV: E=Sophos;i="5.96,185,1665471600"; d="scan'208";a="816228132" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by orsmga005.jf.intel.com with ESMTP; 22 Nov 2022 12:28:13 -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 3/7] sched: Teach arch_asym_cpu_priority() the idle state of SMT siblings Date: Tue, 22 Nov 2022 12:35:28 -0800 Message-Id: <20221122203532.15013-4-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?1750229586105324686?= X-GMAIL-MSGID: =?utf-8?q?1750229586105324686?= Some processors (e.g., Intel processors with ITMT) use asym_packing to balance load between physical cores with SMT. In such case, a core with all its SMT siblings idle is more desirable than another with one or more busy siblings. Other processors (e.g, Power7 with SMT8) use asym_packing to balance load among SMT siblings of different priority, regardless of their idle state. Add a new parameter, check_smt, that architectures can use as needed. 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 Suggested-by: Peter Zijlstra (Intel) Signed-off-by: Ricardo Neri --- Changes since v1: * Introduced this patch. --- arch/x86/kernel/itmt.c | 2 +- include/linux/sched/topology.h | 2 +- kernel/sched/fair.c | 5 ++++- kernel/sched/sched.h | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/itmt.c b/arch/x86/kernel/itmt.c index 9ff480e94511..4cb5a5e4fa47 100644 --- a/arch/x86/kernel/itmt.c +++ b/arch/x86/kernel/itmt.c @@ -167,7 +167,7 @@ void sched_clear_itmt_support(void) mutex_unlock(&itmt_update_mutex); } -int arch_asym_cpu_priority(int cpu) +int arch_asym_cpu_priority(int cpu, bool check_smt) { return per_cpu(sched_core_priority, cpu); } diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h index 816df6cc444e..87b64b9776f6 100644 --- a/include/linux/sched/topology.h +++ b/include/linux/sched/topology.h @@ -63,7 +63,7 @@ static inline int cpu_numa_flags(void) } #endif -extern int arch_asym_cpu_priority(int cpu); +extern int arch_asym_cpu_priority(int cpu, bool check_smt); struct sched_domain_attr { int relax_domain_level; diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index d18947a9c03e..0e4251f83807 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -142,8 +142,11 @@ __setup("sched_thermal_decay_shift=", setup_sched_thermal_decay_shift); #ifdef CONFIG_SMP /* * For asym packing, by default the lower numbered CPU has higher priority. + * + * When doing ASYM_PACKING at the "MC" or higher domains, architectures may + * want to check the idle state of the SMT siblngs of @cpu. */ -int __weak arch_asym_cpu_priority(int cpu) +int __weak arch_asym_cpu_priority(int cpu, bool check_smt) { return -cpu; } diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 0fc7c0130755..e5e52c2e82de 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -802,7 +802,8 @@ static inline long se_weight(struct sched_entity *se) */ static inline bool sched_asym_prefer(int a, int b, bool check_smt) { - return arch_asym_cpu_priority(a) > arch_asym_cpu_priority(b); + return arch_asym_cpu_priority(a, check_smt) > + arch_asym_cpu_priority(b, check_smt); } struct perf_domain {