Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp175105rdb; Mon, 22 Jan 2024 16:26:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IHLng5Er6Scx00FRSZaixVHy6wJTXLGBsluhSunvPtf7/Cgg9rNcaJssyHOcsCIBMjQyoBx X-Received: by 2002:a05:6512:39d1:b0:50e:8dd7:82a9 with SMTP id k17-20020a05651239d100b0050e8dd782a9mr2347841lfu.99.1705969594283; Mon, 22 Jan 2024 16:26:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705969594; cv=pass; d=google.com; s=arc-20160816; b=Q/tdtXgSBiW82fu9YNorUpzmxaH0gXQpxHllAKnUauzZcYYUNYNVUtCVI9ckhi1eyo bO49TdjcgC4UJFd/GV6lxsZjQwuHAQBmuFo6ZBT6ce9q/b1mt6FYHGL/i8chUS2ImgS1 jV1JijYhFGUhrhfPb7IOjzuAyiLeGKL5suOITW36JvvSTeAnteUN0frjbDXNOS4kIu// k/MLciaWc0W0Y1nt0lrBjYYlJLFjnjpZoCaBbfQ93XEcar7gN/MOKR0VpQSxO9hdeurP l7qpZx/jg4icXk5BCc7qLYz/GfuCR+wKF/pdKrxBf22vQlkrmu7H8SF00M3R2cOj8HBm SP1A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=G6cA2qNLbxS+vZebAAL8WoY0Nx/0VJxefFzSxVQNr0E=; fh=kWDztcDR2Gz5loyVvsSJRwe5APOf3kI8T8J/m2W/tVw=; b=daF1bebNByA1wrUDFBKAHp5NoqZ43uWxdFozWCFTkPE8UjvXiy+rTE6X6xoOAch6Hx t5RzAWAPQAzTYbsCzyVoetSA5T3zQKWDKmI5cjvJHxee7F65q1Q+pQVT3a87qvSUx3ki KUvlbHAG/7aT6pvi1IbdQlOFz3JI6Kz0LGPMbossWoi3WlSFf9AfjyKye2TVsWTbIfBS iypQnGRETREUTlSe9sj/AWgd7vVQVZp8OPGH//ySHZ8WTP24Pm74LUMrb+s3qVEvgYB8 gWDRVOsoc6GLgytW0i6yE6fSlNdsSk+GK1O0ncg9DdixE7AhGRzT3ftOmN5r7oo+KNWl tN4g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=a2ck8Ek1; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-34216-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34216-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id q4-20020a1709066b0400b00a29efb615c5si11408029ejr.613.2024.01.22.16.26.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 16:26:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-34216-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=a2ck8Ek1; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-34216-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34216-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 2E30C1F290F6 for ; Mon, 22 Jan 2024 21:59:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E954B482F6; Mon, 22 Jan 2024 21:59:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="a2ck8Ek1" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) (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 8B5F5482DA for ; Mon, 22 Jan 2024 21:59:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.55.52.115 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705960758; cv=none; b=A9J+LK5Rt1180iLbLi2cjEnO0Ux5d2wFesV9PWnUb3dKeEj6TO1uU3jgytrXWDcIeOAF59AvxQjFQjRSK/MrHk2a/SaYR+i56lTEbUjSqAFDDQMu43haaM3Wsgs3PjNiM15GTyj+4DLocjDdmNsM0qHyYgvIx4P2t3OtNPulfEg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705960758; c=relaxed/simple; bh=ECFKPL3PnElBsExFBI86TFUGond9GFIE0/soQcR69uQ=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=bUZNlHOktMYJzbdCGBM+Vd5KHsYZNuBKjlvwz8rOJJ9PcBb0bNMEbUKErEeEo/6LDrjeQXlkzhVty6jcaJz+LQNtznV/4lIa30Yfr7SF8tUgzJxgIDoTVhf4WZIXFPlmA4qG47uRUzTFFkqRAdDft5/xNiHz+2qL/GSzZE2L9Fg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=a2ck8Ek1; arc=none smtp.client-ip=192.55.52.115 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705960756; x=1737496756; h=message-id:subject:from:to:cc:date:in-reply-to: references:content-transfer-encoding:mime-version; bh=ECFKPL3PnElBsExFBI86TFUGond9GFIE0/soQcR69uQ=; b=a2ck8Ek1KPwO+aRHok8w5+xum+5t5iPzyUl+qLclnXzm1KYuCMM6Gy5k hjW9tx0Yvl7yyExNcEXVbUH8Jj5TX/FvzXktIv9q1jsiECxDYNZlm0TI5 pSeIANX9ZMeq4TJw3bZ5HvGcZdd48C8zxxxkoxBWDVCcXNnZT+GB7HHgP 9iyVbUhveaI9XFC2kTUF0H5Ln34JzQ2GokXIFqPcqvKZWeQl4LNCKZj// /PYizuS+9aJoDRFIMOCxo1LqIXY+vMN25+2sj+KUTUqUAgN4Su4HuMhqX 8JWwu1xJgfqtHJtCXLsxhRaLtSGwF6c2kRn6jzbPFg6W0te+qkpGBo+7C w==; X-IronPort-AV: E=McAfee;i="6600,9927,10961"; a="400994288" X-IronPort-AV: E=Sophos;i="6.05,212,1701158400"; d="scan'208";a="400994288" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2024 13:59:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,212,1701158400"; d="scan'208";a="27500674" Received: from ishandes-mobl1.amr.corp.intel.com (HELO [10.209.49.194]) ([10.209.49.194]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2024 13:59:15 -0800 Message-ID: Subject: Re: [PATCH] sched/fair: Skip newidle_balance() when an idle CPU is woken up to process an IPI From: Tim Chen To: K Prateek Nayak , linux-kernel@vger.kernel.org Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, gautham.shenoy@amd.com Date: Mon, 22 Jan 2024 13:59:14 -0800 In-Reply-To: <20240119084548.2788-1-kprateek.nayak@amd.com> References: <20240119084548.2788-1-kprateek.nayak@amd.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4 (3.44.4-2.fc36) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Fri, 2024-01-19 at 14:15 +0530, K Prateek Nayak wrote: >=20 > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index b803030c3a03..1fedc7e29c98 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -8499,6 +8499,16 @@ done: __maybe_unused; > if (!rf) > return NULL; > =20 > + /* > + * An idle CPU in TIF_POLLING mode might end up here after processing > + * an IPI when the sender sets the TIF_NEED_RESCHED bit and avoids > + * sending an actual IPI. In such cases, where an idle CPU was woken > + * up only to process an interrupt, without necessarily queuing a task > + * on it, skip newidle_balance() to facilitate faster idle re-entry. > + */ > + if (prev =3D=3D rq->idle) > + return NULL; > + Should we check the call function queue directly to detect that there is an IPI waiting to be processed? something like if (!llist_empty(&per_cpu(call_single_queue, rq->cpu))) return NULL; Could there be cases where we want to do idle balance in this code path? Say a cpu is idle and a scheduling tick came in, we may try to look for something to run on the idle cpu. Seems like after your change above, that would be skipped.=20 Tim > new_tasks =3D newidle_balance(rq, rf); > =20 > /*