rcu.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.ibm.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: rcu@vger.kernel.org
Subject: Re: [bug report] rcu/nocb: Add bypass callback queueing
Date: Wed, 14 Aug 2019 05:29:22 -0700	[thread overview]
Message-ID: <20190814122922.GQ28441@linux.ibm.com> (raw)
In-Reply-To: <20190814103839.GA12599@mwanda>

On Wed, Aug 14, 2019 at 01:38:39PM +0300, Dan Carpenter wrote:
> Hello Paul E. McKenney,
> 
> The patch 1afc4b18724f: "rcu/nocb: Add bypass callback queueing" from
> Jul 2, 2019, leads to the following static checker warning:
> 
> 	kernel/rcu/tree_plugin.h:1792 rcu_nocb_try_bypass()
> 	warn: unsigned 'c' is never less than zero.

Good catch, but Coverity and Colin Ian King beat you to it.  The alleged
fixed commit may be found on -rcu at d1b222c6be1f ("rcu/nocb: Add bypass
callback queueing").

							Thanx, Paul

> kernel/rcu/tree_plugin.h
>   1761  static bool rcu_nocb_try_bypass(struct rcu_data *rdp, struct rcu_head *rhp,
>   1762                                  bool *was_alldone, unsigned long flags)
>   1763  {
>   1764          unsigned long c;
>                 ^^^^^^^^^^^^^^^
>   1765          unsigned long cur_gp_seq;
>   1766          unsigned long j = jiffies;
>   1767          long ncbs = rcu_cblist_n_cbs(&rdp->nocb_bypass);
>   1768  
>   1769          if (!rcu_segcblist_is_offloaded(&rdp->cblist)) {
>   1770                  *was_alldone = !rcu_segcblist_pend_cbs(&rdp->cblist);
>   1771                  return false; /* Not offloaded, no bypassing. */
>   1772          }
>   1773          lockdep_assert_irqs_disabled();
>   1774  
>   1775          // Don't use ->nocb_bypass during early boot.
>   1776          if (rcu_scheduler_active != RCU_SCHEDULER_RUNNING) {
>   1777                  rcu_nocb_lock(rdp);
>   1778                  WARN_ON_ONCE(rcu_cblist_n_cbs(&rdp->nocb_bypass));
>   1779                  *was_alldone = !rcu_segcblist_pend_cbs(&rdp->cblist);
>   1780                  return false;
>   1781          }
>   1782  
>   1783          // If we have advanced to a new jiffy, reset counts to allow
>   1784          // moving back from ->nocb_bypass to ->cblist.
>   1785          if (j == rdp->nocb_nobypass_last) {
>   1786                  c = rdp->nocb_nobypass_count + 1;
>   1787          } else {
>   1788                  WRITE_ONCE(rdp->nocb_nobypass_last, j);
>   1789                  c = rdp->nocb_nobypass_count - nocb_nobypass_lim_per_jiffy;
>   1790                  if (c > nocb_nobypass_lim_per_jiffy)
>   1791                          c = nocb_nobypass_lim_per_jiffy;
>   1792                  else if (c < 0)
>                                  ^^^^^
> Impossible!
> 
>   1793                          c = 0;
>   1794          }
> 
> regards,
> dan carpenter
> 

      reply	other threads:[~2019-08-14 12:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-14 10:38 [bug report] rcu/nocb: Add bypass callback queueing Dan Carpenter
2019-08-14 12:29 ` Paul E. McKenney [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=20190814122922.GQ28441@linux.ibm.com \
    --to=paulmck@linux.ibm.com \
    --cc=dan.carpenter@oracle.com \
    --cc=rcu@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).