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 X-Spam-Level: X-Spam-Status: No, score=-13.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73A7CC433E6 for ; Wed, 27 Jan 2021 17:02:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 16C2F64DA5 for ; Wed, 27 Jan 2021 17:02:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 16C2F64DA5 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6CE256B0070; Wed, 27 Jan 2021 12:02:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 67ED86B0071; Wed, 27 Jan 2021 12:02:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F9106B0072; Wed, 27 Jan 2021 12:02:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0195.hostedemail.com [216.40.44.195]) by kanga.kvack.org (Postfix) with ESMTP id 388D56B0070 for ; Wed, 27 Jan 2021 12:02:27 -0500 (EST) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id EEAB582499B9 for ; Wed, 27 Jan 2021 17:02:26 +0000 (UTC) X-FDA: 77752173492.02.slave60_231853127598 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin02.hostedemail.com (Postfix) with ESMTP id F3AB610097AB2 for ; Wed, 27 Jan 2021 17:02:24 +0000 (UTC) X-HE-Tag: slave60_231853127598 X-Filterd-Recvd-Size: 7516 Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Wed, 27 Jan 2021 17:02:24 +0000 (UTC) Received: by mail-lj1-f172.google.com with SMTP id y11so2961135ljk.1 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=VCL3IDcE4mBy7X2xev1nWFk+TdZRsVWg8hg+ZIsyf3ea+msLqC0tKXm8YYkJqEG2eC ZG2kc2Gyjes5QkrS5mMhE+pYFnQWxYELTKXVi1rJKDJAO8zaM26ovfVwh02xb8S0b6c6 YKRe5PzavEnLDCw5mIRMXC3BLVjY0SESdTY6SAb/DUkeILKYVBwtGjC4yxz1cuEQ0buo mbk1AGKSWuLf+7fBemFNqpIYKcwq+g8iOufcAR4bN8tMgCdcN40MtzZxhPpsvM2dz4K0 LJG5xwAn37qrWOWxs7nFxscQty6et1n6gwRQS2tmGYsl9ggw+Jf7GhRNxY3pzZBce7qo 7VFw== X-Gm-Message-State: AOAM532WRNVKeolKnwGL/fLfXTkePEBQU+sgbLECOJWilkH1m5AQoM01 QZWrbcVpJYC+Ak2AIWtrpo+8HFNzSveNak85PWUgFg== X-Google-Smtp-Source: ABdhPJzn3+brB6ijk7rnoncHsjbUhtCxiDrzyrub1UFfa0DwbZ0yKW/AEqV+N1JM57R5nuh2wtjRmyWYVYp2tkZOOho= 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" 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 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