kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dongli Zhang <dongli.zhang@oracle.com>
To: Li RongQing <lirongqing@baidu.com>,
	pbonzini@redhat.com, mingo@redhat.com, peterz@infradead.org,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: Consider SMT idle status when halt polling
Date: Thu, 22 Jul 2021 08:20:14 -0700	[thread overview]
Message-ID: <e981a94b-b429-b444-feab-eb352bc3e99e@oracle.com> (raw)
In-Reply-To: <fcdfd388-60f3-2c71-646e-5638ee0b5dde@oracle.com>

Please ignore my question. I saw the data from discussion.

"Run a copy (single thread) Unixbench, with or without a busy poll program in
its SMT sibling,  and Unixbench score can lower 1/3 with SMT busy polling program"

Dongli Zhang

On 7/22/21 8:07 AM, Dongli Zhang wrote:
> Hi RongQing,
> 
> Would you mind share if there is any performance data to demonstrate how much
> performance can be improved?
> 
> Thank you very much!
> 
> Dongli Zhang
> 
> On 7/21/21 8:58 PM, Li RongQing wrote:
>> SMT siblings share caches and other hardware, halt polling
>> will degrade its sibling performance if its sibling is busy
>>
>> Signed-off-by: Li RongQing <lirongqing@baidu.com>
>> ---
>>  include/linux/kvm_host.h |  5 ++++-
>>  include/linux/sched.h    | 17 +++++++++++++++++
>>  kernel/sched/fair.c      | 17 -----------------
>>  3 files changed, 21 insertions(+), 18 deletions(-)
>>
>> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
>> index ae7735b..15b3ef4 100644
>> --- a/include/linux/kvm_host.h
>> +++ b/include/linux/kvm_host.h
>> @@ -269,7 +269,10 @@ static inline bool kvm_vcpu_mapped(struct kvm_host_map *map)
>>  
>>  static inline bool kvm_vcpu_can_poll(ktime_t cur, ktime_t stop)
>>  {
>> -	return single_task_running() && !need_resched() && ktime_before(cur, stop);
>> +	return single_task_running() &&
>> +		   !need_resched() &&
>> +		   ktime_before(cur, stop) &&
>> +		   is_core_idle(raw_smp_processor_id());
>>  }
>>  
>>  /*
>> diff --git a/include/linux/sched.h b/include/linux/sched.h
>> index ec8d07d..c333218 100644
>> --- a/include/linux/sched.h
>> +++ b/include/linux/sched.h
>> @@ -34,6 +34,7 @@
>>  #include <linux/rseq.h>
>>  #include <linux/seqlock.h>
>>  #include <linux/kcsan.h>
>> +#include <linux/topology.h>
>>  #include <asm/kmap_size.h>
>>  
>>  /* task_struct member predeclarations (sorted alphabetically): */
>> @@ -2191,6 +2192,22 @@ int sched_trace_rq_nr_running(struct rq *rq);
>>  
>>  const struct cpumask *sched_trace_rd_span(struct root_domain *rd);
>>  
>> +static inline bool is_core_idle(int cpu)
>> +{
>> +#ifdef CONFIG_SCHED_SMT
>> +	int sibling;
>> +
>> +	for_each_cpu(sibling, cpu_smt_mask(cpu)) {
>> +		if (cpu == sibling)
>> +			continue;
>> +
>> +		if (!idle_cpu(cpu))
>> +			return false;
>> +	}
>> +#endif
>> +	return true;
>> +}
>> +
>>  #ifdef CONFIG_SCHED_CORE
>>  extern void sched_core_free(struct task_struct *tsk);
>>  extern void sched_core_fork(struct task_struct *p);
>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>> index 44c4520..5b0259c 100644
>> --- a/kernel/sched/fair.c
>> +++ b/kernel/sched/fair.c
>> @@ -1477,23 +1477,6 @@ struct numa_stats {
>>  	int idle_cpu;
>>  };
>>  
>> -static inline bool is_core_idle(int cpu)
>> -{
>> -#ifdef CONFIG_SCHED_SMT
>> -	int sibling;
>> -
>> -	for_each_cpu(sibling, cpu_smt_mask(cpu)) {
>> -		if (cpu == sibling)
>> -			continue;
>> -
>> -		if (!idle_cpu(cpu))
>> -			return false;
>> -	}
>> -#endif
>> -
>> -	return true;
>> -}
>> -
>>  struct task_numa_env {
>>  	struct task_struct *p;
>>  
>>

      reply	other threads:[~2021-07-22 15:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-22  3:58 [PATCH] KVM: Consider SMT idle status when halt polling Li RongQing
2021-07-22  4:15 ` Mika Penttilä
2021-07-22  5:22   ` 答复: " Li,Rongqing
2021-07-22  5:55 ` Wanpeng Li
2021-07-22  7:10   ` 答复: " Li,Rongqing
2021-07-22 12:16   ` Li,Rongqing
2021-07-27  1:25     ` Sean Christopherson
2021-07-27  6:39       ` 答复: " Li,Rongqing
2021-07-22 13:35 ` kernel test robot
2021-07-22 14:52 ` kernel test robot
2021-07-22 15:07 ` Dongli Zhang
2021-07-22 15:20   ` Dongli Zhang [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=e981a94b-b429-b444-feab-eb352bc3e99e@oracle.com \
    --to=dongli.zhang@oracle.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lirongqing@baidu.com \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.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 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).