Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp6096813ioo; Wed, 1 Jun 2022 21:29:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1tRj8YcouVuL28IvmKa6ALhfuoyw5j3ZxKosGlZa1XYA4sCj7KqqAC4uHFg4+C2d6kH6j X-Received: by 2002:a17:90b:4c4e:b0:1e3:368b:c09c with SMTP id np14-20020a17090b4c4e00b001e3368bc09cmr3092221pjb.140.1654144199130; Wed, 01 Jun 2022 21:29:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654144199; cv=none; d=google.com; s=arc-20160816; b=GEaOm2I4vXkl7ejZ3Oerceffp/8ykN6deKUEGhioQ7sJidyLjjH0KM6/EkINsRC6Nu b/onLFfyPjwbqxkDyUeM+UgV56WmdRfExdvmVjHgVJnuZqGddEoAef1ReoimLj8mszwv XaI8qQ2FcB++b3Eb38QDYY2Pe/dSMvcFNkQ+n1FD+G1fV4HOgBzuRMufBptRbJB0c7ZR yLXSuT7Seqp3wGtBkcRYmUCe+bV4ILzE903VsiWpRYnz92q/3W07SWMDnVKYKgUq5jJb aGsQYu8B6Skdio2WzQ01U43nNbAN5I54w1zXH0ipuNk/1MzZrVWTqqoPLHdSvwNuDcLm FK1w== 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; bh=qn/11avj3yq0msPLMA8MWoGvehgPGkKXTZYCKwG1B3c=; b=RwT3fVmz03mWkZxLFgifg1wcZ7wDYbIytBHAiS/KBikbGzloHCYj4mY5SEe0oEdofT kiraRrNr52s1k21FL2fTcayIq+lUEju0qB11FkF3Sy8q4doqfWs+82/5fePtX/DRECfA Jg5rN4W02pVMBUUG/lf8F9QTes3x0tuCxqjsffB7BtwSbEwc7FjhR48ld5d6RBQhKp7e +5j9z5hTrE85i9ilsXYHBEr4OgWyxd2c9zT4D4Fn4dS0OJo448Re5ZN2wf7jd3CK8839 oEaIvMRCINEewlhF+MC35OEkb5bAP2j/p0iXK5N3nFALtCpJKqa03uuYHY/U3F1dGDq8 U92Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x67-20020a633146000000b003fc88542b01si4447161pgx.208.2022.06.01.21.29.46; Wed, 01 Jun 2022 21:29:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229683AbiFBEHJ (ORCPT + 99 others); Thu, 2 Jun 2022 00:07:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbiFBEG7 (ORCPT ); Thu, 2 Jun 2022 00:06:59 -0400 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C2084ECF1 for ; Wed, 1 Jun 2022 21:06:58 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R611e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04423;MF=dtcccc@linux.alibaba.com;NM=1;PH=DS;RN=11;SR=0;TI=SMTPD_---0VF8oYOH_1654142814; Received: from localhost.localdomain(mailfrom:dtcccc@linux.alibaba.com fp:SMTPD_---0VF8oYOH_1654142814) by smtp.aliyun-inc.com(127.0.0.1); Thu, 02 Jun 2022 12:06:55 +0800 From: Tianchen Ding To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider Cc: linux-kernel@vger.kernel.org Subject: [PATCH v3 1/2] sched: Fix the check of nr_running at queue wakelist Date: Thu, 2 Jun 2022 12:06:44 +0800 Message-Id: <20220602040645.275555-2-dtcccc@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220602040645.275555-1-dtcccc@linux.alibaba.com> References: <20220602040645.275555-1-dtcccc@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,HK_RANDOM_ENVFROM,HK_RANDOM_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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 The commit 2ebb17717550 ("sched/core: Offload wakee task activation if it the wakee is descheduling") checked nr_running <= 1 to avoid task stacking when WF_ON_CPU. Consider the order of p->on_rq and p->on_cpu, if we have WF_ON_CPU here then we must have !p->on_rq, so the deactivate has happened, thus the task being alone on the rq implies nr_running==0. Change the check to !cpu_rq(cpu)->nr_running to fix it. Signed-off-by: Tianchen Ding --- kernel/sched/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index bfa7452ca92e..a9efe134fbe5 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3830,7 +3830,7 @@ static inline bool ttwu_queue_cond(int cpu, int wake_flags) * the soon-to-be-idle CPU as the current CPU is likely busy. * nr_running is checked to avoid unnecessary task stacking. */ - if ((wake_flags & WF_ON_CPU) && cpu_rq(cpu)->nr_running <= 1) + if ((wake_flags & WF_ON_CPU) && !cpu_rq(cpu)->nr_running) return true; return false; -- 2.27.0