linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Wang <wangyun@linux.vnet.ibm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>, Mike Galbraith <efault@gmx.de>,
	Alex Shi <alex.shi@intel.com>, Namhyung Kim <namhyung@kernel.org>,
	Paul Turner <pjt@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	"Nikunj A. Dadhania" <nikunj@linux.vnet.ibm.com>,
	Ram Pai <linuxram@us.ibm.com>
Subject: Re: [PATCH v2] sched: smart wake-affine
Date: Wed, 03 Jul 2013 17:11:45 +0800	[thread overview]
Message-ID: <51D3EAD1.7080507@linux.vnet.ibm.com> (raw)
In-Reply-To: <20130703085025.GG23916@twins.programming.kicks-ass.net>

On 07/03/2013 04:50 PM, Peter Zijlstra wrote:
> On Wed, Jul 03, 2013 at 02:10:32PM +0800, Michael Wang wrote:
>> +static int wake_wide(struct task_struct *p)
>> +{
>> +	int factor = nr_cpus_node(cpu_to_node(smp_processor_id()));
> 
> That's still a cpumask_weight() in there... 

Exactly, although the scale is lower but still it's a mask...

> we should avoid that. How about something like the below:

Amazing, cost will be lowest when we got such counter, will make them a
patch set and test again ;-)

Regards,
Michael Wang

> 
>> +
>> +	/*
>> +	 * Yeah, it's the switching-frequency, could means many wakee or
>> +	 * rapidly switch, use factor here will just help to automatically
>> +	 * adjust the loose-degree, so bigger node will lead to more pull.
>> +	 */
>> +	if (p->nr_wakee_switch > factor) {
>> +		/*
>> +		 * wakee is somewhat hot, it needs certain amount of cpu
>> +		 * resource, so if waker is far more hot, prefer to leave
>> +		 * it alone.
>> +		 */
>> +		if (current->nr_wakee_switch > (factor * p->nr_wakee_switch))
>> +			return 1;
>> +	}
>> +
>> +	return 0;
>> +}
> 
> ---
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 9b1f2e5..166ab9b 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -5081,18 +5083,23 @@ static void destroy_sched_domains(struct sched_domain *sd, int cpu)
>   * two cpus are in the same cache domain, see cpus_share_cache().
>   */
>  DEFINE_PER_CPU(struct sched_domain *, sd_llc);
> +DEFINE_PER_CPU(int, sd_llc_size);
>  DEFINE_PER_CPU(int, sd_llc_id);
> 
>  static void update_top_cache_domain(int cpu)
>  {
>  	struct sched_domain *sd;
>  	int id = cpu;
> +	int size = 1;
> 
>  	sd = highest_flag_domain(cpu, SD_SHARE_PKG_RESOURCES);
> -	if (sd)
> +	if (sd) {
>  		id = cpumask_first(sched_domain_span(sd));
> +		size = cpumask_weight(sched_domain_span(sd));
> +	}
> 
>  	rcu_assign_pointer(per_cpu(sd_llc, cpu), sd);
> +	per_cpu(sd_llc_size, cpu) = size;
>  	per_cpu(sd_llc_id, cpu) = id;
>  }
> 
> diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
> index ef0a7b2..c992f58 100644
> --- a/kernel/sched/sched.h
> +++ b/kernel/sched/sched.h
> @@ -595,6 +595,7 @@ static inline struct sched_domain *highest_flag_domain(int cpu, int flag)
>  }
> 
>  DECLARE_PER_CPU(struct sched_domain *, sd_llc);
> +DECLARE_PER_CPU(int, sd_llc_size);
>  DECLARE_PER_CPU(int, sd_llc_id);
> 
>  struct sched_group_power {
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -3175,7 +3175,7 @@ static inline unsigned long effective_lo
> 
>  static int wake_wide(struct task_struct *p)
>  {
> -	int factor = nr_cpus_node(cpu_to_node(smp_processor_id()));
> +	int factor = this_cpu_read(sd_llc_size);
> 
>  	/*
>  	 * Yeah, it's the switching-frequency, could means many wakee or
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 


      reply	other threads:[~2013-07-03  9:11 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-28  5:05 [RFC PATCH] sched: smart wake-affine Michael Wang
2013-06-03  2:28 ` Michael Wang
2013-06-03  3:09   ` Mike Galbraith
2013-06-03  3:26     ` Michael Wang
2013-06-03  3:53       ` Mike Galbraith
2013-06-03  4:52         ` Michael Wang
2013-06-03  5:22           ` Mike Galbraith
2013-06-03  5:50             ` Michael Wang
2013-06-03  6:05               ` Mike Galbraith
2013-06-03  6:31                 ` Michael Wang
2013-06-13  3:09 ` Michael Wang
2013-07-02  4:43 ` [PATCH] " Michael Wang
2013-07-02  5:38   ` Mike Galbraith
2013-07-02  5:50     ` Michael Wang
2013-07-02  5:54   ` Mike Galbraith
2013-07-02  6:17     ` Michael Wang
2013-07-02  6:29       ` Mike Galbraith
2013-07-02  6:45         ` Michael Wang
2013-07-02  8:52   ` Peter Zijlstra
2013-07-02  9:35     ` Michael Wang
2013-07-02  9:44       ` Michael Wang
2013-07-04  9:13       ` Peter Zijlstra
2013-07-04  9:38         ` Michael Wang
2013-07-04 10:33           ` Mike Galbraith
2013-07-05  2:47             ` Michael Wang
2013-07-05  4:08               ` Mike Galbraith
2013-07-05  4:33                 ` Michael Wang
2013-07-05  5:41                   ` Mike Galbraith
2013-07-05  6:16                     ` Michael Wang
2013-07-07  6:43                       ` Mike Galbraith
2013-07-08  2:49                         ` Michael Wang
2013-07-08  3:12                           ` Mike Galbraith
2013-07-08  8:21                         ` Peter Zijlstra
2013-07-08  8:49                           ` Mike Galbraith
2013-07-08  9:08                             ` Michael Wang
2013-07-08  8:58                           ` Michael Wang
2013-07-08 18:59                           ` Davidlohr Bueso
2013-07-09  2:30                             ` Michael Wang
2013-07-09  2:36                               ` Davidlohr Bueso
2013-07-09  2:52                                 ` Michael Wang
2013-07-15  5:13                                   ` Michael Wang
2013-07-15  5:57                                     ` Davidlohr Bueso
2013-07-15  6:01                                       ` Michael Wang
2013-07-18  2:15                                       ` Michael Wang
2013-07-03  6:10   ` [PATCH v2] " Michael Wang
2013-07-03  8:50     ` Peter Zijlstra
2013-07-03  9:11       ` Michael Wang [this message]

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=51D3EAD1.7080507@linux.vnet.ibm.com \
    --to=wangyun@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=alex.shi@intel.com \
    --cc=efault@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxram@us.ibm.com \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=nikunj@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=pjt@google.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).