Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3708046pxb; Mon, 24 Jan 2022 15:59:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJz9z55LqwHdoDfLqjxZcLa2v/euTgJ88aPwfPPhkPi6tb2aNrAekaQQRGKRZQ6eKlfjuKXd X-Received: by 2002:a17:90a:1c10:: with SMTP id s16mr671360pjs.115.1643068743402; Mon, 24 Jan 2022 15:59:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643068743; cv=none; d=google.com; s=arc-20160816; b=iDyqi35LpPd1b+s5eL2p5sGawZ3jpjfMTx4QobS1dOMQURRnE33nNfIFFLk7NDhnvR EWMDVN1cIH4+5wHCUgvq6TaMaDbee8cf1pAXRcWNeglolSdxgQ+EntPWjKQoSlQ7PgYE f2WzMdwnbNaTI15AjtrFD1gHTfpPV27bmp7kQFfne1PrpHF+37PoEs4Q41e6fuYmr7gs lrFEr9nS5TxfRog4KCvJ5qPkWISdcIg3HPy04NNMaMA1dZwzj+Iqm+kQpZCXa45v+kx5 MxT9GJEUOEXzQVrDEU1wUeHqgtowthZ4Ay2yjUgLlAazY3mk8ZLSoHpVVdHq++QgYhQ5 OCWw== 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=QfxxDTIyMdLCX7kotMPrLRjMcyEzeN4qE36A0sc57Z4=; b=G2c7zfNQvnSOMRk5Rhrd1vCqcXlVL8xfWSGTAu6v1Ba+B66RX3jZOQEmSmaYETODCW Sq51gXah6nm9YfNcXy7DAxqHf9xvgwTURC+b7Ibey1b0QIhyFhgWSNjiJcw8hbxgEB/a qlf4cYlSjywuzL7wM3qOxnWGPCY6FYR3nATxUch6jFJOrJnMQayaieRw7s03ferOzIzv iHW+JI2U43NB9v/Yo/4y7U0fAluW/0ksph0GdqUA8rDEmgAX3UfUrDI8GNpeksq90D1E Rm+jBO15zpoXT6wXLUz+2lt4EQBul1bQjX6RV5/lhpBxlyZQYdevSer94PRmEy23rjaP UHSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uERMQBz8; 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 w16si16491704plg.444.2022.01.24.15.58.51; Mon, 24 Jan 2022 15:59:03 -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=uERMQBz8; 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 S2367454AbiAXXzc (ORCPT + 99 others); Mon, 24 Jan 2022 18:55:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1846531AbiAXXQP (ORCPT ); Mon, 24 Jan 2022 18:16:15 -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 27FA1C07E2B3; Mon, 24 Jan 2022 11:47:38 -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 B9F2D60909; Mon, 24 Jan 2022 19:47:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A645C340E5; Mon, 24 Jan 2022 19:47:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643053657; bh=mmvAoJjg43JXHo+H49l9ox+6UY5dyipU5KxhAj68wNo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uERMQBz8ZculV3aWLnga7v0AiuZQLXmzuWs1SlULGNvrjakjH3CTCHIaulu+sDK/i ZY3Qa5VgDl/33ja+KiBGvILh/mkggkKJQC9DGThBx3E46Gf8CFu6Q6ZfPavGWdLLYK nS/Jkl/ChyVZcxrLyrtmnhG94z+QeJdjWeUASwbY= 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.10 134/563] sched/fair: Fix detection of per-CPU kthreads waking a task Date: Mon, 24 Jan 2022 19:38:19 +0100 Message-Id: <20220124184029.032288957@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184024.407936072@linuxfoundation.org> References: <20220124184024.407936072@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 c004e3b89c324..a7589552be5fc 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6284,6 +6284,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