Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp627866rwe; Thu, 25 Aug 2022 06:38:08 -0700 (PDT) X-Google-Smtp-Source: AA6agR6e1ovdcAs6CS8dcaO7ByPsi9xMi2nXxQrWIHteJEZCWrFn9ROrcg7KeAgPWWYLgH4+ztJ4 X-Received: by 2002:a17:907:3f94:b0:73d:8f71:b56a with SMTP id hr20-20020a1709073f9400b0073d8f71b56amr2586156ejc.328.1661434688024; Thu, 25 Aug 2022 06:38:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661434688; cv=none; d=google.com; s=arc-20160816; b=uMBUjsdcL2cwwyfnE0ggVOdQgPzPLx1rmQFl0k45YikEa2RnAA8eKEVu1vY1vCZF1t sLcy+y93NtisygU007oCpVM+JiaMzisnv5Oxgek7pZloszw8T7TjS4OpqQuSzYSivwCB VwByhpiE7b5wso9ANXG64+1cliYUINR2YXXegAAoq4CRBPq8F4xmhGxxAFkQcHm+zqHF zmwk/3//zcMlFA+7MZRVpvBCU6omU+6NpdYPwVicJjafSechsJ5lYvnEH2/hdLb7/Txy AGsd0Z2I9ov44+pwHiphM7OB7IQxAIqRUqoJIG3RHOs7PKVwHvQLdJZu++TktSJD6QxA ZCQQ== 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=1jOusZgKkm5WANPXGaVYE6KRJlFGGUsuCyFNE7JUooM=; b=GCsTxKZmHtFGOmipHY1r3fsr9FxgPh0+szOY92HjbeIIXnO2EBMuEPbLuA25tMwDKV bYIBrjgnJ1JX0yyxQfabwFYmgTESfO269qNcZ7MUEAN97vTdYiOTXh7DzkhF1NlYN3+R 2uaH1DfrZtjl6Ws7AYoOQAlBWgq7/bk8ucPbu9aVCsagVGv9CelhunwF5CRLDAO0qc3K gL7wdP7Sg0mi3HkzoQs56ZzXw4V2xiV1VJ8DswvFjct2tw4tNs84X1RvhMlT5oB0ToHN T6p/bPzDgBmVeUawmKOX7m5mA4/V3S7dVXaUjcDh/IVxkoS5xwxnKGOnzjIS2owpsuGy iKBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CEA9syvD; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qb11-20020a1709077e8b00b0073d9c29892csi3775671ejc.939.2022.08.25.06.37.41; Thu, 25 Aug 2022 06:38:08 -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=@linaro.org header.s=google header.b=CEA9syvD; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240663AbiHYM1l (ORCPT + 99 others); Thu, 25 Aug 2022 08:27:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240538AbiHYM1f (ORCPT ); Thu, 25 Aug 2022 08:27:35 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22B15B2874 for ; Thu, 25 Aug 2022 05:27:34 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id k9so24420779wri.0 for ; Thu, 25 Aug 2022 05:27:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc; bh=1jOusZgKkm5WANPXGaVYE6KRJlFGGUsuCyFNE7JUooM=; b=CEA9syvDnBy12AASzhjTKQePZq/nDobaYDFG33wpBoHuTYHBS+aGzekCp/7KATl82q pneAop0fiEfoG1GSROoAovfj7ob6z6FPikrFGC/Q01FKgXeAjKKTktGrS2XHQnGbo7lv DOpasbdR3Ggjn3/S7XEkZyJkvycx8YgKfGsdF6S3WW8MkgZfZKvMw1jPKLrsCIdKKjYP TBRBNdt9MAsxZLop6/5VMDXe4jPte55IrtJz7zxExSqKXzdxLHlYgcrAwOS2OzBX7e/u BiQZ1ue8UVldKu93ERpMi460AcuS31+lx3z3Q0YSqRk6+FTuEnFcVlADiKl2l84E+SiK UXjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc; bh=1jOusZgKkm5WANPXGaVYE6KRJlFGGUsuCyFNE7JUooM=; b=inPw6XkyHAMHvL3BPa9Ezhc58DljzBD4UYFNplB044KHAwoAH8hqnXnJ/xvsm3qDoz NWSWj31mjNwaaHt3Dhy6vX/ACEnMecwQ7BaS2FqbsfPEXLtgt4hGXGn9mEAifqI6P7WB aHRjGiuoM3axrWp7z0Cv0JUJ0Rwlzghfq9DjBBSAKmnhi6gbJYlX3XEOpJkNyg5NY5JT 4cvXm/jojtr3R67Q9o2ZXQsLLM1YYm8iYXCSp64zkHk4eAtL61e0qjjgEXVEKJwsyMrR QiILZoCZt4qbD2qnt/8FBzZlE1reuDivZx/JIOaduKZIXZW5Xmzo48Wb4GjKC6pxNKU8 BBAQ== X-Gm-Message-State: ACgBeo33CR0gwJQ0YE/SANELfeyzNxjbhZgD7gSQ/N4Rq861xS5mxar7 fx5uLxKJ1xneNk7T5yMPRaUvCA== X-Received: by 2002:a5d:47cc:0:b0:225:7827:70d4 with SMTP id o12-20020a5d47cc000000b00225782770d4mr2104040wrc.315.1661430452431; Thu, 25 Aug 2022 05:27:32 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:f:6020:55dd:3519:10d3:b07b]) by smtp.gmail.com with ESMTPSA id c7-20020a05600c0ac700b003a5ee64cc98sm5417809wmr.33.2022.08.25.05.27.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Aug 2022 05:27:30 -0700 (PDT) From: Vincent Guittot To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, linux-kernel@vger.kernel.org Cc: zhangqiao22@huawei.com, Vincent Guittot Subject: [PATCH 1/4] sched/fair: make sure to try to detach at least one movable task Date: Thu, 25 Aug 2022 14:27:23 +0200 Message-Id: <20220825122726.20819-2-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220825122726.20819-1-vincent.guittot@linaro.org> References: <20220825122726.20819-1-vincent.guittot@linaro.org> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 During load balance, we try at most env->loop_max time to move a task. But it can happen that the loop_max LRU tasks (ie tail of the cfs_tasks list) can't be moved to dst_cpu because of affinity. In this case, loop in the list until we found at least one. The maximum of detached tasks remained the same as before. Signed-off-by: Vincent Guittot --- kernel/sched/fair.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index da388657d5ac..02b7b808e186 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -8052,8 +8052,12 @@ static int detach_tasks(struct lb_env *env) p = list_last_entry(tasks, struct task_struct, se.group_node); env->loop++; - /* We've more or less seen every task there is, call it quits */ - if (env->loop > env->loop_max) + /* + * We've more or less seen every task there is, call it quits + * unless we haven't found any movable task yet. + */ + if (env->loop > env->loop_max && + !(env->flags & LBF_ALL_PINNED)) break; /* take a breather every nr_migrate tasks */ @@ -10182,7 +10186,9 @@ static int load_balance(int this_cpu, struct rq *this_rq, if (env.flags & LBF_NEED_BREAK) { env.flags &= ~LBF_NEED_BREAK; - goto more_balance; + /* Stop if we tried all running tasks */ + if (env.loop < busiest->nr_running) + goto more_balance; } /* -- 2.17.1