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 53150C04A95 for ; Fri, 23 Sep 2022 20:28:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 50C508001F; Fri, 23 Sep 2022 16:28:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4BBC680016; Fri, 23 Sep 2022 16:28:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2C1048001F; Fri, 23 Sep 2022 16:28:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 0B7E780016 for ; Fri, 23 Sep 2022 16:28:42 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D315FC0F7E for ; Fri, 23 Sep 2022 20:28:41 +0000 (UTC) X-FDA: 79944488442.24.6FA3E74 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by imf17.hostedemail.com (Postfix) with ESMTP id 849D54000A for ; Fri, 23 Sep 2022 20:28:41 +0000 (UTC) Received: by mail-pj1-f42.google.com with SMTP id x1-20020a17090ab00100b001fda21bbc90so6932672pjq.3 for ; Fri, 23 Sep 2022 13:28:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=uHzKBVTjEHdcyxBK/e9a9aAi8Q9V4sIUcMdI9R+NeBw=; b=jBye91GcJQpuPM4eGpC1kN+s6wjUWqJyd/v7aTXGIRUnvrWux7XpJSTzfPNIqoJyf/ pMGFjdgFAwJgoiWOA2c87VkOJrEq9UrR6eF7rfeUvysqGBQ29Hn46KFQuYrECrQx3mfB P+ik2svTHcyq3xMw+1ZNMITx6akxpdQwuEOp4n8vE7AUDEMnhiVQZkmLvtB1pEiiARi6 aOwW1Sb9j+BYeDkSmSxkjFnHqZtxRG8fvPcOM2z+5pBdYhY00wWVMYq65WN7KZO/Gb2t kFDgwVXjgKklRkGH2rKro9uPOrjVTTNfME1BGgHsA33x35b11E1KmBQGSSxqTPDeogcc fPNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=uHzKBVTjEHdcyxBK/e9a9aAi8Q9V4sIUcMdI9R+NeBw=; b=MIqDZWRtx0qCF+MYjKIyp2aFSRRkcTjYGx0X0AlUnSJTPNakYmeo2htGL0eCVjj6KT kBQCzy+U4pKs+gQmzC3Lx6XPpl13IxbljLausFd/LN76del21HVzGWSR+9G1aVjoeG+n RNv5s5ec6NS+e0axRGH/YfPRTlWK0CgvxRsB3G//R91BV8rC12+9RwAx2zzbLK5QefgA fSMRTnPXF0agB3XWidxZIVaCIZGrRRiadId2OSZYM/5W5/mvl8ZV6PfGKnxmZoeLu7Yu bAzeR0yeQJpz0f8jG2mb56qgUl8cKSoDirXP6Jse0mCHso6IPx3z3A3zV0gw6TRW5Hu+ jacQ== X-Gm-Message-State: ACrzQf3r0Xqtj82q4aAk1COPZ4JG4NOHpNWfy9zje/lQ3+uVCBGxKIKX el+0/m/Y2SYj96/2J0Rc6uVKsw== X-Google-Smtp-Source: AMsMyM7t4qHFld3zzoNO7/9jFvEv+SqU6/d9JqvrRQbm1VPCqer3MTjhooRHzu9ktvjs5vn0RrOU6w== X-Received: by 2002:a17:90b:4b03:b0:202:eab3:e174 with SMTP id lx3-20020a17090b4b0300b00202eab3e174mr22407036pjb.12.1663964920411; Fri, 23 Sep 2022 13:28:40 -0700 (PDT) Received: from google.com (223.103.125.34.bc.googleusercontent.com. [34.125.103.223]) by smtp.gmail.com with ESMTPSA id b67-20020a621b46000000b0053e22c7f135sm6922461pfb.141.2022.09.23.13.28.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Sep 2022 13:28:39 -0700 (PDT) Date: Fri, 23 Sep 2022 13:28:35 -0700 From: David Matlack To: Jim Mattson Cc: Maxim Levitsky , "kvm@vger.kernel.org" , Paolo Bonzini , Vladimir Davydov , linux-mm@kvack.org, Sean Christopherson , Emanuele Giuseppe Esposito Subject: Re: The root cause of failure of access_tracking_perf_test in a nested guest Message-ID: References: <50dfe81bf95db91e6148b421740490c35c33233e.camel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663964921; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=uHzKBVTjEHdcyxBK/e9a9aAi8Q9V4sIUcMdI9R+NeBw=; b=RJHux5IJoyBJmp67wntk0YRc0592eaF94tF6FaAQxWph3F2EzAjiT3YWc6RH5aMyCpLl8P 05KlVcSsPks+PZZOLis28ZOxJJDPb/2wzO1O6WDDlsZhLMUO8OcMlBOq+kyExur1cdsJZ1 NKMSD1s6kfURzS3elCRPIOniMZX/wrY= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=jBye91Gc; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf17.hostedemail.com: domain of dmatlack@google.com designates 209.85.216.42 as permitted sender) smtp.mailfrom=dmatlack@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663964921; a=rsa-sha256; cv=none; b=dXI3Dk/uczpa/95vSYhhw94frQsZUyoYNeLfOgIaTsSvyc0m2F9ICDYHRtPz8vWCBb9CTa wp1ETqu+jGjn90UPch2FUUKbkT2lZ3Kbi/pULC7JZPD50jlDcYF0YYVVldbhu48fa6/MTN ywgArAbxveHVB7XcGGpVoU2NkNcIYdI= Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=jBye91Gc; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf17.hostedemail.com: domain of dmatlack@google.com designates 209.85.216.42 as permitted sender) smtp.mailfrom=dmatlack@google.com X-Rspam-User: X-Stat-Signature: rgqmna17995wraut6h7shp7jy7kro7q8 X-Rspamd-Queue-Id: 849D54000A X-Rspamd-Server: rspam06 X-HE-Tag: 1663964921-212871 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: 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.