Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1377008pxb; Thu, 14 Apr 2022 05:01:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGSKmT/0P+h4XcZQEeXWepOQbAzJO6X8Cn9AX3k3DjPZee4zEfFyiwJWZtE+jwizMO9tAc X-Received: by 2002:a17:90a:ba15:b0:1c6:7873:b192 with SMTP id s21-20020a17090aba1500b001c67873b192mr3401587pjr.76.1649937694179; Thu, 14 Apr 2022 05:01:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649937694; cv=none; d=google.com; s=arc-20160816; b=ZfzDUzjvWxRfsZFa6np+wS7XV5cZKPs42cQrJnooZzqRo3LD+NSkmxFPdNp0pxh3O1 gz6Y2pako5ozQsXcJAGZAVsoWLR9i482UneEPyyHjYAOOkwA+9zt8B+rb7GrT56sOSsx KrssdHQEvRmxTTe11eqvkb5ObJcHGxxEyJJAjNVUCiBQQudq1yfDaYJ1KcVYz5ScVNFU ULdnOsnhIdqW6Tmt4kP8bdC7waiuhirzj4dJ/Va2ewZaQpIAldr/sjf3mgCVL8R5iIFx /neviXpFndtevgPhrDpIryqGBXY30e8jbgI/UqLa8z2qWUQ0FWS62uh7Ulb2L9qcDtLw wcTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=KRjESF5FJIppkqvq7rWvqVyiT3uWKLMco+KRyugPGuY=; b=saQMFszB5pgy6DvXVB1cMZekxAeZ4eyy2QF8N2PWuCGRdNlMWecsetcIpb4zn289b1 29ngHEcf8XhddR4rSp7k4ZMZrVpI4qWc1D+2MJT359y7L/tBD1d1KK9I+2fr6p6BRJg1 xzaVke026bPwxR5WiPZRIHOPw3TmWw84XGL2t3LDIsV/uxIrLMz/UUiDJ0U1KaLcx3pI RpX/U8CfOn8rp0jrkEUx/NCG+HhzD6BgcfHD2nrb++Ubwblkugo6lK6itHDbmhiDkm+2 S6nbL3e2wWO3FfIiWN5dzg7GIFo1ibwB4SB0g1Q8rzn7OYy/p6O4mCE8AIGKZxtA77rZ +/xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=bL8WjOj9; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id be3-20020a170902aa0300b0015605a7d777si1847296plb.294.2022.04.14.05.01.21; Thu, 14 Apr 2022 05:01:34 -0700 (PDT) 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=@google.com header.s=20210112 header.b=bL8WjOj9; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238028AbiDNALN (ORCPT + 99 others); Wed, 13 Apr 2022 20:11:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231599AbiDNALM (ORCPT ); Wed, 13 Apr 2022 20:11:12 -0400 Received: from mail-yb1-xb32.google.com (mail-yb1-xb32.google.com [IPv6:2607:f8b0:4864:20::b32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73DC9554A7 for ; Wed, 13 Apr 2022 17:08:48 -0700 (PDT) Received: by mail-yb1-xb32.google.com with SMTP id m132so6653089ybm.4 for ; Wed, 13 Apr 2022 17:08:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KRjESF5FJIppkqvq7rWvqVyiT3uWKLMco+KRyugPGuY=; b=bL8WjOj97hcTkM3aWTWjot6/IEfmif43UxKTHCD8UiyXMbdT1G05tw7JE+5DJDIiDT 4OkR3EJYpd0Skz6FhTbv9fwuSsEPniUelRLmy6pn58XwX1bReuKb/eJ6DQOeV3Pw7eyI pyxCTUWSysLQHJ4g4+xfgZqSw4R/76YX8XuvPGLstjWPhqTP35JvlOVDNfIYYYS2QF9X l86l9p5I0pRfZfpp1MS63SsJfeVWtWYRSVRjXZH8op+5hOSe5ZdSrDGviJN6JJ/xyNfn j+F2/LfRfk5BW2PH44Q4T4oB5chqnDjanpPLeGce2mkfStni3RrNBvJQUm5gShUi/zL1 0v2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KRjESF5FJIppkqvq7rWvqVyiT3uWKLMco+KRyugPGuY=; b=YHrn3m6NXEiiiTBmn4eXl862nxcfuBZtuTOrs1PlLbs8Ae+HZbW0dlIbIdW7FhpSVY 4k2WeJew5AcMJ3cbtRf5dNVQYcQCvS+ydy1blouDGViQl/IvKd4yJ9Re6M0W+ux+IDLJ DYEZgvhk0SRQidAzOXu4m684sxumSIOVcVDIb7EZZIhI5TkRJHQ4a1pwOr3rOB3jTAsn BYhU+SHsXBfGIMdIDO6k72goKHyISe7a5/AC8LXIC/+9bNXki19LhA3v3ml27hgZ9FsZ h4mSaP25aguF2YmuWWKx4UVdSnZJt9OR8yosCL/jmWZ8rzMNdezZ4l3nsXKzo7VdaNKH /cKQ== X-Gm-Message-State: AOAM531kdiUtKTqIzuRdhroFk1OgrnohPdTfDmVo67M8NRYsBsAnkbiP t3XyyS6NEBNGH9jigi4uEhNSi1bUlY3pzuZWWlRGFw== X-Received: by 2002:a25:41cf:0:b0:641:1857:ac7c with SMTP id o198-20020a2541cf000000b006411857ac7cmr19703yba.281.1649894927444; Wed, 13 Apr 2022 17:08:47 -0700 (PDT) MIME-Version: 1.0 References: <20220409135104.3733193-1-wuyun.abel@bytedance.com> <20220409135104.3733193-3-wuyun.abel@bytedance.com> <801da029-6bbe-2a0c-7de0-afffc3d5de02@bytedance.com> In-Reply-To: <801da029-6bbe-2a0c-7de0-afffc3d5de02@bytedance.com> From: Josh Don Date: Wed, 13 Apr 2022 17:08:36 -0700 Message-ID: Subject: Re: [RFC v2 2/2] sched/fair: introduce sched-idle balance To: Abel Wu Cc: Peter Zijlstra , Mel Gorman , Vincent Guittot , linux-kernel Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 > >> /* > >> * Use locality-friendly rq->overloaded to cache the status of the rq > >> * to minimize the heavy cost on LLC shared data. > >> @@ -7837,6 +7867,22 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env) > >> if (kthread_is_per_cpu(p)) > >> return 0; > >> > >> + if (unlikely(task_h_idle(p))) { > >> + /* > >> + * Disregard hierarchically idle tasks during sched-idle > >> + * load balancing. > >> + */ > >> + if (env->idle == CPU_SCHED_IDLE) > >> + return 0; > >> + } else if (!static_branch_unlikely(&sched_asym_cpucapacity)) { > >> + /* > >> + * It's not gonna help if stacking non-idle tasks on one > >> + * cpu while leaving some idle. > >> + */ > >> + if (cfs_rq_busy(env->src_rq) && !need_pull_cfs_task(env->dst_rq)) > >> + return 0; > > > > These checks don't involve the task at all, so this kind of check > > should be pushed into the more general load balance function. But, I'm > > not totally clear on the motivation here. If we have cpu A with 1 > > non-idle task and 100 idle tasks, and cpu B with 1 non-idle task, we > > should definitely try to load balance some of the idle tasks from A to > > B. idle tasks _do_ get time to run (although little), and this can add > > up and cause antagonism to the non-idle task if there are a lot of > > idle threads. > > CPU_SCHED_IDLE means triggered by sched_idle_balance() in which pulls > a non-idle task for the unoccupied cpu from the overloaded ones, so > idle tasks are not the target and should be skipped. > > The second part is: if we have cpu A with 1 non-idle task and 100 idle > tasks, and B with >=1 non-idle task, we don't migrate the last non-idle > task on A to B. It could be possible that we do want to migrate the last non-idle task from A to B, if the weight sum of idle tasks on A is very high (easily possible with affinity restrictions). So I think we should leave regular load balance alone here if it really wants to move the non-idle task, and wrap this entire block in an if (env->idle == CPU_SCHED_IDLE). Thanks, Josh