Received: by 2002:a19:771d:0:0:0:0:0 with SMTP id s29csp1243109lfc; Wed, 1 Jun 2022 12:52:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpLaL6aS8wCptlEoL2jhcYA/z9khjx66pKKqMvxcj+BKXkmdtSCN+Z1PEzliJkdQECOnR7 X-Received: by 2002:a17:902:e845:b0:163:ebca:a026 with SMTP id t5-20020a170902e84500b00163ebcaa026mr1116454plg.40.1654113148516; Wed, 01 Jun 2022 12:52:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654113148; cv=none; d=google.com; s=arc-20160816; b=nAbWAfiB57mGCY47F+ZIbhVSDWggsYbJJjFhtHqBKMBul3mpmUATtOg77CCnHlpM50 nFTwNXJiIgkRKIyE9VNUz6JNBrpCoT39de16ViRo/sslDT12YMJ3jMQSQ4Thi44bOCt4 /xDOsPqjPV/SnOF+GRoq6Sfi9ToJIY7Iu1jgp2y4n+tY7J3lYI0WKA9uxuXOoFa+BXTa ljoViJMSK9dm14poBlYJ0YIes1Ng7N25v4ZGZkRj/ENwWkYMad0JzlA+tiilW809myAI rvsmNo+TRdyAGbW7E3XGrKtfjQLdSwLXX6EIpqsutusZihhvq4OsR9ttVbZLKnaj8kR6 1SfQ== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=z/NoV9I8jOCvDwMgobzt/uHdK430DQiaYPn7maOeSMA=; b=CsVoE2HvRRA4h4HGhNVfnwgU+rn4CqDfr9lyZ8BEdZJsWOo5jzJdRbulovBRSu3qtd kNW+bbGex3JwEBy4XwpWtusHARGAkk5UnWfnLuHa5P6z8fk9vO7viFUntnKrA7Nud5c/ J6N0CfxipQ2Aci3nAWOKR9GKk/cIEQABC32IEwh2fGymCvUE5azM1JI0BGml9sLRx4Jg 51Oj0CCz0N1D0+rnIIuqYcUrBSBhPt8pZVp4FNu6RYfjpqNsUwwrxcw+7we7mqq4Csyd 3C+vsGcJc+PYW2FZs6nrhJQYg0E9yTCDgC6TXPhHz2N9caQTvX5SNUUeK2iVa+gBmcdW j5TA== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id d6-20020a170903230600b00163c985bb45si3964068plh.101.2022.06.01.12.52.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 12:52:28 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 394EB1FE3B9; Wed, 1 Jun 2022 12:14:27 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345779AbiEaPim (ORCPT + 99 others); Tue, 31 May 2022 11:38:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345758AbiEaPik (ORCPT ); Tue, 31 May 2022 11:38:40 -0400 Received: from out30-45.freemail.mail.aliyun.com (out30-45.freemail.mail.aliyun.com [115.124.30.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FCBC62A36 for ; Tue, 31 May 2022 08:38:38 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;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_---0VEvuo0x_1654011513; Received: from 192.168.0.205(mailfrom:dtcccc@linux.alibaba.com fp:SMTPD_---0VEvuo0x_1654011513) by smtp.aliyun-inc.com(127.0.0.1); Tue, 31 May 2022 23:38:34 +0800 Message-ID: Date: Tue, 31 May 2022 23:38:32 +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.1 Subject: Re: [PATCH v2] sched: Queue task on wakelist in the same llc if the wakee cpu is idle Content-Language: en-US To: Mel Gorman , Valentin Schneider Cc: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Daniel Bristot de Oliveira , linux-kernel@vger.kernel.org References: <20220527090544.527411-1-dtcccc@linux.alibaba.com> <1d0eb8f4-e474-86a9-751a-7c2e1788df85@linux.alibaba.com> <20220531135532.GA3332@suse.de> From: Tianchen Ding In-Reply-To: <20220531135532.GA3332@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,MAILING_LIST_MULTI, NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY 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 On 2022/5/31 21:55, Mel Gorman wrote: > On Tue, May 31, 2022 at 12:50:49PM +0100, Valentin Schneider wrote: >>>> With all that in mind, I'm curious whether your patch is functionaly close >>>> to the below. >>>> >>>> --- >>>> diff --git a/kernel/sched/core.c b/kernel/sched/core.c >>>> index 66c4e5922fe1..ffd43264722a 100644 >>>> --- a/kernel/sched/core.c >>>> +++ b/kernel/sched/core.c >>>> @@ -3836,7 +3836,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 (cpu_rq(cpu)->nr_running <= 1) >>>> return true; >>>> >>>> return false; >>> >>> It's a little different. This may bring extra IPIs when nr_running == 1 >>> and the current task on wakee cpu is not the target wakeup task (i.e., >>> rq->curr == another_task && rq->curr != p). Then this another_task may >>> be disturbed by IPI which is not expected. So IMO the promise by >>> WF_ON_CPU is necessary. >> >> You're right, actually taking a second look at that WF_ON_CPU path, >> shouldn't the existing condition be: >> >> if ((wake_flags & WF_ON_CPU) && !cpu_rq(cpu)->nr_running) >> >> ? Per the p->on_rq and p->on_cpu ordering, 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. >> >> @Mel, do you remember why you went for <=1 here? I couldn't find any clues >> on the original posting. >> > > I don't recall exactly why I went with <= 1 there but I may not have > considered the memory ordering of on_rq and nr_running and the comment > above it is literally what I was thinking at the time. I think you're > right and that check can be !cpu_rq(cpu)->nr_running. > If the check becomes !cpu_rq(cpu)->nr_running My patch would change, too. Shall we remove WF_ON_CPU completely?