From: Stephen Hemminger <stephen@networkplumber.org>
To: Michael Witten <mfwitten@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>,
Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
Eric Dumazet <eric.dumazet@gmail.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net 3/3] net: skb_queue_purge(): lock/unlock the queue only once
Date: Sun, 1 Oct 2017 17:59:09 -0700 [thread overview]
Message-ID: <20171001175909.4b9e53d8@xeon-e3> (raw)
In-Reply-To: <ccfa23a0f76c4c9ebd07fc991db2f829-mfwitten@gmail.com>
On Sun, 01 Oct 2017 22:19:20 -0000
Michael Witten <mfwitten@gmail.com> wrote:
> + spin_lock_irqsave(&q->lock, flags);
> + skb = q->next;
> + __skb_queue_head_init(q);
> + spin_unlock_irqrestore(&q->lock, flags);
Other code manipulating lists uses splice operation and
a sk_buff_head temporary on the stack. That would be easier
to understand.
struct sk_buf_head head;
__skb_queue_head_init(&head);
spin_lock_irqsave(&q->lock, flags);
skb_queue_splice_init(q, &head);
spin_unlock_irqrestore(&q->lock, flags);
> + while (skb != head) {
> + next = skb->next;
> kfree_skb(skb);
> + skb = next;
> + }
It would be cleaner if you could use
skb_queue_walk_safe rather than open coding the loop.
skb_queue_walk_safe(&head, skb, tmp)
kfree_skb(skb);
next prev parent reply other threads:[~2017-10-02 0:59 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-08 5:05 [PATCH 0/3] net: TCP/IP: A few minor cleanups Michael Witten
2017-09-08 5:05 ` [PATCH 1/3] net: __sock_cmsg_send(): Remove unused parameter `msg' Michael Witten
2017-09-08 5:06 ` [PATCH 2/3] net: inet_recvmsg(): Remove unnecessary bitwise operation Michael Witten
2017-09-08 5:06 ` [PATCH 3/3] net: skb_queue_purge(): lock/unlock the list only once Michael Witten
2017-09-08 16:01 ` Eric Dumazet
2017-09-08 16:51 ` Stephen Hemminger
2017-09-09 5:50 ` [PATCH v1 3/3] net: skb_queue_purge(): lock/unlock the queue " Michael Witten
2017-09-09 16:52 ` Eric Dumazet
2017-10-01 22:19 ` [PATCH net " Michael Witten
2017-10-02 0:59 ` Stephen Hemminger [this message]
2017-10-02 5:15 ` Michael Witten
2017-10-02 14:55 ` Stephen Hemminger
2017-10-01 22:19 ` [PATCH net 0/3] net: TCP/IP: A few minor cleanups Michael Witten
2017-10-01 22:19 ` [PATCH net 1/3] net: __sock_cmsg_send(): Remove unused parameter `msg' Michael Witten
2017-10-01 22:19 ` [PATCH net 2/3] net: inet_recvmsg(): Remove unnecessary bitwise operation Michael Witten
2018-02-06 0:54 ` Please apply these tiny, 4-month-old patches Michael Witten
2018-02-06 1:12 ` David Miller
2018-02-06 1:31 ` Michael Witten
2018-02-06 1:42 ` Andrew Lunn
2018-02-06 2:19 ` Michael Witten
2018-02-06 12:58 ` Andrew Lunn
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=20171001175909.4b9e53d8@xeon-e3 \
--to=stephen@networkplumber.org \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=kuznet@ms2.inr.ac.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=mfwitten@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=yoshfuji@linux-ipv6.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.