From: Urs Thuermann <urs@isnogud.escape.de>
To: linux-kernel@vger.kernel.org
Cc: "Paul E. McKenney" <paulmck@us.ibm.com>
Subject: Re: Q: locking mechanisms
Date: 05 Jul 2006 11:35:52 +0200 [thread overview]
Message-ID: <m2y7v8gzrb.fsf@janus.isnogud.escape.de> (raw)
In-Reply-To: <20060705061126.GA20483@us.ibm.com>; from "Paul E. McKenney" on Tue, 4 Jul 2006 23:11:26 -0700
"Paul E. McKenney" <paulmck@us.ibm.com> writes:
> > I have code that receives network packets by registering with
> > dev_add_pack(). Each packet received is then delivered to a list
> > of receivers, where this list can contain quite a lot of items:
> >
> > receive_function(struct sk_buff *skb, struct net_device *dev,
> > struct packet_type *pt, struct net_device *orig_dev)
> > {
> > ...
> > rcu_read_lock();
> > head = find_list(dev);
> > hlist_for_each_entry_rcu(p, n, head, list) {
> > deliver_packet_to_receiver(skb, p);
> > }
> > rcu_read_unlock();
> > }
> >
> > The deliver_packet_to_receiver() function finally ends up in a call to
> > sock_queue_rcv_skb().
> "Holding" rcu_read_lock() for long time periods is much less of a
> concern than holding other types of synchronization mechanisms.
Why is that? I thought, if I hold a spinlock (or rw_lock in my case)
I only block other threads that try to get that same lock. With
rcu_read_lock() I disable preemption which I thought affects more
(all) other parts of the kernel.
> But I have to ask: roughly how long is "quite long"?
Depends on how many and what types of sockets are opened and which
packets they want to receive. The code is part of a new protocol
family implementation for CAN (controller area network), which you can
see at belios.de, project name socket-can. It implements several
types of PF_CAN sockets, which register for packets of certain CAN
IDs, which are then lightly processed (filtered) and eventually
delivered into a queue using sock_queue_rcv_skb(). Usually, the list
has one receiver per open PF_CAN sockets. Typical usage here has
shown list lengths of 30-100 entries, i.e. 30-100 packets delivered
with sock_queue_rcv_skb(). But it all depends on what the user space
does, how many PF_CAN sockets are opened by all processes.
Is that value of "quite long" also "too long" for doing an
rcu_read_lock()?
urs
BTW, while implementing PF_CAN and reading kernel code and
documentation I often run into questions on details like this which
I'd like answered to get a better understanding of kernel internals,
sometimes not directly related to some concrete implementation
problem. Is LKML the right place for these questions?
next prev parent reply other threads:[~2006-07-05 9:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-01 5:58 Urs Thuermann
2006-07-01 9:36 ` Thomas Gleixner
2006-07-02 5:26 ` Urs Thuermann
2006-07-04 12:58 ` Urs Thuermann
2006-07-05 6:11 ` Paul E. McKenney
2006-07-05 9:35 ` Urs Thuermann [this message]
2006-07-05 14:13 ` Paul E. McKenney
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=m2y7v8gzrb.fsf@janus.isnogud.escape.de \
--to=urs@isnogud.escape.de \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@us.ibm.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
all inboxes | Powered by JetHome®