Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp594025pxb; Wed, 27 Jan 2021 16:09:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJw3kTayEYAh0ji2ou7mkJyiyO88UkCGBPBBfRCjYVklM1au9BA5o9rZMAxtl5yOuTevgIqh X-Received: by 2002:a17:906:9616:: with SMTP id s22mr8796549ejx.270.1611792558249; Wed, 27 Jan 2021 16:09:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611792558; cv=none; d=google.com; s=arc-20160816; b=KBwemZzTPxo3dulYjXP0MO7IvZdvWTft055hHOYxWzsm5FE929mKXbdOeGgkuQCKcZ tI7d5p7O9D4VZ9U7sDnXlhNxUCR5BVcRWR3h0olS6LFf6ziv3taUey/RF7dF5Rhc+MrN 0GKi/PHcks2o92pexvEXOBOQE5FoAOByBlRAxXMOitvRnYSFqLjtzcwzdK2zeH0WU5Nj VzXS6Z374UPi9TYu62Q55y7ZLzFPhVjv0YiUr+3ZxboOoxsSvZGBW10hICgW/rOx4tTD BYZjBqlQ8/DgvwZyHEUSisUgvfVR0kUcgjHSE5k44tkxDuDeg9hEw3ZtwQ6O6pKYXUl1 0vOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=cH2HNFoWtmWpnWYeEkgVq7KIaf7LBJ3O9RpwqmgIKSA=; b=TiauMDsvEVVBfiepWp6z4adSp8V4auczSN4frJ3EcE61InAhVWwhUPIOz8/mPFR6zw 0Q99W/TEuh5nAJpLG9bCe7rK2mstQ3ofmNrTe8t4ysoYgsTzWCVNp3RvBQiXGOGZGVPC eG7x0Hg9FjfZz2LRDyiU2FNMkMkciNmM7cZlPNYzlI9jjLI/W+oSAddyycDqJAfoPPpB sxYI3DZVJPsvV4GLgt1/vZpEZIAH0+paFOisWTWHXu9nhrFzQOBFWL59SKwY0Bhs9ISL gr+fLAX7HRVYKNY2Vt4uifxbJztXw5sH9hVnz+stm7zoTCP/mLjnasEdZQ3IPdh8XNOU nkQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=mz5PDFTJ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u10si1516105ejr.222.2021.01.27.16.08.53; Wed, 27 Jan 2021 16:09:18 -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=@google.com header.s=20161025 header.b=mz5PDFTJ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235581AbhA0RFk (ORCPT + 99 others); Wed, 27 Jan 2021 12:05:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235397AbhA0RDK (ORCPT ); Wed, 27 Jan 2021 12:03:10 -0500 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74053C061788 for ; Wed, 27 Jan 2021 09:02:24 -0800 (PST) Received: by mail-lj1-x22b.google.com with SMTP id u4so1410003ljh.6 for ; Wed, 27 Jan 2021 09:02:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cH2HNFoWtmWpnWYeEkgVq7KIaf7LBJ3O9RpwqmgIKSA=; b=mz5PDFTJyoJh/pyXtv5YLKAkeJPvhgWZ4xIUUoAvtBLEVzYk9nyIDv+wGNoXKh4Img t1mLGgGAMfiUZCeoJZIn1ohcgMrhO48vDuCErg8HEJOmehktLiU8sO8YS/5TiTspPc5j m+OCKAXkv8bjFaBRU5MNZsxu92R/U3xIeHD0zZioRKHMCtAmcJESSKr3tMoDI25xKIoM BdRXLVPeg06O4uYFFcoyMy6vIL+8dAN8sN0Y40ZvFObmvDVtKIYbG4ja6GiWua+GHCZL 7/NrVww2ym7LOXu0cuFEjW5WMrjDmlnUms8KKHsWYmVG9r2arbXQgVW6MqEbiHoad6DW tKVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cH2HNFoWtmWpnWYeEkgVq7KIaf7LBJ3O9RpwqmgIKSA=; b=JnPHQZkhb0njWaSEkjhMnDSmIUjBHsFfnwPDQl6z3vQu8OLbQ8osi9UdoMcaatktrg 1VXPccUe+CKtvfm6OAGjDKMU0k0YWqaew2FDbbqr2HkhwjQ8MCyFrLw4mZbn4LFGUkje iWHef1mjclCv58w5rxHz29HmeZnUBvzgQzGcHvVzfyjRWHagynV0VFRqWEg/Jmv0glzs dthAznw5MiajNA1sWDTXUzUa/FBv4WpTUD1V7OfEJLAXw5SueMsXlBjvz07dC6mOlkBl vqkEAVgZMh7ezO5pBzoPWzShZ8EcnRTua1FYNWv+8bojWSclLd7v1IyJTwQpShcWNmOb tVvw== X-Gm-Message-State: AOAM532MJqf7VDe35rP+qlJmhvhimnCA6szKRPYbB2I7G5rgP5M6c9HB v3remeU/67otzE0NakxBqUt63bP+RuJBqTgm6AGAZw== X-Received: by 2002:a2e:9090:: with SMTP id l16mr6467976ljg.122.1611766942605; Wed, 27 Jan 2021 09:02:22 -0800 (PST) MIME-Version: 1.0 References: <20201224071111.11551-1-sjpark@amazon.com> <20210127165630.29904-1-sjpark@amazon.com> In-Reply-To: <20210127165630.29904-1-sjpark@amazon.com> From: Shakeel Butt Date: Wed, 27 Jan 2021 09:02:11 -0800 Message-ID: Subject: Re: [PATCH v23 05/15] mm/damon: Implement primitives for the virtual memory address spaces To: SeongJae Park Cc: Jonathan.Cameron@huawei.com, Andrea Arcangeli , acme@kernel.org, alexander.shishkin@linux.intel.com, amit@kernel.org, benh@kernel.crashing.org, brendan.d.gregg@gmail.com, Brendan Higgins , Qian Cai , Colin Ian King , Jonathan Corbet , David Hildenbrand , dwmw@amazon.com, Marco Elver , "Du, Fan" , foersleo@amazon.de, Greg Thelen , Ian Rogers , jolsa@redhat.com, "Kirill A. Shutemov" , Mark Rutland , Mel Gorman , Minchan Kim , Ingo Molnar , namhyung@kernel.org, "Peter Zijlstra (Intel)" , Randy Dunlap , Rik van Riel , David Rientjes , Steven Rostedt , Mike Rapoport , sblbir@amazon.com, Shuah Khan , sj38.park@gmail.com, snu@amazon.de, Vlastimil Babka , Vladimir Davydov , Yang Shi , Huang Ying , zgf574564920@gmail.com, linux-damon@amazon.com, Linux MM , linux-doc@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 27, 2021 at 8:57 AM SeongJae Park wrote: > > 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 for confirming. I am still going over the whole series and will send out the emails in a couple of days. Shakeel