From: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
To: kernelfans@gmail.com
Cc: Paul Mackerras <paulus@samba.org>,
linuxppc-dev@lists.ozlabs.org, Alexander Graf <agraf@suse.de>,
kvm-ppc@vger.kernel.org
Subject: Re: [RFC 02/11] powerpc: kvm: ensure vcpu-thread run only on primary hwthread
Date: Wed, 12 Nov 2014 10:29:41 +0000 [thread overview]
Message-ID: <20141112101741.GB16566@linux.vnet.ibm.com> (raw)
In-Reply-To: <1413487800-7162-3-git-send-email-kernelfans@gmail.com>
* kernelfans@gmail.com <kernelfans@gmail.com> [2014-10-16 15:29:51]:
> When vcpu thread runs at the first time, it will ensure to stick
> to the primary thread.
>
> Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
> ---
> arch/powerpc/include/asm/kvm_host.h | 3 +++
> arch/powerpc/kvm/book3s_hv.c | 17 +++++++++++++++++
> 2 files changed, 20 insertions(+)
>
> diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
> index 98d9dd5..9a3355e 100644
> --- a/arch/powerpc/include/asm/kvm_host.h
> +++ b/arch/powerpc/include/asm/kvm_host.h
> @@ -666,6 +666,9 @@ struct kvm_vcpu_arch {
> spinlock_t tbacct_lock;
> u64 busy_stolen;
> u64 busy_preempt;
> +#ifdef CONFIG_KVMPPC_ENABLE_SECONDARY
> + bool cpu_selected;
> +#endif
> #endif
> };
>
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index 27cced9..ba258c8 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -1909,6 +1909,23 @@ static int kvmppc_vcpu_run_hv(struct kvm_run *run, struct kvm_vcpu *vcpu)
> {
> int r;
> int srcu_idx;
> +#ifdef CONFIG_KVMPPC_ENABLE_SECONDARY
> + int cpu = smp_processor_id();
> + int target_cpu;
> + unsigned int cpu;
2 variables with same name... cpu
> + struct task_struct *p = current;
> +
> + if (unlikely(!vcpu->arch.cpu_selected)) {
> + vcpu->arch.cpu_selected = true;
Nit: something like cpumask_set seems to be better than cpu_selected
> + for (cpu = 0; cpu < NR_CPUS; cpu+=threads_per_core) {
> + cpumask_set_cpu(cpu, &p->sys_allowed);
Dont we need to reset the cpumask first before we set
the cpumask here?
> + }
> + if (cpu%threads_per_core != 0) {
At this time, cpu should be NR_CPUS and most times it should be a
multiple of threads_per_core. Unfortunately there wont be a cpu with
cpu number NR_CPUS.
> + target_cpu = cpu/threads_per_core*threads_per_core;
Its probably better of to have parenthesis here.
> + migrate_task_to(current, target_cpu);
We are probably migrating to a non-existant cpu.
Also dont you need to check if the target_cpu is part of the cpumask?
> + }
> + }
> +#endif
>
> if (!vcpu->arch.sane) {
> run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
> --
> 1.8.3.1
>
>
--
Thanks and Regards
Srikar Dronamraju
WARNING: multiple messages have this Message-ID (diff)
From: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
To: kernelfans@gmail.com
Cc: Paul Mackerras <paulus@samba.org>,
linuxppc-dev@lists.ozlabs.org, Alexander Graf <agraf@suse.de>,
kvm-ppc@vger.kernel.org
Subject: Re: [RFC 02/11] powerpc: kvm: ensure vcpu-thread run only on primary hwthread
Date: Wed, 12 Nov 2014 15:47:41 +0530 [thread overview]
Message-ID: <20141112101741.GB16566@linux.vnet.ibm.com> (raw)
In-Reply-To: <1413487800-7162-3-git-send-email-kernelfans@gmail.com>
* kernelfans@gmail.com <kernelfans@gmail.com> [2014-10-16 15:29:51]:
> When vcpu thread runs at the first time, it will ensure to stick
> to the primary thread.
>
> Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
> ---
> arch/powerpc/include/asm/kvm_host.h | 3 +++
> arch/powerpc/kvm/book3s_hv.c | 17 +++++++++++++++++
> 2 files changed, 20 insertions(+)
>
> diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
> index 98d9dd5..9a3355e 100644
> --- a/arch/powerpc/include/asm/kvm_host.h
> +++ b/arch/powerpc/include/asm/kvm_host.h
> @@ -666,6 +666,9 @@ struct kvm_vcpu_arch {
> spinlock_t tbacct_lock;
> u64 busy_stolen;
> u64 busy_preempt;
> +#ifdef CONFIG_KVMPPC_ENABLE_SECONDARY
> + bool cpu_selected;
> +#endif
> #endif
> };
>
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index 27cced9..ba258c8 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -1909,6 +1909,23 @@ static int kvmppc_vcpu_run_hv(struct kvm_run *run, struct kvm_vcpu *vcpu)
> {
> int r;
> int srcu_idx;
> +#ifdef CONFIG_KVMPPC_ENABLE_SECONDARY
> + int cpu = smp_processor_id();
> + int target_cpu;
> + unsigned int cpu;
2 variables with same name... cpu
> + struct task_struct *p = current;
> +
> + if (unlikely(!vcpu->arch.cpu_selected)) {
> + vcpu->arch.cpu_selected = true;
Nit: something like cpumask_set seems to be better than cpu_selected
> + for (cpu = 0; cpu < NR_CPUS; cpu+=threads_per_core) {
> + cpumask_set_cpu(cpu, &p->sys_allowed);
Dont we need to reset the cpumask first before we set
the cpumask here?
> + }
> + if (cpu%threads_per_core != 0) {
At this time, cpu should be NR_CPUS and most times it should be a
multiple of threads_per_core. Unfortunately there wont be a cpu with
cpu number NR_CPUS.
> + target_cpu = cpu/threads_per_core*threads_per_core;
Its probably better of to have parenthesis here.
> + migrate_task_to(current, target_cpu);
We are probably migrating to a non-existant cpu.
Also dont you need to check if the target_cpu is part of the cpumask?
> + }
> + }
> +#endif
>
> if (!vcpu->arch.sane) {
> run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
> --
> 1.8.3.1
>
>
--
Thanks and Regards
Srikar Dronamraju
next prev parent reply other threads:[~2014-11-12 10:29 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-16 7:25 [RFC 00/11]: powerKVM, release the compute power of secondary hwthread on host kernelfans
2014-10-16 19:29 ` kernelfans
2014-10-16 7:25 ` [RFC 01/11] sched: introduce sys_cpumask in tsk to adapt asymmetric system kernelfans
2014-10-16 19:29 ` kernelfans
2014-11-12 9:22 ` Srikar Dronamraju
2014-11-12 9:34 ` Srikar Dronamraju
2014-11-18 5:07 ` Liu ping fan
2014-11-18 5:07 ` Liu ping fan
2014-10-16 7:25 ` [RFC 02/11] powerpc: kvm: ensure vcpu-thread run only on primary hwthread kernelfans
2014-10-16 19:29 ` kernelfans
2014-11-12 10:17 ` Srikar Dronamraju [this message]
2014-11-12 10:29 ` Srikar Dronamraju
2014-10-16 7:25 ` [RFC 03/11] powerpc: kvm: add interface to control kvm function on a core kernelfans
2014-10-16 19:29 ` kernelfans
2014-10-27 4:04 ` Preeti U Murthy
2014-10-27 4:16 ` Preeti U Murthy
2014-11-18 5:17 ` Liu ping fan
2014-11-18 5:17 ` Liu ping fan
2014-11-12 13:01 ` Srikar Dronamraju
2014-11-12 13:13 ` Srikar Dronamraju
2014-10-16 7:25 ` [RFC 04/11] powerpc: kvm: introduce a kthread on primary thread to anti tickless kernelfans
2014-10-16 19:29 ` kernelfans
2014-10-27 4:45 ` Preeti U Murthy
2014-10-27 4:57 ` Preeti U Murthy
2014-11-18 5:24 ` Liu ping fan
2014-11-18 5:24 ` Liu ping fan
2014-10-16 7:25 ` [RFC 05/11] sched: introduce stop_cpus_async() to schedule special tsk on cpu kernelfans
2014-10-16 19:29 ` kernelfans
2014-10-16 7:26 ` [RFC 06/11] powerpc: kvm: introduce online in paca to indicate whether cpu is needed by host kernelfans
2014-10-16 19:29 ` kernelfans
2014-10-27 5:32 ` Preeti U Murthy
2014-10-27 5:44 ` Preeti U Murthy
2014-11-18 5:29 ` Liu ping fan
2014-11-18 5:29 ` Liu ping fan
2014-10-16 7:26 ` [RFC 07/11] powerpc: kvm: the stopper func to cease secondary hwthread kernelfans
2014-10-16 19:29 ` kernelfans
2014-10-22 7:12 ` Preeti U Murthy
2014-10-22 7:24 ` Preeti U Murthy
2014-10-27 6:07 ` Preeti U Murthy
2014-10-27 6:19 ` Preeti U Murthy
2014-10-16 7:26 ` [RFC 08/11] powerpc: kvm: add a flag in vcore to sync primary with secondry hwthread kernelfans
2014-10-16 19:29 ` kernelfans
2014-10-27 6:28 ` Preeti U Murthy
2014-10-27 6:40 ` Preeti U Murthy
2014-10-16 7:26 ` [RFC 09/11] powerpc: kvm: handle time base on secondary hwthread kernelfans
2014-10-16 19:29 ` kernelfans
2014-10-27 6:40 ` Preeti U Murthy
2014-10-27 6:52 ` Preeti U Murthy
2014-11-18 5:43 ` Liu ping fan
2014-11-18 5:43 ` Liu ping fan
2014-10-16 7:26 ` [RFC 10/11] powerpc: kvm: on_primary_thread() force the secondary threads into NAP mode kernelfans
2014-10-16 19:29 ` kernelfans
2014-10-16 7:26 ` [RFC 11/11] powerpc: kvm: Kconfig add an option for enabling secondary hwthread kernelfans
2014-10-16 19:30 ` kernelfans
2014-10-27 6:44 ` Preeti U Murthy
2014-10-27 6:56 ` Preeti U Murthy
2014-11-18 5:47 ` Liu ping fan
2014-11-18 5:47 ` Liu ping fan
2014-11-18 17:54 ` [RFC 00/11]: powerKVM, release the compute power of secondary hwthread on host Alexander Graf
2014-11-18 17:54 ` Alexander Graf
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=20141112101741.GB16566@linux.vnet.ibm.com \
--to=srikar@linux.vnet.ibm.com \
--cc=agraf@suse.de \
--cc=kernelfans@gmail.com \
--cc=kvm-ppc@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=paulus@samba.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.