From: Joan Raventos <jraventos@yahoo.com>
To: linux-kernel@vger.kernel.org
Subject: poll problem with PF_PACKET when using PACKET_RX_RING
Date: Sat, 14 Oct 2006 14:43:28 -0700 (PDT) [thread overview]
Message-ID: <20061014214328.25873.qmail@web50614.mail.yahoo.com> (raw)
Hello,
In order to use PF_PACKET/SOCK_RAW with PACKET_RX_RING
one would possibly do (as described in
Documentation/networking/packet_mmap.txt):
1. setup PF_PACKET socket via socket call.
2. use setsockopt to change the PF_PACKET socket into
PACKET_RX_RING mode and alloc the ring.
3. mmap the ring.
4. use poll with the socket descriptor and then
directly access the pkts from the mmaped ring.
However I've observed that if the socket is opened on
a link with substantial traffic, chances are that some
pkts might hit the socket between (1) and (2). At that
point those pkts will make the socket descriptor be
active (packet_poll is built as an OR from
datagram_poll -essentially whether sk_receive_queue is
empty- and the ring status). However after (2) pkts
are no longer processed by packet_rcv but via
tpacket_rcv, and thus no longer queued in the
sk_receive_queue but into the ring. Moreover since the
user-space app is likely to access them directly (4),
no one is going to empty the socket queue and the
descriptor will remain always active, converting the
poll loop into a busy wait (100% cpu occupied by the
user-space process, etc.).
Is this a bug in PF_PACKET? Should the socket queue be
emptied by packet_set_ring (called via setsockopt when
PACKET_RX_RING is used) so the above cannot happen?
Should the user-space app drain the socket queue with
recvfrom prior to (4) -quite unlikely in practice-?
Thx in advance for your comments!
Salu2,
J.
next reply other threads:[~2006-10-14 21:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-14 21:43 Joan Raventos [this message]
2006-10-15 14:00 ` Patrick McHardy
2006-10-16 10:56 ` Pádraig Brady
2006-10-15 18:10 Joan Raventos
2006-10-16 6:18 ` Patrick McHardy
2006-10-16 19:39 Joan Raventos
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=20061014214328.25873.qmail@web50614.mail.yahoo.com \
--to=jraventos@yahoo.com \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®