Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp148526pxv; Wed, 30 Jun 2021 17:22:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBCB4UqMYLuABj8q1qdZyZRq2UbpBeIABRV0mOw/jL3eyOAoSEfP/iGSV7aplkZHcCCvl+ X-Received: by 2002:a92:1e04:: with SMTP id e4mr26757750ile.260.1625098973848; Wed, 30 Jun 2021 17:22:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625098973; cv=none; d=google.com; s=arc-20160816; b=btS68H7zE9W37jxJDZplV9AFNpFY/zTmvvMUzYqX1ZDM/1D6aQH54eyvczdT9yNPVF E0q5qb7IvApeUOOBtMeabbn31MzKo/ybGCbjAwiTCRlrPgvwXgJFBPCwcgohBTwNav36 UUBso5AK7sqAJg4qbwHnZhc3FyhSaGLDPDfNgjW1VcTfu2igGu7Wt+gzrlU+HUje5Jm5 1m4tTrGgJN31rQnyqXOT8hQrpvk2PF9zt4nYuh89CLNdRb1efYhAuNiCHqxUNEz/sYvG WJu+tFvljytNqKqJiF4KlGLtcK9r5U9eXficZNkJ7xvitcUTe6SggRospDYSkqTd12kI lWPw== 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=Y7O5yPPqy47i4kWXigRNtGqLZWA5RvHaA+tBBNz9j/E=; b=HDcwwSeN3u9fZE/KOJ9g8XjXPEoFBq6rbCMVxc1z4AN+owvaIOaoULFqGwCdTaNIu+ oo/ZVlQGzt22ksLPHt6M/yFuP9O1snk0ObALXHjkQ6788uuySLfDpp2CNpTWURRtp0tj tQPfHwpDBUF8l7P6iXScigRAn8y7i/I/G0KuehmY5fpq3EO55XwTyuLkpBDOiZwTm+nX x079wUsi9vUDNZ8X7k0vdS+WJpmV0tYHE9EbnVDP/2w/KvvrDm1OiQFiYP0rI9QNkpUY hO21qKn5wn9noxOdzmZTLOLYn/WD/6YAovc62SFomxkrEnpr5a2Vdcc8rSMbPC8TU9eC R7rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=euBEeyqP; 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 t13si19205979ilq.138.2021.06.30.17.22.37; Wed, 30 Jun 2021 17:22:53 -0700 (PDT) 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=euBEeyqP; 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 S238114AbhGAAWY (ORCPT + 99 others); Wed, 30 Jun 2021 20:22:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237259AbhGAAWW (ORCPT ); Wed, 30 Jun 2021 20:22:22 -0400 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F493C0617A8 for ; Wed, 30 Jun 2021 17:19:51 -0700 (PDT) Received: by mail-lj1-x233.google.com with SMTP id x20so5842263ljc.5 for ; Wed, 30 Jun 2021 17:19:51 -0700 (PDT) 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=Y7O5yPPqy47i4kWXigRNtGqLZWA5RvHaA+tBBNz9j/E=; b=euBEeyqPefv/L+lWYKMqvVCnpFOJSCkB4S4OIAh7Alk/L1QWouT6aCWZQJ0CLELthY I6Skv8RNTgsFv8x2KFss5JbWxXaeCq4ej9+fkGAwSKboNRWjAX/jyhbTCI9ldNRn1aW/ i9YxyF63YTJJZoJMHFAKoSisjhmU8Mg86UIXeB+6RuIFRzQYerTTEOEXMNAipCTtshcV 74/aT5khIWAH2xKsSet0l1PNPfNz9h5MWoLhXnlPSDpeMgM/FpYHSupSNt1ftnXG+kax RYQf+2h1o8dwAPBlZ8Ho1v2mjraCpTa9xpt0jrMSXcZJMoZwidnmufi42dHeEpXZ3m1i /D1w== 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=Y7O5yPPqy47i4kWXigRNtGqLZWA5RvHaA+tBBNz9j/E=; b=i/mERMAinIESpdGiCsEImcpcDqR82mYbNXhR95TstIDSahIpjWY/UypfFaPo+RfjFE gUmvgD87r8ARqMWRNQOD1CCq/83Lo66OjMlidBgkFdmo8tVIDyaFbSWR8TjpiJnoXUus 7ACnJhPOaiQ5pa8tHlYSxI3W4xcq83WxRwBAdTkTA+Gxp7kmnuAyh/XB7Eeo2xDwmlZU RalknqBjcr78owE2/uZub44vFPCwYXFpTPYaZ4WpeuLw7meIztPVP5YyvO0aTWyVWj5B 6IZmY2PCwY4yxCl/B/7ML9bSQxPjf8DFhTsHTlEGSfGZ1TUND5BlFHyvra54tDei6ikd DAEw== X-Gm-Message-State: AOAM531v6W3BxX9Nm8QtKWOUUXKeBH01Fc+S5KnH4uzjECs2J0PASWA7 8QFdV/GGskoUhSDLS9qlzq3JtMW+5HamXxWW9pGG+g== X-Received: by 2002:a2e:9252:: with SMTP id v18mr10131163ljg.122.1625098789518; Wed, 30 Jun 2021 17:19:49 -0700 (PDT) MIME-Version: 1.0 References: <20210628133355.18576-1-sj38.park@gmail.com> <20210628133355.18576-6-sj38.park@gmail.com> In-Reply-To: <20210628133355.18576-6-sj38.park@gmail.com> From: Shakeel Butt Date: Wed, 30 Jun 2021 17:19:38 -0700 Message-ID: Subject: Re: [PATCH v32 05/13] mm/damon: Implement primitives for the virtual memory address spaces To: SeongJae Park Cc: Andrew Morton , SeongJae Park , Jonathan.Cameron@huawei.com, acme@kernel.org, alexander.shishkin@linux.intel.com, amit@kernel.org, benh@kernel.crashing.org, Brendan Higgins , Jonathan Corbet , David Hildenbrand , dwmw@amazon.com, Marco Elver , "Du, Fan" , foersleo@amazon.de, greg@kroah.com, Greg Thelen , guoju.fgj@alibaba-inc.com, jgowans@amazon.com, Mel Gorman , mheyne@amazon.de, Minchan Kim , Ingo Molnar , namhyung@kernel.org, "Peter Zijlstra (Intel)" , Rik van Riel , David Rientjes , Steven Rostedt , Mike Rapoport , Shuah Khan , sieberf@amazon.com, snu@zelle79.org, Vlastimil Babka , Vladimir Davydov , 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 Mon, Jun 28, 2021 at 6:34 AM SeongJae Park wrote: > > From: SeongJae Park > > This commit introduces a reference implementation of the address space > specific low level primitives for the virtual address space, so that > users of DAMON can easily monitor the data accesses on virtual address > spaces of specific processes by simply configuring the implementation to > be used by DAMON. > > The low level primitives for the fundamental access monitoring are > defined in two parts: > > 1. Identification of the monitoring target address range for the address > space. > 2. Access check of specific address range in the target space. > > The reference implementation for the virtual address space does the > works as below. > > PTE Accessed-bit Based Access Check > ----------------------------------- > > The implementation uses PTE Accessed-bit for basic access checks. That > is, it clears the bit for the next sampling target page and checks > whether it is set again after one sampling period. This could disturb > the reclaim logic. DAMON uses ``PG_idle`` and ``PG_young`` page flags > to solve the conflict, as Idle page tracking does. > > VMA-based Target Address Range Construction > ------------------------------------------- > > Only small parts in the super-huge virtual address space of the > processes are mapped to physical memory and accessed. Thus, tracking > the unmapped address regions is just wasteful. However, because DAMON > can deal with some level of noise using the adaptive regions adjustment > mechanism, tracking every mapping is not strictly required but could > even incur a high overhead in some cases. That said, too huge unmapped > areas inside the monitoring target should be removed to not take the > time for the adaptive mechanism. > > For the reason, this implementation converts the complex mappings to > three distinct regions that cover every mapped area of the address > space. Also, the two gaps between the three regions are the two biggest > unmapped areas in the given address space. The two biggest unmapped > areas would be the gap between the heap and the uppermost mmap()-ed > region, and the gap between the lowermost mmap()-ed region and the stack > in most of the cases. Because these gaps are exceptionally huge in > usual address spaces, excluding these will be sufficient to make a > reasonable trade-off. Below shows this in detail:: > > > > > (small mmap()-ed regions and munmap()-ed regions) > > > > > Signed-off-by: SeongJae Park > Reviewed-by: Leonard Foerster > Reviewed-by: Fernand Sieber Acked-by: Shakeel Butt