Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp443983lqc; Fri, 8 Mar 2024 02:00:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXz5fX7JuGtzgDWJO5KSKqW/N3KNgLjpSY0+0CIbu+w4J8MOquZFlVtCML/1u0SyMN7ouM6BINeMLAfpHg/BxDs7+h1d/sjAf3UYfJA9g== X-Google-Smtp-Source: AGHT+IEAereT9mLQK45CyR1TPnItwoXyObeBZPGHDHPyLz2yLRanQ2POwHQ/9RxwHKMVwd4DEiGU X-Received: by 2002:a05:6a00:2d1a:b0:6e6:351c:bb28 with SMTP id fa26-20020a056a002d1a00b006e6351cbb28mr13048851pfb.19.1709892010822; Fri, 08 Mar 2024 02:00:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709892010; cv=pass; d=google.com; s=arc-20160816; b=lffNBEwyIe9Ogksg4rXP+jpXVglOMNVLhUuAGis+iFcAj4KAbHKnIgP2j3xYSM/Erv 5GothIAPWNqNfOhQg3pdRlBnc34oKJNf6jdcjZHRAIwdXqmkpE1e12GF9ipSe/GMLnr8 vTQ2PdDOcUTgwZP87kZIX5sav91GEBQdA6S1UlsOllh16cGrk4lKvTNI3b8+jtFiDhCy qVUIiwJ8/qT1MvnRX4SXCGpXCPPH+XJxBacb9Vt/tT991XdNMe3zBxoyM3qW0lhji+XC DptulNH9Fw9tR0m3VPwmmVk/bXoKwAzNk/3TqCRk5K7Z+WGtJjMXC1at64GOFg/LRlmw frFw== 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:sender:dkim-signature; bh=1SeR5og9yTjPR65icnbxspPrnmiFvWNAcIfMp3pXu5k=; fh=H81F3NhZEbKTxvC1sbNn1cw/vEiVSSsm2EoMyGRxKFs=; b=aesNOrn+eZb1QejyGIEOBJAnrScUAGV3KTNS8MUkJaYacaGZlnZ+5+3M+dr4cTvl8y gbdSCMsghHSRSEPL8vgaxI64V7xMoQ4M41mbUvOVdbDEAiSTbMk3YQVmyVGwbdtD/R/M uVg+a/eLh9AHBOnqhcGhTWlZSHq5/FEXPmYiPx//F6qR0xAvTos5aCO0sYXvI0lhAm2K J9pXofN54CHhNJOXFXeoFsCTBciW0mn7YX8QSayQPkpku8sUqmCCuAJwCm08EqyNV8fv a41Ql907dW9InkvZR2YuyPaDoJtMKpLYsC1rBJNAtF8WdMGIteZ9XkcsJMHk9jKbzuGq 6AwA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=GU0CIt7m; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-96787-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96787-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id fa16-20020a056a002d1000b006e6306e5b5csi7995202pfb.369.2024.03.08.02.00.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 02:00:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-96787-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=GU0CIt7m; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-96787-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96787-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 814942840AD for ; Fri, 8 Mar 2024 10:00:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A4B6C53800; Fri, 8 Mar 2024 10:00:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GU0CIt7m" Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (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 00168535C8 for ; Fri, 8 Mar 2024 10:00:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709892003; cv=none; b=BAIt+VRNJ0FnMarelhJj3QDGEY9rzjtxpC+VC8JHmh84HNJJna70UA6ew+G+Eovqeu9jA+a7OY/WHyimFitOPk2lEbKex5S0UQbZZUyov+DV4lD5NTtNTnLL+GQ9JBYCjQzbT2o3oeEjWWTz+fP7UbA1yDrhARO6Gbt66FQoUIo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709892003; c=relaxed/simple; bh=ZK6noPrmKxUC4atN9oG0vDIpDb5ltfo6u3smF80Dmpc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=b/hJ3sTDhMWJ7llOwPGlaeKbVQ3rayxNNcmk7X5jwEWLrIsJ1G3VLAi/Awx/zkbmPN1GAo2crDe3PTMDGlCOqtI1uNPDr1X8SFjkvx/QgoLs2jg3TtAGRTR5McAeKuLuf9FgGO3x3ScjibbjYCdt+lmjVqgs/NGhvHxGRCNryw8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GU0CIt7m; arc=none smtp.client-ip=209.85.167.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-5133bd7eb47so2148464e87.3 for ; Fri, 08 Mar 2024 02:00:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709892000; x=1710496800; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=1SeR5og9yTjPR65icnbxspPrnmiFvWNAcIfMp3pXu5k=; b=GU0CIt7mvfGwzs81Fm2zPETAFDZa7JgqYnXJQtpIozIvicNdyMX4knyCkw7NrOwNi7 nkvKM02odvocsUdnd7iS38zNto4lY/Z06eZxmAx9ERy3bFmBAbJySpDnOi6LgIWw0Znz G8/mwTmI+tUb095LXQ7nSdair30xnAN6Kr2cgv5mDJq0j04g0b6kqJvKKizNQpCwLq+F 1EMVQzhmYCaSO3j5x8ssU1mMgjhvtfeYOlqT2+x0kbqsz6xuEqe4I8RMbkIdUFjrsWL0 Hyc4OpfCiEhkRCA9WtIziQGGqln+2z5FZeGNzVjNxDkeFVvBhLnmhiJdJvJT0S2Kanzr HfQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709892000; x=1710496800; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1SeR5og9yTjPR65icnbxspPrnmiFvWNAcIfMp3pXu5k=; b=ZNYeB2k41CfSJZ67zHA+1uNyK7ExD6xKQwJRDJhe1aPxmRNXXJxFC0LTJJ8bjLQwJq 1RXUE51ejylBeKhnvmLj+HvX5ye1HBIJtSHPuI8dTpGlCO2CFrUhywztPZ4mf1n8zB7Q zQh9GefdB0XltQElfnELG9VKmchs78Db2s6Xj1rw7/i+gtgvlYcYAOSjw0PJ/goMT74R Ohu7Tazzves235GRmkbN6ek2KEdAcHI0r2U4upA05uu9s/BX9BlHJ2he0D0NhOtdRd2B PYvBmJfAHUL3IYFfqblKJTL+F2i2XpYQ4m/PiBjHw+7O5MdgpLaLCc7usMQauGsSdtjk 14LA== X-Gm-Message-State: AOJu0YyabKj+xy5fk/GZSaMoUJbFr4IE4OQvVlAfF/GnJuYWa+zXYlbj ZQ/5zbn02IFZmdOlZXzuVntlb3zbHxUojyrBab0D3Um8KF+bYkO1 X-Received: by 2002:a05:6512:2152:b0:512:ed82:fd6f with SMTP id s18-20020a056512215200b00512ed82fd6fmr3038693lfr.60.1709891999388; Fri, 08 Mar 2024 01:59:59 -0800 (PST) Received: from gmail.com (1F2EF3E5.nat.pool.telekom.hu. [31.46.243.229]) by smtp.gmail.com with ESMTPSA id c6-20020a05600c0a4600b00412f2136793sm5585678wmq.44.2024.03.08.01.59.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 01:59:58 -0800 (PST) Sender: Ingo Molnar Date: Fri, 8 Mar 2024 10:59:56 +0100 From: Ingo Molnar To: Vincent Guittot Cc: linux-kernel@vger.kernel.org, Shrikanth Hegde , Peter Zijlstra , Dietmar Eggemann , Linus Torvalds , Valentin Schneider Subject: Re: [PATCH 3/9] sched/balancing: Change 'enum cpu_idle_type' to have more natural definitions Message-ID: References: <20240304094831.3639338-1-mingo@kernel.org> <20240304094831.3639338-4-mingo@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: * Vincent Guittot wrote: > On Mon, 4 Mar 2024 at 10:48, Ingo Molnar wrote: > > > > The cpu_idle_type enum has the confusingly inverted property > > that 'not idle' is 1, and 'idle' is '0'. > > > > This resulted in a number of unnecessary complications in the code. > > > > Reverse the order, remove the CPU_NOT_IDLE type, and convert > > all code to a natural boolean form. > > > > It's much more readable: > > > > - enum cpu_idle_type idle = this_rq->idle_balance ? > > - CPU_IDLE : CPU_NOT_IDLE; > > - > > + enum cpu_idle_type idle = this_rq->idle_balance; > > > > -------------------------------- > > > > - if (env->idle == CPU_NOT_IDLE || !busiest->sum_nr_running) > > + if (!env->idle || !busiest->sum_nr_running) > > > > -------------------------------- > > > > And gets rid of the double negation in these usages: > > > > - if (env->idle != CPU_NOT_IDLE && env->src_rq->nr_running <= 1) > > + if (env->idle && env->src_rq->nr_running <= 1) > > > > Furthermore, this makes code much more obvious where there's > > differentiation between CPU_IDLE and CPU_NEWLY_IDLE. > > > > Signed-off-by: Ingo Molnar > > Cc: Peter Zijlstra > > Cc: Vincent Guittot > > Cc: Dietmar Eggemann > > Cc: Linus Torvalds > > Cc: Valentin Schneider > > --- > > include/linux/sched/idle.h | 3 +-- > > kernel/sched/fair.c | 27 ++++++++++++--------------- > > 2 files changed, 13 insertions(+), 17 deletions(-) > > > > diff --git a/include/linux/sched/idle.h b/include/linux/sched/idle.h > > index 478084f9105e..4a6423700ffc 100644 > > --- a/include/linux/sched/idle.h > > +++ b/include/linux/sched/idle.h > > @@ -5,8 +5,7 @@ > > #include > > > > enum cpu_idle_type { > > - CPU_IDLE, > > - CPU_NOT_IDLE, > > Could be set CPU_NOT_IDLE = 0 to help keeping in mind that 0 means > cpu is not idle even if we don't use it ? Yeah, makes sense. I've added back __CPU_NOT_IDLE = 0 (with the underscore to make sure some pending patch isn't accidentally relying on something it shouldn't), and added your Reviewed-by. Thanks, Ingo