Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp6138604pxu; Wed, 23 Dec 2020 14:55:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJzGbRNtWrpZnYoSwNVvYhp3o53YL/fPnzllFaltIkRh1CYl7iS4lC4/LTaQdZyLAiR3zbY7 X-Received: by 2002:a17:906:a008:: with SMTP id p8mr13010888ejy.117.1608764141789; Wed, 23 Dec 2020 14:55:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608764141; cv=none; d=google.com; s=arc-20160816; b=y2nI9vqpLLMzMT64w4roLsBPDp6hvyyEm85ObdC3qxI8vAvzQXMZD6FKw+IJ+/I7SF gt/oO8P6g0rACEABuLFeCbymh1ZltT8jWjg7D8SR10ItT2br7aPEOMzj7ndCFtAuFDbj wSXbNxgo7dTfo9vYggopE8KlacfKP0nNN+SNonaHNUNqK8y+go5mClYTdgUMJZN10vf4 oAZ+umWmTPxlLguMLs2aN0cl6xhC6Lp3Yi7Q23yDKI/FEz1zOHzK6HywXmiDNLr1lnoH v2i5hHF5s0wnlWCh0Vgy3wxv7mZNO0PO+bOQ4D7Sq0CfTEA0dm18ZJPY2vaDZkzqBRuy OEXw== 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=toS9/UXOgygIv5/JsFXSLZjtZRcGltwDge5uvyW+ZWE=; b=sfh2cKS1wCU+30mG35bBTddVQUWTGdLyovviqRWKenIr5wv5MPH69F9ZqGrW0PG5o7 3CG7WUeTLx5KB/doqaUWSix9zBn+J7MoRk3dfAOWPYRaA+WzjRC6N33iwi3V+kjN3qTg TWajLw2eYccf1SY0HUjbC5zcC06yT+52IcYDE3B8DaOvvUAocL7YpXK9HdVLub1pua/j C7cEJMPUSq5jASj7F3rpgPiP5slhGFbMBcU69SiX6YnNbYhWZ5d+NCn1lcRQqDK1vXNm yzqFe+blq6DdwT3s6Guf60Xo/Cvi+Zpn8/DG1DjDmFjZUPYiIGF6XxikGug8JybJdFeW zmIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=G6K+frm4; 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 35si15081280edm.126.2020.12.23.14.55.19; Wed, 23 Dec 2020 14:55:41 -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=G6K+frm4; 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 S1726746AbgLWWy4 (ORCPT + 99 others); Wed, 23 Dec 2020 17:54:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726319AbgLWWyz (ORCPT ); Wed, 23 Dec 2020 17:54:55 -0500 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BFCFC061794 for ; Wed, 23 Dec 2020 14:54:15 -0800 (PST) Received: by mail-lf1-x133.google.com with SMTP id o17so982757lfg.4 for ; Wed, 23 Dec 2020 14:54:14 -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=toS9/UXOgygIv5/JsFXSLZjtZRcGltwDge5uvyW+ZWE=; b=G6K+frm4usiDNsy54nqovFvsVKgDfwnlcqwizLUB2sMkLMPHlYnxgfuXUHsOojVXFw /xt2oZRbXSu5CI8DX5+rRvzw4S9LW+Xj/Nc7JSgAoW8ivJkV45cWCKrLTf7PxLxxx+Cx zI9Wm8nTWe1MMOuXTFlce9/yjl8z85vEMsRETL370DlXbffiE1ivHgPADKgCqZwgtqDg 0LcU6uoZKF6W6BUO1wtPdKNyDZLyWe38U3Svmx06IfXYwGPUreI5Omz+Bg1G+IrGOhLF lMfckB64+SM8Xa8ny/ivZLlqJpHPuzr94Aqf+oMcRLV8kMeb5FdyS2AmK/NtXoAU3WCf ocBg== 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=toS9/UXOgygIv5/JsFXSLZjtZRcGltwDge5uvyW+ZWE=; b=sBn74D4jfb6CMag/SfHf2vwGPklM09B/D+451Lit7Z0+UOEbPzG5vaaB9aP++DLK7e ugeKUoe8mvhkthgnzJ7mEsExAlaD0LrrJpAK3O3VCpq9YmpPJg0eb2+3xtaWPRlt5Uf8 5t18NBBNervNH/zHW1s/VZjpc+mn+tSTHqeqjqPnFOnUEnt/0cvR/p01EeA0go89KnbD dbxWPRJdU9YZGqfsWmH9+OCtaIBfH81k1TkSY52najbajMipvG9ONm+0rylT/w36dIKV 6M+NmMRxUIib4GI2Cg68biF2xH9sf/VFRRJUYyB7/wPC463FSQW/20exbvmLE9nPZt1K bzyA== X-Gm-Message-State: AOAM533lnempVlBN7BMAgV+fTL4M4309i7qIDS+UwTwezOScyPsztKsg xHnkNKjJAuPMYqEAGqjueooMXeL+S6NQfJ76AcoWcQ== X-Received: by 2002:ac2:46d4:: with SMTP id p20mr11066331lfo.299.1608764053186; Wed, 23 Dec 2020 14:54:13 -0800 (PST) MIME-Version: 1.0 References: <20201223164700.29723-1-sjpark@amazon.com> In-Reply-To: <20201223164700.29723-1-sjpark@amazon.com> From: Shakeel Butt Date: Wed, 23 Dec 2020 14:54:02 -0800 Message-ID: Subject: Re: [PATCH v23 05/15] mm/damon: Implement primitives for the virtual memory address spaces To: SeongJae Park Cc: SeongJae Park , 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, 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?