From patchwork Fri Feb 18 10:26:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonghyeon Kim X-Patchwork-Id: 12751278 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 D39F0C433F5 for ; Fri, 18 Feb 2022 10:26:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6D3A16B0075; Fri, 18 Feb 2022 05:26:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 65C5C6B0078; Fri, 18 Feb 2022 05:26:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4D6806B007B; Fri, 18 Feb 2022 05:26:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0143.hostedemail.com [216.40.44.143]) by kanga.kvack.org (Postfix) with ESMTP id 3F9EC6B0075 for ; Fri, 18 Feb 2022 05:26:55 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 0CB7E180FC138 for ; Fri, 18 Feb 2022 10:26:55 +0000 (UTC) X-FDA: 79155522390.06.9E40500 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by imf13.hostedemail.com (Postfix) with ESMTP id 9DA9A20005 for ; Fri, 18 Feb 2022 10:26:54 +0000 (UTC) Received: by mail-pj1-f49.google.com with SMTP id a11-20020a17090a740b00b001b8b506c42fso12014777pjg.0 for ; Fri, 18 Feb 2022 02:26:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ajou.ac.kr; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=48kB5lAYgSfFmsICPZUMRy13W44Wv8CdeSdM5zh36Ro=; b=W3astCwwAyNQranzslt+8SIVB9svslnNne9hAGV/MpxQw0cP0JbyeBOEZWHKEgcYDw eOrC4GquiAZGyMgCCpI9y1/lx0HkTTsehtY3KV73v6w/8qmqjQnPvlTQIvSLjiI0eRu/ P6UFKhgUola5sBEkHxBF5NPbMKzYmwHN05py0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=48kB5lAYgSfFmsICPZUMRy13W44Wv8CdeSdM5zh36Ro=; b=2eqPsbEOmnHH1niisIYWYV5G6ZX2gNQwdUYMAf0g97i5dUZa1GV4+HzJWJxSC0q/Zr H5PNWTl5Z5PEUTQUk8o8W4aP0PrryHT9PvX5XAJWwM+oMAWZkY4nqS34mvfawgZqqi2C o6qd4eGlr1EzkFmutlH/c+tHQna22J4KYACq5Zzwc0Z+5rE0GXGc7AJS525IhHuQtphm K5/oXhN5IOQH8+wYWf9IV6o8j68rCtet8R0TlooHP5ufRgKyvdyKLSZDlmqVdNftLOQj 0B54a7DVo4VuZkVKouBMBu6ZejU3LD3YqU0F6p5kNPdJIcgtTCcGNw2AUv2ceXGOt4J/ 8kyQ== X-Gm-Message-State: AOAM531L8thME2JNNtfU//06v/6LI+F5dwCCbKcQY4yq8Gn5OaGcK5MD RDF9ft+r5HtFgvhp75TEG2hxMg== X-Google-Smtp-Source: ABdhPJw7BKEUMMQFo15QZFrb31FFqmsj+eQYpuHpVdwZyvtZncX1W/2Fxnh8PllN3pxemTfjNuGIkQ== X-Received: by 2002:a17:902:6902:b0:14d:6aa4:f3f5 with SMTP id j2-20020a170902690200b0014d6aa4f3f5mr6987246plk.20.1645180013550; Fri, 18 Feb 2022 02:26:53 -0800 (PST) Received: from localhost.localdomain ([210.107.197.32]) by smtp.googlemail.com with ESMTPSA id k13sm2767696pfc.176.2022.02.18.02.26.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Feb 2022 02:26:53 -0800 (PST) From: Jonghyeon Kim To: akpm@linux-foundation.org Cc: Jonghyeon Kim , Jonathan.Cameron@Huawei.com, amit@kernel.org, benh@kernel.crashing.org, corbet@lwn.net, david@redhat.com, dwmw@amazon.com, elver@google.com, foersleo@amazon.de, gthelen@google.com, markubo@amazon.de, rientjes@google.com, shakeelb@google.com, shuah@kernel.org, linux-damon@amazon.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v1 1/3] mm/damon: Rebase damos watermarks for NUMA systems Date: Fri, 18 Feb 2022 19:26:09 +0900 Message-Id: <20220218102611.31895-2-tome01@ajou.ac.kr> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220218102611.31895-1-tome01@ajou.ac.kr> References: <20220218102611.31895-1-tome01@ajou.ac.kr> X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 9DA9A20005 X-Rspam-User: Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=ajou.ac.kr header.s=google header.b=W3astCww; spf=pass (imf13.hostedemail.com: domain of tome01@ajou.ac.kr designates 209.85.216.49 as permitted sender) smtp.mailfrom=tome01@ajou.ac.kr; dmarc=pass (policy=reject) header.from=ajou.ac.kr X-Stat-Signature: mo6g779xmtx84q8nbi4i8fnispfmt4hn X-HE-Tag: 1645180014-422903 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000049, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: For NUMA systems, there is a need to allow damos to select watermark options for monitoring each NUMA node or whole system free memory. Even if we do not use NUMA, since the default NUMA node number is 0, we can monitor the whole system memory without any configuration. Signed-off-by: Jonghyeon Kim --- include/linux/damon.h | 2 ++ mm/damon/core.c | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 49c4a11ecf20..c0adf1566603 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -170,6 +170,7 @@ enum damos_wmark_metric { * @high: High watermark. * @mid: Middle watermark. * @low: Low watermark. + * @node: NUMA node for the watermarks. * * If &metric is &DAMOS_WMARK_NONE, the scheme is always active. Being active * means DAMON does monitoring and applying the action of the scheme to @@ -186,6 +187,7 @@ struct damos_watermarks { unsigned long high; unsigned long mid; unsigned long low; + int node; /* private: */ bool activated; diff --git a/mm/damon/core.c b/mm/damon/core.c index 82e0a4620c4f..290c9c0535ee 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -179,6 +179,7 @@ struct damos *damon_new_scheme( scheme->wmarks.high = wmarks->high; scheme->wmarks.mid = wmarks->mid; scheme->wmarks.low = wmarks->low; + scheme->wmarks.node = wmarks->node; scheme->wmarks.activated = true; return scheme; @@ -951,14 +952,15 @@ static bool kdamond_need_stop(struct damon_ctx *ctx) return true; } -static unsigned long damos_wmark_metric_value(enum damos_wmark_metric metric) +static unsigned long damos_wmark_metric_value(struct damos_watermarks wmarks) { - struct sysinfo i; + unsigned long nr_total, nr_free; - switch (metric) { + switch (wmarks.metric) { case DAMOS_WMARK_FREE_MEM_RATE: - si_meminfo(&i); - return i.freeram * 1000 / i.totalram; + nr_total = node_present_pages(wmarks.node); + nr_free = sum_zone_node_page_state(wmarks.node, NR_FREE_PAGES); + return nr_free * 1000 / nr_total; default: break; } @@ -976,7 +978,7 @@ static unsigned long damos_wmark_wait_us(struct damos *scheme) if (scheme->wmarks.metric == DAMOS_WMARK_NONE) return 0; - metric = damos_wmark_metric_value(scheme->wmarks.metric); + metric = damos_wmark_metric_value(scheme->wmarks); /* higher than high watermark or lower than low watermark */ if (metric > scheme->wmarks.high || scheme->wmarks.low > metric) { if (scheme->wmarks.activated)