kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kvm: selftests: Support dirty log initial-all-set test
@ 2020-03-03  8:07 Jay Zhou
  2020-03-03  8:53 ` Paolo Bonzini
  2020-03-03  8:54 ` Paolo Bonzini
  0 siblings, 2 replies; 5+ messages in thread
From: Jay Zhou @ 2020-03-03  8:07 UTC (permalink / raw)
  To: kvm
  Cc: pbonzini, peterx, shuah, linux-kselftest, linux-kernel,
	wangxinxin.wang, weidong.huang, liu.jinsong, jianjay.zhou

Since the new capability KVM_DIRTY_LOG_INITIALLY_SET of
KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 has been introduced, tweak the
clear_dirty_log_test to test it.

Signed-off-by: Jay Zhou <jianjay.zhou@huawei.com>
---
 tools/testing/selftests/kvm/clear_dirty_log_test.c |  4 ++++
 tools/testing/selftests/kvm/dirty_log_test.c       | 20 +++++++++++++++++---
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/kvm/clear_dirty_log_test.c b/tools/testing/selftests/kvm/clear_dirty_log_test.c
index 7493369..11672ec 100644
--- a/tools/testing/selftests/kvm/clear_dirty_log_test.c
+++ b/tools/testing/selftests/kvm/clear_dirty_log_test.c
@@ -1,2 +1,6 @@
 #define USE_CLEAR_DIRTY_LOG
+#define KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE (1 << 0)
+#define KVM_DIRTY_LOG_INITIALLY_SET         (1 << 1)
+#define KVM_DIRTY_LOG_MANUAL_CAPS   (KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE | \
+		KVM_DIRTY_LOG_INITIALLY_SET)
 #include "dirty_log_test.c"
