Skip to content
  • Jan Kara's avatar
    lib/flex_proportions.c: fix corruption of denominator in flexible proportions · b5bd6a0e
    Jan Kara authored
    
    
    When racing with CPU hotplug, percpu_counter_sum() can return negative
    values for the number of observed events.
    
    This confuses fprop_new_period(), which uses unsigned type and as a
    result number of events is set to big *positive* number.  From that
    moment on, things go pear shaped and can result e.g.  in division by
    zero as denominator is later truncated to 32-bits.
    
    This bug causes a divide-by-zero oops in bdi_dirty_limit() in Borislav's
    3.6.0-rc6 based kernel.
    
    Fix the issue by using a signed type in fprop_new_period().  That makes
    us bail out from the function without doing anything (mistakenly)
    thinking there are no events to age.  That makes aging somewhat
    inaccurate but getting accurate data would be rather hard.
    
    Signed-off-by: default avatarJan Kara <jack@suse.cz>
    Reported-by: default avatarBorislav Petkov <bp@amd64.org>
    Reported-by: default avatarSrivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
    Cc: Wu Fengguang <fengguang.wu@intel.com>
    Cc: Peter Zijlstra <a...
    b5bd6a0e