Message ID | 20220218102611.31895-2-tome01@ajou.ac.kr (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Rebase DAMON_RECALIM for NUMA system | expand |
Hello Jonghyeon, On Fri, 18 Feb 2022 19:26:09 +0900 Jonghyeon Kim <tome01@ajou.ac.kr> wrote: > 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. Some users using NUMA machines but don't do NUMA-specific memory allocations and therefore assume memory free rate in each NUMA node will be similar might want to monitor only global free memory ratio, to limit number of kdamonds for reducing CPU overhead. In the case, this patch would make them monitor only the first node. How about leaving DAMOS_WMARK_FREE_MEM_RATE to work as is, and adding a new metric type, say, DAMOS_WMARK_NODE_FREE_MEM_RATE? Thanks, SJ > > Signed-off-by: Jonghyeon Kim <tome01@ajou.ac.kr> > --- > 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) > -- > 2.17.1 > >
On Wed, Feb 23, 2022 at 02:10:56PM +0900, Jonghyeon Kim wrote: > On Tue, Feb 22, 2022 at 09:53:17AM +0000, SeongJae Park wrote: > > Hello Jonghyeon, > > > > Hello SeongJae, > > > On Fri, 18 Feb 2022 19:26:09 +0900 Jonghyeon Kim <tome01@ajou.ac.kr> wrote: > > > > > 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. > > > > Some users using NUMA machines but don't do NUMA-specific memory allocations > > and therefore assume memory free rate in each NUMA node will be similar might > > want to monitor only global free memory ratio, to limit number of kdamonds for > > reducing CPU overhead. In the case, this patch would make them monitor only > > the first node. > > I think that the purpose of DAMON_RECALIM is proactively reclaiming memory > before waking up kswapd. But I missed that case you mentioned. In that case, > they might not want to monitor each NUMA node. I agree with this. > > > > > How about leaving DAMOS_WMARK_FREE_MEM_RATE to work as is, and adding a new > > metric type, say, DAMOS_WMARK_NODE_FREE_MEM_RATE? > > > > Yes, it looks good to me. > > > Thanks, > Jonghyeon
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)
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 <tome01@ajou.ac.kr> --- include/linux/damon.h | 2 ++ mm/damon/core.c | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-)