From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B2CDC07E9D for ; Mon, 26 Sep 2022 08:50:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BB4EA8E0033; Mon, 26 Sep 2022 04:50:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B66548E0007; Mon, 26 Sep 2022 04:50:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A050A8E0033; Mon, 26 Sep 2022 04:50:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 900388E0007 for ; Mon, 26 Sep 2022 04:50:08 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 69FEA16074A for ; Mon, 26 Sep 2022 08:50:08 +0000 (UTC) X-FDA: 79953614496.15.1325395 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf19.hostedemail.com (Postfix) with ESMTP id 0CB001A0006 for ; Mon, 26 Sep 2022 08:50:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664182207; 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=ISvikFtP5DIuopUJ+ZDU0jE0NajkftdGvG2rBa3msvE=; b=VVy7+IFHSEeTd6Vv7CW7t2VsN7ayRyo6wzOC23ITsstY9PynHCv69BTx3HEyRI8Aa233/D /zoeBpA+MrilVOpuimBJSfSLUalXE63ouxaC+a5oNdpiZKBi6dX6ufAlQI/ovSGSiaWYZ6 nGhBOoLB/9quTfAFiF8Rs6DzKmY6G2Y= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-202-18DLXP4mPFy40eMvkw62vw-1; Mon, 26 Sep 2022 04:50:06 -0400 X-MC-Unique: 18DLXP4mPFy40eMvkw62vw-1 Received: by mail-wm1-f72.google.com with SMTP id p36-20020a05600c1da400b003b4faefa2b9so3848522wms.6 for ; Mon, 26 Sep 2022 01:50:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=ISvikFtP5DIuopUJ+ZDU0jE0NajkftdGvG2rBa3msvE=; b=HsbqdFo6oMdoweXaU+Q09r94vizEz59Iatak8NiiY977g/rCyEXBHLbCTiH+kcL7rP iZW1nWk3xhr+hd8d5Z6N8AdL7aWzoO1VtYKXEtBOSoTi4U6/96QZ4hngNPILTbCA8gxb Uv2l1jSsYWZgIQvYX0ZMCjvxux1vb9mfKy9YBSJpczS0/KfZfQA/ed5056Hqa3fXPGuL IAp/1ZibZ1WDG7Wu3d7QWNeSXD+SXEeXtd+brFMlGk3UWn0pTXAIhrfWo/vHj5leElod c2JvFNcTCso0+pk3SUiTzg8ZNrlNd/p+vAb5v+A/vzlHYg4E716+7oYZ9lnnyhL0WX6q Nuxw== X-Gm-Message-State: ACrzQf2fWnchsxl9CaB+sR0GFQRL4pOdE9AuQkGHr06b22C1MFxvMHXq LU//3ZzHHZVIS+vE73oB6J21TyAILpu51QdZN1yS9zeA3lultLx2H+k6BC6TFYk/vcLAByR/EUy IeDnN4tLXjBQ= X-Received: by 2002:a05:6000:1849:b0:228:c848:2593 with SMTP id c9-20020a056000184900b00228c8482593mr12788824wri.557.1664182205220; Mon, 26 Sep 2022 01:50:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Hfh3ycDEEf+U8H4S0LbycgueuKVXF2+jFJr6wuVTH0HDBDxm6tsWjWlimAj6cOgR6DfVtFg== X-Received: by 2002:a05:6000:1849:b0:228:c848:2593 with SMTP id c9-20020a056000184900b00228c8482593mr12788811wri.557.1664182205014; Mon, 26 Sep 2022 01:50:05 -0700 (PDT) Received: from [192.168.149.123] (58.254.164.109.static.wline.lns.sme.cust.swisscom.ch. [109.164.254.58]) by smtp.gmail.com with ESMTPSA id bg7-20020a05600c3c8700b003a5c999cd1asm13194689wmb.14.2022.09.26.01.50.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Sep 2022 01:50:04 -0700 (PDT) Message-ID: Date: Mon, 26 Sep 2022 10:50:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: The root cause of failure of access_tracking_perf_test in a nested guest To: David Matlack , Jim Mattson Cc: Maxim Levitsky , "kvm@vger.kernel.org" , Paolo Bonzini , Vladimir Davydov , linux-mm@kvack.org, Sean Christopherson References: <50dfe81bf95db91e6148b421740490c35c33233e.camel@redhat.com> From: Emanuele Giuseppe Esposito In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664182208; a=rsa-sha256; cv=none; b=468Y9sdeem+XDvNV+6rktbAqNLE1xYaYraBbQ1CZZpBqFtRjlL/SLz1MQW36FD+eZ1gbn5 E5it0i6gpNuy6pw1yTcW/dFYcafcegXnmGsRZYoz4msWrCeTmG0n5KIqmQJvI92F6JjqpE lHQw032R3P5oAVPngNvUj5sNhTpkz58= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VVy7+IFH; spf=pass (imf19.hostedemail.com: domain of eesposit@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=eesposit@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664182208; h=from:from:sender: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:dkim-signature; bh=ISvikFtP5DIuopUJ+ZDU0jE0NajkftdGvG2rBa3msvE=; b=nYJooNQa28HGtFasK2l58P2/yianTzwP1OZn7aUPp1U+RVI1oAIEXaVqgL46/92EAe60j7 eEW9uxzkn+32jBFiRhx7gfnb/tLzeMz2oflJueMWaOBuFjKZhPEqbCC6vkZBgNr2KtNHL2 m3iTABZVbXqCgZ7qgPtKUtHqAwa4ahM= X-Rspamd-Queue-Id: 0CB001A0006 X-Rspamd-Server: rspam07 X-Rspam-User: Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VVy7+IFH; spf=pass (imf19.hostedemail.com: domain of eesposit@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=eesposit@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Stat-Signature: q11r3tyekh5toemozwganore1frxmw4p X-HE-Tag: 1664182207-216163 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Am 23/09/2022 um 22:28 schrieb David Matlack: > On Fri, Sep 23, 2022 at 12:25:00PM -0700, Jim Mattson wrote: >> On Fri, Sep 23, 2022 at 3:16 AM Maxim Levitsky wrote: >>> >>> Because of this, when the guest clears the accessed bit in its nested EPT entries, KVM doesn't >>> notice/intercept it and corresponding EPT sptes remain the same, thus later the guest access to >>> the memory is not intercepted and because of this doesn't turn back >>> the accessed bit in the guest EPT tables. >> >> Does the guest execute an INVEPT after clearing the accessed bit? > > No, that's the problem. In L1, access_tracking_perf_test is using > page_idle to mark guest memory as idle, which results in clear_young() > notifiers being sent to KVM clear access bits. clear_young() is > explicitly allowed to omit flushes, so KVM happily obliges. > > /* > * clear_young is a lightweight version of clear_flush_young. Like the > * latter, it is supposed to test-and-clear the young/accessed bitflag > * in the secondary pte, but it may omit flushing the secondary tlb. > */ > int (*clear_young)(struct mmu_notifier *subscription, > struct mm_struct *mm, > unsigned long start, > unsigned long end); > > We could modify page_idle so that KVM performs TLB flushes. For example, > add a mechanism for userspace to trigger a TLB flush. Or change > page_idle to use clear_flush_young() (although that would be incredibly > expensive since page_idle only allows clearing one pfn at a time). But > I'm not sure creating a new userspace API just for this test is really > worth it, especially with multigen LRU coming soon. > Thank you David and Jim for the feedback. I sent a patch converting the assertion in warning here: https://lkml.org/lkml/2022/9/26/238 Thank you, Emanuele