From patchwork Fri Dec 10 15:00:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12669741 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F0A7C433EF for ; Fri, 10 Dec 2021 15:04:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8ACC06B007D; Fri, 10 Dec 2021 10:00:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 85C2F6B007E; Fri, 10 Dec 2021 10:00:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 724486B0080; Fri, 10 Dec 2021 10:00:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0235.hostedemail.com [216.40.44.235]) by kanga.kvack.org (Postfix) with ESMTP id 5DD676B007E for ; Fri, 10 Dec 2021 10:00:50 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 1EFA6180ED7A5 for ; Fri, 10 Dec 2021 15:00:40 +0000 (UTC) X-FDA: 78902196240.21.B4ED284 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf05.hostedemail.com (Postfix) with ESMTP id 2BBE3100014 for ; Fri, 10 Dec 2021 15:00:39 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id F3F14CE211C; Fri, 10 Dec 2021 15:00:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC5FBC341C6; Fri, 10 Dec 2021 15:00:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1639148433; bh=0DBfCKxzXHXT13GYpJ/VzJt0LR3r7vy6DNUS7LwYu1Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G6DG/skQ7bdfCphAh9baNqLBid0tqgRbatRsHPCtdREM7GhXqgLz99V4JcfNB/J8q HE+V17nTS1sFjdWRNpVEFWIFT9te8nyDFbxC/fYlTcQe3S82Ie5trtmbp1XY9j53Wb LxTfFYvMhO4vXVSuA8HsnsOzNYuK4UDSKFbreP2JidwzDqRcsZxKncf43supyMplLl W/yJwk20AEQSav9EJSwa4YnKAsIdx3PgqxgoA0RlysSMa0OQtvRkoI895nW8okWXUG zOjMTaJlIKXt+LPoBDlyQFzLSi00Tlyca/EKQYB3SCzDZzQe1dHRx3l739GsgmPDFh VS6VGLCoK2P3A== From: SeongJae Park To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 1/6] mm/damon/schemes: Account scheme actions that successfully applied Date: Fri, 10 Dec 2021 15:00:11 +0000 Message-Id: <20211210150016.35349-2-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211210150016.35349-1-sj@kernel.org> References: <20211210150016.35349-1-sj@kernel.org> X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 2BBE3100014 X-Stat-Signature: 3y44imr5n4ouq5nzqc9yg7tnz4did3xj Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="G6DG/skQ"; spf=pass (imf05.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-HE-Tag: 1639148439-187341 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: DAMON-based operation schemes (DAMOS) stats provide only the number and the amount of regions that the action of the scheme has tried to be applied. Because the action could be failed for some reasons, the currently provided information is sometimes not useful or convenient enough for schemes profiling and tuning. To improve this situation, this commit extends the DAMOS stats to provide the number and the amount of regions that the action has successfully applied. Signed-off-by: SeongJae Park --- include/linux/damon.h | 28 +++++++++++++++++++++------- mm/damon/core.c | 13 ++++++++----- mm/damon/dbgfs.c | 2 +- mm/damon/paddr.c | 13 +++++++------ mm/damon/vaddr.c | 30 ++++++++++++++++-------------- 5 files changed, 53 insertions(+), 33 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 97f4a224e950..e0ad3d9aaeed 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -192,6 +192,20 @@ struct damos_watermarks { bool activated; }; +/** + * struct damos_stat - Statistics on a given scheme. + * @nr_tried: Total number of regions that the scheme is tried to be applied. + * @sz_tried: Total size of regions that the scheme is tried to be applied. + * @nr_applied: Total number of regions that the scheme is applied. + * @sz_applied: Total size of regions that the scheme is applied. + */ +struct damos_stat { + unsigned long nr_tried; + unsigned long sz_tried; + unsigned long nr_applied; + unsigned long sz_applied; +}; + /** * struct damos - Represents a Data Access Monitoring-based Operation Scheme. * @min_sz_region: Minimum size of target regions. @@ -203,8 +217,7 @@ struct damos_watermarks { * @action: &damo_action to be applied to the target regions. * @quota: Control the aggressiveness of this scheme. * @wmarks: Watermarks for automated (in)activation of this scheme. - * @stat_count: Total number of regions that this scheme is applied. - * @stat_sz: Total size of regions that this scheme is applied. + * @stat: Statistics of this scheme. * @list: List head for siblings. * * For each aggregation interval, DAMON finds regions which fit in the @@ -235,8 +248,7 @@ struct damos { enum damos_action action; struct damos_quota quota; struct damos_watermarks wmarks; - unsigned long stat_count; - unsigned long stat_sz; + struct damos_stat stat; struct list_head list; }; @@ -281,7 +293,8 @@ struct damon_ctx; * as an integer in [0, &DAMOS_MAX_SCORE]. * @apply_scheme is called from @kdamond when a region for user provided * DAMON-based operation scheme is found. It should apply the scheme's action - * to the region. + * to the region and return bytes of the region that the action is successfully + * applied. * @target_valid should check whether the target is still valid for the * monitoring. * @cleanup is called from @kdamond just before its termination. @@ -295,8 +308,9 @@ struct damon_primitive { int (*get_scheme_score)(struct damon_ctx *context, struct damon_target *t, struct damon_region *r, struct damos *scheme); - int (*apply_scheme)(struct damon_ctx *context, struct damon_target *t, - struct damon_region *r, struct damos *scheme); + unsigned long (*apply_scheme)(struct damon_ctx *context, + struct damon_target *t, struct damon_region *r, + struct damos *scheme); bool (*target_valid)(void *target); void (*cleanup)(struct damon_ctx *context); }; diff --git a/mm/damon/core.c b/mm/damon/core.c index 70771cf7da89..6d59047b8923 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -112,8 +112,7 @@ struct damos *damon_new_scheme( scheme->min_age_region = min_age_region; scheme->max_age_region = max_age_region; scheme->action = action; - scheme->stat_count = 0; - scheme->stat_sz = 0; + scheme->stat = (struct damos_stat){}; INIT_LIST_HEAD(&scheme->list); scheme->quota.ms = quota->ms; @@ -603,6 +602,7 @@ static void damon_do_apply_schemes(struct damon_ctx *c, struct damos_quota *quota = &s->quota; unsigned long sz = r->ar.end - r->ar.start; struct timespec64 begin, end; + unsigned long sz_applied = 0; if (!s->wmarks.activated) continue; @@ -665,7 +665,7 @@ static void damon_do_apply_schemes(struct damon_ctx *c, damon_split_region_at(c, t, r, sz); } ktime_get_coarse_ts64(&begin); - c->primitive.apply_scheme(c, t, r, s); + sz_applied = c->primitive.apply_scheme(c, t, r, s); ktime_get_coarse_ts64(&end); quota->total_charged_ns += timespec64_to_ns(&end) - timespec64_to_ns(&begin); @@ -679,8 +679,11 @@ static void damon_do_apply_schemes(struct damon_ctx *c, r->age = 0; update_stat: - s->stat_count++; - s->stat_sz += sz; + s->stat.nr_tried++; + s->stat.sz_tried += sz; + if (sz_applied) + s->stat.nr_applied++; + s->stat.sz_applied += sz_applied; } } diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c index 5b628990ae6e..ef79b7b7716d 100644 --- a/mm/damon/dbgfs.c +++ b/mm/damon/dbgfs.c @@ -117,7 +117,7 @@ static ssize_t sprint_schemes(struct damon_ctx *c, char *buf, ssize_t len) s->quota.weight_age, s->wmarks.metric, s->wmarks.interval, s->wmarks.high, s->wmarks.mid, s->wmarks.low, - s->stat_count, s->stat_sz); + s->stat.nr_tried, s->stat.sz_tried); if (!rc) return -ENOMEM; diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 4318134cbc4c..5e8244f65a1a 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -213,14 +213,15 @@ bool damon_pa_target_valid(void *t) return true; } -static int damon_pa_apply_scheme(struct damon_ctx *ctx, struct damon_target *t, - struct damon_region *r, struct damos *scheme) +static unsigned long damon_pa_apply_scheme(struct damon_ctx *ctx, + struct damon_target *t, struct damon_region *r, + struct damos *scheme) { - unsigned long addr; + unsigned long addr, applied; LIST_HEAD(page_list); if (scheme->action != DAMOS_PAGEOUT) - return -EINVAL; + return 0; for (addr = r->ar.start; addr < r->ar.end; addr += PAGE_SIZE) { struct page *page = damon_get_page(PHYS_PFN(addr)); @@ -241,9 +242,9 @@ static int damon_pa_apply_scheme(struct damon_ctx *ctx, struct damon_target *t, put_page(page); } } - reclaim_pages(&page_list); + applied = reclaim_pages(&page_list); cond_resched(); - return 0; + return applied * PAGE_SIZE; } static int damon_pa_scheme_score(struct damon_ctx *context, diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c index 68d9e4134816..a10df3fd3d02 100644 --- a/mm/damon/vaddr.c +++ b/mm/damon/vaddr.c @@ -572,32 +572,34 @@ bool damon_va_target_valid(void *target) } #ifndef CONFIG_ADVISE_SYSCALLS -static int damos_madvise(struct damon_target *target, struct damon_region *r, - int behavior) +static unsigned long damos_madvise(struct damon_target *target, + struct damon_region *r, int behavior) { - return -EINVAL; + return 0; } #else -static int damos_madvise(struct damon_target *target, struct damon_region *r, - int behavior) +static unsigned long damos_madvise(struct damon_target *target, + struct damon_region *r, int behavior) { struct mm_struct *mm; - int ret = -ENOMEM; + unsigned long start = PAGE_ALIGN(r->ar.start); + unsigned long len = PAGE_ALIGN(r->ar.end - r->ar.start); + unsigned long applied; mm = damon_get_mm(target); if (!mm) - goto out; + return 0; - ret = do_madvise(mm, PAGE_ALIGN(r->ar.start), - PAGE_ALIGN(r->ar.end - r->ar.start), behavior); + applied = do_madvise(mm, start, len, behavior) ? 0 : len; mmput(mm); -out: - return ret; + + return applied; } #endif /* CONFIG_ADVISE_SYSCALLS */ -static int damon_va_apply_scheme(struct damon_ctx *ctx, struct damon_target *t, - struct damon_region *r, struct damos *scheme) +static unsigned long damon_va_apply_scheme(struct damon_ctx *ctx, + struct damon_target *t, struct damon_region *r, + struct damos *scheme) { int madv_action; @@ -620,7 +622,7 @@ static int damon_va_apply_scheme(struct damon_ctx *ctx, struct damon_target *t, case DAMOS_STAT: return 0; default: - return -EINVAL; + return 0; } return damos_madvise(t, r, madv_action); From patchwork Fri Dec 10 15:00:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12669737 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A721C433F5 for ; Fri, 10 Dec 2021 15:03:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1D0236B0078; Fri, 10 Dec 2021 10:00:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 17EA06B007B; Fri, 10 Dec 2021 10:00:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 06C8A6B007D; Fri, 10 Dec 2021 10:00:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0232.hostedemail.com [216.40.44.232]) by kanga.kvack.org (Postfix) with ESMTP id EB0976B0078 for ; Fri, 10 Dec 2021 10:00:48 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id AD3DD84A31 for ; Fri, 10 Dec 2021 15:00:38 +0000 (UTC) X-FDA: 78902196156.21.A066D43 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf18.hostedemail.com (Postfix) with ESMTP id D9C6A1C001D for ; Fri, 10 Dec 2021 15:00:34 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 037CBB82879; Fri, 10 Dec 2021 15:00:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67EBDC341CB; Fri, 10 Dec 2021 15:00:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1639148433; bh=C2qhY6YuvnwZQD5xmb0IYoRaBXExlfMZfsAc2y0PKK0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GS2hX3w+lE7fcNOTyVglTF42x31DoN0vkwRQHi/ApqVwPrSX4dH3AtiCW1Y+qxBFq whwKGmAqCR5tRbgNqpJyVlBgwDbWGgMnPgGv2tIUBjGNnYKRX136NFFlMgK7YB4q9Q 1P29htK6lydrJacuP456jlVJS5k81QGBKPRwI0gz6/tcAg+pmpAz505UHK7Yvx+56B AzpfpR2f4dto5zTiz0zxW/9VdNyJyeoR50QrPeZSGNymUO748vUPi5yP0MtBVaGJiL tdWKmdjm4202Ru4T1eqy9XSziG1x/EYQ9QnxkY8S7kI9pd6x2GfwmOfMrtsoUqL2PR g8gshGOpJwyWA== From: SeongJae Park To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 2/6] mm/damon/schemes: Account how many times quota limit has exceeded Date: Fri, 10 Dec 2021 15:00:12 +0000 Message-Id: <20211210150016.35349-3-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211210150016.35349-1-sj@kernel.org> References: <20211210150016.35349-1-sj@kernel.org> X-Stat-Signature: wp64noniex6qkuebs8nom4cx3xm745r1 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GS2hX3w+; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf18.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: D9C6A1C001D X-HE-Tag: 1639148434-267018 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: If the time/space quotas of a given DAMON-based operation scheme is too small, the scheme could show unexpectedly slow progress. However, there is no good way to notice the case in runtime. This commit extends the DAMOS stat to provide how many times the quota limits exceeded so that the users can easily notice the case and tune the scheme. Signed-off-by: SeongJae Park --- include/linux/damon.h | 2 ++ mm/damon/core.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index e0ad3d9aaeed..af648388e759 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -198,12 +198,14 @@ struct damos_watermarks { * @sz_tried: Total size of regions that the scheme is tried to be applied. * @nr_applied: Total number of regions that the scheme is applied. * @sz_applied: Total size of regions that the scheme is applied. + * @qt_exceeds: Total number of times the quota of the scheme has exceeded. */ struct damos_stat { unsigned long nr_tried; unsigned long sz_tried; unsigned long nr_applied; unsigned long sz_applied; + unsigned long qt_exceeds; }; /** diff --git a/mm/damon/core.c b/mm/damon/core.c index 6d59047b8923..30d4b6e1a434 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -731,6 +731,8 @@ static void kdamond_apply_schemes(struct damon_ctx *c) if (time_after_eq(jiffies, quota->charged_from + msecs_to_jiffies( quota->reset_interval))) { + if (quota->esz && quota->charged_sz >= quota->esz) + s->stat.qt_exceeds++; quota->total_charged_sz += quota->charged_sz; quota->charged_from = jiffies; quota->charged_sz = 0; From patchwork Fri Dec 10 15:00:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12669739 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50F48C433EF for ; Fri, 10 Dec 2021 15:03:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3F30D6B007B; Fri, 10 Dec 2021 10:00:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3A3666B007D; Fri, 10 Dec 2021 10:00:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 269316B007E; Fri, 10 Dec 2021 10:00:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0056.hostedemail.com [216.40.44.56]) by kanga.kvack.org (Postfix) with ESMTP id 16C2C6B007B for ; Fri, 10 Dec 2021 10:00:50 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id CCD8E89133 for ; Fri, 10 Dec 2021 15:00:39 +0000 (UTC) X-FDA: 78902196198.25.7EC5C27 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf21.hostedemail.com (Postfix) with ESMTP id DDA691C0010 for ; Fri, 10 Dec 2021 15:00:37 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 0EFD3CE2B7E; Fri, 10 Dec 2021 15:00:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E86F7C341CE; Fri, 10 Dec 2021 15:00:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1639148434; bh=y8H2kQ+tPKgYwCE/ltPr01vYVYZxxqWoen6fskpcMaw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wt+UhGrlWtr+uavnEf3zkUDnl3VqoboivqmVA9ZYYNQoTMapB1x7/VQ5t0XpI17GV jiIVI7v7AhImubbO2iRL78fxCOtJ+++24nDn/pMd0H1pOQ/ax+cjM3vinSrZxkbWBQ X0C/2NOR3Cibp5pkt9il7zWAKL4ACoEW319XOce1BcOfMD/RsLZc1cIjPsfvoE4tw9 m9yXlgIQzrra2GTD2mwgUL9O42BvVoINfQXT7BNKPO77M1xS7YSdysuUfljwlhKVKl HFO+MAjolsO0jI76NFkC1NS+hoRl7i9Sh4s9wLOfhRCLYmRKJABIP8MJlBiZLapWP0 H5NO7PnHab0yg== From: SeongJae Park To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 3/6] mm/damon/reclaim: Provide reclamation statistics Date: Fri, 10 Dec 2021 15:00:13 +0000 Message-Id: <20211210150016.35349-4-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211210150016.35349-1-sj@kernel.org> References: <20211210150016.35349-1-sj@kernel.org> X-Stat-Signature: uz7587ab8au1us4arz6g35urzfkx3j6o Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Wt+UhGrl; spf=pass (imf21.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: DDA691C0010 X-HE-Tag: 1639148437-196914 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: This commit implements new DAMON_RECLAIM parameters for statistics reporting. Those can be used for understanding how DAMON_RECLAIM is working, and for tuning the other parameters. Signed-off-by: SeongJae Park --- mm/damon/reclaim.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index dc1485044eaf..bc476cef688e 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -185,6 +185,36 @@ module_param(monitor_region_end, ulong, 0600); static int kdamond_pid __read_mostly = -1; module_param(kdamond_pid, int, 0400); +/* + * Number of memory regions that tried to be reclaimed. + */ +static unsigned long nr_reclaim_tried_regions __read_mostly; +module_param(nr_reclaim_tried_regions, ulong, 0400); + +/* + * Total bytes of memory regions that tried to be reclaimed. + */ +static unsigned long bytes_reclaim_tried_regions __read_mostly; +module_param(bytes_reclaim_tried_regions, ulong, 0400); + +/* + * Number of memory regions that successfully be reclaimed. + */ +static unsigned long nr_reclaimed_regions __read_mostly; +module_param(nr_reclaimed_regions, ulong, 0400); + +/* + * Total bytes of memory regions that successfully be reclaimed. + */ +static unsigned long bytes_reclaimed_regions __read_mostly; +module_param(bytes_reclaimed_regions, ulong, 0400); + +/* + * Number of times that the time/space quota limits have exceeded + */ +static unsigned long nr_quota_exceeds __read_mostly; +module_param(nr_quota_exceeds, ulong, 0400); + static struct damon_ctx *ctx; static struct damon_target *target; @@ -333,6 +363,21 @@ static void damon_reclaim_timer_fn(struct work_struct *work) } static DECLARE_DELAYED_WORK(damon_reclaim_timer, damon_reclaim_timer_fn); +static int damon_reclaim_after_aggregation(struct damon_ctx *c) +{ + struct damos *s; + + /* update the stats parameter */ + damon_for_each_scheme(s, c) { + nr_reclaim_tried_regions = s->stat.nr_tried; + bytes_reclaim_tried_regions = s->stat.sz_tried; + nr_reclaimed_regions = s->stat.nr_applied; + bytes_reclaimed_regions = s->stat.sz_applied; + nr_quota_exceeds = s->stat.qt_exceeds; + } + return 0; +} + static int __init damon_reclaim_init(void) { ctx = damon_new_ctx(); @@ -340,6 +385,7 @@ static int __init damon_reclaim_init(void) return -ENOMEM; damon_pa_set_primitives(ctx); + ctx->callback.after_aggregation = damon_reclaim_after_aggregation; /* 4242 means nothing but fun */ target = damon_new_target(4242); From patchwork Fri Dec 10 15:00:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12669731 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88BC1C433EF for ; Fri, 10 Dec 2021 15:01:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 617756B0075; Fri, 10 Dec 2021 10:00:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5EB066B0072; Fri, 10 Dec 2021 10:00:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A5516B0078; Fri, 10 Dec 2021 10:00:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0047.hostedemail.com [216.40.44.47]) by kanga.kvack.org (Postfix) with ESMTP id 1EC086B0074 for ; Fri, 10 Dec 2021 10:00:48 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id DC39B894D8 for ; Fri, 10 Dec 2021 15:00:37 +0000 (UTC) X-FDA: 78902196114.06.E9B0CBD Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf17.hostedemail.com (Postfix) with ESMTP id C4A0940010 for ; Fri, 10 Dec 2021 15:00:34 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 156F7B82877; Fri, 10 Dec 2021 15:00:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76287C341CD; Fri, 10 Dec 2021 15:00:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1639148434; bh=Pbz9u8rLTWkTjeevVw9SjnPsm1pLh7jc6BKApdh3UKI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DCayG3+C7rKdtuQ/dkWkKIq6gQrhAgtYkHDlUIpdgjyu68t1MgQigzJobp55NaHoW NwVhBYlpvLFZ6jv2e6Hg0VvjqA/a3GKGVxIg8B0mH+YvQSlNoWwnRyyQhQuchB2ncR n5iupDLLJwNVzXfFAIIUQq0nZOQGf0w5A3WpeiAYkVWoYOnFadjUIB8Va82sexbdFC sXcvmEHrukDh0vwp3CXUA7E7RdjToXeK5CkmgiW47irbolZFWbZlMIV95/A2orURXE xLzgVF+ft75fYjo2CbFqIqxf3EBLnAffDKbLTRMiJGWR4ttmex862mhavLsf+xhLRN BtBzJJucdKiqQ== From: SeongJae Park To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 4/6] Docs/admin-guide/mm/damon/reclaim: Document statistics parameters Date: Fri, 10 Dec 2021 15:00:14 +0000 Message-Id: <20211210150016.35349-5-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211210150016.35349-1-sj@kernel.org> References: <20211210150016.35349-1-sj@kernel.org> X-Stat-Signature: weg8sbe6yjrfizsx55jozxkcaeipmkaq Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=DCayG3+C; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf17.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: C4A0940010 X-HE-Tag: 1639148434-187945 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: This commit adds descriptions for the DAMON_RECLAIM statistics parameters. Signed-off-by: SeongJae Park --- .../admin-guide/mm/damon/reclaim.rst | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Documentation/admin-guide/mm/damon/reclaim.rst b/Documentation/admin-guide/mm/damon/reclaim.rst index fb9def3a7355..0af51a9705b1 100644 --- a/Documentation/admin-guide/mm/damon/reclaim.rst +++ b/Documentation/admin-guide/mm/damon/reclaim.rst @@ -208,6 +208,31 @@ PID of the DAMON thread. If DAMON_RECLAIM is enabled, this becomes the PID of the worker thread. Else, -1. +nr_reclaim_tried_regions +------------------------ + +Number of memory regions that tried to be reclaimed by DAMON_RECLAIM. + +bytes_reclaim_tried_regions +--------------------------- + +Total bytes of memory regions that tried to be reclaimed by DAMON_RECLAIM. + +nr_reclaimed_regions +-------------------- + +Number of memory regions that successfully be reclaimed by DAMON_RECLAIM. + +bytes_reclaimed_regions +----------------------- + +Total bytes of memory regions that successfully be reclaimed by DAMON_RECLAIM. + +nr_quota_exceeds +---------------- + +Number of times that the time/space quota limits have exceeded. + Example ======= From patchwork Fri Dec 10 15:00:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12669729 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2BD3C433F5 for ; Fri, 10 Dec 2021 15:00:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 132F96B0071; Fri, 10 Dec 2021 10:00:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0E2996B0072; Fri, 10 Dec 2021 10:00:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EEC3A6B0074; Fri, 10 Dec 2021 10:00:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0175.hostedemail.com [216.40.44.175]) by kanga.kvack.org (Postfix) with ESMTP id E0E2F6B0071 for ; Fri, 10 Dec 2021 10:00:47 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id AC211181AF5D0 for ; Fri, 10 Dec 2021 15:00:37 +0000 (UTC) X-FDA: 78902196114.07.63D5384 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf08.hostedemail.com (Postfix) with ESMTP id 160B0160018 for ; Fri, 10 Dec 2021 15:00:35 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 944CEB8286F; Fri, 10 Dec 2021 15:00:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02F36C341CF; Fri, 10 Dec 2021 15:00:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1639148435; bh=2b/kJPy6Ru8lp4mLuBC4gZhE6gEGLdtczcdpxF4fXV8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IA6wPuKs8/wSWbByJbY83094uMyDXF4cihcUBuGdTNkLB+xqcdS7kvAaK+XX6p3PP YmH62jgVYIWn9BByLhZEOrGUh6KrkXbYrdf4oaUK4I76roB1iI/rsWRtIGsfU+YZ63 4JM9r429ufnL/AbYEgw79x1PZWsgAAYIdKBPSNyrHmoU9SFP5/l5veDCfnk2GWXAPx /xPerIXRdUYid/Pbdd1zUXSgYxHoKpbQN4VRqpSrp2ASfWzdhHNOsjov8lrvRddhad PUWbpOpUi0FGwT5opBYcSUxIJu2sNBOrgebjNY4s1DS1iVnJAKI6MQBbHshZ+Aht4H o52UESh7tSydQ== From: SeongJae Park To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 5/6] mm/damon/dbgfs: Support all DAMOS stats Date: Fri, 10 Dec 2021 15:00:15 +0000 Message-Id: <20211210150016.35349-6-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211210150016.35349-1-sj@kernel.org> References: <20211210150016.35349-1-sj@kernel.org> X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 160B0160018 X-Stat-Signature: stwj9ozh71unf7hnb8wycwrpg6oqjfuc Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=IA6wPuKs; spf=pass (imf08.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-HE-Tag: 1639148435-410645 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: Currently, DAMON debugfs interface is not supporting DAMON-based Operation Schemes (DAMOS) stats for schemes successfully applied regions and time/space quota limit exceeds. This commit adds the support. Signed-off-by: SeongJae Park --- mm/damon/dbgfs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c index ef79b7b7716d..58dbb9692279 100644 --- a/mm/damon/dbgfs.c +++ b/mm/damon/dbgfs.c @@ -105,7 +105,7 @@ static ssize_t sprint_schemes(struct damon_ctx *c, char *buf, ssize_t len) damon_for_each_scheme(s, c) { rc = scnprintf(&buf[written], len - written, - "%lu %lu %u %u %u %u %d %lu %lu %lu %u %u %u %d %lu %lu %lu %lu %lu %lu\n", + "%lu %lu %u %u %u %u %d %lu %lu %lu %u %u %u %d %lu %lu %lu %lu %lu %lu %lu %lu %lu\n", s->min_sz_region, s->max_sz_region, s->min_nr_accesses, s->max_nr_accesses, s->min_age_region, s->max_age_region, @@ -117,7 +117,9 @@ static ssize_t sprint_schemes(struct damon_ctx *c, char *buf, ssize_t len) s->quota.weight_age, s->wmarks.metric, s->wmarks.interval, s->wmarks.high, s->wmarks.mid, s->wmarks.low, - s->stat.nr_tried, s->stat.sz_tried); + s->stat.nr_tried, s->stat.sz_tried, + s->stat.nr_applied, s->stat.sz_applied, + s->stat.qt_exceeds); if (!rc) return -ENOMEM; From patchwork Fri Dec 10 15:00:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12669735 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E069C433F5 for ; Fri, 10 Dec 2021 15:02:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BB4D06B0074; Fri, 10 Dec 2021 10:00:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E3376B007B; Fri, 10 Dec 2021 10:00:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 74DA46B0078; Fri, 10 Dec 2021 10:00:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0073.hostedemail.com [216.40.44.73]) by kanga.kvack.org (Postfix) with ESMTP id 481416B0074 for ; Fri, 10 Dec 2021 10:00:48 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id EF5C2180EB6EF for ; Fri, 10 Dec 2021 15:00:37 +0000 (UTC) X-FDA: 78902196114.24.4319509 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf12.hostedemail.com (Postfix) with ESMTP id A54774000A for ; Fri, 10 Dec 2021 15:00:35 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 20C77B8287C; Fri, 10 Dec 2021 15:00:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82C03C341C5; Fri, 10 Dec 2021 15:00:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1639148435; bh=4d4SLklUxQ2JQcAHxAn5MLm1T/njPSHJ9DpKaw+ZmvM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f0SDocJ2hOpYjfmxziuXYpl0FwZsFru7efEfq6frz/DfpYtFEj2pfi6ymZ4l0CHie 4Ou9chp6LFdmTP+NcgeQ+0taSYepL8rjWIhKvCEQGbv3iG0Oqn/m4znSv+cdLm1kxe y8VbHqcEZr2dF1j2WLZImzOXA/OgkDWR2eGeNiFjr18gZGk44t55nOPlcpg294wwkH IzozUj8iVerleJBiFH+jFU9LnqU2mjU1txIzuHO1/u29NQAy0WB+6oTFO1a2gbOfrl HZX0PTI8nEr17fVXeDzrvuTsS4UtG0u6rdQK0ML71HRX1R5whpu+XRZcWi9NWJjCAb lTenzDOsqG3oA== From: SeongJae Park To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 6/6] Docs/admin-guide/mm/damon/usage: Update for schemes statistics Date: Fri, 10 Dec 2021 15:00:16 +0000 Message-Id: <20211210150016.35349-7-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211210150016.35349-1-sj@kernel.org> References: <20211210150016.35349-1-sj@kernel.org> X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: A54774000A X-Stat-Signature: 7f45ko6ydots1c7rgt1uybu3o4gdboiy Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=f0SDocJ2; spf=pass (imf12.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-HE-Tag: 1639148435-491230 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: This commit updates DAMON debugfs interface for statistics of schemes successfully applied regions and time/space quota limit exceeds counts. Signed-off-by: SeongJae Park --- Documentation/admin-guide/mm/damon/usage.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst index cb614c84ba9e..59b84904a854 100644 --- a/Documentation/admin-guide/mm/damon/usage.rst +++ b/Documentation/admin-guide/mm/damon/usage.rst @@ -223,12 +223,13 @@ is activated. Statistics ~~~~~~~~~~ -It also counts the total number and bytes of regions that each scheme is -applied. This statistics can be used for online analysis or tuning of the -schemes. +It also counts the total number and bytes of regions that each scheme is tried +to be applied, the two numbers for the regions that each scheme is successfully +applied, and the total number of the quota limit exceeds. This statistics can +be used for online analysis or tuning of the schemes. The statistics can be shown by reading the ``schemes`` file. Reading the file -will show each scheme you entered in each line, and the two numbers for the +will show each scheme you entered in each line, and the five numbers for the statistics will be added at the end of each line. Example