public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: "Radim Krčmář" <rkrcmar@redhat.com>
Cc: kvm@vger.kernel.org, x86@kernel.org,
	Paolo Bonzini <pbonzini@redhat.com>,
	Roman Kagan <rkagan@virtuozzo.com>,
	"K. Y. Srinivasan" <kys@microsoft.com>,
	Haiyang Zhang <haiyangz@microsoft.com>,
	Stephen Hemminger <sthemmin@microsoft.com>,
	"Michael Kelley \(EOSG\)" <Michael.H.Kelley@microsoft.com>,
	Mohammed Gamal <mmorsy@redhat.com>,
	Cathy Avery <cavery@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 5/8] KVM: introduce kvm_make_vcpus_request_mask() API
Date: Mon, 11 Jun 2018 13:57:01 +0200	[thread overview]
Message-ID: <87bmchtu2a.fsf@vitty.brq.redhat.com> (raw)
In-Reply-To: <20180526144946.GF23390@flask> ("Radim \=\?utf-8\?B\?S3LEjW3DocWZ\?\= \=\?utf-8\?B\?Iidz\?\= message of "Sat, 26 May 2018 16:49:47 +0200")

Radim Krčmář <rkrcmar@redhat.com> writes:

> 2018-05-16 17:21+0200, Vitaly Kuznetsov:
>> Hyper-V style PV TLB flush hypercalls inmplementation will use this API.
>> To avoid memory allocation in CONFIG_CPUMASK_OFFSTACK case add
>> cpumask_var_t argument.
>> 
>> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
>> ---
>> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
>> -bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req)
>> +bool kvm_make_vcpus_request_mask(struct kvm *kvm, unsigned int req,
>> +				 unsigned long *vcpu_bitmap, cpumask_var_t tmp)
>>  {
>>  	int i, cpu, me;
>> -	cpumask_var_t cpus;
>> -	bool called;
>>  	struct kvm_vcpu *vcpu;
>> -
>> -	zalloc_cpumask_var(&cpus, GFP_ATOMIC);
>> +	bool called;
>>  
>>  	me = get_cpu();
>> +
>
> Two optimizations come to mind: First is to use for_each_set_bit instead
> of kvm_for_each_vcpu to improve the sparse case.
>

I think I had such version at some point but then for some reason I
decided I'm re-implementing kvm_for_each_vcpu for no particular
reason.

>>  	kvm_for_each_vcpu(i, vcpu, kvm) {
>> +		if (!test_bit(i, vcpu_bitmap))
>
> And the second is to pass vcpu_bitmap = NULL instead of building the
> bitmap with all VCPUs.  Doesn't looks too good in the end, though:
>
> #define kvm_for_each_vcpu_bitmap(idx, vcpup, kvm, bitmap, len) \
> 	for (idx = (bitmap ? find_first_bit(bitmap, len) : 0); \
> 	     idx < len && (vcpup = kvm_get_vcpu(kvm, idx)) != NULL; \
> 	     bitmap ? find_next_bit(bitmap, len, idx + 1) : idx++)

I'll take a try, thanks!

-- 
  Vitaly

  reply	other threads:[~2018-06-11 11:57 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-16 15:21 [PATCH v4 0/8] KVM: x86: hyperv: PV TLB flush for Windows guests Vitaly Kuznetsov
2018-05-16 15:21 ` [PATCH v4 1/8] x86/hyper-v: move struct hv_flush_pcpu{,ex} definitions to common header Vitaly Kuznetsov
2018-05-16 15:52   ` KY Srinivasan
2018-05-17  7:05     ` Vitaly Kuznetsov
2018-05-17 19:33       ` KY Srinivasan
2018-05-19 12:17       ` Thomas Gleixner
2018-05-16 15:21 ` [PATCH v4 2/8] x86/hyperv: fix typo in 'HV_GENERIC_SET_SPARCE_4K' definition Vitaly Kuznetsov
2018-05-16 15:21 ` [PATCH v4 3/8] KVM: x86: hyperv: use defines when parsing hypercall parameters Vitaly Kuznetsov
2018-05-16 15:21 ` [PATCH v4 4/8] KVM: x86: hyperv: do rep check for each hypercall separately Vitaly Kuznetsov
2018-05-16 15:21 ` [PATCH v4 5/8] KVM: introduce kvm_make_vcpus_request_mask() API Vitaly Kuznetsov
2018-05-26 14:49   ` Radim Krčmář
2018-06-11 11:57     ` Vitaly Kuznetsov [this message]
2018-05-16 15:21 ` [PATCH v4 6/8] KVM: x86: hyperv: simplistic HVCALL_FLUSH_VIRTUAL_ADDRESS_{LIST,SPACE} implementation Vitaly Kuznetsov
2018-05-16 15:21 ` [PATCH v4 7/8] KVM: x86: hyperv: simplistic HVCALL_FLUSH_VIRTUAL_ADDRESS_{LIST,SPACE}_EX implementation Vitaly Kuznetsov
2018-05-16 15:21 ` [PATCH v4 8/8] KVM: x86: hyperv: declare KVM_CAP_HYPERV_TLBFLUSH capability Vitaly Kuznetsov
2018-05-18  7:00 ` [PATCH v4 0/8] KVM: x86: hyperv: PV TLB flush for Windows guests Wanpeng Li
2018-05-18 11:00   ` Vitaly Kuznetsov
2018-05-18 11:19     ` Vitaly Kuznetsov
2018-05-18 11:56       ` Wanpeng Li
2018-05-18 12:42         ` Vitaly Kuznetsov
2018-05-18 12:55           ` Wanpeng Li
2018-05-18 13:19             ` Vitaly Kuznetsov
2018-05-26 14:31 ` Radim Krčmář

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=87bmchtu2a.fsf@vitty.brq.redhat.com \
    --to=vkuznets@redhat.com \
    --cc=Michael.H.Kelley@microsoft.com \
    --cc=cavery@redhat.com \
    --cc=haiyangz@microsoft.com \
    --cc=kvm@vger.kernel.org \
    --cc=kys@microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mmorsy@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rkagan@virtuozzo.com \
    --cc=rkrcmar@redhat.com \
    --cc=sthemmin@microsoft.com \
    --cc=x86@kernel.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