Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1742918
| From | Stephen Hemminger <stephen@networkplumber.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH net 3/3] net: skb_queue_purge(): lock/unlock the queue only once |
| Date | 2017-10-02 03:00 +0200 |
| Message-ID | <uvXfr-z0-3@gated-at.bofh.it> (permalink) |
| References | <unkuB-2yh-5@gated-at.bofh.it> <uvV3X-7M7-1@gated-at.bofh.it> <uvVdE-7RC-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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);
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH net 0/3] net: TCP/IP: A few minor cleanups Michael Witten <mfwitten@gmail.com> - 2017-10-02 00:40 +0200
[PATCH net 2/3] net: inet_recvmsg(): Remove unnecessary bitwise operation Michael Witten <mfwitten@gmail.com> - 2017-10-02 00:50 +0200
[PATCH net 3/3] net: skb_queue_purge(): lock/unlock the queue only once Michael Witten <mfwitten@gmail.com> - 2017-10-02 00:50 +0200
Re: [PATCH net 3/3] net: skb_queue_purge(): lock/unlock the queue only once Stephen Hemminger <stephen@networkplumber.org> - 2017-10-02 03:00 +0200
Re: [PATCH net 3/3] net: skb_queue_purge(): lock/unlock the queue only once Michael Witten <mfwitten@gmail.com> - 2017-10-02 07:20 +0200
[PATCH net 1/3] net: __sock_cmsg_send(): Remove unused parameter `msg' Michael Witten <mfwitten@gmail.com> - 2017-10-02 00:50 +0200
csiph-web