Skip to contentSkip to conversation

mm: introduce validity check on vm dirtiness settings

PATCH Superseded Yafang Shao 2 participants 2 messages Sep 21, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 mm: introduce validity check on vm dirtiness settings

we can find the logic in domain_dirty_limits() that when dirty bg_thresh is bigger than dirty thresh, bg_thresh will be set as thresh * 1 / 2.

	if (bg_thresh >= thresh)
		bg_thresh = thresh / 2;

But actually we can set vm background dirtiness bigger than vm dirtiness successfully. This behavior may mislead us. We'd better do this validity check at the beginning.

---
 Documentation/sysctl/vm.txt |  6 ++++
 kernel/sysctl.c             |  4 +--
 mm/page-writeback.c         | 80 ++++++++++++++++++++++++++++++++++++++++-----
 3 files changed, 80 insertions(+), 10 deletions(-)
Documentation/sysctl/vm.txt +6 -0
index 9baf66a..0bab85d 100644
@@ -156,6 +156,9 @@ read.
 Note: the minimum value allowed for dirty_bytes is two pages (in bytes); any
 value lower than this limit will be ignored and the old configuration will be
 retained.
+Note: the value of dirty_bytes also cannot be set lower than
+dirty_background_bytes or the amount of memory corresponding to
+dirty_background_ratio.
 
 ==============================================================
 
@@ -176,6 +179,9 @@ generating disk writes will itself start writing out dirty data.
 
 The total available memory is not equal to total system memory.
 
+Note: dirty_ratio cannot be set lower than dirty_background_ratio or
+ratio corresponding to dirty_background_bytes.
+
 ==============================================================
 
 dirty_writeback_centisecs
kernel/sysctl.c +2 -2
index 6648fbb..7b525cf 100644
@@ -1293,7 +1293,7 @@ static int sysrq_sysctl_handler(struct ctl_table *table, int write,
 		.maxlen		= sizeof(dirty_background_ratio),
 		.mode		= 0644,
 		.proc_handler	= dirty_background_ratio_handler,
-		.extra1		= &zero,
+		.extra1		= &one,
 		.extra2		= &one_hundred,
 	},
 	{
@@ -1310,7 +1310,7 @@ static int sysrq_sysctl_handler(struct ctl_table *table, int write,
 		.maxlen		= sizeof(vm_dirty_ratio),
 		.mode		= 0644,
 		.proc_handler	= dirty_ratio_handler,
-		.extra1		= &zero,
+		.extra1		= &one,
 		.extra2		= &one_hundred,
 	},
 	{
mm/page-writeback.c +72 -8

113 lines not on this page · raw message

Signature · 7 lines
1.8.3.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
maintainer Reviewed-by on v4 1/1
#1 lore raw
Quoted 11 lines · Yafang Shao

we can find the logic in domain_dirty_limits() that when dirty bg_thresh is bigger than dirty thresh, bg_thresh will be set as thresh * 1 / 2.

	if (bg_thresh >= thresh)
		bg_thresh = thresh / 2;

But actually we can set vm background dirtiness bigger than vm dirtiness successfully. This behavior may mislead us. We'd better do this validity check at the beginning.

Looks good. You can add:

Just one nit below:

mm/page-writeback.c bool node_dirty_ok(struct pglist_data *pgdat) · line 560

Quoted 3 lines
mm/page-writeback.c +3 -0
+
+    /* needn't do validity check if the value is not different. */
+	if (ret == 0 && write && dirty_background_ratio != old_ratio) {

Whitespace before the comment is broken. Generally I don't think the comment brings much so I'd just delete it.

Honza

Signature · 8 lines
Jan Kara <[email protected]>
SUSE Labs, CR

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>