Skip to contentSkip to conversation

swap: cond_resched in swap_cgroup_prepare()

PATCH Superseded Yu Zhao 3 participants 6 messages Jun 1, 2017 – Jun 5, 2017

Subsystems (2)
lore
Share & tools
lore

Yu Zhao

author
#0 lore raw

PATCH 1/1 swap: cond_resched in swap_cgroup_prepare()

Saw need_resched() warnings when swapping on large swapfile (TBs) because page allocation in swap_cgroup_prepare() took too long.

We already cond_resched when freeing page in swap_cgroup_swapoff(). Do the same for the page allocation.

---
 mm/swap_cgroup.c | 3 +++
 1 file changed, 3 insertions(+)
mm/swap_cgroup.c +3 -0
index ac6318a064d3..3405b4ee1757 100644
@@ -48,6 +48,9 @@ static int swap_cgroup_prepare(int type)
 		if (!page)
 			goto not_enough_page;
 		ctrl->map[idx] = page;
+
+		if (!(idx % SWAP_CLUSTER_MAX))
+			cond_resched();
 	}
 	return 0;
 not_enough_page:
Signature · 7 lines
2.13.0.219.gdb65acc882-goog

--
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>
Acked-by on v1 1/1
#1 lore raw
Quoted 2 lines · Yu Zhao

Saw need_resched() warnings when swapping on large swapfile (TBs) because page allocation in swap_cgroup_prepare() took too long.

Hmm, but the page allocator makes sure to cond_resched for sleeping allocations. I guess what you mean is something different. It is not the allocation which took too look but there are too many of them and none of them sleeps because there is enough memory and the allocator doesn't sleep in that case. Right?

Quoted 4 lines

We already cond_resched when freeing page in swap_cgroup_swapoff(). Do the same for the page allocation.

The patch itself makes sense to me, the changelog could see some clarification but other than that

Quoted 20 lines
---
 mm/swap_cgroup.c | 3 +++
 1 file changed, 3 insertions(+)
mm/swap_cgroup.c +3 -0
index ac6318a064d3..3405b4ee1757 100644
@@ -48,6 +48,9 @@ static int swap_cgroup_prepare(int type)
 		if (!page)
 			goto not_enough_page;
 		ctrl->map[idx] = page;
+
+		if (!(idx % SWAP_CLUSTER_MAX))
+			cond_resched();
 	}
 	return 0;
 not_enough_page:
Signature · 1 line
2.13.0.219.gdb65acc882-goog
Signature · 2 lines
Michal Hocko
SUSE Labs
Acked-by on v1 1/1
#3 lore raw
In reply to Yu Zhao
Quoted 7 lines · Yu Zhao

Saw need_resched() warnings when swapping on large swapfile (TBs) because page allocation in swap_cgroup_prepare() took too long.

We already cond_resched when freeing page in swap_cgroup_swapoff(). Do the same for the page allocation.

Quoted 9 lines
---
 mm/swap_cgroup.c | 3 +++
 1 file changed, 3 insertions(+)
mm/swap_cgroup.c +0 -0
index ac6318a064d3..3405b4ee1757 100644

mm/swap_cgroup.c static int swap_cgroup_prepare(int type) · line 56

Quoted 9 lines
mm/swap_cgroup.c +3 -0
@@ -48,6 +48,9 @@ static int swap_cgroup_prepare(int type)
 		if (!page)
 			goto not_enough_page;
 		ctrl->map[idx] = page;
+
+		if (!(idx % SWAP_CLUSTER_MAX))
+			cond_resched();
 	}
 	return 0;
 not_enough_page:

We should probably do the same on the error path.

author
#2 lore raw
In reply to Michal Hocko
Quoted 10 lines · Michal Hocko
Quoted 2 lines · Yu Zhao

Saw need_resched() warnings when swapping on large swapfile (TBs) because page allocation in swap_cgroup_prepare() took too long.

Hmm, but the page allocator makes sure to cond_resched for sleeping allocations. I guess what you mean is something different. It is not the allocation which took too look but there are too many of them and none of them sleeps because there is enough memory and the allocator doesn't sleep in that case. Right?

Quoted 8 lines
Quoted 4 lines

We already cond_resched when freeing page in swap_cgroup_swapoff(). Do the same for the page allocation.

The patch itself makes sense to me, the changelog could see some clarification but other than that

Thanks, I'll clarify the problem in the commit message and resend the patch.

--
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>

author
#4 lore raw

PATCH v2 1/1 swap: cond_resched in swap_cgroup_prepare()

In reply to Yu Zhao

Saw need_resched() warnings when swapping on large swapfile (TBs) because continuously allocating many pages in swap_cgroup_prepare() took too long.

We already cond_resched when freeing page in swap_cgroup_swapoff(). Do the same for the page allocation.

---
Changelog since v1:
* clarify the problem in the commit message

 mm/swap_cgroup.c | 3 +++
 1 file changed, 3 insertions(+)
mm/swap_cgroup.c +3 -0
index ac6318a064d3..3405b4ee1757 100644
@@ -48,6 +48,9 @@ static int swap_cgroup_prepare(int type)
 		if (!page)
 			goto not_enough_page;
 		ctrl->map[idx] = page;
+
+		if (!(idx % SWAP_CLUSTER_MAX))
+			cond_resched();
 	}
 	return 0;
 not_enough_page:
Signature · 1 line
2.13.0.506.g27d5fe0cd-goog
#5 lore raw

[CC Andrew]

Quoted 33 lines · Yu Zhao

Saw need_resched() warnings when swapping on large swapfile (TBs) because continuously allocating many pages in swap_cgroup_prepare() took too long.

We already cond_resched when freeing page in swap_cgroup_swapoff(). Do the same for the page allocation.

---
Changelog since v1:
* clarify the problem in the commit message

 mm/swap_cgroup.c | 3 +++
 1 file changed, 3 insertions(+)
mm/swap_cgroup.c +3 -0
index ac6318a064d3..3405b4ee1757 100644
@@ -48,6 +48,9 @@ static int swap_cgroup_prepare(int type)
 		if (!page)
 			goto not_enough_page;
 		ctrl->map[idx] = page;
+
+		if (!(idx % SWAP_CLUSTER_MAX))
+			cond_resched();
 	}
 	return 0;
 not_enough_page:
Signature · 1 line
2.13.0.506.g27d5fe0cd-goog
Signature · 8 lines
Michal Hocko
SUSE Labs

--
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>