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.3 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 13A72C2B9F4 for ; Tue, 22 Jun 2021 14:59:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 01FAA61001 for ; Tue, 22 Jun 2021 14:59:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232125AbhFVPCI (ORCPT ); Tue, 22 Jun 2021 11:02:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232107AbhFVPCF (ORCPT ); Tue, 22 Jun 2021 11:02:05 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F75CC061756 for ; Tue, 22 Jun 2021 07:59:48 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id f13so3435111ljp.10 for ; Tue, 22 Jun 2021 07:59:48 -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=qwYAfiYXqjI2nwrVAYIcKqS0ZhT5P4dOm2JQEAubKpQ=; b=EUy5hSQvlr8ahlU4CaiCb2eNOofiUSD+vYfRdctNN157O9jl4+Qq6tJH0mQqexJocZ dFdPNn1PjMVEHq0IZrzaliNGMXUSDFSr0EdImVqstiim9tRoM3nKofzeXq7b/mU/6fty anECsJMjFdAuTnUKKVJ11E+l4p0WdjrMpeySt/wlkJTwGd7SsFHtEeXIXcNuTjGHMvif 9h2PLYOQfdmOMXX7EfR8VWZPsOkylWcIVTdCA+Bj5Me7VVI2kDE2ii9bRPqlXimNXQvk oD5k6m6h/LW9X2W11+sf10Dr+i9o0gQYG4rsiI9twScaF761lflMTuA++iJv/mB9b7z6 PwFg== 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=qwYAfiYXqjI2nwrVAYIcKqS0ZhT5P4dOm2JQEAubKpQ=; b=cmgRXYLKyHyDgGAAXcOKg3YsuQpxqE9ArM++C/nu1RgOPmZHk8KhMqOcNP2dCtMb4I 800Lbv1ZiYMlWvj7qE09npCuQNi1DkG5LPxwPDgaLAW2yy4pXKxtgD8foDBnfe1jve5h /KcjV5oVE5ctfC8KEbyt1ggh9TnFsazwa97p0bbKtlldl+DCrydyzHzukJPgh7PEpLVg QnkXTYQVMlwoDPs1U/5/nvJB3k5u73fC1M4/4ltRP3308fq9IvsXeqL/JTAhwWufwe4a 4KpaYRIZi2ZpNbQbjcFHlmOb/NfeVS8OSfJRZVO73Mqf5roIsf8DhXImKwGDsrAhVDJp D9dg== X-Gm-Message-State: AOAM531dy7IKgv6fJHHU28jtOH2NeCEhL1p9F2tj1nZbt/x4HLuqzpXx qNbNA6KhLuS8d9SqnsHzRo2tvRmS+IjubnMUAJyvLg== X-Google-Smtp-Source: ABdhPJxnakeCsIeusqxGOiH57rUIiE9gS1DlKbFj5pW3GBl5tNKGv95nzwlgEJzP4ve+0FfyN/FCxE/tKR0t7RUWsLQ= X-Received: by 2002:a2e:8190:: with SMTP id e16mr3684033ljg.81.1624373986663; Tue, 22 Jun 2021 07:59:46 -0700 (PDT) MIME-Version: 1.0 References: <20210621083108.17589-1-sj38.park@gmail.com> <20210621083108.17589-4-sj38.park@gmail.com> In-Reply-To: <20210621083108.17589-4-sj38.park@gmail.com> From: Shakeel Butt Date: Tue, 22 Jun 2021 07:59:35 -0700 Message-ID: Subject: Re: [PATCH v31 03/13] mm/damon: Adaptively adjust regions 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 > > Even somehow the initial monitoring target regions are well constructed > to fulfill the assumption (pages in same region have similar access > frequencies), the data access pattern can be dynamically changed. This > will result in low monitoring quality. To keep the assumption as much > as possible, DAMON adaptively merges and splits each region based on > their access frequency. > > For each ``aggregation interval``, it compares the access frequencies of > adjacent regions and merges those if the frequency difference is small. > Then, after it reports and clears the aggregated access frequency of > each region, it splits each region into two or three regions if the > total number of regions will not exceed the user-specified maximum > number of regions after the split. > > In this way, DAMON provides its best-effort quality and minimal overhead > while keeping the upper-bound overhead that users set. > > Signed-off-by: SeongJae Park > Reviewed-by: Leonard Foerster > Reviewed-by: Fernand Sieber [...] > > +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++; This bugs me everytime. Please just have nr_regions field in the damon_target instead of traversing the list to count the number of regions. Other than that, it looks good to me. 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.3 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 570F7C48BDF for ; Tue, 22 Jun 2021 14:59:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E5E5960234 for ; Tue, 22 Jun 2021 14:59:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E5E5960234 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 E07426B0072; Tue, 22 Jun 2021 10:59:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DB7826B0073; Tue, 22 Jun 2021 10:59:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C31566B0074; Tue, 22 Jun 2021 10:59:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0053.hostedemail.com [216.40.44.53]) by kanga.kvack.org (Postfix) with ESMTP id 872806B0072 for ; Tue, 22 Jun 2021 10:59:48 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id ACAA08249980 for ; Tue, 22 Jun 2021 14:59:48 +0000 (UTC) X-FDA: 78281669256.19.43C3498 Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) by imf23.hostedemail.com (Postfix) with ESMTP id 724B8A002D4D for ; Tue, 22 Jun 2021 14:59:48 +0000 (UTC) Received: by mail-lj1-f174.google.com with SMTP id k8so30398902lja.4 for ; Tue, 22 Jun 2021 07:59:48 -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=qwYAfiYXqjI2nwrVAYIcKqS0ZhT5P4dOm2JQEAubKpQ=; b=EUy5hSQvlr8ahlU4CaiCb2eNOofiUSD+vYfRdctNN157O9jl4+Qq6tJH0mQqexJocZ dFdPNn1PjMVEHq0IZrzaliNGMXUSDFSr0EdImVqstiim9tRoM3nKofzeXq7b/mU/6fty anECsJMjFdAuTnUKKVJ11E+l4p0WdjrMpeySt/wlkJTwGd7SsFHtEeXIXcNuTjGHMvif 9h2PLYOQfdmOMXX7EfR8VWZPsOkylWcIVTdCA+Bj5Me7VVI2kDE2ii9bRPqlXimNXQvk oD5k6m6h/LW9X2W11+sf10Dr+i9o0gQYG4rsiI9twScaF761lflMTuA++iJv/mB9b7z6 PwFg== 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=qwYAfiYXqjI2nwrVAYIcKqS0ZhT5P4dOm2JQEAubKpQ=; b=rfodahYDwW+fNZnTcsR2Aj3Z6Qa9zdjqbTshRfBKSIC/Z3gAtg+BhH2b8IjwIr6Yta XVwTl3dEx+Am1gK18AnWWRZqnLt3GzPBwSNxc6RwS3r9e0MKDL9sKv14L8DzdeaXkr3G 7ohlhDyXzGg8ohsTLRzVxZEfRfnCH/rDsHbEIKxcjDpnLlErz6kaoBPIzZVuzPvLMbTY D3Q+lbtLcIBXJnBi7A5e2m5EDKZhchLmpw+PYtll1p8hHKBprtdhKjlDl/EL1If8qOrI a9n3P9FV1McFTm11UbMfKrOsvTZw/klCLntyG//ClpeUyqIMcmB2DzU3j93TqX4nWpFN RajQ== X-Gm-Message-State: AOAM530yk2xe9IBain3ZiduyPssmBk9l6xS7W6FJGsFkorISKDsPUSU+ TN/EPniMANOVaP6mz2GMoo/X8fVm+O4R0reo9HEGjA== X-Google-Smtp-Source: ABdhPJxnakeCsIeusqxGOiH57rUIiE9gS1DlKbFj5pW3GBl5tNKGv95nzwlgEJzP4ve+0FfyN/FCxE/tKR0t7RUWsLQ= X-Received: by 2002:a2e:8190:: with SMTP id e16mr3684033ljg.81.1624373986663; Tue, 22 Jun 2021 07:59:46 -0700 (PDT) MIME-Version: 1.0 References: <20210621083108.17589-1-sj38.park@gmail.com> <20210621083108.17589-4-sj38.park@gmail.com> In-Reply-To: <20210621083108.17589-4-sj38.park@gmail.com> From: Shakeel Butt Date: Tue, 22 Jun 2021 07:59:35 -0700 Message-ID: Subject: Re: [PATCH v31 03/13] mm/damon: Adaptively adjust regions 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" X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 724B8A002D4D Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=EUy5hSQv; spf=pass (imf23.hostedemail.com: domain of shakeelb@google.com designates 209.85.208.174 as permitted sender) smtp.mailfrom=shakeelb@google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: uaw64y59c665q8ejx4ex9mxzaf4h18o6 X-HE-Tag: 1624373988-129119 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 > > Even somehow the initial monitoring target regions are well constructed > to fulfill the assumption (pages in same region have similar access > frequencies), the data access pattern can be dynamically changed. This > will result in low monitoring quality. To keep the assumption as much > as possible, DAMON adaptively merges and splits each region based on > their access frequency. > > For each ``aggregation interval``, it compares the access frequencies of > adjacent regions and merges those if the frequency difference is small. > Then, after it reports and clears the aggregated access frequency of > each region, it splits each region into two or three regions if the > total number of regions will not exceed the user-specified maximum > number of regions after the split. > > In this way, DAMON provides its best-effort quality and minimal overhead > while keeping the upper-bound overhead that users set. > > Signed-off-by: SeongJae Park > Reviewed-by: Leonard Foerster > Reviewed-by: Fernand Sieber [...] > > +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++; This bugs me everytime. Please just have nr_regions field in the damon_target instead of traversing the list to count the number of regions. Other than that, it looks good to me.