* [PATCH v2] mm: Fix memcg writeback for rt tasks
@ 2023-04-11 8:22 yizhou.tang
2023-04-11 11:21 ` Jan Kara
0 siblings, 1 reply; 3+ messages in thread
From: yizhou.tang @ 2023-04-11 8:22 UTC (permalink / raw)
To: neilb, tj, wufengguang
Cc: jack, linux-mm, linux-kernel, tangyeechou, chunguang.xu,
yue.zhao, Tang Yizhou
From: Tang Yizhou <yizhou.tang@shopee.com>
In domain_dirty_limits(), the calculation of the thresh and bg_thresh
variable needs to consider whether it's for global dirtypage writeback
or memcg dirtypage writeback. However, in the rt_task branch, the
accumulation of both variables only considers the global_wb_domain,
which seems strange to me.
I find the accumulation was introduced in the commit a53eaff8c119 ("MM:
increase safety margin provided by PF_LESS_THROTTLE"). IMHO, realtime
tasks are given a higher page cache limit because they require higher
responsiveness, but we also need to consider whether the writeback of
realtime tasks occurs in the global dirtypage writeback or in the memcg
dirtypage writeback scenario.
Later Neil said he didn't know what was wanted for realtime in the
commit message of commit a37b0715ddf3 ("mm/writeback: replace
PF_LESS_THROTTLE with PF_LOCAL_THROTTLE"). I guess he made this small
mistake since the commit a53eaff8c119 ("MM: increase safety margin
provided by PF_LESS_THROTTLE").
Fixes: a53eaff8c119 ("MM: increase safety margin provided by PF_LESS_THROTTLE")
CC: NeilBrown <neilb@suse.com>
CC: Tejun Heo <tj@kernel.org>
CC: Fengguang Wu <wufengguang@huawei.com>
Signed-off-by: Tang Yizhou <yizhou.tang@shopee.com>
---
v2:
Rewrite the commit message.
mm/page-writeback.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 516b1aa247e8..7d92de73360e 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -419,8 +419,8 @@ static void domain_dirty_limits(struct dirty_throttle_control *dtc)
bg_thresh = thresh / 2;
tsk = current;
if (rt_task(tsk)) {
- bg_thresh += bg_thresh / 4 + global_wb_domain.dirty_limit / 32;
- thresh += thresh / 4 + global_wb_domain.dirty_limit / 32;
+ bg_thresh += bg_thresh / 4 + dtc_dom(dtc)->dirty_limit / 32;
+ thresh += thresh / 4 + dtc_dom(dtc)->dirty_limit / 32;
}
dtc->thresh = thresh;
dtc->bg_thresh = bg_thresh;
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] mm: Fix memcg writeback for rt tasks
2023-04-11 8:22 [PATCH v2] mm: Fix memcg writeback for rt tasks yizhou.tang
@ 2023-04-11 11:21 ` Jan Kara
2023-04-21 14:57 ` Tang Yizhou
0 siblings, 1 reply; 3+ messages in thread
From: Jan Kara @ 2023-04-11 11:21 UTC (permalink / raw)
To: yizhou.tang
Cc: neilb, tj, wufengguang, jack, linux-mm, linux-kernel,
tangyeechou, chunguang.xu, yue.zhao
On Tue 11-04-23 16:22:48, yizhou.tang@shopee.com wrote:
> From: Tang Yizhou <yizhou.tang@shopee.com>
>
> In domain_dirty_limits(), the calculation of the thresh and bg_thresh
> variable needs to consider whether it's for global dirtypage writeback
> or memcg dirtypage writeback. However, in the rt_task branch, the
> accumulation of both variables only considers the global_wb_domain,
> which seems strange to me.
>
> I find the accumulation was introduced in the commit a53eaff8c119 ("MM:
> increase safety margin provided by PF_LESS_THROTTLE"). IMHO, realtime
> tasks are given a higher page cache limit because they require higher
> responsiveness, but we also need to consider whether the writeback of
> realtime tasks occurs in the global dirtypage writeback or in the memcg
> dirtypage writeback scenario.
>
> Later Neil said he didn't know what was wanted for realtime in the
> commit message of commit a37b0715ddf3 ("mm/writeback: replace
> PF_LESS_THROTTLE with PF_LOCAL_THROTTLE"). I guess he made this small
> mistake since the commit a53eaff8c119 ("MM: increase safety margin
> provided by PF_LESS_THROTTLE").
>
> Fixes: a53eaff8c119 ("MM: increase safety margin provided by PF_LESS_THROTTLE")
> CC: NeilBrown <neilb@suse.com>
> CC: Tejun Heo <tj@kernel.org>
> CC: Fengguang Wu <wufengguang@huawei.com>
> Signed-off-by: Tang Yizhou <yizhou.tang@shopee.com>
Thanks for the patch! Was this found just by code inspection or is there
any practical problem you are trying to fix with this patch?
> diff --git a/mm/page-writeback.c b/mm/page-writeback.c
> index 516b1aa247e8..7d92de73360e 100644
> --- a/mm/page-writeback.c
> +++ b/mm/page-writeback.c
> @@ -419,8 +419,8 @@ static void domain_dirty_limits(struct dirty_throttle_control *dtc)
> bg_thresh = thresh / 2;
> tsk = current;
> if (rt_task(tsk)) {
> - bg_thresh += bg_thresh / 4 + global_wb_domain.dirty_limit / 32;
> - thresh += thresh / 4 + global_wb_domain.dirty_limit / 32;
> + bg_thresh += bg_thresh / 4 + dtc_dom(dtc)->dirty_limit / 32;
> + thresh += thresh / 4 + dtc_dom(dtc)->dirty_limit / 32;
This makes sense but I'm not 100% sure this does not reintroduce the
problem a53eaff8c119 was trying to fix. Reading the changelog, it seems the
extra term you are fixing is there specifically to deal with ratelimiting,
which is global (and not per-memcg), of calls to balance_dirty_pages() and
hence using global_wb_domain.dirty_limit is indeed correct. Neil?
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] mm: Fix memcg writeback for rt tasks
2023-04-11 11:21 ` Jan Kara
@ 2023-04-21 14:57 ` Tang Yizhou
0 siblings, 0 replies; 3+ messages in thread
From: Tang Yizhou @ 2023-04-21 14:57 UTC (permalink / raw)
To: Jan Kara
Cc: neilb, tj, wufengguang, linux-mm, linux-kernel, hch, mhocko,
tangyeechou, chunguang.xu, yue.zhao
CC Christoph Hellwig and Michal Hocko.
On Tue, Apr 11, 2023 at 7:21 PM Jan Kara <jack@suse.cz> wrote:
>
> On Tue 11-04-23 16:22:48, yizhou.tang@shopee.com wrote:
> > From: Tang Yizhou <yizhou.tang@shopee.com>
> >
> > In domain_dirty_limits(), the calculation of the thresh and bg_thresh
> > variable needs to consider whether it's for global dirtypage writeback
> > or memcg dirtypage writeback. However, in the rt_task branch, the
> > accumulation of both variables only considers the global_wb_domain,
> > which seems strange to me.
> >
> > I find the accumulation was introduced in the commit a53eaff8c119 ("MM:
> > increase safety margin provided by PF_LESS_THROTTLE"). IMHO, realtime
> > tasks are given a higher page cache limit because they require higher
> > responsiveness, but we also need to consider whether the writeback of
> > realtime tasks occurs in the global dirtypage writeback or in the memcg
> > dirtypage writeback scenario.
> >
> > Later Neil said he didn't know what was wanted for realtime in the
> > commit message of commit a37b0715ddf3 ("mm/writeback: replace
> > PF_LESS_THROTTLE with PF_LOCAL_THROTTLE"). I guess he made this small
> > mistake since the commit a53eaff8c119 ("MM: increase safety margin
> > provided by PF_LESS_THROTTLE").
> >
> > Fixes: a53eaff8c119 ("MM: increase safety margin provided by PF_LESS_THROTTLE")
> > CC: NeilBrown <neilb@suse.com>
> > CC: Tejun Heo <tj@kernel.org>
> > CC: Fengguang Wu <wufengguang@huawei.com>
> > Signed-off-by: Tang Yizhou <yizhou.tang@shopee.com>
>
> Thanks for the patch! Was this found just by code inspection or is there
> any practical problem you are trying to fix with this patch?
>
> > diff --git a/mm/page-writeback.c b/mm/page-writeback.c
> > index 516b1aa247e8..7d92de73360e 100644
> > --- a/mm/page-writeback.c
> > +++ b/mm/page-writeback.c
> > @@ -419,8 +419,8 @@ static void domain_dirty_limits(struct dirty_throttle_control *dtc)
> > bg_thresh = thresh / 2;
> > tsk = current;
> > if (rt_task(tsk)) {
> > - bg_thresh += bg_thresh / 4 + global_wb_domain.dirty_limit / 32;
> > - thresh += thresh / 4 + global_wb_domain.dirty_limit / 32;
> > + bg_thresh += bg_thresh / 4 + dtc_dom(dtc)->dirty_limit / 32;
> > + thresh += thresh / 4 + dtc_dom(dtc)->dirty_limit / 32;
>
> This makes sense but I'm not 100% sure this does not reintroduce the
> problem a53eaff8c119 was trying to fix. Reading the changelog, it seems the
> extra term you are fixing is there specifically to deal with ratelimiting,
> which is global (and not per-memcg), of calls to balance_dirty_pages() and
> hence using global_wb_domain.dirty_limit is indeed correct. Neil?
>
> Honza
> --
> Jan Kara <jack@suse.com>
> SUSE Labs, CR
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-04-21 14:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-11 8:22 [PATCH v2] mm: Fix memcg writeback for rt tasks yizhou.tang
2023-04-11 11:21 ` Jan Kara
2023-04-21 14:57 ` Tang Yizhou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox