From patchwork Tue Feb 7 05:10:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Neri X-Patchwork-Id: 53676 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2653068wrn; Mon, 6 Feb 2023 21:03:26 -0800 (PST) X-Google-Smtp-Source: AK7set/fDQoHtWkhvEKeZ++vUsG/evq8x580Ny32b4bW85fdzC7mR5tKWXfLaTwr6CP+2zKY/D6b X-Received: by 2002:a62:1b05:0:b0:593:92b3:b757 with SMTP id b5-20020a621b05000000b0059392b3b757mr2005983pfb.3.1675746206669; Mon, 06 Feb 2023 21:03:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675746206; cv=none; d=google.com; s=arc-20160816; b=sHq9id39n3E3tNiXAYj8Cu7y+E0+IvkBVJxDYakQYrEGIfWnuK5jXyj6xpzVVS9a7c dVLdJzy6XYzbf1IOdym2BQJbvKO19asKEaHCnLHBk5fVILUh26N3MDmjJ4YcPniS0vFK +O6319QHxenv20q0ZLj+QdfNlAj3qs6ojZPauPooqqnsgHorinEsODZOWx+ZJlzJm21m kb0RcD9tGkz584RqUUvFCCkUjteck1wmlLU3GVNwWoFXx9xYhm4i7rOoIDHtJHxpS0Sf DR9beVopDVEv3LQJNbyghZnAhBOZ9TgbzGH4gyV5ymfoMZ244njLvyYmDkgsAbAXxwc6 +zhA== 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=ZzrEy83LY5oTNovx4i2my1dVT3cKurU/QzvH4Lq0/po=; b=Xn1viPXxH5ICcDDKzS4awPmLots5JDSKML0akhYlCxyMJn9e/Op7IwnrEGr/R2aGx3 BZqGnjEM+8YUwvfgYnZXW0j/InCSnAe3yGo0UBYznl2G/obPf+21AWkQeUFFSE8TabS4 swjdsyZLVj81YZm4i5DpSnz0DxPR/gnDFM6nOosZ+ToL4deuqdFFpY8ZqW5ebzqO+lvW MdYEfEPoqKK0NEuLzOJTvY5i1uldQnPKThhjw26eb90l8FPFPk2/XU1NJE/JfnBrhXPA l+m+zMkdJMTI+OPqNoeZJvWeSZhAlzCHt7URc1y6bE7Z30eRgRd2E5QkRCiFfPdmD/qC ZpcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="dhD9I/7m"; 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 r29-20020aa79edd000000b00592591f1972si13255304pfq.64.2023.02.06.21.03.12; Mon, 06 Feb 2023 21:03:26 -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="dhD9I/7m"; 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 S230340AbjBGFCi (ORCPT + 99 others); Tue, 7 Feb 2023 00:02:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230161AbjBGFBz (ORCPT ); Tue, 7 Feb 2023 00:01:55 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D43E4901F; Mon, 6 Feb 2023 21:01:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675746113; x=1707282113; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=XBeyrfeapZSrbuAay+AhGt8TNoIKKt2H5iHcCn0WtSs=; b=dhD9I/7mLVj2Pggklg/grywvghBoSKaHwulbTuRAAHYuSm415n4FAEfV tYcSr+xDP+sso3ijlWudcK+qfujjfWET/RZHe5mWc7Rcarq7kwPwyaejx 47TbMWIgSkkkWrwRxyQj36YO2mQVrMudO8wQ6VkRhb3nBeHdigjm46e/P UcpJL10fI5HT6suN3NwaKLGJj+pvhcYvFoR/acBhYiGK6LiYaVum9sCkr 0eA0Q3jPQDP1zUSOpT3mVTJ6y95Mj7Ri7Ecd6mFaDJPs4JiLYb/8bPE2h Gacexu2m7mQUSjj3I1fzWPF+F+YLmpc4k+EivlWM2dlB1gDdZCQDiMkc1 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10613"; a="415625837" X-IronPort-AV: E=Sophos;i="5.97,278,1669104000"; d="scan'208";a="415625837" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2023 21:01:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10613"; a="668657723" X-IronPort-AV: E=Sophos;i="5.97,278,1669104000"; d="scan'208";a="668657723" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by fmsmga007.fm.intel.com with ESMTP; 06 Feb 2023 21:01:42 -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 , Lukasz Luba , Ionela Voinescu , x86@kernel.org, "Joel Fernandes (Google)" , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Ricardo Neri , "Tim C . Chen" Subject: [PATCH v3 09/24] sched/fair: Use IPCC stats to break ties between fully_busy SMT groups Date: Mon, 6 Feb 2023 21:10:50 -0800 Message-Id: <20230207051105.11575-10-ricardo.neri-calderon@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230207051105.11575-1-ricardo.neri-calderon@linux.intel.com> References: <20230207051105.11575-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_NONE, 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?1757147253970345175?= X-GMAIL-MSGID: =?utf-8?q?1757147253970345175?= IPCC statistics are used during idle load balancing. After balancing one of the siblings of an SMT core will become idle. The rest of the busy siblings will enjoy increased throughput. The IPCC statistics provide a measure of the increased throughput. Use them to pick a busiest group from otherwise identical fully_busy scheduling groups (of which the avg_load is equal - and zero). Using IPCC scores to break ties with non-SMT fully_busy sched groups is not necessary. SMT sched groups always need more help. Add a stub sched_asym_ipcc_prefer() for !CONFIG_IPC_CLASSES. Cc: Ben Segall Cc: Daniel Bristot de Oliveira Cc: Dietmar Eggemann Cc: Ionela Voinescu Cc: Joel Fernandes (Google) Cc: Len Brown Cc: Lukasz Luba 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-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Ricardo Neri --- Changes since v2: * Introduced this patch. Changes since v1: * N/A --- kernel/sched/fair.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 841927b9b192..72d88270b320 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -9415,6 +9415,12 @@ static void update_sg_lb_stats_scores(struct sg_lb_stats *sgs, { } +static bool sched_asym_ipcc_prefer(struct sg_lb_stats *a, + struct sg_lb_stats *b) +{ + return false; +} + static bool sched_asym_ipcc_pick(struct sched_group *a, struct sched_group *b, struct sg_lb_stats *a_stats, @@ -9698,10 +9704,21 @@ static bool update_sd_pick_busiest(struct lb_env *env, if (sgs->avg_load == busiest->avg_load) { /* * SMT sched groups need more help than non-SMT groups. - * If @sg happens to also be SMT, either choice is good. */ - if (sds->busiest->flags & SD_SHARE_CPUCAPACITY) - return false; + if (sds->busiest->flags & SD_SHARE_CPUCAPACITY) { + if (!(sg->flags & SD_SHARE_CPUCAPACITY)) + return false; + + /* + * Between two SMT groups, use IPCC scores to pick the + * one that would improve throughput the most (only + * asym_packing uses IPCC scores for now). + */ + if (sched_ipcc_enabled() && + env->sd->flags & SD_ASYM_PACKING && + sched_asym_ipcc_prefer(busiest, sgs)) + return false; + } } break;