Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1410654rdb; Wed, 24 Jan 2024 14:45:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IGFbmm2IRLvzOpoNh4vGNHPXKl1zeg6MFZiIyDGIlGBA35zr/TzsqirwzVSX4oT5nxF2ihQ X-Received: by 2002:a05:6358:d141:b0:175:77e8:6c31 with SMTP id jz1-20020a056358d14100b0017577e86c31mr89064rwb.42.1706136327675; Wed, 24 Jan 2024 14:45:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706136327; cv=pass; d=google.com; s=arc-20160816; b=QwgvGSuYRqTXCPUYV2ndBCX9yRRNcW2sNPu6GuiJHEGMDpFZF8FwyaCF3KBAMIhksr TdXjMxIorVYVn1rxWaA4MgArfknvu+Ew8PZ0I0DhaiVTwPFGEVK09TGpq/3AmxMnK78Q X9lbdA7az2g0hb2VINzAHC8PMica/chlutM4LgxJp/qVR/q8hLhZyOZvUmVAb8pEFKCk UPvSq9rpA4W2A882xJU5IZwkmu9LbGzaYPXpvWhsTSSZOecmBJ5xeH/Ft6J6HTav4JBG 0p4lTBNG4qd6wNBhT7BP7pxJ3ucMc72Yy/sYIB5dLj5QviKY/mJO7tBLvzCWbnwSBHMK f7RA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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=Lzjx1bk00QTl7T0INBKVmgz2bdGhTs7haxC4/89GTjA=; fh=mHfqAwIJ+l/+euW351aOg70DZG7IOEjGqFN7T21HVfE=; b=n/SvPkD1LvljEa6zJkq+wlENLA9sh7l3toDMKxUsJIyJY20SsppLSU6q1GsftsGNw/ TRUl7dRFonUNBwjK9SNIcCuzDzBQdTPOGi8jwNfdiAftJeCB63UL8qmk418Nj44dBj36 aaL0l979uQrHbf+g8+BWrF/c5OJT41eh+lWAX0xqBBbc3TUuxjcqsEx7r+rvse/4il7P SNnMg1wrros+EMSLHD+42V390EB9Py/EOF4qKkFlxgxtOlFNc5aiE1ITDOaVOZjHETrM 2EeIVNvr6GA4f7xjVbBhd5ceijg5hX8eU5lIkZjIv4lWGMNYjIuyCqzpFBzomCrdxxm5 m2dA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=fcGVCah8; arc=pass (i=1 spf=pass spfdomain=layalina.io dkim=pass dkdomain=layalina-io.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-37761-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37761-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id q4-20020a17090aa00400b0028fef76a8f6si242417pjp.8.2024.01.24.14.45.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 14:45:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-37761-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; dkim=pass header.i=@layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=fcGVCah8; arc=pass (i=1 spf=pass spfdomain=layalina.io dkim=pass dkdomain=layalina-io.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-37761-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37761-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 D984BB26494 for ; Wed, 24 Jan 2024 22:39:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 51478135A71; Wed, 24 Jan 2024 22:38:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=layalina-io.20230601.gappssmtp.com header.i=@layalina-io.20230601.gappssmtp.com header.b="fcGVCah8" Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 851DF134750 for ; Wed, 24 Jan 2024 22:38:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706135927; cv=none; b=rg9mlSA2P2PG1JClXy3sjQ4ZnRdYnCqbFgleIe/ZYQWJhDve+LlWycUNxBrwd87H1JPCq1qYaslGzm4YvMuFjNI6JJ6Dkc17Fp0L2mJN46Y5H9E5cpCLoVviO031paa1FqpKfBZ/LUICH2+fqOSzVfxPQDswbuFJQ5rr2gI3gHI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706135927; c=relaxed/simple; bh=xjeJlV55+kPHUU5TbYsfmkt4Ye/0S6xdDaU/VwH/rko=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=K8MVg8rs47SzgyNwoQ3HjFwLeHB797QKG62Mu1FVWsy/UP7ZC0YFu4LBhm/jctgh4qIWDBB0hr+ryMul/zieCZqT61GQHJJUoSp3HIr47LXgybXL01FbYyGLOVU0lv2M9xneAAav1bfc33cjkptB5D6nMRpsaBHM85NPxPFWQsk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=layalina.io; spf=pass smtp.mailfrom=layalina.io; dkim=pass (2048-bit key) header.d=layalina-io.20230601.gappssmtp.com header.i=@layalina-io.20230601.gappssmtp.com header.b=fcGVCah8; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=layalina.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=layalina.io Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-40ece18638fso2238285e9.1 for ; Wed, 24 Jan 2024 14:38:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20230601.gappssmtp.com; s=20230601; t=1706135923; x=1706740723; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Lzjx1bk00QTl7T0INBKVmgz2bdGhTs7haxC4/89GTjA=; b=fcGVCah8otFYwboL/xYWVgVAD3xGVP2UQLD1kMZGhZjwyWsooH167JuTJljIYUecCI IEGsBGahqZmaU38gGaAMeAMlz0drhBdfRRDuCqjDhXrox6H5lMEAW+YIwOBP/Ti92WZo TjPaUGV+cd/odHjhG4DcKa/+R+FTMTuUecmI7xDEYunTI+36qag1NqIZ4HJ56yaQMNUN 2F+ooK8HP9S+TNLLQXeuCIowzGHHt34dogJ0s9xu5sYTfksSr3nvXX6uncf+kAYOn3bA mELF9oCkuG9+vIRWa/djswaKTxQwYjsaX3qcXswdq1pvo/k8y8SXtu6Vba6xP5xFb+Am gFGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706135923; x=1706740723; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Lzjx1bk00QTl7T0INBKVmgz2bdGhTs7haxC4/89GTjA=; b=HJ943VywOOFQhz3sFtda3+0ZWV08+IZAZL7EKgU300pXkMJG04z+yUMKb3mnsdmwt1 KyQAS2dQiYmJhPS7LPbjttPKDKnzblIqH5BSQKgZu/kHv8RzHPSWvUdoQTL/MyiAcBse FTIyoz7cncv5dytsKhk9zj4CLIicGgOtjWKeRKJnUv8RWgkh2lXW6PlQeS0s/AERBiVJ qbu7iVEWPMH52gBSgGpMpx27WRauk6wLwYkM0UNjfocfe18a3/nvyh2ZD2OWP1TeC2kc goy3toRm47cP9w8jLkOs4S6OBR+LTAy8C22DTZCPY1D4T6aZ0IIPO7iiS7cBMCgpJw73 2+vQ== X-Gm-Message-State: AOJu0Yyktu65K4425TYsvCoJrRJwMt56QuL51oPZ2lhE4j+VhBa6x6qO v/PvPX20cGmj5bJbN9m/ZODPKj1LV+kx6ddGKISGkgnW6upb/0ZcBtabcV2eUxY= X-Received: by 2002:a05:600c:1c98:b0:40e:50ac:d24e with SMTP id k24-20020a05600c1c9800b0040e50acd24emr2162428wms.13.1706135923674; Wed, 24 Jan 2024 14:38:43 -0800 (PST) Received: from airbuntu ([213.122.231.14]) by smtp.gmail.com with ESMTPSA id f16-20020a05600c155000b0040ebf5956absm449116wmg.29.2024.01.24.14.38.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 14:38:43 -0800 (PST) Date: Wed, 24 Jan 2024 22:38:42 +0000 From: Qais Yousef To: Vincent Guittot Cc: Ingo Molnar , Peter Zijlstra , Dietmar Eggemann , linux-kernel@vger.kernel.org, Pierre Gondois Subject: Re: [PATCH v4 1/2] sched/fair: Check a task has a fitting cpu when updating misfit Message-ID: <20240124223842.zjsolwhp26w7vowu@airbuntu> References: <20240105222014.1025040-1-qyousef@layalina.io> <20240105222014.1025040-2-qyousef@layalina.io> 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=utf-8 Content-Disposition: inline In-Reply-To: On 01/23/24 18:22, Vincent Guittot wrote: > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > > index bcea3d55d95d..0830ceb7ca07 100644 > > --- a/kernel/sched/fair.c > > +++ b/kernel/sched/fair.c > > @@ -5065,17 +5065,61 @@ 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 uclamp_min, uclamp_max; > > + unsigned long util, 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 == SCHED_CAPACITY_SCALE) > > + goto out; > > + > > + uclamp_min = uclamp_eff_value(p, UCLAMP_MIN); > > + uclamp_max = uclamp_eff_value(p, UCLAMP_MAX); > > + util = task_util_est(p); > > + > > + if (util_fits_cpu(util, uclamp_min, uclamp_max, cpu) > 0) > > + goto out; > > + > > + /* > > + * If the task affinity is not set to default, make sure it is not > > + * restricted to a subset where no CPU can ever fit it. Triggering > > + * misfit in this case is pointless as it has no where better to move > > + * to. And it can lead to balance_interval to grow too high as we'll > > + * continuously fail to move it anywhere. > > + */ > > + if (!cpumask_equal(p->cpus_ptr, cpu_possible_mask)) { > > + unsigned long clamped_util = clamp(util, uclamp_min, uclamp_max); > > + bool has_fitting_cpu = false; > > + struct asym_cap_data *entry; > > + > > + rcu_read_lock(); > > + list_for_each_entry_rcu(entry, &asym_cap_list, link) { > > Do we really want to potentially do this loop at every pick_next task ? The common case should return quickly as the biggest CPU should be present in every task by default. And after sorting the biggest CPU will be the first entry and we should return after one check. Could we move the update to another less expensive location instead? We could try to do better tracking for CPUs that has their affinity changed, but I am not keen on sprinkling more complexity else where to deal with this. We could keep the status quouo and just prevent the misfit load balancing from increment nr_failed similar to newidle_balance too. I think this should have a similar effect. Not ideal but if this is considered too expensive still I can't think of other options that don't look ugly to me FWIW. Thanks -- Qais Yousef