Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1432149 > unrolled thread

Re: [PATCH 4/5] sched/debug: remove several CONFIG_SCHEDSTATS guards

Started byPeter Zijlstra <peterz@infradead.org>
First post2016-06-27 18:30 +0200
Last post2016-06-27 18:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH 4/5] sched/debug: remove several CONFIG_SCHEDSTATS guards Peter Zijlstra <peterz@infradead.org> - 2016-06-27 18:30 +0200
    Re: [PATCH 4/5] sched/debug: remove several CONFIG_SCHEDSTATS guards Josh Poimboeuf <jpoimboe@redhat.com> - 2016-06-27 18:40 +0200

#1432149 — Re: [PATCH 4/5] sched/debug: remove several CONFIG_SCHEDSTATS guards

FromPeter Zijlstra <peterz@infradead.org>
Date2016-06-27 18:30 +0200
SubjectRe: [PATCH 4/5] sched/debug: remove several CONFIG_SCHEDSTATS guards
Message-ID<rOHA5-2Ez-23@gated-at.bofh.it>
On Fri, Jun 17, 2016 at 12:43:26PM -0500, Josh Poimboeuf wrote:
> index 017a4f5..0aee5dd 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -1626,10 +1626,15 @@ static inline int __set_cpus_allowed_ptr(struct task_struct *p,
>  static void
>  ttwu_stat(struct task_struct *p, int cpu, int wake_flags)
>  {
> -#ifdef CONFIG_SCHEDSTATS
> -	struct rq *rq = this_rq();
> +	struct rq *rq;
> +
> +	if (!schedstat_enabled())
> +		return;
> +
> +	rq = this_rq();
>  
>  #ifdef CONFIG_SMP
> +{
>  	int this_cpu = smp_processor_id();
>  
>  	if (cpu == this_cpu) {
> @@ -1651,7 +1656,7 @@ ttwu_stat(struct task_struct *p, int cpu, int wake_flags)
>  
>  	if (wake_flags & WF_MIGRATED)
>  		schedstat_inc(p->se.statistics.nr_wakeups_migrate);
> -
> +}
>  #endif /* CONFIG_SMP */
>  
>  	schedstat_inc(rq->ttwu_count);

I did:

--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1636,10 +1636,7 @@ ttwu_stat(struct task_struct *p, int cpu
 	rq = this_rq();
 
 #ifdef CONFIG_SMP
-{
-	int this_cpu = smp_processor_id();
-
-	if (cpu == this_cpu) {
+	if (cpu == rq->cpu) {
 		schedstat_inc(rq->ttwu_local);
 		schedstat_inc(p->se.statistics.nr_wakeups_local);
 	} else {
@@ -1647,7 +1644,7 @@ ttwu_stat(struct task_struct *p, int cpu
 
 		schedstat_inc(p->se.statistics.nr_wakeups_remote);
 		rcu_read_lock();
-		for_each_domain(this_cpu, sd) {
+		for_each_domain(rq->cpu, sd) {
 			if (cpumask_test_cpu(cpu, sched_domain_span(sd))) {
 				schedstat_inc(sd->ttwu_wake_remote);
 				break;
@@ -1658,7 +1655,6 @@ ttwu_stat(struct task_struct *p, int cpu
 
 	if (wake_flags & WF_MIGRATED)
 		schedstat_inc(p->se.statistics.nr_wakeups_migrate);
-}
 #endif /* CONFIG_SMP */
 
 	schedstat_inc(rq->ttwu_count);

[toc] | [next] | [standalone]


#1432151

FromJosh Poimboeuf <jpoimboe@redhat.com>
Date2016-06-27 18:40 +0200
Message-ID<rOHJM-2Ik-11@gated-at.bofh.it>
In reply to#1432149
On Mon, Jun 27, 2016 at 06:21:11PM +0200, Peter Zijlstra wrote:
> On Fri, Jun 17, 2016 at 12:43:26PM -0500, Josh Poimboeuf wrote:
> > index 017a4f5..0aee5dd 100644
> > --- a/kernel/sched/core.c
> > +++ b/kernel/sched/core.c
> > @@ -1626,10 +1626,15 @@ static inline int __set_cpus_allowed_ptr(struct task_struct *p,
> >  static void
> >  ttwu_stat(struct task_struct *p, int cpu, int wake_flags)
> >  {
> > -#ifdef CONFIG_SCHEDSTATS
> > -	struct rq *rq = this_rq();
> > +	struct rq *rq;
> > +
> > +	if (!schedstat_enabled())
> > +		return;
> > +
> > +	rq = this_rq();
> >  
> >  #ifdef CONFIG_SMP
> > +{
> >  	int this_cpu = smp_processor_id();
> >  
> >  	if (cpu == this_cpu) {
> > @@ -1651,7 +1656,7 @@ ttwu_stat(struct task_struct *p, int cpu, int wake_flags)
> >  
> >  	if (wake_flags & WF_MIGRATED)
> >  		schedstat_inc(p->se.statistics.nr_wakeups_migrate);
> > -
> > +}
> >  #endif /* CONFIG_SMP */
> >  
> >  	schedstat_inc(rq->ttwu_count);
> 
> I did:
> 
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -1636,10 +1636,7 @@ ttwu_stat(struct task_struct *p, int cpu
>  	rq = this_rq();
>  
>  #ifdef CONFIG_SMP
> -{
> -	int this_cpu = smp_processor_id();
> -
> -	if (cpu == this_cpu) {
> +	if (cpu == rq->cpu) {
>  		schedstat_inc(rq->ttwu_local);
>  		schedstat_inc(p->se.statistics.nr_wakeups_local);
>  	} else {
> @@ -1647,7 +1644,7 @@ ttwu_stat(struct task_struct *p, int cpu
>  
>  		schedstat_inc(p->se.statistics.nr_wakeups_remote);
>  		rcu_read_lock();
> -		for_each_domain(this_cpu, sd) {
> +		for_each_domain(rq->cpu, sd) {
>  			if (cpumask_test_cpu(cpu, sched_domain_span(sd))) {
>  				schedstat_inc(sd->ttwu_wake_remote);
>  				break;
> @@ -1658,7 +1655,6 @@ ttwu_stat(struct task_struct *p, int cpu
>  
>  	if (wake_flags & WF_MIGRATED)
>  		schedstat_inc(p->se.statistics.nr_wakeups_migrate);
> -}
>  #endif /* CONFIG_SMP */
>  
>  	schedstat_inc(rq->ttwu_count);

Much better, thanks.

-- 
Josh

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web