Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp385497rdb; Thu, 25 Jan 2024 20:30:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IGh61A4TBWRrJS0h8XOJBQVK1pzjVV8P6eFdV0tx0iLPvVzLVAKPdZ16CvAfcmJkCSBmmwH X-Received: by 2002:a0c:e48b:0:b0:686:8e21:be0 with SMTP id n11-20020a0ce48b000000b006868e210be0mr546342qvl.58.1706243429986; Thu, 25 Jan 2024 20:30:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706243429; cv=pass; d=google.com; s=arc-20160816; b=Et2Qm6uyN50LOsXk7in50DsdqtHTO8H03VJOmIc+S1V5HmkulO6XQoCErDU7/JdC+2 NV49D+C4fU8/89G9itCl0jCE113P+nvGByHCmfGnqDuygS5BMF0AQSVYQs87430vu9iH sDQrWsYYGAcz0IhanNnup4Zh0Q18X3cD/w2ijuWrQt4RwOE4aB/S6/Nl2NIhB1KPV2vg EEdxxYE/ukmoCXmT4OzsC6JPXRs74ub9a+dwHEId9vWKDw6adOoP7T3S3Ppj32x6gije aMiCcWSqP0VeGmpXSRV8FTz2YQXgBjt78zEZMjWsE+wgH+tWF2YLOVQFplAjyBcpBOBz Eovw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=bYUoTgr8Xx5nlIpGQuqq51LDGuWDNXInLpf5rPQWAo8=; fh=YC7xs7ltfFCClXHHyZq8VZLObWiMbcap3b/zViYKNv4=; b=l7MUeWrhaebWRdwjBz+f8dYAn8eyTU4dCgxsovDY+/9j/5MACXVD9hhAt9p3IXXe4j HkSeQm5DsSYD2sZX7O1thN0gAMfdFgifPmFMOPiF69GUIX2qWUtMhbGcBOU69ejMvnaQ DKEncyNDdZwUIRztbVFtmtzchvJ+HQizmAbMQO/aAnK2nr2oy8EnXFQ6hZGQNg/jHq3j SX5z5F8zX3jpE7l89D33C6KU7WfeE2k2kN13FmX/CZBazhTooBWyRyz0xjTLigtTeY3+ vx38GXZGy7+pnqzPcvGptH3q0EeFcBBMdrOmz0sGeo1woazzLvwOW9JgSehL+yB5W78E gyyg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eGGeCt8E; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-39338-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39338-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id k9-20020ad45be9000000b0067f931f6bfcsi489888qvc.395.2024.01.25.20.30.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 20:30:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-39338-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eGGeCt8E; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-39338-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39338-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E34E41C22F87 for ; Thu, 25 Jan 2024 21:55:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D3D913AA22; Thu, 25 Jan 2024 21:55:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="eGGeCt8E" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D86C513A256 for ; Thu, 25 Jan 2024 21:54:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706219700; cv=none; b=Bl3/8cJdpsnQt9/ZCn0c/5jIm3wSzGtiiw5Hd5ShEg3fLVpIX6A8zliHcMoyl+hsQDSHBaw+S1wH/JfchA5EKhOA/yRkYy2RyRvfBOKpIQxL4enxh9xqgUonHc+bQviB1p6jro/30uBw62CXw014ASwrShRK9/cI3oq6Kw8drOc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706219700; c=relaxed/simple; bh=AGl4mfuEIRIb97234E65SCb6I5D/9ie2c/A/vPwWkZo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=art1m0oKoJ/RPoQ0LWJxOE7QRCnbm7rVpJyqsSWGSuD5crhl2V9AElgU3YCJNo4+e35Jl3uA4TRcMdgQGO5Am7uCCtWAd+2glE8qGNsSTJYFOcTUPClc9GcyCvlTpc0rkUd6+kbPzliX9un5+yCtc00zBtOQmzPbfRN0IhDj+00= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=eGGeCt8E; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706219699; x=1737755699; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=AGl4mfuEIRIb97234E65SCb6I5D/9ie2c/A/vPwWkZo=; b=eGGeCt8ERJ1Vg1ZB4fHHDQY3tIT+G7koMCzuPqki0Dd6kcsvyP80jiVC kVgp+i/c3YqkSdOrRDDy3vsqo1cpKYIHQcqo35WPmBGp70Qqut5RmJT8U pEmESRQcxXTmBzcZr5xq0bmvitVCh63TpUEE6GfpGEAdWnKvkQLvwznbM s1BwcBApp2l5ezjnstbSkRG83WkoIgEAli4Cb5hHZW9u+B4cgzXmC5O2r PLvnyD43SDxhwwnfZgshJVtZvnHBXNEpt+XeYt2ESet7LWgxeI10wkeWh T5Qtmbfvy9H6WQiPlGWxaq7q7SGqzA5+hLAfzSQ8mQ6zXx9Zt750KuBWd A==; X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="1233844" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="1233844" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2024 13:54:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="930160806" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="930160806" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by fmsmga001.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2024 13:54:56 -0800 Date: Thu, 25 Jan 2024 13:56:22 -0800 From: Ricardo Neri To: alexs@kernel.org Cc: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/5] sched/fair: add a func _sched_asym Message-ID: <20240125215622.GA17237@ranerica-svr.sc.intel.com> References: <20240117085715.2614671-1-alexs@kernel.org> <20240117085715.2614671-4-alexs@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240117085715.2614671-4-alexs@kernel.org> User-Agent: Mutt/1.9.4 (2018-02-28) On Wed, Jan 17, 2024 at 04:57:14PM +0800, alexs@kernel.org wrote: > From: Alex Shi > > Use this func in sched_asym and other path to simply code. > No function change. > > Signed-off-by: Alex Shi > To: Valentin Schneider > To: Vincent Guittot > To: Peter Zijlstra > To: Ingo Molnar > --- > kernel/sched/fair.c | 27 +++++++++++++-------------- > 1 file changed, 13 insertions(+), 14 deletions(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index ebd659af2d78..96163ab69ae0 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -9745,6 +9745,14 @@ static bool sched_use_asym_prio(struct sched_domain *sd, int cpu) > (sd->flags & SD_SHARE_CPUCAPACITY) || is_core_idle(cpu); > } > > +static inline bool _sched_asym(struct sched_domain *sd, > + int dst_cpu, int repl_cpu) What does repl_cpu mean? Maybe renaming to src_cpu? > +{ > + /* Ensure that the whole local core is idle, if applicable. */ > + return sched_use_asym_prio(sd, dst_cpu) && > + sched_asym_prefer(dst_cpu, repl_cpu); The comment no longer applies to the whole expression. Perhaps rewording is in order. First we check for the whole idle core if applicable (i.e., when not balancing among SMT siblings). Then we check priorities. Also, indentation should be aligned with `return`, IMO. > +} > + > /** > * sched_asym - Check if the destination CPU can do asym_packing load balance > * @env: The load balancing environment > @@ -9768,20 +9776,13 @@ static bool sched_use_asym_prio(struct sched_domain *sd, int cpu) > static inline bool > sched_asym(struct lb_env *env, struct sg_lb_stats *sgs, struct sched_group *group) > { > - /* Ensure that the whole local core is idle, if applicable. */ > - if (!sched_use_asym_prio(env->sd, env->dst_cpu)) > - return false; > - > /* > * CPU priorities does not make sense for SMT cores with more than one > * busy sibling. While here, it might be good to fix a syntax error above: s/does/do/. > */ > - if (group->flags & SD_SHARE_CPUCAPACITY) { > - if (sgs->group_weight - sgs->idle_cpus != 1) > - return false; > - } > - > - return sched_asym_prefer(env->dst_cpu, group->asym_prefer_cpu); > + return !(group->flags & SD_SHARE_CPUCAPACITY && > + sgs->group_weight - sgs->idle_cpus != 1) && > + _sched_asym(env->sd, env->dst_cpu, group->asym_prefer_cpu); Perhaps we can come up with a better name than _sched_asym(). After this patch the difference between sched_asym() and _sched_asym() is that the former considers the stats of the source group. Maybe sched_asym() can be renamed as sched_group_asym(); it is only used in update_sg_lb_stats(). Your _sched_asym() can become sched_asym(). > } > > /* One group has more than one SMT CPU while the other group does not */ > @@ -11036,8 +11037,7 @@ static struct rq *find_busiest_queue(struct lb_env *env, > * SMT cores with more than one busy sibling. > */ > if ((env->sd->flags & SD_ASYM_PACKING) && > - sched_use_asym_prio(env->sd, i) && > - sched_asym_prefer(i, env->dst_cpu) && > + _sched_asym(env->sd, i, env->dst_cpu) && > nr_running == 1) > continue; > > @@ -11907,8 +11907,7 @@ static void nohz_balancer_kick(struct rq *rq) > * preferred CPU must be idle. > */ > for_each_cpu_and(i, sched_domain_span(sd), nohz.idle_cpus_mask) { > - if (sched_use_asym_prio(sd, i) && > - sched_asym_prefer(i, cpu)) { > + if (_sched_asym(sd, i, cpu)) { > flags = NOHZ_STATS_KICK | NOHZ_BALANCE_KICK; > goto unlock; > } > -- > 2.43.0 >