All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Yafang Shao <laoar.shao@gmail.com>
Cc: mingo@redhat.com, mgorman@suse.de, juri.lelli@redhat.com,
	vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
	rostedt@goodmis.org, bsegall@google.com, bristot@redhat.com,
	achaiken@aurora.tech, lkp@intel.com,
	linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org
Subject: Re: [PATCH v3 2/7] sched: make struct sched_statistics independent of fair sched class
Date: Tue, 31 Aug 2021 12:19:50 +0200	[thread overview]
Message-ID: <YS4CRi7nzfGk2o7u@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20210824112946.9324-3-laoar.shao@gmail.com>

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:

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));
	}



  parent reply	other threads:[~2021-08-31 10:20 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-24 11:29 [PATCH v3 0/7] sched: support schedstats for RT sched class Yafang Shao
2021-08-24 11:29 ` [PATCH v3 1/7] sched, fair: use __schedstat_set() in set_next_entity() Yafang Shao
2021-08-24 11:29 ` [PATCH v3 2/7] sched: make struct sched_statistics independent of fair sched class Yafang Shao
2021-08-31 10:14   ` Peter Zijlstra
2021-08-31 13:25     ` Yafang Shao
2021-08-31 10:19   ` Peter Zijlstra [this message]
2021-08-31 13:25     ` Yafang Shao
2021-08-24 11:29 ` [PATCH v3 3/7] sched: make schedstats helpers " Yafang Shao
2021-08-31 11:07   ` Peter Zijlstra
2021-08-31 13:27     ` Yafang Shao
2021-08-24 11:29 ` [PATCH v3 4/7] sched: make the output of schedstats " Yafang Shao
2021-08-31 11:08   ` Peter Zijlstra
2021-08-31 13:27     ` Yafang Shao
2021-08-24 11:29 ` [PATCH v3 5/7] sched: introduce task block time in schedstats Yafang Shao
2021-08-24 11:29 ` [PATCH v3 6/7] sched, rt: support sched_stat_runtime tracepoint for RT sched class Yafang Shao
2021-08-24 11:29 ` [PATCH v3 7/7] sched, rt: support schedstats " Yafang Shao
2021-08-31 10:08 ` [PATCH v3 0/7] sched: " Peter Zijlstra
2021-08-31 10:44   ` Peter Zijlstra
2021-08-31 13:21     ` Yafang Shao
2021-08-31 12:57   ` Yafang Shao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YS4CRi7nzfGk2o7u@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=achaiken@aurora.tech \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=laoar.shao@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.