Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp594245pxb; Wed, 27 Jan 2021 16:09:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQPxp2tddCpTGCVGIIbCnTZUKKW1t+8FtjsT+xLWjQ9p/Dv1f0e0Cyj7csXcYGKQNh/2ZE X-Received: by 2002:a17:906:bc5a:: with SMTP id s26mr8398453ejv.327.1611792579952; Wed, 27 Jan 2021 16:09:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611792579; cv=none; d=google.com; s=arc-20160816; b=smoIW/eGZD6GMWS2rH+Y+QOjKpTMEI8euPF/km9nKk44hVjTyCIQSDVPq8+dO2bnuF 1BojxMsMaZDZm1UtD6TuffPETlGPF7YkQwJgTTEz+yKYpc1y5vNi2lRZVlAJRuV7f2gN ccK+R3wDZsmNPOoh0DSMHUGs8q2KYAz/K89KylBitEExqqdkhNPI/YJO4yZNhO/ox0MN PLjMHjVs3d8tx4hkbxR4Ymlt65gYW25I37HDf7gdin/iqlnqX2byEcwXOPp5nBi0ZHFA Ityyh0bNT19Iu55/OADubBcyz0/FntAfSqvFDmrZHhm/yTUxlS6fujnGya9q0bBU+haz Bszg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=i5zluJQ8Ep7MHqr2mjA7/P86f9akCWCX+vhcFXDo1AU=; b=M3gkcgi3L2g1mnXI3dGFqUY/hNzjhBGE5SJJ2yq9uI77MbEVauUiarCK5eyC4nLntX YXXJ9+cEaeSKgX517FV4tXFt3lqlX1l7VshzRHrAhBMmhqLvuKXwN00+yPKT3LvBY/hF 80jE2Pr1uRFnJ9UpcezUvwTdbglC5DqHLeebyfSUwNmZoblls4KlKdAjHPm4GXU4EI/I TCtP9I7+/3qri/O2/zM1HFhXIS0PVjfW/cjpB6NYK35ODNv76z3lwPCOU0LeihFAN+WL Iemxz3kDD577W0m0xzis13xnqNUMiU9R/tDndbDBmxHpn5Ey+7vJRoGhBs7GJkKTla8N lonA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=JMUVhCBn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w25si1801911edr.140.2021.01.27.16.09.15; Wed, 27 Jan 2021 16:09:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=JMUVhCBn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233781AbhA0RAR (ORCPT + 99 others); Wed, 27 Jan 2021 12:00:17 -0500 Received: from smtp-fw-9101.amazon.com ([207.171.184.25]:18732 "EHLO smtp-fw-9101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234192AbhA0Q5z (ORCPT ); Wed, 27 Jan 2021 11:57:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1611766675; x=1643302675; h=from:to:cc:subject:date:message-id:in-reply-to: mime-version; bh=i5zluJQ8Ep7MHqr2mjA7/P86f9akCWCX+vhcFXDo1AU=; b=JMUVhCBndDaSn1y7adHTCK8wAbUfbFbi8KFDlT5kQwRB3zN3Vvfclzve 9sQDaS57ZhZdJX5O8254NIVoiwBL7u37EUnw2dEim3U+0wqMUzmCH+nAH KewWxaN7vZymBhUcnUyRv4p9z0MjR/dOMsGXMzyop/DDHvG3WZCTixI3U 0=; X-IronPort-AV: E=Sophos;i="5.79,380,1602547200"; d="scan'208";a="106835424" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-2b-8cc5d68b.us-west-2.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-9101.sea19.amazon.com with ESMTP; 27 Jan 2021 16:57:08 +0000 Received: from EX13D31EUA001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-2b-8cc5d68b.us-west-2.amazon.com (Postfix) with ESMTPS id 6986AA18C3; Wed, 27 Jan 2021 16:57:05 +0000 (UTC) Received: from u3f2cd687b01c55.ant.amazon.com (10.43.160.132) by EX13D31EUA001.ant.amazon.com (10.43.165.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 27 Jan 2021 16:56:48 +0000 From: SeongJae Park To: SeongJae Park CC: Shakeel Butt , , "Andrea Arcangeli" , , , , , , Brendan Higgins , Qian Cai , Colin Ian King , Jonathan Corbet , "David Hildenbrand" , , Marco Elver , "Du, Fan" , , "Greg Thelen" , Ian Rogers , , "Kirill A. Shutemov" , Mark Rutland , Mel Gorman , Minchan Kim , Ingo Molnar , , "Peter Zijlstra (Intel)" , Randy Dunlap , Rik van Riel , David Rientjes , Steven Rostedt , Mike Rapoport , , Shuah Khan , , , Vlastimil Babka , Vladimir Davydov , Yang Shi , Huang Ying , , , Linux MM , , LKML Subject: Re: [PATCH v23 05/15] mm/damon: Implement primitives for the virtual memory address spaces Date: Wed, 27 Jan 2021 17:56:30 +0100 Message-ID: <20210127165630.29904-1-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201224071111.11551-1-sjpark@amazon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.160.132] X-ClientProxiedBy: EX13D28UWC004.ant.amazon.com (10.43.162.24) To EX13D31EUA001.ant.amazon.com (10.43.165.15) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 24 Dec 2020 08:11:11 +0100 SeongJae Park wrote: > On Wed, 23 Dec 2020 14:54:02 -0800 Shakeel Butt wrote: > > > On Wed, Dec 23, 2020 at 8:47 AM SeongJae Park wrote: > > > > > [snip] > > > > [snip] > > > > > + > > > > > +static bool damon_va_young(struct mm_struct *mm, unsigned long addr, > > > > > + unsigned long *page_sz) > > > > > +{ > > > > > + pte_t *pte = NULL; > > > > > + pmd_t *pmd = NULL; > > > > > + spinlock_t *ptl; > > > > > + bool young = false; > > > > > + > > > > > + if (follow_pte_pmd(mm, addr, NULL, &pte, &pmd, &ptl)) > > > > > + return false; > > > > > + > > > > > + *page_sz = PAGE_SIZE; > > > > > + if (pte) { > > > > > + young = pte_young(*pte); > > > > > + if (!young) > > > > > + young = !page_is_idle(pte_page(*pte)); > > > > > + pte_unmap_unlock(pte, ptl); > > > > > + return young; > > > > > + } > > > > > + > > > > > +#ifdef CONFIG_TRANSPARENT_HUGEPAGE > > > > > + young = pmd_young(*pmd); > > > > > + if (!young) > > > > > + young = !page_is_idle(pmd_page(*pmd)); > > > > > + spin_unlock(ptl); > > > > > + *page_sz = ((1UL) << HPAGE_PMD_SHIFT); > > > > > +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ > > > > > + > > > > > + return young; > > > > > > > > You need mmu_notifier_test_young() here. Hmm I remember mentioning > > > > this in some previous version as well. > > > > > > Your question and my answer was as below: > > > > > > > Don't you need mmu_notifier_clear_young() here? > > > > > > I think we don't need it here because we only read the Accessed bit and PG_Idle > > > if Accessed bit was not set. > > > > > > I should notice that you mean 'test_young()' but didn't, sorry. I will add it > > > in the next version. > > > > > > > I should have said mmu_notifier_test_young() instead of > > mmu_notifier_clear_young(). > > > > > > > > > > BTW have you tested this on a VM? > > > > > > Yes. Indeed, I'm testing this on a QEMU/KVM environment. You can get more > > > detail at: https://damonitor.github.io/doc/html/latest/vm/damon/eval.html#setup > > > > > > > Hmm without mmu_notifier_test_young() you should be missing the kvm > > mmu access updates. Can you please recheck if your eval is correctly > > seeing the memory accesses from the VM? > > Seems I didn't clearly answered, sorry. My test setup installs the > DAMON-enabled kernel in a guest VM and run it for workloads in the guest, > rather than running DAMON in host to monitor accesses of VMs. The MMU notifier > is for latter case, AFAIU, so my test setup didn't see the problem. Just FYI. I confirmed the mmu_notifier_test_young() added version works for the use case. I tested it by running a program accessing 200MB memory in a QEMU/KVM guest having 120GB memory and monitoring the qemu process' virtual address space from the host using DAMON. The 200MB memory region was clearly identifiable. Thanks, SeongJae Park