Bug 88051

Summary: vmpressure_work_fn is not multi-thread safe
Product: Memory Management Reporter: ji_ang
Component: OtherAssignee: Andrew Morton (akpm)
Status: RESOLVED CODE_FIX    
Severity: high    
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 3.18-rc4 and all earlier versions Subsystem:
Regression: No Bisected commit-id:

Description ji_ang 2014-11-11 16:47:58 UTC
static void vmpressure_work_fn(struct work_struct *work)
{
 ...
	if (!vmpr->scanned)
		return;

	spin_lock(&vmpr->sr_lock);
	scanned = vmpr->scanned;

In some android devices, there will be a "divided by zero" expection. the vmpr->scanned could be zero before “spin_lock(&vmpr->sr_lock)”

So the above source code should be changed to:

	spin_lock(&vmpr->sr_lock);
	scanned = vmpr->scanned;
	if (!scanned)
	{
		spin_unlock(&vmpr->sr_lock);
		return;
	}
Comment 1 Andrew Morton 2014-11-19 21:21:50 UTC
Thanks, I queued that fix.