Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d60d1bdd authored by Tejun Heo's avatar Tejun Heo Committed by Jens Axboe
Browse files

writeback: memcg dirty_throttle_control should be initialized with wb->memcg_completions



MDTC_INIT() is used to initialize dirty_throttle_control for memcg
domains.  It used DTC_INIT_COMMON() to initialized mdtc->wb and
->wb_completions which is incorrect as DTC_INIT_COMMON() sets the
latter to wb->completions instead of wb->memcg_completions.  This can
lead to wildly incorrect results when calculating the proportion of
dirty memory the memcg domain should get.

Remove DTC_INIT_COMMON() and update MDTC_INIT() to initialize
mdtc->wb_completions to wb->memcg_completions.

Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Fixes: c2aa723a ("writeback: implement memcg writeback domain based throttling")
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent b817525a
Loading
Loading
Loading
Loading
+11 −9
Original line number Original line Diff line number Diff line
@@ -145,9 +145,6 @@ struct dirty_throttle_control {
	unsigned long		pos_ratio;
	unsigned long		pos_ratio;
};
};


#define DTC_INIT_COMMON(__wb)	.wb = (__wb),				\
				.wb_completions = &(__wb)->completions

/*
/*
 * Length of period for aging writeout fractions of bdis. This is an
 * Length of period for aging writeout fractions of bdis. This is an
 * arbitrarily chosen number. The longer the period, the slower fractions will
 * arbitrarily chosen number. The longer the period, the slower fractions will
@@ -157,12 +154,16 @@ struct dirty_throttle_control {


#ifdef CONFIG_CGROUP_WRITEBACK
#ifdef CONFIG_CGROUP_WRITEBACK


#define GDTC_INIT(__wb)		.dom = &global_wb_domain,		\
#define GDTC_INIT(__wb)		.wb = (__wb),				\
				DTC_INIT_COMMON(__wb)
				.dom = &global_wb_domain,		\
				.wb_completions = &(__wb)->completions

#define GDTC_INIT_NO_WB		.dom = &global_wb_domain
#define GDTC_INIT_NO_WB		.dom = &global_wb_domain
#define MDTC_INIT(__wb, __gdtc)	.dom = mem_cgroup_wb_domain(__wb),	\

				.gdtc = __gdtc,				\
#define MDTC_INIT(__wb, __gdtc)	.wb = (__wb),				\
				DTC_INIT_COMMON(__wb)
				.dom = mem_cgroup_wb_domain(__wb),	\
				.wb_completions = &(__wb)->memcg_completions, \
				.gdtc = __gdtc


static bool mdtc_valid(struct dirty_throttle_control *dtc)
static bool mdtc_valid(struct dirty_throttle_control *dtc)
{
{
@@ -213,7 +214,8 @@ static void wb_min_max_ratio(struct bdi_writeback *wb,


#else	/* CONFIG_CGROUP_WRITEBACK */
#else	/* CONFIG_CGROUP_WRITEBACK */


#define GDTC_INIT(__wb)		DTC_INIT_COMMON(__wb)
#define GDTC_INIT(__wb)		.wb = (__wb),                           \
				.wb_completions = &(__wb)->completions
#define GDTC_INIT_NO_WB
#define GDTC_INIT_NO_WB
#define MDTC_INIT(__wb, __gdtc)
#define MDTC_INIT(__wb, __gdtc)