Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4390452pxk; Wed, 30 Sep 2020 01:21:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHDV0ueAtihLqo3ncVMQ1x+8kc99AYtBg+4GO5tGrE96wXnSPceeO7FrPJAJvj3C2ScLe6 X-Received: by 2002:a50:e79c:: with SMTP id b28mr1473183edn.371.1601454100724; Wed, 30 Sep 2020 01:21:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601454100; cv=none; d=google.com; s=arc-20160816; b=GHmo/bRnhilTCFuX92ezlQQ/KmDVcFP6Cat2/XE7o9YMRhFuaYVAWDxF4fjGuBroJW g89hTfmcDdFL9f7wnlNB29UStRVuaq9IWEjOx/hFnHPzdCYxb+OOA/AzzpbGaR40gD1F JLAKt2t2Me5vjbpOgYbgnz3rdu+Rp26Q3voE0vUXPNe6yOyNCck23sDX2CQIU2IZT9mZ spQ/9JUZm4pLdiIHGNRv66CnNCJoPwiJSfiS5laNVoAtS/aQdbvEYmHxQ4wN3kZZ/tYG 0Qg89HdBm6V6IpkSiLO7IK6JAVoBs8BmFNsxihwyAUyo0CwXOFrK+JQDJfl3otaw0bQd jrJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=dGo6Hzacst8W3YunzMcZXx1pw1z/iSKi8zRtqxheYh4=; b=rV1+/QWVUHpUeny3jmUjfs0qJiWgXWvz1BWzFVQE5y4vb9HmNNeBkUyJsdfraIe8N8 fqu5MuOsqRFLe2IKANDPQ7qA6FhoMv+AiKmO7PMBvPjBNnGjO9Y6rCRZ0OS3ooP/2CQI urZCZgPHylOjbOoloX08rDyZULBWgkAuLmD7dUALwXzVZtrAovKKNwzghq9s7gMIK3bO 3CD2ZBK8gCTMS+PoCE/ILcbd7zXqFVQWvEbm5eamK4mXKhGlx4jNe6CeMdTrFXhH2b4Z /LUdzh1RULAYnrItVVOhPf/T0X8ExH8h9srgotGyCmwg1DFjuBPhBoAviKsIYtgTfC0F CxeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=lUoU4wJq; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w17si693662ejq.623.2020.09.30.01.21.18; Wed, 30 Sep 2020 01:21:40 -0700 (PDT) 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=@infradead.org header.s=merlin.20170209 header.b=lUoU4wJq; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728478AbgI3IUI (ORCPT + 99 others); Wed, 30 Sep 2020 04:20:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725776AbgI3IUI (ORCPT ); Wed, 30 Sep 2020 04:20:08 -0400 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33C49C061755 for ; Wed, 30 Sep 2020 01:20:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=dGo6Hzacst8W3YunzMcZXx1pw1z/iSKi8zRtqxheYh4=; b=lUoU4wJqMwIpwnF1QejJF6fTK+ iyyG1aTqCIwLo2K5kIgDtkUjMC6bAV3zPR3C0KCG5z3ZlVkdMzBWX2wOAjog5RJc7k09D6KOStO+u uWewCLhvV07JtTr3cukXKOO1C93gzV1wsjwjfnvAeTeXid4RR+m+A50mzy8/cgNXFhtDwk9wnIio0 aHrRVBrJ4q3JA4tM2oVJRenhQarbj7eENJd/jVnq42+ehbR6bnKi0NADqGfgvcCNOi/xigghqrcFz UkmTFc+16oJ+Ko3NeHS02ZMYfTLeqG9goLy9EpxtOsCogr3+D6RRZzeYSzU5CRmoxl0FyJeE8HR0L Yojj4sdg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNXLC-00011O-02; Wed, 30 Sep 2020 08:19:58 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 71607303A02; Wed, 30 Sep 2020 10:19:53 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 543ED202A40A0; Wed, 30 Sep 2020 10:19:53 +0200 (CEST) Date: Wed, 30 Sep 2020 10:19:53 +0200 From: Peter Zijlstra To: qianjun.kernel@gmail.com Cc: mingo@redhat.com, vincent.guittot@linaro.org, juri.lelli@redhat.com, linux-kernel@vger.kernel.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, Yafang Shao Subject: Re: [PATCH 1/1] sched/fair: Fix the wrong sched_stat_wait time Message-ID: <20200930081953.GU2628@hirez.programming.kicks-ass.net> References: <20200930024712.88258-1-qianjun.kernel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200930024712.88258-1-qianjun.kernel@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 30, 2020 at 10:47:12AM +0800, qianjun.kernel@gmail.com wrote: > From: jun qian > > When the sched_schedstat changes from 0 to 1, some sched se maybe > already in the runqueue, the se->statistics.wait_start will be 0. > So it will let the (rq_of(cfs_rq)) - se->statistics.wait_start) > wrong. We need to avoid this scenario. Is this really the only problem there? Did you do a full audit of that schedstat nonsense? > Signed-off-by: jun qian > Signed-off-by: Yafang Shao > --- > kernel/sched/fair.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 658aa7a..dd7c3bb 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -908,6 +908,14 @@ static void update_curr_fair(struct rq *rq) your git-diff is 'funny', it got the function ^ wrong. > if (!schedstat_enabled()) > return; > > + /* > + * When the sched_schedstat changes from 0 to 1, some sched se maybe > + * already in the runqueue, the se->statistics.wait_start will be 0. > + * So it will let the delta wrong. We need to avoid this scenario. > + */ > + if (unlikely(!schedstat_val(se->statistics.wait_start))) > + return; > + > delta = rq_clock(rq_of(cfs_rq)) - schedstat_val(se->statistics.wait_start); > > if (entity_is_task(se)) { > -- > 1.8.3.1 >