All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Tejun Heo <tj@kernel.org>
Cc: Jan Kara <jack@suse.cz>,
	linux-kernel@vger.kernel.org,
	Fengguang Wu <fengguang.wu@intel.com>
Subject: Re: [PATCH block/for-4.1-fixes] writeback: use |1 instead of +1 to protect against div by zero
Date: Thu, 23 Apr 2015 10:37:58 -0600	[thread overview]
Message-ID: <55391FE6.2050102@kernel.dk> (raw)
In-Reply-To: <20150421204913.GE9455@htj.duckdns.org>

On 04/21/2015 02:49 PM, Tejun Heo wrote:
> mm/page-writeback.c has several places where 1 is added to the divisor
> to prevent division by zero exceptions; however, if the original
> divisor is equivalent to -1, adding 1 leads to division by zero.
>
> There are three places where +1 is used for this purpose - one in
> pos_ratio_polynom() and two in bdi_position_ratio().  The second one
> in bdi_position_ratio() actually triggered div-by-zero oops on a
> machine running a 3.10 kernel.  The divisor is
>
>    x_intercept - bdi_setpoint + 1 == span + 1
>
> span is confirmed to be (u32)-1.  It isn't clear how it ended up that
> but it could be from write bandwidth calculation underflow fixed by
> c72efb658f7c ("writeback: fix possible underflow in write bandwidth
> calculation").
>
> At any rate, +1 isn't a proper protection against div-by-zero.  This
> patch converts all +1 protections to |1.  Note that
> bdi_update_dirty_ratelimit() was already using |1 before this patch.

The |1 is a litle iffy imho, but I guess it gets the job done. Applied 
for 4.1.

-- 
Jens Axboe


      parent reply	other threads:[~2015-04-23 16:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-21 20:49 [PATCH block/for-4.1-fixes] writeback: use |1 instead of +1 to protect against div by zero Tejun Heo
2015-04-22 10:58 ` Jan Kara
2015-04-23 16:37 ` Jens Axboe [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55391FE6.2050102@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=fengguang.wu@intel.com \
    --cc=jack@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.