Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3707889pxb; Mon, 24 Jan 2022 15:58:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJwPH7pLZtwo3sT3KPTci6Map+IjimAJhGu6Vc+X73Djq1BZAsHBJvRGHkNOhsoRP7S4xmeN X-Received: by 2002:a17:902:b489:b0:14a:4747:9917 with SMTP id y9-20020a170902b48900b0014a47479917mr16194915plr.26.1643068722734; Mon, 24 Jan 2022 15:58:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643068722; cv=none; d=google.com; s=arc-20160816; b=ARs6WtLkSbiFUnvzhAUMfPEQmkhnHpVVJO+Jd4Ezya0SPbc9LB1TD6sFtg66GP6h3m FQEfxP8941lHyUJBl/1CwBda2mZ6LvvQIKZluu7Yg+fnBVhncPoIN+sOTGxT/qQU/lan geoo+BtwwFN6NdiGEsxPbbesT7l7ac2c+ci1iDD4yD0H4WqET0PJ1MSbHBuRP70cB7FT qO/FDnjX7K7xLnbHawkdJbWaPOJYS19vCWst+nhqC+1VfNNMwma7ltCRr6m1JMQ2ox/h XDZY29D/Le8Gs11GUN9CAc8XaUW8tt1mQLLAHU//ARV2OYYMrWd6NusELXU+bkz5V2cr jlkg== 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=74zrU2RQaOvW/BJeEEmZuaChM2JXiPm02n9K/tKznDc=; b=RhgSUomZhGusExoqoH9lYIKlNSXMbwECTDbD9lnUqe6uIP1cFioCNwL4uVoSJiGas0 1cWhdPEaQ562Sh1+n/RUrbsNM7t6ELE/qmss9qUr8ekNTBcOWluBliYuQ0xbYmzwBkLD 5Fkc/P8Q5SPKfli4u7kpXlGqlMO9UDlWe1xGJTHKB+fcOgLatru0JUlUEGFQby8eMkgv fIPHHo3hDVepJSs5LgojJioW7p1UdklXITpz9qrnoQblqiHwKT5DenMCVQet2Y0Pqahp C/76zmQcjImDoCYvSOeelpNhOG4BjN5IICFXsb2P0vzKDr2qynEcXocOJ5XezGHxtleL kLmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GPDib1kg; 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 my13si1190368pjb.1.2022.01.24.15.58.31; Mon, 24 Jan 2022 15:58:42 -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=GPDib1kg; 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 S2367116AbiAXXyM (ORCPT + 99 others); Mon, 24 Jan 2022 18:54:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1837907AbiAXWpe (ORCPT ); Mon, 24 Jan 2022 17:45:34 -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 4B248C0550CC; Mon, 24 Jan 2022 13:05:56 -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 DC1196142E; Mon, 24 Jan 2022 21:05:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC90EC340E5; Mon, 24 Jan 2022 21:05:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058355; bh=bRSguhJPl84harqENFcTRVmow9GIgHPy1csFS3mmJgc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GPDib1kgn+XJ4rW5nCXjJl/UMc3HpysAQX6W7sRGXJyYZsEKq3dpRE5pqCXEMbqZ6 i9lbS0uwXA2lhH/ihvZLP4wppRFA4bom0ZGqXsfJBTpbk6ACMJNzDzRGYapdRGu3/G YneZH12yIp5T0N2xnNxhptydTjaVNZnTfIagzfVw= 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.16 0230/1039] sched/fair: Fix detection of per-CPU kthreads waking a task Date: Mon, 24 Jan 2022 19:33:39 +0100 Message-Id: <20220124184133.054095952@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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 6e476f6d94351..97d89516fbea2 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6398,6 +6398,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