Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3057939rwa; Mon, 22 Aug 2022 20:22:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR6WSwypphyAlFaybjHPhqaYOZihkSrHljrJGIur9hnUue4acZbcUikcWCKTgo7jpYUSWKJr X-Received: by 2002:a17:907:75f2:b0:73d:585e:547b with SMTP id jz18-20020a17090775f200b0073d585e547bmr10863118ejc.147.1661224974307; Mon, 22 Aug 2022 20:22:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661224974; cv=none; d=google.com; s=arc-20160816; b=R1BCDyWOTQgTP4xzzI3EsmWwIUe381yUn68FCLfbcrFohxyIO9nkNkXqFLb4dZ21pz WxpaarS7tLT49+FCYnWBiZ5/CsT5Un7XBBmqwlAKZthANWGIBQLa2EUR3TeMc3X+UoSz 5GQIvFeyGbYsRsvZOFjJpMQttak0MHA10396DdwMsMUrOeFHI4v+5BH7E110FQExNoMJ eW+0sA+NFj0wBfoTkB/6xwFi+0D28BCl6/2pk9y0KYFmvRaVlfKGHIf4ufJeGHljUHDm 5MfmvTimssAvgpjxjsQLeImSz8VEurOXH+Ug8Iv9Qxhdfgd4tEviTi/vyVk/d4fHSehA hk1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:references:cc :to:from:subject:reply-to:dkim-signature; bh=PdyIPdKorQDXK1tldjSfL+LVZR0k6xko4u2KPDklhbE=; b=OFxB4fD6gi6tPGK10RA7F3Iq/TXtJoBvjBtQXo/SXoN888MdliFgpuS8fmJ0kF8l2G adTQsgbY4Szu+XHC9ni7P/BMUO38WrtJRKbm86wA6naauo4fL0/5AopFVyM2EEZrSs+k qqOH7GM1apIrSVufS/jkLQUj+Y+xerdHoE2fumcYSTKvvw+HP3M9ZFMvBM97HBq5MO+u weBZGc9jOXWJ23Sp65/X3RtbPeFxx89faHIwSCj8+zPzzj5k0qgsC1Qq03Srt6tHnBFV EgncI/yYQWmGeNojSxKukY2XesQ/1yguZEWSwf8nSdTgMPynfx4aD5dFvK/Fo+KJzwqY CvnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Eoo/flel"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ne32-20020a1709077ba000b0073d72dbfdf8si6067913ejc.220.2022.08.22.20.22.29; Mon, 22 Aug 2022 20:22:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Eoo/flel"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239696AbiHWDLi (ORCPT + 99 others); Mon, 22 Aug 2022 23:11:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240180AbiHWDKy (ORCPT ); Mon, 22 Aug 2022 23:10:54 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CF7C5C9F9 for ; Mon, 22 Aug 2022 20:09:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661224189; h=from:from:reply-to: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=PdyIPdKorQDXK1tldjSfL+LVZR0k6xko4u2KPDklhbE=; b=Eoo/flel6hLt/KZy7cD9iidZ7wNixoQud4lCyOkgFFotYgL9bOqE06EOK0tUuljW78oYyl JzUkvaLEf5q44yYoQx/JMNsBPtnMH4dBfNmpEvRC57mlgzipcBrcttVbYQ/+c7dyujaWuv k1FgpzIGTExgr1/EZKqklYyd4S9aJco= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-663-d3zYu98qMW-lWG9QS1UrQg-1; Mon, 22 Aug 2022 23:09:42 -0400 X-MC-Unique: d3zYu98qMW-lWG9QS1UrQg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7EADE185A79C; Tue, 23 Aug 2022 03:09:41 +0000 (UTC) Received: from [10.64.54.16] (vpn2-54-16.bne.redhat.com [10.64.54.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6E92E492C3B; Tue, 23 Aug 2022 03:09:32 +0000 (UTC) Reply-To: Gavin Shan Subject: Re: [PATCH v1 3/5] KVM: selftests: Dirty host pages in dirty_log_test From: Gavin Shan To: Andrew Jones Cc: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, peterx@redhat.com, pbonzini@redhat.com, corbet@lwn.net, maz@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, catalin.marinas@arm.com, will@kernel.org, shuah@kernel.org, seanjc@google.com, drjones@redhat.com, dmatlack@google.com, bgardon@google.com, ricarkol@google.com, zhenyzha@redhat.com, shan.gavin@gmail.com References: <20220819005601.198436-1-gshan@redhat.com> <20220819005601.198436-4-gshan@redhat.com> <20220819052805.qnhw2d3arxixzvhl@kamzik> <3abb690f-e616-630f-ba40-e590ec8bb5c1@redhat.com> Message-ID: <0496fe72-e3da-9778-b307-eb5cc157e8fe@redhat.com> Date: Tue, 23 Aug 2022 13:09:28 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.0 MIME-Version: 1.0 In-Reply-To: <3abb690f-e616-630f-ba40-e590ec8bb5c1@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Drew, On 8/22/22 4:29 PM, Gavin Shan wrote: > On 8/19/22 3:28 PM, Andrew Jones wrote: >> On Fri, Aug 19, 2022 at 08:55:59AM +0800, Gavin Shan wrote: >>> It's assumed that 1024 host pages, instead of guest pages, are dirtied >>> in each iteration in guest_code(). The current implementation misses >>> the case of mismatched page sizes in host and guest. For example, >>> ARM64 could have 64KB page size in guest, but 4KB page size in host. >>> (TEST_PAGES_PER_LOOP / 16), instead of TEST_PAGES_PER_LOOP, host pages >>> are dirtied in every iteration. >>> >>> Fix the issue by touching all sub-pages when we have mismatched >>> page sizes in host and guest. >> >> I'll let the dirty-log test authors decide what's best to do for this >> test, but I'd think we should let the guest continue dirtying its >> pages without knowledge of the host pages. Then, adjust the host test >> code to assert all sub-pages, other than the ones it expects the guest >> to have written, remain untouched. >> > > I don't think what is clarified in the change log is correct. The current > implementation already had the logic to handle the mismatched page sizes > in vm_dirty_log_verify() where 'step' is used for it by fetching value > from vm_num_host_pages(mode, 1). Please ignore this patch for now, as > explained below. > > The issue I have is the 'dirty_log_test' hangs when I have 4KB host page size > and 64KB guest page size. It seems the vcpu doesn't exit due to full ring > buffer state or kick-off. I will have more investigations to figure out the > root cause. > [...] Please ignore this PATCH[3/5], I think this should be fixed by selecting correct dirty ring count and the fix will be folded to PATCH[5/5] in next revision. In dirty_log_test, we have 1GB memory for guest to write and make them dirty. When we have mismatch page sizes on host and guest, which is either 4kb-host-64kb-guest or 64kb-host-4kb-guest apart from 16kb case, 16384 host pages are dirtied in each iteration. The default dirty ring count is 65536. So the vcpu never exit due to full-dirty-ring-buffer state. This leads the guest's code keep running and the dirty log isn't collected by the main thread. #define TEST_DIRTY_RING_COUNT 65536 dirty_pages_per_iteration = (0x40000000 / 0x10000) = 0x4000 = 16384 Thanks, Gavin