Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2958633rdb; Tue, 6 Feb 2024 03:03:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IF18CD0vGOvuoxMgoxlOCQ9Y7Dj5vaXoMBjt1eX09bWssWPVrvYtekiKcIbNgfReLJplnzX X-Received: by 2002:a17:902:f68f:b0:1d9:cc00:524c with SMTP id l15-20020a170902f68f00b001d9cc00524cmr2186921plg.19.1707217382709; Tue, 06 Feb 2024 03:03:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707217382; cv=pass; d=google.com; s=arc-20160816; b=hZq5lKQeJ6rF0Uj8/YAtRAbfk8gN2sxk4+cqJFhzBbKZEmF4LfS43U8kOyGf8cB0jV WxPeNmTh0jZXao/VsMRPk5hRqy7oVsIHIfy7Fzd7iltofNP7UjeluLGulxi9MpMbTbgU 3cdPzEXckb9f8styN4hqun6sgsoPkuqkV6Qe1X+KKjTD5oocnv4YxO7wusTSWndcyl+n dudw3tRc1m4hQGaRUNoi2c9RpA8uulEffq2egjx+SPV50cLDTWdl/2iNQNkU8iFMGm2m wXlFfx7waJg49d4b98JLNS7RCB1j+Zz1MjBDFl2I9B1QkW+z+iBiaU7xUiI0S70u3ioD 6DEA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=t8zJ+SwyQQodJxcemTb612mJQqGnP4kdLP+p5qhz57E=; fh=+G0ustJlcA7NniCzYK7SO8Yf4rPK0ox9VcQND5TcK1w=; b=CDfHUiu3g7Bd2XJX8mYM1rEct/B6hRiPmn1KJuxWwZEjWcev6gJdGQw8GuDZ0dhET9 DJZBt6qdBm2H4+wDehUwKkGlBMcuQDQ/1aEnA5ggkk0DQIoQGbAppQUs03smh+I78wa5 1hAPZIGN/Rn9X1Z9XSUIEliwUuwOf4oBfd5vIe9Kgx7agmM1IRSbjBi/EOB7NW448WML mANqBkpb3sYnVzNGDGliqTLtnGPlbzEm78d0N3frJzbXnf3FhzDlsvQiCpD1X+CSgq3K d12fY+1wzzADfJstGZLhim59frIn7jjyPL+xV3Xtqgt9edWsgfpP0uW+nvvCC5xMjSvh UhXA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=sina.com); spf=pass (google.com: domain of linux-kernel+bounces-54721-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54721-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCVL+3JCZaD1uoDuruOXxCzfyvdwClqD4aaGxoqigIKp/aAvXGv7nBIwY8axCkhfGZI6IA9d0c/yl9Kt1frxM55n+pCEpm7X1BfB8ST85Q== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id e6-20020a170902b78600b001d959170f5bsi1455060pls.12.2024.02.06.03.03.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 03:03:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54721-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=sina.com); spf=pass (google.com: domain of linux-kernel+bounces-54721-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54721-linux.lists.archive=gmail.com@vger.kernel.org" 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 07086B21242 for ; Tue, 6 Feb 2024 10:56:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 380CC12CDBE; Tue, 6 Feb 2024 10:55:57 +0000 (UTC) Received: from mail115-100.sinamail.sina.com.cn (mail115-100.sinamail.sina.com.cn [218.30.115.100]) (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 127C158131 for ; Tue, 6 Feb 2024 10:55:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=218.30.115.100 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707216956; cv=none; b=HkmK8pTRPC5rA24Zj9aWHhc1ZYETv8kXrzYBcbTLr9t9xp5VO4DE6n3G3EiCAZGTYFkmU0Kt4vc8X0T+1zVaLa/S0DtjNYRDpl3oCeW8kVh+VfhmxrtzAxWF2j214p0mCb7c8VDd1dXF3KTNbco8H2KO+P36EV73YKpIRaDlQuM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707216956; c=relaxed/simple; bh=Rz8sbgycJLKAZBfAqkmFCkKszu2C/D37PBPjyk4d8LU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HhNt3NMDnjMFdetTr2YbKLFppB1KNVEZwxzDuhSd33eaWXNt3cJbJiLStINmhYH6Ifk+y90hkbfiL1t0x1fTCTb4ncpntULjx4Xiw0IGGAF+/zD7yrY32KBX2jY3PzcCVAXJ6xmJMG4Q9hWylLpBaH1n3bI4ev0FlFHlEKSTues= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com; spf=pass smtp.mailfrom=sina.com; arc=none smtp.client-ip=218.30.115.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([113.88.51.138]) by sina.com (172.16.235.24) with ESMTP id 65C2102B00005DAB; Tue, 6 Feb 2024 18:55:42 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=hdanton@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=hdanton@sina.com X-SMAIL-MID: 34362945088986 X-SMAIL-UIID: 363A5DE36BF243C2AA6DAD8F9285E6A2-20240206-185542-1 From: Hillf Danton To: Qais Yousef Cc: Ingo Molnar , Peter Zijlstra , Vincent Guittot , Dietmar Eggemann , linux-kernel@vger.kernel.org, Pierre Gondois Subject: Re: [PATCH v5 2/2] sched/fair: Check a task has a fitting cpu when updating misfit Date: Tue, 6 Feb 2024 18:55:30 +0800 Message-Id: <20240206105530.763-1-hdanton@sina.com> In-Reply-To: <20240205021123.2225933-3-qyousef@layalina.io> References: <20240205021123.2225933-1-qyousef@layalina.io> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Mon, 5 Feb 2024 02:11:23 +0000 Qais Yousef > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -5092,24 +5092,36 @@ static inline int task_fits_cpu(struct task_struct *p, int cpu) > > static inline void update_misfit_status(struct task_struct *p, struct rq *rq) > { > + unsigned long cpu_cap; > + int cpu = cpu_of(rq); > + > if (!sched_asym_cpucap_active()) > return; > > - if (!p || p->nr_cpus_allowed == 1) { > - rq->misfit_task_load = 0; > - return; > - } > + if (!p || p->nr_cpus_allowed == 1) > + goto out; > > - if (task_fits_cpu(p, cpu_of(rq))) { > - rq->misfit_task_load = 0; > - return; > - } > + cpu_cap = arch_scale_cpu_capacity(cpu); > + > + /* If we can't fit the biggest CPU, that's the best we can ever get. */ > + if (cpu_cap == rq->rd->max_cpu_capacity) > + goto out; > + > + /* Affinity allows us to go somewhere higher? */ > + if (cpu_cap == p->max_allowed_capacity) > + goto out; Looks good. > + > + if (task_fits_cpu(p, cpu)) > + goto out; > > /* > * Make sure that misfit_task_load will not be null even if > * task_h_load() returns 0. > */ > rq->misfit_task_load = max_t(unsigned long, task_h_load(p), 1); > + return; > +out: > + rq->misfit_task_load = 0; > } > > #else /* CONFIG_SMP */ > @@ -8241,6 +8253,36 @@ static void task_dead_fair(struct task_struct *p) > remove_entity_load_avg(&p->se); > } > > +/* > + * Check the max capacity the task is allowed to run at for misfit detection. > + */ > +static void set_task_max_allowed_capacity(struct task_struct *p) > +{ > + struct asym_cap_data *entry; > + > + if (!sched_asym_cpucap_active()) > + return; > + > + rcu_read_lock(); > + list_for_each_entry_rcu(entry, &asym_cap_list, link) { > + cpumask_t *cpumask; > + > + cpumask = cpu_capacity_span(entry); > + if (!cpumask_intersects(p->cpus_ptr, cpumask)) > + continue; > + > + p->max_allowed_capacity = entry->capacity; > + break; Given what max_allowed_capacity could mean, it is needed to find the max capacity by iterating the asym_cap_list instead of the first capacity determined by the allowed CPU mask. > + } > + rcu_read_unlock(); > +} BTW is it working in case of systems with a super core? cpu0-3 cpu4-6 cpu7 little big super core core core