Wind River Support Network

HomeDefectsLIN5-9365
Fixed

LIN5-9365 : When adjust dirty_ratio to zero, will cause kernel exception of divdied by zero

Created: Nov 6, 2012    Updated: Dec 19, 2017
Resolved Date: Dec 19, 2013
Previous ID: LIN4-13265
Found In Version: 5.0
Fix Version: 5.0.1.11
Severity: Severe
Applicable for: Wind River Linux 5
Component/s: Kernel

Description

1. wrlinux4.3 + c600 BSP  (32G memory)
2. when adjust /proc/sys/vm/dirty_ratio to zero, then scp many files from other linux host, will cause kernel exception of dividied by zero.

analyse:
problem 1:
 static int calc_period_shift(void)
{
 unsigned long dirty_total;
 if (vm_dirty_bytes)
  dirty_total = vm_dirty_bytes / PAGE_SIZE;
 else
  dirty_total = (vm_dirty_ratio * determine_dirtyable_memory()) /
    100;
 return 2 + ilog2(dirty_total - 1);   //  dirty_total=0, and ilog2(-1)=63
}

problem 2:
static void task_dirty_limit(struct task_struct *tsk, unsigned long *pdirty)
{
 long numerator, denominator;
 unsigned long dirty = *pdirty;
 u64 inv = dirty >> 3;
 task_dirties_fraction(tsk, &numerator, &denominator);
 inv *= numerator;
 do_div(inv, denominator);  // denominator low 32bits is zero and ignore high 32bits, so cause divide zero exception.
 dirty -= inv;
 if (dirty < *pdirty/2)
  dirty = *pdirty/2;
 *pdirty = dirty;
}

Steps to Reproduce

1. set /proc/sys/vm/dirty_ratio =0
2.scp files from other linux host to local

Other Downloads


Live chat
Online