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=-18.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=unavailable 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 40BD8C11F66 for ; Thu, 1 Jul 2021 00:18:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1B27E61466 for ; Thu, 1 Jul 2021 00:18:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237585AbhGAAUw (ORCPT ); Wed, 30 Jun 2021 20:20:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236647AbhGAAUu (ORCPT ); Wed, 30 Jun 2021 20:20:50 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 256F3C061756 for ; Wed, 30 Jun 2021 17:18:21 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id t17so8527827lfq.0 for ; Wed, 30 Jun 2021 17:18:21 -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=CmjVxgCuZa7W1IB2rE7Ahs8xwAc6kD7PBq+4uE9+JOg=; b=MwGuYq470DmmxyRW4pUzKJAiI4H+QXWtWt+NTxQliXHh0rcaeFKoVfPZgD6OBSkoeG YFK7kzI7NdXqOnjvIk9UbPglOGKun5fmzyA7G09R69iUwxLwGFkfLbQu2SHKAC88o91m g0aY9S4Y8QJy8Sy6GgZAZtSNU5JQmRivsHihX1qNcdnmjhYbEOGPjgliq8iesXVK3S3P w59/vFnMZbpLHyfmLBy0+tgwGLmD3CoPbifnp6OsA+FgqfJTdBgWQbRbKz38k7JdCjZ1 J4UlP0kiYjFkxQAye44s4FCOOvw+H/ydsXoCp7JfjR0eVeW2R72lPix4v4E91Wjnj41K 1AIQ== 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=CmjVxgCuZa7W1IB2rE7Ahs8xwAc6kD7PBq+4uE9+JOg=; b=eRNdgZDUyZa3CspztsZC5GIbKT3LuV4Atjm4hKjFEJ+tAdzitKZ2eTL5q1Po5b8bha ItsJFSFONBXaod83LFATqmvplEyej1b5pvcRRqhXQg6pBm+2++Fg4CMKje0Rrr3kLJXJ ZjPybg5lSQRB7R4+ks8DRVf53lmDiatgpUIJvJ6TLW3HYtS4+vkgFGcjj+2pXj2c5O3C Yk+51LPeTtLYd3zy2WVKzp91KMMtovy7cW850LpP4bkh5DEHsAaWvWshU3P4xIUzMJK/ WrKqNOADjVOP1s/1gbDa+YSAoZcRogBUxXHK0AMOmGYljiq4NXXSxnjQsu3PyyEgB9AH h0QA== X-Gm-Message-State: AOAM533tgId4xfdPUYS8YfmyNTrNn0SowqO5r0M800r3z8BkVg3p9PCv bc8IAf/dzefypMVVO/vPJZ6yAclpacdckqig2TvJRg== X-Google-Smtp-Source: ABdhPJxhdsug23dO9aKrK0MJcADXuwga3FJN8Rqu74M+5beXZR3CMYGYDeoM6AE7Daeb6YUcq+j6pJ9NWKihh6AqwT8= X-Received: by 2002:a19:5016:: with SMTP id e22mr16601403lfb.299.1625098698637; Wed, 30 Jun 2021 17:18:18 -0700 (PDT) MIME-Version: 1.0 References: <20210621083108.17589-1-sj38.park@gmail.com> <20210621083108.17589-6-sj38.park@gmail.com> In-Reply-To: <20210621083108.17589-6-sj38.park@gmail.com> From: Shakeel Butt Date: Wed, 30 Jun 2021 17:18:07 -0700 Message-ID: Subject: Re: [PATCH v31 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 21, 2021 at 1:31 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 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=-18.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=ham 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 2D42AC11F66 for ; Thu, 1 Jul 2021 00:18:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C106361408 for ; Thu, 1 Jul 2021 00:18:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C106361408 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 35CCB8D01CE; Wed, 30 Jun 2021 20:18:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E5A48D01C8; Wed, 30 Jun 2021 20:18:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1386D8D01CE; Wed, 30 Jun 2021 20:18:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0229.hostedemail.com [216.40.44.229]) by kanga.kvack.org (Postfix) with ESMTP id DD9668D01C8 for ; Wed, 30 Jun 2021 20:18:20 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id A2918181AEF1E for ; Thu, 1 Jul 2021 00:18:20 +0000 (UTC) X-FDA: 78312107160.07.0E1C4E6 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by imf14.hostedemail.com (Postfix) with ESMTP id 67C3E6001AAA for ; Thu, 1 Jul 2021 00:18:20 +0000 (UTC) Received: by mail-lf1-f44.google.com with SMTP id h15so8376509lfv.12 for ; Wed, 30 Jun 2021 17:18:20 -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=CmjVxgCuZa7W1IB2rE7Ahs8xwAc6kD7PBq+4uE9+JOg=; b=MwGuYq470DmmxyRW4pUzKJAiI4H+QXWtWt+NTxQliXHh0rcaeFKoVfPZgD6OBSkoeG YFK7kzI7NdXqOnjvIk9UbPglOGKun5fmzyA7G09R69iUwxLwGFkfLbQu2SHKAC88o91m g0aY9S4Y8QJy8Sy6GgZAZtSNU5JQmRivsHihX1qNcdnmjhYbEOGPjgliq8iesXVK3S3P w59/vFnMZbpLHyfmLBy0+tgwGLmD3CoPbifnp6OsA+FgqfJTdBgWQbRbKz38k7JdCjZ1 J4UlP0kiYjFkxQAye44s4FCOOvw+H/ydsXoCp7JfjR0eVeW2R72lPix4v4E91Wjnj41K 1AIQ== 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=CmjVxgCuZa7W1IB2rE7Ahs8xwAc6kD7PBq+4uE9+JOg=; b=TNV5YfOPIkwlFxTtcqK6cCPogDIjdG9otXzBTmjvPb8VkbUmvNNj0EJLaHLHBsRBpB x9dQZdQGAi4fHwT+i5hOmj4mkKTMcdUCJGq1p/GjjJJGkIByIjQyIKV6b2Ta/6w82Zkg lKofq/jiW4v7x8NZDbz6426HCbvVfmasIqNprCD1+s6EULTgxu3tNfl8Khzaz/2ALVGl RqFZUhUezWjFI55uGup6Jn05jHZpQN7d8NXFbtynBcXf8eBoENWxtSFEBnEQ/NhtrcmS GLaDSx651Ly9Mh/tg+gpXALGIvFI/5ebhqh9BdIXAjV0eFeIy37B5nzdJb+iUWHFPV2i Dvlw== X-Gm-Message-State: AOAM531nTwOu3SSLDoF9KhpV1YOurLk11k/2NjuXTd+yUyUZQdtXGDJR Q9cvoq1tqbQLlvbayfpXPha2Cydni59CJa3zjsdgCg== X-Google-Smtp-Source: ABdhPJxhdsug23dO9aKrK0MJcADXuwga3FJN8Rqu74M+5beXZR3CMYGYDeoM6AE7Daeb6YUcq+j6pJ9NWKihh6AqwT8= X-Received: by 2002:a19:5016:: with SMTP id e22mr16601403lfb.299.1625098698637; Wed, 30 Jun 2021 17:18:18 -0700 (PDT) MIME-Version: 1.0 References: <20210621083108.17589-1-sj38.park@gmail.com> <20210621083108.17589-6-sj38.park@gmail.com> In-Reply-To: <20210621083108.17589-6-sj38.park@gmail.com> From: Shakeel Butt Date: Wed, 30 Jun 2021 17:18:07 -0700 Message-ID: Subject: Re: [PATCH v31 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" Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=MwGuYq47; spf=pass (imf14.hostedemail.com: domain of shakeelb@google.com designates 209.85.167.44 as permitted sender) smtp.mailfrom=shakeelb@google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: cfn95j5tjkgcyi11fomfdu7zhkpgfsr5 X-Rspamd-Queue-Id: 67C3E6001AAA X-Rspamd-Server: rspam06 X-HE-Tag: 1625098700-75740 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 Mon, Jun 21, 2021 at 1:31 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