From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2BE061F9F79 for ; Tue, 17 Dec 2024 23:59:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734479990; cv=none; b=ZPmtCV531PoxMhSQxixzwYw+f8bWx/KEg/voeHmgVgmZqxZL3I3OpUT34qxJpdDQD2j1HmY0inDMIpWor7ZMLG6osRc4e+wUDEq8fTmjBFrYJn5w6b5kF4eaMmGm1RvQFssz8VB0idjV7XxiVBHBIWgTcJ7T0GsQGEnJhKmhQpA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734479990; c=relaxed/simple; bh=HQcTbZF4VMZK8Gh4tXVj30gF2zRoK9ozXa54vb+6DVg=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=jrv8V+WUh0rTPrbJctzzEK73CGDKsvK7TTzR1UQG1c8B71E4wVSUlamTXvZDEY24vA2JiIbj73WencZbYJOFwJ9N9fyHDmFJKMd11TsDhk8jMN9F4MQ8ydiX+OgKf/OPcNZWYzaV7x+Mx7OLsqv+mCFqxdvGWiTLJe9KLulwh3Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=LU1E42vt; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LU1E42vt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734479987; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Xsypa/lk2ZGEp9VFcicxVIBsaAtVG1MIYQ3EBVCbIQM=; b=LU1E42vtzvsbHd2Xr1hBmjdEzbOus+PdiHN+LXSWLvKIDU05o8G+F+BTkdWfO/LNhko/+e SKU6jj4uxBNhWHofasYiOmQx2flDOSsd4eJ3/C3CpduV9FKhu8LiO79bRYV2pFYopmA7Gc RwrzAUXjmCCTdw7zjvDqHeDucSQ4A6U= Received: from mail-il1-f199.google.com (mail-il1-f199.google.com [209.85.166.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-124-XXbwfdNMNwCeb60pV_vd5Q-1; Tue, 17 Dec 2024 18:59:45 -0500 X-MC-Unique: XXbwfdNMNwCeb60pV_vd5Q-1 X-Mimecast-MFC-AGG-ID: XXbwfdNMNwCeb60pV_vd5Q Received: by mail-il1-f199.google.com with SMTP id e9e14a558f8ab-3a9cd0b54c1so62617105ab.0 for ; Tue, 17 Dec 2024 15:59:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734479984; x=1735084784; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Xsypa/lk2ZGEp9VFcicxVIBsaAtVG1MIYQ3EBVCbIQM=; b=Vkzgphi0AM9DzNfPwFNFze0VUEFdJej6I8MPzbkABw2+fhIRIVe73ISqxH1qvfmzEe bssise6WWvygcCbzrUuV+vdA0bpUXTFmgFXQpLmtsum9QH1Hn4dthqMsuprYhJRVvh7Z WVLSOnc39Zi0TmTHxVF0arviPFwwrD52pMWQdgGyeDvE29oRvl34O0mYFTWJuFOPZzit 0VB901HHoVs0MQqvNuzG3Iy52Hre1+dX2cCBPTA7VUtSt2X3ebAQr8xP2rirAslbwTJT 3ZdbwvEIc6F2zdy2/g5wT14Zf69fX66m9HUpxthm2c6TlVTNGymcH85sH1764eA7q7eX Gonw== X-Forwarded-Encrypted: i=1; AJvYcCVtt+tyh/YNTvPXtGABGVcxvoz5r7JkbYyeTij6or1yZl0EGZL649WPxZ6P2BCawQgOoRjMv+ObmhQiam4=@vger.kernel.org X-Gm-Message-State: AOJu0YzMvX017OQb6gz3A+BrlHrKQFJqFOBnCTyVkbPLOrdkgaj76Bh0 7a8haaHcaiKifIvwpz3444BeKljhoXPOKTKgakdwyxv0QfAtJC3jns93FDlbtsBO7T9rTadbouI fTQndG74wqgt2FV2Qu2kbENjqwvB9De2iTSEhe8p7omec61O91cTprPPjqX253w== X-Gm-Gg: ASbGncuRFU0Cx8Ap3EjX6kiJaqxC5wXjN0hYTzubsxSfhzVmKnJEaa9G+EhgOjBLSVl 5AvfoLFFjda5ntv3Z9D9il/oS6+fcDS42MKxlAyV6m1A9uQee0RY7q8FjmCOH5xJxPgMtzd+xuu ks4gV960M/v5qx8LZppZkSvDjBKnpxb9iYU84Uvkwh4upaSZ9andOfG1lTVQc5wL37ewQQY5OD9 LAlyZBK3ouL3DxKAFhPWffI5DylxoE43tOAniQymWMwllbwN3vRUrF7 X-Received: by 2002:a05:6e02:1a6f:b0:3a7:6566:1e8f with SMTP id e9e14a558f8ab-3bdc437a770mr6531575ab.16.1734479984508; Tue, 17 Dec 2024 15:59:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IEh6/ypJZLhK7ivl0lgAtAroRZ1XmcT/bT9+gVvRVYoPSUO/W9REARAZoYFbA0fbPyZB29Hmg== X-Received: by 2002:a05:6e02:1a6f:b0:3a7:6566:1e8f with SMTP id e9e14a558f8ab-3bdc437a770mr6531445ab.16.1734479984103; Tue, 17 Dec 2024 15:59:44 -0800 (PST) Received: from starship ([2607:fea8:fc01:8d8d:6adb:55ff:feaa:b156]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3b24cf3ae02sm24028405ab.49.2024.12.17.15.59.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 15:59:43 -0800 (PST) Message-ID: <5b5b12bdc8a653901f28c754fcdced9103ae5c27.camel@redhat.com> Subject: Re: [PATCH 05/20] KVM: selftests: Precisely track number of dirty/clear pages for each iteration From: Maxim Levitsky To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Xu Date: Tue, 17 Dec 2024 18:59:42 -0500 In-Reply-To: <20241214010721.2356923-6-seanjc@google.com> References: <20241214010721.2356923-1-seanjc@google.com> <20241214010721.2356923-6-seanjc@google.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7bit On Fri, 2024-12-13 at 17:07 -0800, Sean Christopherson wrote: > Track and print the number of dirty and clear pages for each iteration. > This provides parity between all log modes, and will allow collecting the > dirty ring multiple times per iteration without spamming the console. > > Opportunistically drop the "Dirtied N pages" print, which is redundant > and wrong. For the dirty ring testcase, the vCPU isn't guaranteed to > complete a loop. And when the vCPU does complete a loot, there are no Typo > guarantees that it has *dirtied* that many pages; because the writes are > to random address, the vCPU may have written the same page over and over, > i.e. only dirtied one page. Counting how many times a vCPU wrote is also a valid statistic I think it would be the best to include it as well (e.g call it number of loops that vCPU did). Best regards, Maxim Levitsky > > Signed-off-by: Sean Christopherson > --- > tools/testing/selftests/kvm/dirty_log_test.c | 18 +++++++++--------- > 1 file changed, 9 insertions(+), 9 deletions(-) > > diff --git a/tools/testing/selftests/kvm/dirty_log_test.c b/tools/testing/selftests/kvm/dirty_log_test.c > index 55a744373c80..08cbecd1a135 100644 > --- a/tools/testing/selftests/kvm/dirty_log_test.c > +++ b/tools/testing/selftests/kvm/dirty_log_test.c > @@ -388,8 +388,6 @@ static void dirty_ring_collect_dirty_pages(struct kvm_vcpu *vcpu, int slot, > > if (READ_ONCE(dirty_ring_vcpu_ring_full)) > dirty_ring_continue_vcpu(); > - > - pr_info("Iteration %ld collected %u pages\n", iteration, count); > } > > static void dirty_ring_after_vcpu_run(struct kvm_vcpu *vcpu) > @@ -508,24 +506,20 @@ static void log_mode_after_vcpu_run(struct kvm_vcpu *vcpu) > static void *vcpu_worker(void *data) > { > struct kvm_vcpu *vcpu = data; > - uint64_t pages_count = 0; > > while (!READ_ONCE(host_quit)) { > - pages_count += TEST_PAGES_PER_LOOP; > /* Let the guest dirty the random pages */ > vcpu_run(vcpu); > log_mode_after_vcpu_run(vcpu); > } > > - pr_info("Dirtied %"PRIu64" pages\n", pages_count); > - > return NULL; > } > > static void vm_dirty_log_verify(enum vm_guest_mode mode, unsigned long *bmap) > { > + uint64_t page, nr_dirty_pages = 0, nr_clean_pages = 0; > uint64_t step = vm_num_host_pages(mode, 1); > - uint64_t page; > uint64_t *value_ptr; > uint64_t min_iter = 0; > > @@ -544,7 +538,7 @@ static void vm_dirty_log_verify(enum vm_guest_mode mode, unsigned long *bmap) > if (__test_and_clear_bit_le(page, bmap)) { > bool matched; > > - host_dirty_count++; > + nr_dirty_pages++; > > /* > * If the bit is set, the value written onto > @@ -605,7 +599,7 @@ static void vm_dirty_log_verify(enum vm_guest_mode mode, unsigned long *bmap) > " incorrect (iteration=%"PRIu64")", > page, *value_ptr, iteration); > } else { > - host_clear_count++; > + nr_clean_pages++; > /* > * If cleared, the value written can be any > * value smaller or equals to the iteration > @@ -639,6 +633,12 @@ static void vm_dirty_log_verify(enum vm_guest_mode mode, unsigned long *bmap) > } > } > } > + > + pr_info("Iteration %2ld: dirty: %-6lu clean: %-6lu\n", > + iteration, nr_dirty_pages, nr_clean_pages); > + > + host_dirty_count += nr_dirty_pages; > + host_clear_count += nr_clean_pages; > } > > static struct kvm_vm *create_vm(enum vm_guest_mode mode, struct kvm_vcpu **vcpu,