Skip to contentSkip to conversation

kswapd: assign new_order and new_classzone_idx after wakeup in sleeping

PATCH In review Alex Shi 2 participants 3 messages Jul 29, 2011

Subsystems (3)
lore
Share & tools
lore

Alex Shi

author
#0 lore raw

PATCH 1/1 kswapd: assign new_order and new_classzone_idx after wakeup in sleeping

There 2 place to read pgdat in kswapd. One is return from a successful balance, another is waked up from sleeping. But the new_order and new_classzone_idx are not assigned after kswapd_try_to_sleep(), that will cause a bug in the following scenario.

After the last time successful balance, kswapd goes to sleep. So the new_order and new_classzone_idx were assigned to 0 and MAX-1 since there is no new wakeup during last time balancing. Now, a new wakeup came and finish balancing successful with order > 0. But since new_order is still 0, this time successful balancing were judged as a failed balance. so, if there is another new wakeup coming during balancing, kswapd cann't read this and still want to try to sleep. And if the new wakeup is a tighter request, kswapd may goes to sleep, not to do balancing. That is incorrect.

So, to avoid above problem, the new_order and new_classzone_idx need to be assigned for later successful comparison.

Paidrag Brady, Could like do a retry for your problem on this patch?

---
 mm/vmscan.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
mm/vmscan.c +2 -0
index 7ef6912..eb7bcce 100644
@@ -2850,6 +2850,8 @@ static int kswapd(void *p)
 			kswapd_try_to_sleep(pgdat, order, classzone_idx);
 			order = pgdat->kswapd_max_order;
 			classzone_idx = pgdat->classzone_idx;
+			new_order = order;
+			new_classzone_idx = classzone_idx;
 			pgdat->kswapd_max_order = 0;
 			pgdat->classzone_idx = pgdat->nr_zones - 1;
 		}
Signature · 1 line
1.6.3.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Alex Shi

There 2 place to read pgdat in kswapd. One is return from a successful balance, another is waked up from sleeping. But the new_order and new_classzone_idx are not assigned after kswapd_try_to_sleep(), that will cause a bug in the following scenario.

After the last time successful balance, kswapd goes to sleep. So the new_order and new_classzone_idx were assigned to 0 and MAX-1 since there is no new wakeup during last time balancing. Now, a new wakeup came and finish balancing successful with order > 0. But since new_order is still 0, this time successful balancing were judged as a failed balance. so, if there is another new wakeup coming during balancing, kswapd cann't read this and still want to try to sleep. And if the new wakeup is a tighter request, kswapd may goes to sleep, not to do balancing. That is incorrect.

Quoted 7 lines

So, to avoid above problem, the new_order and new_classzone_idx need to be assigned for later successful comparison.

Paidrag Brady, Could like do a retry for your problem on this patch?

Signature · 2 lines
Kind regards,
Minchan Kim
author
#2 lore raw
Quoted 26 lines

-----Original Message-----
From: Minchan Kim [mailto:[email protected]]
Sent: Friday, July 29, 2011 4:57 PM
To: Shi, Alex
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Chen, Tim C; Li, Shaohua; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] kswapd: assign new_order and new_classzone_idx after wakeup in sleeping

Quoted 15 lines · Alex Shi

There 2 place to read pgdat in kswapd. One is return from a successful balance, another is waked up from sleeping. But the new_order and new_classzone_idx are not assigned after kswapd_try_to_sleep(), that will cause a bug in the following scenario.

After the last time successful balance, kswapd goes to sleep. So the new_order and new_classzone_idx were assigned to 0 and MAX-1 since there is no new wakeup during last time balancing. Now, a new wakeup came and finish balancing successful with order > 0. But since new_order is still 0, this time successful balancing were judged as a failed balance. so, if there is another new wakeup coming during balancing, kswapd cann't read this and still want to try to sleep. And if the new wakeup is a tighter request, kswapd may goes to sleep, not to do balancing. That is incorrect.

Quoted 8 lines
Quoted 7 lines

So, to avoid above problem, the new_order and new_classzone_idx need to be assigned for later successful comparison.

Paidrag Brady, Could like do a retry for your problem on this patch?

Thanks for review.
BTW, I remove the incorrect email address of linux-mm. sorry for this!

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>