Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp4491984pxb; Tue, 31 Aug 2021 06:34:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTVjEhsxNt++LJ3HNcD42RQcZpRvs9TqZaTvFdmxieXU10Tv9/u45ZPBuPnGJ/66Qk03zB X-Received: by 2002:adf:f743:: with SMTP id z3mr31309687wrp.211.1630416870731; Tue, 31 Aug 2021 06:34:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630416870; cv=none; d=google.com; s=arc-20160816; b=k1wZbVjmPFpNtbqxYFJv7sNRP6pNC8rPkS39IClxcKrUvpZDnk38mIe2VPJ+Hv7h3Z yv+kaDrg6rP5H1nRGSdryf1DNmE1XTcmy8wRE8dtrZ8aqsQpRq76PluZn1qFEBqazKDo HeRbJot7uMEw9dv9fZvSyEoFaQ/yRB4NBy5gGvArvB4UFvaNkr0ZkTOQ5kCsJKddxdWK prp6p1Xtv0BjEIcohziTHbro4P2DXNd7fbrrbl3AmMr4zz1R/pX2VFYtIq2HTq7agF4o 1h5BP0TuTNCuQ1WBC7qhNZRnbGlXCS81OTDHqxWng83MEZaxwYYoGal4//uohPu2erFz p8xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=9ZS2rq7TdX/lH9ThK6GDPfAidwJG5w2VZOyeSQOB1m0=; b=IiD4kafeBJjoYyxNr27UfJaFulXLkZPYZ89tZvMVGLWeBx5Qprr4/0P8xZT4xJPSby 0T8pVD3tHT3AMFhX3QByoPpsnyMG/zQkvZ/fjgySZ5AV7106075G4KQLwPUBtcfbbRAU oIPwwqvTJ1M3zShP3RKgDh94a7ww1ZigvTLTbqeqHzdPgobhI2hvFUxqjesl6FZCvzBe /N3t7iP5QPYQgbS09RGlAQ9syEiRzIvQptEThGtkdcl26w/oatyb2u6C1FhWMCB5ouxY pI1rI4721EkHg7iOYyNZ8vAUE+6a1mzUDjzVsIqCgsOkH+pgtiIK0w1G4iK2FnVk2K5A icjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XHGcX+O7; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y8si18203418edq.559.2021.08.31.06.33.53; Tue, 31 Aug 2021 06:34:30 -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=@gmail.com header.s=20161025 header.b=XHGcX+O7; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235771AbhHaN1Z (ORCPT + 99 others); Tue, 31 Aug 2021 09:27:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233512AbhHaN1X (ORCPT ); Tue, 31 Aug 2021 09:27:23 -0400 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE305C061575; Tue, 31 Aug 2021 06:26:28 -0700 (PDT) Received: by mail-il1-x136.google.com with SMTP id u7so19911577ilk.7; Tue, 31 Aug 2021 06:26:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9ZS2rq7TdX/lH9ThK6GDPfAidwJG5w2VZOyeSQOB1m0=; b=XHGcX+O7iUV4pWgRoeWLQ6OgWYc0j1iBce8scG93nSMR34nifJV/IKMcFSHs6WIqUh WGrcElbCwPTBYS2dbaORFGLxEKbt2icD/wlFJIXGLoMRBMPWPYik39nWWdFDiryUk+6Z FNhaBRNH6Oo7kM9NPX7GxzoIXD1idTx88ZehyLnB+E7zW5q8dQa4q6uhhmt0tcZkMnAH 2ERhGsmurHKhrRPwn6DhuIRcSmGUMfi6G7+b2XbrixyCuYqPLDeXEU/20VgB3mfZDzBM q+6wdF9eHv6RPfSDhefv3IluZZv7pkPvXjAdyoxMWiFatGPUnt8LjpOgwp9OY3xhIav8 GWlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9ZS2rq7TdX/lH9ThK6GDPfAidwJG5w2VZOyeSQOB1m0=; b=J3nBZVX+K+602Mk+orxzjQB5tIDGKOgce9tsoK6y0UwjmSnnC4WpQvJeNcqRLxZ8ny zLp6BqcCuWS+yhMdnlcB54+kf9PWMy6SGceHLfOv4fynV+GlCZ0/8T5c1GMrFhOJqRby g/obNRRZ8CvlvqFsdEkGgCmmEKsD1WGDCABYWMW+KR84kAtDHdLkxrQ4A1l7OExunsYU OLokvbrSTTR89IPJzqKAlYOU9OlG/rD7Xwn4REP9as9a5M2/61NN6/qZlbS7RRbNeR3Q HgsaaaI5BlHOa9xAhlSGF2kMRSUJ9Wjgde1jJlIOY1Xbx/F+QWxengq4N2USPfu3b94q OzSA== X-Gm-Message-State: AOAM533SiW5nhaowCrv69LEDMUQ2cD+2TYMiVm9BEtbQN6//2ENyQMXN BtHFby2nnrHFzAOOvFFmeIiLLQg5C7vzYNb8B9g= X-Received: by 2002:a05:6e02:1aa2:: with SMTP id l2mr20570434ilv.168.1630416388169; Tue, 31 Aug 2021 06:26:28 -0700 (PDT) MIME-Version: 1.0 References: <20210824112946.9324-1-laoar.shao@gmail.com> <20210824112946.9324-3-laoar.shao@gmail.com> In-Reply-To: From: Yafang Shao Date: Tue, 31 Aug 2021 21:25:52 +0800 Message-ID: Subject: Re: [PATCH v3 2/7] sched: make struct sched_statistics independent of fair sched class To: Peter Zijlstra Cc: Ingo Molnar , Mel Gorman , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Benjamin Segall , Daniel Bristot de Oliveira , Alison Chaiken , kbuild test robot , LKML , linux-rt-users Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 31, 2021 at 6:19 PM Peter Zijlstra wrote: > > On Tue, Aug 24, 2021 at 11:29:41AM +0000, Yafang Shao wrote: > > > +#ifdef CONFIG_FAIR_GROUP_SCHED > > +static inline void > > +__schedstats_from_sched_entity(struct sched_entity *se, > > + struct sched_statistics **stats) > > +{ > > + struct task_group *tg; > > + struct task_struct *p; > > + struct cfs_rq *cfs; > > + int cpu; > > + > > + if (entity_is_task(se)) { > > + p = task_of(se); > > + *stats = &p->stats; > > + } else { > > + cfs = group_cfs_rq(se); > > + tg = cfs->tg; > > + cpu = cpu_of(rq_of(cfs)); > > + *stats = tg->stats[cpu]; > > + } > > +} > > + > > +#else > > + > > +static inline void > > +__schedstats_from_sched_entity(struct sched_entity *se, > > + struct sched_statistics **stats) > > +{ > > + struct task_struct *p; > > + > > + p = task_of(se); > > + *stats = &p->stats; > > +} > > + > > +#endif > > + > > /* > > * Update the current task's runtime statistics. > > */ > > @@ -826,6 +861,7 @@ static void update_curr(struct cfs_rq *cfs_rq) > > { > > struct sched_entity *curr = cfs_rq->curr; > > u64 now = rq_clock_task(rq_of(cfs_rq)); > > + struct sched_statistics *stats = NULL; > > u64 delta_exec; > > > > if (unlikely(!curr)) > > @@ -837,8 +873,11 @@ static void update_curr(struct cfs_rq *cfs_rq) > > > > curr->exec_start = now; > > > > - schedstat_set(curr->statistics.exec_max, > > - max(delta_exec, curr->statistics.exec_max)); > > + if (schedstat_enabled()) { > > + __schedstats_from_sched_entity(curr, &stats); > > + __schedstat_set(stats->exec_max, > > + max(delta_exec, stats->exec_max)); > > + } > > > > curr->sum_exec_runtime += delta_exec; > > schedstat_add(cfs_rq->exec_clock, delta_exec); > > > That's just really odd style; what's wrong with something like: > I will change it. > static inline struct sched_statistics * > __schedstats_from_se(struct sched_entity *se) > { > ... > } > > if (schedstats_enabled()) { > struct sched_statistics *stats = __schedstats_from_se(curr); > __schedstat_set(stats->exec_max, max(stats->exec_max, delta_exec)); > } > > -- Thanks Yafang