netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Neil Horman <nhorman@tuxdriver.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net, socketcan@hartkopp.net
Subject: Re: [PATCH] Generalize socket rx gap / receive queue overflow cmsg
Date: Thu, 08 Oct 2009 16:45:48 +0200	[thread overview]
Message-ID: <4ACDFB1C.4090107@gmail.com> (raw)
In-Reply-To: <20091008135435.GA23928@hmsreliant.think-freely.org>

Neil Horman a écrit :
>>> +	if (check_drops) {
>>> +		skb = skb_recv_datagram(sk, flags|MSG_PEEK,
>>> +				flags & MSG_DONTWAIT, &err);
>> 	Ouch, this is too expensive, please find another way :)
>>
>>> +		if (skb) {
>>> +			gap = skb->dropcount;
>>> +			consume_skb(skb);
>>> +		}
>>> +	}
>>> +
> I'm not sure that I see the expense here, and what expense there is, I don't see
> how it avoidable.  In order to do this reporting at the socket level, we need to
> look at the skb at the head of the receive queue.  But we need to do so in a way
> thats consistent with the flags being passed in (i.e. if this is a blocking
> socket, we need to block here until something is available to read).  Then its
> just an atomic_inc on skb->users, followed by a dec in the consume_skb.  I could
> implement the logic for DONTWAIT myself, and skip the atomic_inc/dec, but I'm
> not sure thats much of a savings.  If you have another thought, I'm certainly
> open to it.

The expense is a lot of atomic ops. You forgot the lock, so thats four atomic ops.

You can do all this with no extra atomics.

All you need is some function with (struct msghdr *msg, struct sock *sk, struct sk_buff *skb)
triplet.

hint : sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb)

Could be renamed to something else if you want...

sock_recv_ts_or_drops() or whatever

  reply	other threads:[~2009-10-08 14:46 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-07 18:08 [PATCH] Generalize socket rx gap / receive queue overflow cmsg Neil Horman
2009-10-08  1:05 ` Eric Dumazet
2009-10-08 13:54   ` Neil Horman
2009-10-08 14:45     ` Eric Dumazet [this message]
2009-10-08 17:20       ` Neil Horman
2009-10-09 19:35 ` [PATCH] Generalize socket rx gap / receive queue overflow cmsg (v2) Neil Horman
2009-10-09 21:31   ` Eric Dumazet
2009-10-09 23:21     ` Neil Horman
2009-10-09 23:56 ` [PATCH] Generalize socket rx gap / receive queue overflow cmsg (v3) Neil Horman
2009-10-10  4:59   ` Eric Dumazet
2009-10-10  5:12   ` Eric Dumazet
2009-10-10 12:35 ` [PATCH] Generalize socket rx gap / receive queue overflow cmsg (v4) Neil Horman
2009-10-12  4:38   ` Eric Dumazet
2009-10-12  5:48     ` Oliver Hartkopp
2009-10-12 10:01     ` David Miller

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=4ACDFB1C.4090107@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    --cc=socketcan@hartkopp.net \
    /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).