Received: by 2002:ac0:de83:0:0:0:0:0 with SMTP id b3csp730539imk; Sun, 3 Jul 2022 07:30:41 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uV/ZasxVmJV3tTApttoP71fjxKIy5ebl0D8T7HiLFINxn57Gz+v4CMCN3po9I+PLuuyBzO X-Received: by 2002:a17:906:974c:b0:722:eaa7:5e5d with SMTP id o12-20020a170906974c00b00722eaa75e5dmr23793276ejy.541.1656858641621; Sun, 03 Jul 2022 07:30:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656858641; cv=none; d=google.com; s=arc-20160816; b=t9urtCQZwVMrlAL3N6f09L3uaz5hSoXQ+qngA71gnYL89dH3dFe5SADIH5W0qu0dWO Z2BD8o5ND3TmXiYeQ6gSg9LMpsQ2KV3wFeS2bFLRJkEAAT8hrrU7Vaep2wDK6J1U4pMA QvOMCCER4HwHc50GjnGtfTgGxwkVxrUYGeXbmmQo3RPPaZ/2v/OjI1fdNNMjaT0W760Q cgC8A4WefwqmLmBCgiBSfasNJTEHLuSz2UFBwt5qekFu4hcKKA4SSy/rKQe3Ac6WF93t 5fKOtkqGLaTDcIcthDaQjy6UoCkGoLDjX33b5uhWqjJ1AX9PCPgKanDnWgcMbXWoDT2y 2uLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id; bh=gF0tnavjI36wqwOGlJMLdloBdLEU8J8WLi3bvulLMHA=; b=qe3dD1sbf1MbzLxclwGQo15fllV5slhSu5ECq2sv/jKy48dmPmK3qe63iMwbc8YrAm BG59QMVZrSH5gwzyEigTftWsKqTudxe8MP4HFPoctfMQ7MSCJZbDRfvjCuOB084tJqs0 yoDf4QL0JZyXMY93DheBTTkfAu3sYbLnnZms8rN7YwadPfIOnUpOkg1pgRaEc8jDztA4 uR3DYAo8F8gWpr6Ei8XjaUMS7OZJsjue0Eh5DDByA2dvPS2MtXc85mr3VdB64P9/MzFy bIN/M0sArQ1ZHt+fx1oSEv0RBfeXoEGHH33BYSGsZlZvgdIQ4AvZQLl7swOzfZ/l3ZuL MmpQ== 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 e38-20020a056402332600b00437abfa278bsi22072015eda.39.2022.07.03.07.30.16; Sun, 03 Jul 2022 07:30:41 -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 S232868AbiGCOTt (ORCPT + 99 others); Sun, 3 Jul 2022 10:19:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230446AbiGCOTs (ORCPT ); Sun, 3 Jul 2022 10:19:48 -0400 Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 083122DF0 for ; Sun, 3 Jul 2022 07:19:45 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R951e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=cruzzhao@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0VIBiDcp_1656857979; Received: from 30.30.96.30(mailfrom:cruzzhao@linux.alibaba.com fp:SMTPD_---0VIBiDcp_1656857979) by smtp.aliyun-inc.com; Sun, 03 Jul 2022 22:19:41 +0800 Message-ID: Date: Sun, 3 Jul 2022 22:19:38 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH 1/3] sched/core: Fix the bug that task won't enqueue into core tree when update cookie Content-Language: en-US From: cruzzhao To: 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 Cc: linux-kernel@vger.kernel.org References: <1656403045-100840-1-git-send-email-CruzZhao@linux.alibaba.com> <1656403045-100840-2-git-send-email-CruzZhao@linux.alibaba.com> In-Reply-To: <1656403045-100840-2-git-send-email-CruzZhao@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham 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 Ping... This bug really affects the performance, and is this bugfix correct? 在 2022/6/28 下午3:57, Cruz Zhao 写道: > In function sched_core_update_cookie(), a task will enqueue into the > core tree only when it enqueued before, that is, if an uncookied task > is cookied, it will not enqueue into the core tree until it enqueue > again, which will result in unnecessary force idle. > > Here follows the scenario: > CPU x and CPU y are a pair of SMT siblings. > 1. Start task a running on CPU x without sleeping, and task b and > task c running on CPU y without sleeping. > 2. We create a cookie and share it to task a and task b, and then > we create another cookie and share it to task c. > 3. Simpling core_forceidle_sum of task a and b from /proc/PID/sched > > And we will find out that core_forceidle_sum of task a takes 30% > time of the sampling period, which shouldn't happen as task a and b > have the same cookie. > > Then we migrate task a to CPU x', migrate task b and c to CPU y', where > CPU x' and CPU y' are a pair of SMT siblings, and sampling again, we > will found out that core_forceidle_sum of task a and b are almost zero. > > To solve this problem, we enqueue the task into the core tree if it's > on rq. > > Fixes: 6e33cad0af49("sched: Trivial core scheduling cookie management") > Signed-off-by: Cruz Zhao > --- > kernel/sched/core_sched.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/sched/core_sched.c b/kernel/sched/core_sched.c > index 38a2cec..ba2466c 100644 > --- a/kernel/sched/core_sched.c > +++ b/kernel/sched/core_sched.c > @@ -75,7 +75,7 @@ static unsigned long sched_core_update_cookie(struct task_struct *p, > old_cookie = p->core_cookie; > p->core_cookie = cookie; > > - if (enqueued) > + if (task_on_rq_queued(p)) > sched_core_enqueue(rq, p); > > /*