From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EACA8ECAAA2 for ; Thu, 25 Aug 2022 22:49:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243990AbiHYWtt (ORCPT ); Thu, 25 Aug 2022 18:49:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230181AbiHYWtm (ORCPT ); Thu, 25 Aug 2022 18:49:42 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08D54C6CC0 for ; Thu, 25 Aug 2022 15:49:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661467782; x=1693003782; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=iCf2JOGLKwSr4KxwYo6MVIoFBW1cHtkZPlptvpIfquk=; b=hNLtMQXxG0Mbwj5qf99IeCPpRzJC2m7L3I5dgzzS23GgyjEeWk9vup3c Y2v9tePc7bkX9HyzMY/m3G5ov2X2mdp+uCJa3qzBZRo4s+QyJskMseDWA 02+77Sqb+vUO266UvDr+qAXDAodbaWJemizYXUmG48D+vibss24f8Ox6O WU1HR5YL/KiCnFGxZTDDyYTM1asCIi3vJyXvLy5AgkqCkh867Sa/uRK68 xQguy7/9VZtl3Q+pHAdGfQL3bCl/2cbjTvWbNNBGREJLqo6d0KlQJ2TCQ DhnQjCzXm+U61lKdasqgbT/QzUBftpXmyGN9ThHldGMTfmUb/oySSQMRo Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10450"; a="295153916" X-IronPort-AV: E=Sophos;i="5.93,264,1654585200"; d="scan'208";a="295153916" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Aug 2022 15:49:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,264,1654585200"; d="scan'208";a="678642674" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by fmsmga004.fm.intel.com with ESMTP; 25 Aug 2022 15:49:40 -0700 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 1/4] sched/fair: Simplify asym_packing logic for SMT sched groups Date: Thu, 25 Aug 2022 15:55:26 -0700 Message-Id: <20220825225529.26465-2-ricardo.neri-calderon@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220825225529.26465-1-ricardo.neri-calderon@linux.intel.com> References: <20220825225529.26465-1-ricardo.neri-calderon@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the destination CPU is an SMT sibling and idle, it can only help the busiest group if all of its other SMT siblings are also idle. Otherwise, there is not increase in throughput. It does not matter whether the busiest group has SMT siblings. Simply check if there are any tasks running on the local group before proceeding. 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 Reviewed-by: Len Brown Signed-off-by: Ricardo Neri --- kernel/sched/fair.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 77b2048a9326..91f271ea02d2 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -8603,12 +8603,10 @@ static bool asym_smt_can_pull_tasks(int dst_cpu, struct sd_lb_stats *sds, struct sched_group *sg) { #ifdef CONFIG_SCHED_SMT - bool local_is_smt, sg_is_smt; + bool local_is_smt; int sg_busy_cpus; local_is_smt = sds->local->flags & SD_SHARE_CPUCAPACITY; - sg_is_smt = sg->flags & SD_SHARE_CPUCAPACITY; - sg_busy_cpus = sgs->group_weight - sgs->idle_cpus; if (!local_is_smt) { @@ -8629,25 +8627,16 @@ static bool asym_smt_can_pull_tasks(int dst_cpu, struct sd_lb_stats *sds, return sched_asym_prefer(dst_cpu, sg->asym_prefer_cpu); } - /* @dst_cpu has SMT siblings. */ - - if (sg_is_smt) { - int local_busy_cpus = sds->local->group_weight - - sds->local_stat.idle_cpus; - int busy_cpus_delta = sg_busy_cpus - local_busy_cpus; - - if (busy_cpus_delta == 1) - return sched_asym_prefer(dst_cpu, sg->asym_prefer_cpu); - - return false; - } - /* - * @sg does not have SMT siblings. Ensure that @sds::local does not end - * up with more than one busy SMT sibling and only pull tasks if there - * are not busy CPUs (i.e., no CPU has running tasks). + * @dst_cpu has SMT siblings. When both @dst_cpu and the busiest core + * have one or more busy siblings, moving tasks between them results + * in the same throughput. Only if all the siblings of @dst_cpu are + * idle throughput can increase. + * + * If the difference in the number of busy CPUs is two or more, let + * find_busiest_group() take care of it. */ - if (!sds->local_stat.sum_nr_running) + if (sg_busy_cpus == 1 && !sds->local_stat.sum_nr_running) return sched_asym_prefer(dst_cpu, sg->asym_prefer_cpu); return false; -- 2.25.1