Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp145727pxv; Wed, 30 Jun 2021 17:19:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCyaDq6GML4wh8123TIiq/q8GBjZhltXaljwGp0zK4EWqqmH4I2Wo4urZmtcy0prxEi4z/ X-Received: by 2002:a6b:700e:: with SMTP id l14mr9633021ioc.147.1625098744606; Wed, 30 Jun 2021 17:19:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625098744; cv=none; d=google.com; s=arc-20160816; b=K1Zp+Lvl0mmXfIBypZ/OypPCrD+kjpXu+QJpSbpR82WbVqEZXCbbw4ukWorLkxgeQk kvEfV4Pqe1M5G3Fv8B6uf863iJIJg8mAvFIv1KV2/tYGaAyb7PCE2ObNE8ZCW03SPUbW GM04X50F7LfhQ5BF/o3RrM5aF2uC+zi7rFPDtYSq1TmxMPMiSJsQlwsn1LDouXHYQrow jzMd+h2Fs9ICacNoVHXjPpRNGcpYJyK9n+KH+0jGCkWJrMUb7R7h3BoS6ZwfBT0FPSLz dcKa3+iFxJ3dC2GTDUpARlkg7JPS3I0sd61e49/whaKoAjxsL+BbQZXXYV6K1ukBI487 QPrg== 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=CmjVxgCuZa7W1IB2rE7Ahs8xwAc6kD7PBq+4uE9+JOg=; b=DadAnWRefvurn2nC7J6elwyGN5aHV1DLXOKaeTjkju0F9osL1mfa6xYUKKjaJImTCU QxY44K91CWTJXTFgzhCrU02VliSQGtbBKmWxaB+6kLJ5Gf6qGTG8TM0aQH1rkZjhElYC beRAmI7WmSqI2F4a6XhAsceirt3kFi25iHDcZfQ6Z0lrfYqqiEhlHn1H8fTbcGJb21eK klpIpSFd4CQxgR8qg46x0YE86QMwET/8KfJOgHGX4mPmegY3iSzecSZs4u5UA8m9/yIb KL58oRMsjh+rGOCXrI2In0Hko7yk5elbSexFIC117ULMo1iHisc55OAMRiaLR2pDHuMB x2YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=MwGuYq47; 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 p8si29379178ilh.98.2021.06.30.17.18.51; Wed, 30 Jun 2021 17:19:04 -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=MwGuYq47; 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 S237259AbhGAAUv (ORCPT + 99 others); Wed, 30 Jun 2021 20:20:51 -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-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