Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp280693rdb; Fri, 6 Oct 2023 03:25:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFoKBTv2l7GWHhDEslAHGbh6Fe1Rre/WmbeI2LKnhFKCTJHncRBT4N5vUecqjxEgjEIIath X-Received: by 2002:a05:6358:999a:b0:134:c37f:4b5c with SMTP id j26-20020a056358999a00b00134c37f4b5cmr6473802rwb.22.1696587946006; Fri, 06 Oct 2023 03:25:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696587945; cv=none; d=google.com; s=arc-20160816; b=eDjGB5+IxY7o73j5LWZwNgfH94tiPvnAZOF/k0NEhOv/GdjpmkROtKf1bT/xTODV4W S1C4EywP78QtAxBtB3l7bri2xdp65sfJdUxGfxOJ+5cNeyae8geoqwHvcmuiacjGZDeo JV5vi4LkkRTVW77YJ/OO7JTOXnhfZBfhQsew5BhseDmxCjicWRowAoHmADuvsvJ7HSQy KPY+Mh2sMJbbuRhze+6hyssT/x3qhS7bTRYpVgwBpOlGEhotmoS4t+11QBaYdJj/2pQQ gCAcYYPWqelPob/h17w4Y45mlk+ClieEiwj4RKJPzyynQR6mSxLcwkWbuu54fEiAHeKd 62dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=lTTMqokwpEu0MsOdcm3T01Oj4as3iuY9zTcrlzN0rDU=; fh=vpy21g+J0gdi07r6ORLEdtAph1WvtREpjU5Tu1A//7s=; b=d+EagidYk00mvgbQKa63tVX7heWB1IPkqcO96zXDHOnSzTxKbhaeqs/p+kKYvNxP3C 5E1li4zo0jIolKwa1xYVBRE66OIdu5M+4MU4Ubdwe94HCBunxaXK5yQ/wgEbNcTJRecY CVcRSnHuANIFL89b63UjpEhsBEPyOTzifOLdkA21ULB2vWmlBKnO7mQhosYFIRTcoSO+ m2FKXO8zGu5G7B9XI3fLAvtmhqR3Y0a9TjVBouY4ejEfZNU20z5Pj6DMobvpGxIi1QFL WIsg8RmI26QVL3N07w3ryZNZXbZmeIxfhPSQmWLNaJDyp03Q5hjEN6OtxkaEksMswyHi 8B6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="M/8iLqeJ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id cv1-20020a17090afd0100b002636d222400si5402031pjb.14.2023.10.06.03.25.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 03:25:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="M/8iLqeJ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id F03CA803E78D; Fri, 6 Oct 2023 03:25:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231757AbjJFKZl (ORCPT + 99 others); Fri, 6 Oct 2023 06:25:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231696AbjJFKZb (ORCPT ); Fri, 6 Oct 2023 06:25:31 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A2B0E9 for ; Fri, 6 Oct 2023 03:25:30 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-9b9a494cc59so350799266b.3 for ; Fri, 06 Oct 2023 03:25:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696587928; x=1697192728; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=lTTMqokwpEu0MsOdcm3T01Oj4as3iuY9zTcrlzN0rDU=; b=M/8iLqeJu0xzRcKqd8EIx7ok/9ABVKErDCdUZZpsf/XX5X3prvlqWafPpFOParyzJs 2+CF/KSizDVerZHbekNjyFa/fVTl/SvpovO97IwnQ6wShR9lZA+t/VsA56W0LA12bpRK VdGx2jR4P2yY+CtSeHlBaNxjloqeBZss+n7jljuvGOrhJp9H4tdaQNd3KBdK7TxZwd0F K8ng1YoS/a3rts9yG372iUHNqJac7rnfk1nEfZypVPBHG5I2bV+2rxnZDHmMP4Q15Uu/ d8P7rxxiZvDB/bsDM1qtuqL389MgH20FCvUcAacHGbRg91L/lxq8voEATlbWTkpAx1N/ z8bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696587928; x=1697192728; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=lTTMqokwpEu0MsOdcm3T01Oj4as3iuY9zTcrlzN0rDU=; b=Mp5VhGx7UBuy/UFqf4ms6hd4cogHvyYMUpJnaTcR8kwOgyddYdZGwR6dDtllJUNOEB i5K7R8dwU5ZATDYm7JnTBEXfqZxhU4tn9v9To1ivhpYqQj0+/e8SdDcXvl70twz1uNky Q2lhf01M7D+7ko8FU6r4pTI+LyCh2DrZ3CumFjBj32DEj1RxqBJDgaRK4NY26sFGDIGA L3VjRYWg7h2Q5DxZCpezJay+uQr2xDX+n4Wac0Lo9am+QuZksBv0b/e0iiGprkZZN8GW REzL/BKr0LFwm0s4l8d5qsYyRI+O6YjLzgM4fIbX5bZuxPrDcvsMDeDwV2hvnpgdE/Wf 2+8Q== X-Gm-Message-State: AOJu0YxJH2ElwxeB4QihdqM4W5EtBc183rOJeI3CrsnAKh2T98Z4KN0u /TXM93/VQD45qgvP/5rPLIYFCQn9Wk0= X-Received: by 2002:a17:907:77c5:b0:9ad:e180:16e3 with SMTP id kz5-20020a17090777c500b009ade18016e3mr6838021ejc.37.1696587928317; Fri, 06 Oct 2023 03:25:28 -0700 (PDT) Received: from kepler.redhat.com (1F2EF530.nat.pool.telekom.hu. [31.46.245.48]) by smtp.gmail.com with ESMTPSA id n17-20020a170906379100b009b957d5237asm2613502ejc.80.2023.10.06.03.25.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 03:25:27 -0700 (PDT) Sender: Ingo Molnar From: Ingo Molnar To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Frederic Weisbecker , Joel Fernandes , Thomas Gleixner Subject: [PATCH 3/3] sched/nohz: Remove weird error handling from find_new_ilb() Date: Fri, 6 Oct 2023 12:25:18 +0200 Message-Id: <20231006102518.2452758-4-mingo@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231006102518.2452758-1-mingo@kernel.org> References: <20231006102518.2452758-1-mingo@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE, SPF_PASS autolearn=no 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 06 Oct 2023 03:25:45 -0700 (PDT) find_new_ilb() returns nr_cpu_ids on failure - which is a weird choice in itself: not only is it a global variable, it is a +1 out of bounds CPU index... Its only user, kick_ilb(), then checks the return against nr_cpu_ids to decide to return. Instead of this, use a standard -1 return on failure to find an idle CPU, as the argument is signed already. Signed-off-by: Ingo Molnar Cc: linux-kernel@vger.kernel.org --- kernel/sched/fair.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index d4e90d15bd77..dad60576cf56 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -11572,7 +11572,7 @@ static inline int find_new_ilb(void) return ilb_cpu; } - return nr_cpu_ids; + return -1; } /* @@ -11593,8 +11593,7 @@ static void kick_ilb(unsigned int flags) nohz.next_balance = jiffies+1; ilb_cpu = find_new_ilb(); - - if (ilb_cpu >= nr_cpu_ids) + if (ilb_cpu < 0) return; /* -- 2.39.2