Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3653865pxb; Mon, 24 Jan 2022 14:31:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJx6Q2gwTkHbOaAOHWcl9f8x0Bsaj4GuCupvntkWuvMWloqfUrY2hWGPIXoWfneydNebwDDQ X-Received: by 2002:a65:5c0c:: with SMTP id u12mr13584664pgr.176.1643063511028; Mon, 24 Jan 2022 14:31:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643063511; cv=none; d=google.com; s=arc-20160816; b=OfxeTF352lTTpWcv1mR9A3HoL5vs0WKI1asFas3edTq0cM5d6bKargTR7DWWZA5Wx3 w1tyt20jsy/ZU8NwQJNsOiHICBbN1Q2pIFsWdKRnsThroOqVvM5jZvmvFkjAr/8FTsbT Al5zyZ+i94fA0Fzbu5Pqg0yOiJEVJqe2KOHCJpPpOgXwtU6WY8TEzC9J8Ha8Oj+yAjOz 5rbiTW7To1FLmmBp4kLofhgtgQMSLx1SwvjmCjbefdLS688knVCVStPSUMC+dPFsYeXf zCE+/B7OEk0WN3n9/JqGzgLQVuMOjGeuYZK4erlwG82qV8m8DpYWjOuInaoajTSgi00r 61fg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=d/H/bvQVd1faliR9qVSKG6B6OXMI4yyhY1jU9UyMJok=; b=LTP4jsWDJuzlvK5JLif5ZGVeIr7kF7hymuiKBoiV2aS0qGQlHXzGe7SpsKmJE5Uijg pGW2rvUf6stlDj/SUdvXTWAHLOlY8O3AEx5p0W0N47Jz4/jBkm9R1kDlI8kSrEwM5wxj v1M96awztf7P+pItbmhtQ3kBRgQidMgsNJkSxpEjWEit8fcpchwOi4RblgYJ7jpw6dxk xeLTAlzjBIp11Vn3WWYUH2jQVILcntgk5fxpdcWZwL3W4XPgpSXC6rkNOtgvEmY7fh3C JtbC9SPyv/Upx2Ba5uu6L8lOqAeu0eNuuHhm06fny+TjOlxMsqUMm5C9o1yKD0NpCv1L vzHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gxcEy1Gy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l4si10807706pgu.185.2022.01.24.14.31.37; Mon, 24 Jan 2022 14:31:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gxcEy1Gy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1586472AbiAXW0i (ORCPT + 99 others); Mon, 24 Jan 2022 17:26:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1453875AbiAXVbH (ORCPT ); Mon, 24 Jan 2022 16:31:07 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0712C0AD1A5; Mon, 24 Jan 2022 12:19:43 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5B8A561496; Mon, 24 Jan 2022 20:19:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3904BC340E5; Mon, 24 Jan 2022 20:19:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643055582; bh=EJZBgQ2DExYn0jf+mQ9xSJ8Ik+LpQLT9pEL3+xAQ1yk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gxcEy1GyPiDM33zBNqqgDeJI9UV+jzY5OO8N+0RqVVI2zNScpyB/JpUIKnSsYfLCV J3NIxRTva54qBWc+cyeqo4V9lKHdQ81mltVVYWGjq0mYphLPyuwD7kxQgzrqbzXv38 c3susrLcPHl2NShzdL1LYCKD7FxpcKoKzn7XExJ4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vincent Donnefort , "Peter Zijlstra (Intel)" , Vincent Guittot , Valentin Schneider , Sasha Levin Subject: [PATCH 5.15 199/846] sched/fair: Fix detection of per-CPU kthreads waking a task Date: Mon, 24 Jan 2022 19:35:16 +0100 Message-Id: <20220124184107.804854195@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vincent Donnefort [ Upstream commit 8b4e74ccb582797f6f0b0a50372ebd9fd2372a27 ] select_idle_sibling() has a special case for tasks woken up by a per-CPU kthread, where the selected CPU is the previous one. However, the current condition for this exit path is incomplete. A task can wake up from an interrupt context (e.g. hrtimer), while a per-CPU kthread is running. A such scenario would spuriously trigger the special case described above. Also, a recent change made the idle task like a regular per-CPU kthread, hence making that situation more likely to happen (is_per_cpu_kthread(swapper) being true now). Checking for task context makes sure select_idle_sibling() will not interpret a wake up from any other context as a wake up by a per-CPU kthread. Fixes: 52262ee567ad ("sched/fair: Allow a per-CPU kthread waking a task to stack on the same CPU, to fix XFS performance regression") Signed-off-by: Vincent Donnefort Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Vincent Guittot Reviewed-by: Valentin Schneider Link: https://lore.kernel.org/r/20211201143450.479472-1-vincent.donnefort@arm.com Signed-off-by: Sasha Levin --- kernel/sched/fair.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 6f16dfb742462..c6cb8832796b5 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6429,6 +6429,7 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target) * pattern is IO completions. */ if (is_per_cpu_kthread(current) && + in_task() && prev == smp_processor_id() && this_rq()->nr_running <= 1) { return prev; -- 2.34.1