diff --git a/tools/testing/selftests/kvm/dirty_log_test.c b/tools/testing/selftests/kvm/dirty_log_test.c
index 5614222..7e21addc4 100644
--- a/tools/testing/selftests/kvm/dirty_log_test.c
+++ b/tools/testing/selftests/kvm/dirty_log_test.c
@@ -264,6 +264,10 @@ static struct kvm_vm *create_vm(enum vm_guest_mode mode, uint32_t vcpuid,
 #define DIRTY_MEM_BITS 30 /* 1G */
 #define PAGE_SHIFT_4K  12
 
+#ifdef USE_CLEAR_DIRTY_LOG
+static u64 dirty_log_manual_caps;
+#endif
+
 static void run_test(enum vm_guest_mode mode, unsigned long iterations,
 		     unsigned long interval, uint64_t phys_offset)
 {
@@ -320,7 +324,7 @@ static void run_test(enum vm_guest_mode mode, unsigned long iterations,
 	struct kvm_enable_cap cap = {};
 
 	cap.cap = KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2;
-	cap.args[0] = 1;
+	cap.args[0] = dirty_log_manual_caps;
 	vm_enable_cap(vm, &cap);
 #endif
 
@@ -438,8 +442,18 @@ int main(int argc, char *argv[])
 #endif
 
 #ifdef USE_CLEAR_DIRTY_LOG
-	if (!kvm_check_cap(KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2)) {
-		fprintf(stderr, "KVM_CLEAR_DIRTY_LOG not available, skipping tests\n");
+	dirty_log_manual_caps =
+		kvm_check_cap(KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2);
+	if (!dirty_log_manual_caps) {
+		fprintf(stderr, "KVM_CLEAR_DIRTY_LOG not available, "
+				"skipping tests\n");
+		exit(KSFT_SKIP);
+	}
+	if (dirty_log_manual_caps != KVM_DIRTY_LOG_MANUAL_CAPS &&
+		dirty_log_manual_caps != KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE) {
+		fprintf(stderr, "KVM_CLEAR_DIRTY_LOG not valid caps "
+				"%"PRIu64", skipping tests\n",
+				dirty_log_manual_caps);
 		exit(KSFT_SKIP);
 	}
 #endif
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] kvm: selftests: Support dirty log initial-all-set test
  2020-03-03  8:07 [PATCH] kvm: selftests: Support dirty log initial-all-set test Jay Zhou
@ 2020-03-03  8:53 ` Paolo Bonzini
  2020-03-03  8:54 ` Paolo Bonzini
  1 sibling, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2020-03-03  8:53 UTC (permalink / raw)
  To: Jay Zhou, kvm
  Cc: peterx, shuah, linux-kselftest, linux-kernel, wangxinxin.wang,
	weidong.huang, liu.jinsong

On 03/03/20 09:07, Jay Zhou wrote:
>  #ifdef USE_CLEAR_DIRTY_LOG
> -	if (!kvm_check_cap(KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2)) {
> -		fprintf(stderr, "KVM_CLEAR_DIRTY_LOG not available, skipping tests\n");
> +	dirty_log_manual_caps =
> +		kvm_check_cap(KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2);
> +	if (!dirty_log_manual_caps) {
> +		fprintf(stderr, "KVM_CLEAR_DIRTY_LOG not available, "
> +				"skipping tests\n");
> +		exit(KSFT_SKIP);
> +	}
> +	if (dirty_log_manual_caps != KVM_DIRTY_LOG_MANUAL_CAPS &&
> +		dirty_log_manual_caps != KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE) {
> +		fprintf(stderr, "KVM_CLEAR_DIRTY_LOG not valid caps "
> +				"%"PRIu64", skipping tests\n",
> +				dirty_log_manual_caps);
>  		exit(KSFT_SKIP);
>  	}
>  #endif
> 

	dirty_log_manual_caps &= (KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE |
				  KVM_DIRTY_LOG_INITIALLY_SET);


Paolo


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] kvm: selftests: Support dirty log initial-all-set test
  2020-03-03  8:07 [PATCH] kvm: selftests: Support dirty log initial-all-set test Jay Zhou
  2020-03-03  8:53 ` Paolo Bonzini
@ 2020-03-03  8:54 ` Paolo Bonzini
  2020-03-03 10:00   ` Zhoujian (jay)
  1 sibling, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2020-03-03  8:54 UTC (permalink / raw)
  To: Jay Zhou, kvm
  Cc: peterx, shuah, linux-kselftest, linux-kernel, wangxinxin.wang,
	weidong.huang, liu.jinsong

On 03/03/20 09:07, Jay Zhou wrote:
>  #ifdef USE_CLEAR_DIRTY_LOG
> -	if (!kvm_check_cap(KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2)) {
> -		fprintf(stderr, "KVM_CLEAR_DIRTY_LOG not available, skipping tests\n");
> +	dirty_log_manual_caps =
> +		kvm_check_cap(KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2);
> +	if (!dirty_log_manual_caps) {
> +		fprintf(stderr, "KVM_CLEAR_DIRTY_LOG not available, "
> +				"skipping tests\n");
> +		exit(KSFT_SKIP);
> +	}
> +	if (dirty_log_manual_caps != KVM_DIRTY_LOG_MANUAL_CAPS &&
> +		dirty_log_manual_caps != KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE) {
> +		fprintf(stderr, "KVM_CLEAR_DIRTY_LOG not valid caps "
> +				"%"PRIu64", skipping tests\n",
> +				dirty_log_manual_caps);
>  		exit(KSFT_SKIP);
>  	}
>  #endif
> 

Thanks, instead of this final "if" it should be enough to do

	dirty_log_manual_caps &= (KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE |
				  KVM_DIRTY_LOG_INITIALLY_SET);


Otherwise looks good, I'll test it and eventually apply both patches.

Paolo


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] kvm: selftests: Support dirty log initial-all-set test
  2020-03-03  8:54 ` Paolo Bonzini
@ 2020-03-03 10:00   ` Zhoujian (jay)
  2020-03-03 10:14     ` Paolo Bonzini
  0 siblings, 1 reply; 5+ messages in thread
From: Zhoujian (jay) @ 2020-03-03 10:00 UTC (permalink / raw)
  To: Paolo Bonzini, kvm
  Cc: peterx, shuah, linux-kselftest, linux-kernel, wangxin (U),
	Huangweidong (C), Liujinsong (Paul)



> -----Original Message-----
> From: Paolo Bonzini [mailto:pbonzini@redhat.com]
> Sent: Tuesday, March 3, 2020 4:54 PM
> To: Zhoujian (jay) <jianjay.zhou@huawei.com>; kvm@vger.kernel.org
> Cc: peterx@redhat.com; shuah@kernel.org; linux-kselftest@vger.kernel.org;
> linux-kernel@vger.kernel.org; wangxin (U) <wangxinxin.wang@huawei.com>;
> Huangweidong (C) <weidong.huang@huawei.com>; Liujinsong (Paul)
> <liu.jinsong@huawei.com>
> Subject: Re: [PATCH] kvm: selftests: Support dirty log initial-all-set test
> 
> On 03/03/20 09:07, Jay Zhou wrote:
> >  #ifdef USE_CLEAR_DIRTY_LOG
> > -	if (!kvm_check_cap(KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2)) {
> > -		fprintf(stderr, "KVM_CLEAR_DIRTY_LOG not available, skipping
> tests\n");
> > +	dirty_log_manual_caps =
> > +		kvm_check_cap(KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2);
> > +	if (!dirty_log_manual_caps) {
> > +		fprintf(stderr, "KVM_CLEAR_DIRTY_LOG not available, "
> > +				"skipping tests\n");
> > +		exit(KSFT_SKIP);
> > +	}
> > +	if (dirty_log_manual_caps != KVM_DIRTY_LOG_MANUAL_CAPS &&
> > +		dirty_log_manual_caps !=
> KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE) {
> > +		fprintf(stderr, "KVM_CLEAR_DIRTY_LOG not valid caps "
> > +				"%"PRIu64", skipping tests\n",
> > +				dirty_log_manual_caps);
> >  		exit(KSFT_SKIP);
> >  	}
> >  #endif
> >
> 
> Thanks, instead of this final "if" it should be enough to do
> 
> 	dirty_log_manual_caps &= (KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE
> |
> 				  KVM_DIRTY_LOG_INITIALLY_SET);
> 
> 
> Otherwise looks good, I'll test it and eventually apply both patches.

Do I need to resubmit this patch with this modification?

Regards,
Jay Zhou

> 
> Paolo


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] kvm: selftests: Support dirty log initial-all-set test
  2020-03-03 10:00   ` Zhoujian (jay)
@ 2020-03-03 10:14     ` Paolo Bonzini
  0 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2020-03-03 10:14 UTC (permalink / raw)
  To: Zhoujian (jay), kvm
  Cc: peterx, shuah, linux-kselftest, linux-kernel, wangxin (U),
	Huangweidong (C), Liujinsong (Paul)

On 03/03/20 11:00, Zhoujian (jay) wrote:
> 
> 
>> -----Original Message-----
>> From: Paolo Bonzini [mailto:pbonzini@redhat.com]
>> Sent: Tuesday, March 3, 2020 4:54 PM
>> To: Zhoujian (jay) <jianjay.zhou@huawei.com>; kvm@vger.kernel.org
>> Cc: peterx@redhat.com; shuah@kernel.org; linux-kselftest@vger.kernel.org;
>> linux-kernel@vger.kernel.org; wangxin (U) <wangxinxin.wang@huawei.com>;
>> Huangweidong (C) <weidong.huang@huawei.com>; Liujinsong (Paul)
>> <liu.jinsong@huawei.com>
>> Subject: Re: [PATCH] kvm: selftests: Support dirty log initial-all-set test
>>
>> On 03/03/20 09:07, Jay Zhou wrote:
>>>  #ifdef USE_CLEAR_DIRTY_LOG
>>> -	if (!kvm_check_cap(KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2)) {
>>> -		fprintf(stderr, "KVM_CLEAR_DIRTY_LOG not available, skipping
>> tests\n");
>>> +	dirty_log_manual_caps =
>>> +		kvm_check_cap(KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2);
>>> +	if (!dirty_log_manual_caps) {
>>> +		fprintf(stderr, "KVM_CLEAR_DIRTY_LOG not available, "
>>> +				"skipping tests\n");
>>> +		exit(KSFT_SKIP);
>>> +	}
>>> +	if (dirty_log_manual_caps != KVM_DIRTY_LOG_MANUAL_CAPS &&
>>> +		dirty_log_manual_caps !=
>> KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE) {
>>> +		fprintf(stderr, "KVM_CLEAR_DIRTY_LOG not valid caps "
>>> +				"%"PRIu64", skipping tests\n",
>>> +				dirty_log_manual_caps);
>>>  		exit(KSFT_SKIP);
>>>  	}
>>>  #endif
>>>
>>
>> Thanks, instead of this final "if" it should be enough to do
>>
>> 	dirty_log_manual_caps &= (KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE
>> |
>> 				  KVM_DIRTY_LOG_INITIALLY_SET);
>>
>>
>> Otherwise looks good, I'll test it and eventually apply both patches.
> 
> Do I need to resubmit this patch with this modification?

No, thanks.

Paolo


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-03-03 10:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-03  8:07 [PATCH] kvm: selftests: Support dirty log initial-all-set test Jay Zhou
2020-03-03  8:53 ` Paolo Bonzini
2020-03-03  8:54 ` Paolo Bonzini
2020-03-03 10:00   ` Zhoujian (jay)
2020-03-03 10:14     ` Paolo Bonzini

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).