* [bug report] rcu/nocb: Add bypass callback queueing
@ 2019-08-14 10:38 Dan Carpenter
2019-08-14 12:29 ` Paul E. McKenney
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2019-08-14 10:38 UTC (permalink / raw)
To: paulmck; +Cc: rcu
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.
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [bug report] rcu/nocb: Add bypass callback queueing
2019-08-14 10:38 [bug report] rcu/nocb: Add bypass callback queueing Dan Carpenter
@ 2019-08-14 12:29 ` Paul E. McKenney
0 siblings, 0 replies; 2+ messages in thread
From: Paul E. McKenney @ 2019-08-14 12:29 UTC (permalink / raw)
To: Dan Carpenter; +Cc: rcu
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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-08-14 12:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-14 10:38 [bug report] rcu/nocb: Add bypass callback queueing Dan Carpenter
2019-08-14 12:29 ` Paul E. McKenney
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).