From: John Fastabend <john.fastabend@gmail.com>
To: eric.dumazet@gmail.com, paulmck@linux.vnet.ibm.com
Cc: Cong Wang <xiyou.wangcong@gmail.com>,
jhs@mojatatu.com, netdev@vger.kernel.org, davem@davemloft.net
Subject: Re: [RFC PATCH 01/15] net: qdisc: use rcu prefix and silence sparse warnings
Date: Wed, 14 May 2014 12:39:12 -0700 [thread overview]
Message-ID: <5373C660.7030301@gmail.com> (raw)
In-Reply-To: <20140430163504.9021.12828.stgit@nitbit.x32>
On 04/30/2014 09:35 AM, John Fastabend wrote:
> Add __rcu notation to qdisc handling by doing this we can make
> smatch output more legible. And anyways some of the cases should
> be using rcu_dereference() see qdisc_all_tx_empty(),
> qdisc_tx_chainging(), and so on.
>
> Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
> ---
Now I'm trying to resolve the lingering sparse errors/warnings and I
have one that I'm not sure about. Maybe someone has some insight,
net/sched/sch_generic.c:694:9: error: bad constant expression
net/sched/sch_generic.c:694:9: error: cannot size expression
net/sched/sch_generic.c:751:9: error: bad constant expression
net/sched/sch_generic.c:751:9: error: cannot size expression
net/sched/sch_generic.c:800:17: error: bad constant expression
net/sched/sch_generic.c:800:17: error: cannot size expression
net/sched/sch_generic.c:886:9: error: bad constant expression
net/sched/sch_generic.c:886:9: error: cannot size expression
net/sched/sch_generic.c:908:17: error: bad constant expression
net/sched/sch_generic.c:908:17: error: cannot size expression
Here are (what I believe are) the relevant changes to trigger it,
> include/linux/netdevice.h | 29 ++++-------------------------
> include/net/sch_generic.h | 29 +++++++++++++++++++++++------
> net/core/dev.c | 45 +++++++++++++++++++++++++++++++++++++++++++--
> net/sched/sch_generic.c | 4 ++--
> net/sched/sch_mqprio.c | 6 ++++--
> net/sched/sch_teql.c | 9 +++++----
> 6 files changed, 81 insertions(+), 41 deletions(-)
>
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index a803d79..4826988 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -546,7 +546,7 @@ struct netdev_queue {
> * read mostly part
> */
> struct net_device *dev;
> - struct Qdisc *qdisc;
> + struct Qdisc __rcu *qdisc;
Add __rcu here,
> struct Qdisc *qdisc_sleeping;
> #ifdef CONFIG_SYSFS
> struct kobject kobj;
[...]
> +++ b/net/sched/sch_generic.c
[...]
> @@ -871,7 +871,7 @@ static void dev_init_scheduler_queue(struct net_device *dev,
> {
> struct Qdisc *qdisc = _qdisc;
>
> - dev_queue->qdisc = qdisc;
> + rcu_assign_pointer(dev_queue->qdisc, qdisc);
> dev_queue->qdisc_sleeping = qdisc;
> }
Then rcu_assign_pointer() operations throw the "bad constant expression"
and "cannot size expression" errors. The line numbers are a bit off from
the errors above due to some other improvements/fixes but this is line
886 from above sparse output.
I've done similar types of transformations before without sparse errors
so I thought I might see what changed. After doing a revert of
"rcu: Define rcu_assign_pointer() in terms of smp_store_release()"
commit 88c1863066ccfa456797e12c5d8b4631aa1ad0d0
Sparse no longer throws an error. Here is the diff of that commit for
reference
> diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
> index 00a7fd6..4550f22 100644
> --- a/include/linux/rcupdate.h
> +++ b/include/linux/rcupdate.h
> @@ -44,7 +44,6 @@
> #include <linux/debugobjects.h>
> #include <linux/bug.h>
> #include <linux/compiler.h>
> -#include <asm/barrier.h>
>
> extern int rcu_expedited; /* for sysctl */
> #ifdef CONFIG_RCU_TORTURE_TEST
> @@ -582,7 +581,12 @@ static inline void rcu_preempt_sleep_check(void)
> * please be careful when making changes to rcu_assign_pointer() and the
> * other macros that it invokes.
> */
> -#define rcu_assign_pointer(p, v) smp_store_release(&p, RCU_INITIALIZER(v))
> +#define rcu_assign_pointer(p, v) \
> + do { \
> + smp_wmb(); \
> + ACCESS_ONCE(p) = RCU_INITIALIZER(v); \
> + } while (0)
> +
>
> /**
> * rcu_access_pointer() - fetch RCU pointer with no dereferencing
At the moment I'm not seeing what changed that would cause the error.
Any ideas what I got wrong here?
Thanks!
John
--
John Fastabend Intel Corporation
next prev parent reply other threads:[~2014-05-14 19:39 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-30 16:34 [RFC PATCH 00/15] remove qdisc lock from ingress_qdisc John Fastabend
2014-04-30 16:35 ` [RFC PATCH 01/15] net: qdisc: use rcu prefix and silence sparse warnings John Fastabend
2014-04-30 17:00 ` Eric Dumazet
2014-04-30 22:25 ` John Fastabend
2014-04-30 23:29 ` Eric Dumazet
2014-05-01 15:20 ` John Fastabend
2014-05-14 19:39 ` John Fastabend [this message]
2014-05-15 20:41 ` Paul E. McKenney
2014-05-15 21:11 ` John Fastabend
2014-05-15 20:43 ` David Miller
2014-04-30 16:35 ` [RFC PATCH 02/15] net: rcu-ify tcf_proto John Fastabend
2014-04-30 16:36 ` [RFC PATCH 03/15] net: sched: cls_basic use RCU John Fastabend
2014-04-30 16:36 ` [RFC PATCH 04/15] net: sched: cls_cgroup " John Fastabend
2014-04-30 16:36 ` [RFC PATCH 05/15] net: sched: cls_flow " John Fastabend
2014-04-30 16:37 ` [RFC PATCH 06/15] net: sched: fw " John Fastabend
2014-04-30 16:37 ` [RFC PATCH 07/15] net: sched: RCU cls_route John Fastabend
2014-04-30 16:38 ` [RFC PATCH 08/15] net: sched: RCU cls_tcindex John Fastabend
2014-04-30 16:38 ` [RFC PATCH 09/15] net: sched: make cls_u32 lockless John Fastabend
2014-04-30 16:39 ` [RFC PATCH 10/15] net: sched: rcu'ify cls_rsvp John Fastabend
2014-04-30 16:39 ` [RFC PATCH 11/15] net: make cls_bpf rcu safe John Fastabend
2014-04-30 16:39 ` [RFC PATCH 12/15] net: sched: make tc_action safe to walk under RCU John Fastabend
2014-04-30 16:40 ` [RFC PATCH 13/15] net: sched: make bstats per cpu and estimator RCU safe John Fastabend
2014-04-30 16:40 ` [RFC PATCH 14/15] net: sched: make qstats per cpu John Fastabend
2014-04-30 17:08 ` Cong Wang
2014-04-30 22:29 ` John Fastabend
2014-04-30 16:41 ` [RFC PATCH 15/15] net: sched: drop ingress qdisc lock John Fastabend
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=5373C660.7030301@gmail.com \
--to=john.fastabend@gmail.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=jhs@mojatatu.com \
--cc=netdev@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=xiyou.wangcong@gmail.com \
/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).