Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp462484pxu; Wed, 25 Nov 2020 07:31:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJwkv29lJVLDNZi7/j6soUZyFz78hRmBY3yiZVz1f1jQRQ6JQ0fiWXXUyeOhKX6H8MrnNdP5 X-Received: by 2002:a17:906:f752:: with SMTP id jp18mr3489666ejb.331.1606318315894; Wed, 25 Nov 2020 07:31:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606318315; cv=none; d=google.com; s=arc-20160816; b=sTW0ZJRaUMgcCcZKkQVHnTLONCv5PGU9GcI4FK3lUrC8+Qw2o5ym4cQ4Qg8i98wpq/ uFYJC73iz95DIZjpxSfZl083/l80+y/LZHRqWW/q2osuzpteghjJYa027ykl+TNTJ0Bx MMUa72Ef0lgex1puqEYd4Vlf1229i2hWWmES1DH+z4u+D3wQD5EdWoD9D0/bpGMyVPPw T/mek99B8pLtBog7xdECG2rpOV+o+tobWHZvx/wX0j2v5WkBDD5oUDu7RiiBVHIb3XX0 ejB0DrFvJe5qcxxWUM/yIOa7Mzp2zZRPf86d5/x5pUU5tQBqi1elpls91CtAlzTlr1Vm 7j+Q== 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=13PkHEsv5Gfsa10yo6xM+865e/X5/3hhggzHTqOXsfY=; b=pRf24f5LN2euxnoiyxqkOuyAi6bgY4njRkZAIyiT5EBbZbnJhg8M1x3jMI/dRPQh0K 98UHxLSidPHoJK2ZMoCaG1M7ZHN2yc68zh9IEZ32ShnrvtJBe92JAvFOPx0bqfSBWN3/ eMsGzUBuudZg0XEJ4IfXk5E9s+wSzNgNYgSnnTI4O+0HLx8XNfydjhZAeoK4lqUarOWO +SSN7KzKsWDkqXomrekDYSVHUFd0ENJtG41vaZS0Wh9qXw4yuTXOyWFPxH3/dUjrO4nZ NCNAiV+zhAkoeQYyPzffHN6rBXfLtHoB9ur+Gk7f6LxRojQqA+rRa7X2A5bawqtrwYli d4cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=EtFwDakd; 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 62si1403613edc.231.2020.11.25.07.31.32; Wed, 25 Nov 2020 07:31:55 -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=EtFwDakd; 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 S1730222AbgKYP3o (ORCPT + 99 others); Wed, 25 Nov 2020 10:29:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730112AbgKYP3m (ORCPT ); Wed, 25 Nov 2020 10:29:42 -0500 Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11BA6C0613D4 for ; Wed, 25 Nov 2020 07:29:24 -0800 (PST) Received: by mail-lf1-x143.google.com with SMTP id d20so3649807lfe.11 for ; Wed, 25 Nov 2020 07:29:23 -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=13PkHEsv5Gfsa10yo6xM+865e/X5/3hhggzHTqOXsfY=; b=EtFwDakdU9esaLPfWzzJWQtYC0O8QZ1aEjSYd6jyGyNFsHJbU3dKUmYx/8clc5nygX Kg9cV5BthVrMiwyp4ET9GXGQCSU6jr00bTNUXQelW1NTF92XFBTITcCQ2vKtBk2hlbW0 KFCXPk81RL0a6N6E7YzOef0MyTqMww45RtMIX4nu2KfuzH4/RMa93iWSnzzsuHhVtNYI 1sHg6kX7myPLW4vH8t/EMJaLxl+APqJIm//p6N8TOrsTOeIorJxwFOeDShhnZFTLFhG5 duyLIOrAX7uOWCNDMTPoB49Q67kC8++gGKTMbP+k4uDFOPSRdm0XIIEOg0K87bT+1AoV VUww== 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=13PkHEsv5Gfsa10yo6xM+865e/X5/3hhggzHTqOXsfY=; b=C4QthdI3WI875sMhpM0NuANpI9Sqc5OoEfoeHZP8SGrGhbogECQaZJjB3pe6kaKzTy jKiYYlAzRBoBXg0/k71IA5ARGNJFG6PfuIDLO1ZDEVKJ5jlgNHHBwLJi36Ddh4SvCVKU /mwWwvOCrlqcNaS3927jfFf00bqDtslIovkdS0Mhj+mdRIvEvUzTaYpBBJibno8MIsF3 TLlFh4D9trvmGuNiHgHmgNA3grB+8ImpxIULWFK1UXCYhc42YMScLAG0CwITNOJ8TCXz sEU2Ho312KrGuWch6jU09GdeDUVhx07FrrL0SO9QJTsxK5dpwKqEB2gf35TaS8dqUcwx T64g== X-Gm-Message-State: AOAM532F2Ocq5nEilve0vF+fQfES59v/SO7O7dAL5OQzWR8g686/kQi+ CmsN75bTaHHFujE+yMgJXMZrOQ+WPp8dlr9lYCrkkg== X-Received: by 2002:ac2:43cc:: with SMTP id u12mr504816lfl.54.1606318162152; Wed, 25 Nov 2020 07:29:22 -0800 (PST) MIME-Version: 1.0 References: <20201020085940.13875-1-sjpark@amazon.com> <20201020085940.13875-2-sjpark@amazon.com> In-Reply-To: <20201020085940.13875-2-sjpark@amazon.com> From: Shakeel Butt Date: Wed, 25 Nov 2020 07:29:10 -0800 Message-ID: Subject: Re: [PATCH v22 01/18] mm: Introduce Data Access MONitor (DAMON) To: SeongJae Park Cc: Andrew Morton , 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 Tue, Oct 20, 2020 at 2:01 AM SeongJae Park wrote: > > From: SeongJae Park > > DAMON is a data access monitoring framework for the Linux kernel. The > core mechanisms of DAMON make it > > - accurate (the monitoring output is useful enough for DRAM level > performance-centric memory management; It might be inappropriate for > CPU Cache levels, though), > - light-weight (the monitoring overhead is normally low enough to be > applied online), and > - scalable (the upper-bound of the overhead is in constant range > regardless of the size of target workloads). > > Using this framework, hence, we can easily write efficient kernel space > data access monitoring applications. For example, the kernel's memory > management mechanisms can make advanced decisions using this. > Experimental data access aware optimization works that incurring high > access monitoring overhead could implemented again on top of this. > > Due to its simple and flexible interface, providing user space interface > would be also easy. Then, user space users who have some special > workloads can write personalized applications for better understanding > and optimizations of their workloads and systems. > > That said, this commit is implementing only basic data structures and > simple manipulation functions of the structures. The core mechanisms of > DAMON will be implemented by following commits. > > Signed-off-by: SeongJae Park > Reviewed-by: Leonard Foerster > Reviewed-by: Varad Gautam I don't see any benefit of this patch on its own. Some of this should be part of the main damon context patch. I would suggest to separate the core (damon context) from the target related structs (target, region, addr range). Also I would prefer the code be added with the actual usage otherwise it is hard to review. > --- [snip] > +unsigned int damon_nr_regions(struct damon_target *t) > +{ > + struct damon_region *r; > + unsigned int nr_regions = 0; > + > + damon_for_each_region(r, t) > + nr_regions++; > + > + return nr_regions; > +} Why not keep a count instead of traversing to get the size?