Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1728612
| From | Michael Witten <mfwitten@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 3/3] net: skb_queue_purge(): lock/unlock the list only once |
| Date | 2017-09-08 08:10 +0200 |
| Message-ID | <unkEh-2Qx-3@gated-at.bofh.it> (permalink) |
| References | <unkuB-2yh-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Date: Thu, 7 Sep 2017 20:07:40 +0000
With this commit, the list's lock is locked/unlocked only once
for the duration of `skb_queue_purge()'.
Hitherto, the list's lock has been locked/unlocked every time
an item is dequeued; this seems not only inefficient, but also
incorrect, as the whole point of `skb_queue_purge()' is to clear
the list, presumably without giving anything else a chance to
manipulate the list in the interim.
Signed-off-by: Michael Witten <mfwitten@gmail.com>
---
net/core/skbuff.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 68065d7d383f..66c0731a2a5f 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -2834,9 +2834,13 @@ EXPORT_SYMBOL(skb_dequeue_tail);
*/
void skb_queue_purge(struct sk_buff_head *list)
{
+ unsigned long flags;
struct sk_buff *skb;
- while ((skb = skb_dequeue(list)) != NULL)
+
+ spin_lock_irqsave(&list->lock, flags);
+ while ((skb = __skb_dequeue(list)) != NULL)
kfree_skb(skb);
+ spin_unlock_irqrestore(&list->lock, flags);
}
EXPORT_SYMBOL(skb_queue_purge);
--
2.14.1
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/3] net: TCP/IP: A few minor cleanups Michael Witten <mfwitten@gmail.com> - 2017-09-08 08:00 +0200
[PATCH 1/3] net: __sock_cmsg_send(): Remove unused parameter `msg' Michael Witten <mfwitten@gmail.com> - 2017-09-08 08:10 +0200
[PATCH 3/3] net: skb_queue_purge(): lock/unlock the list only once Michael Witten <mfwitten@gmail.com> - 2017-09-08 08:10 +0200
Re: [PATCH 3/3] net: skb_queue_purge(): lock/unlock the list only once Eric Dumazet <eric.dumazet@gmail.com> - 2017-09-08 18:10 +0200
Re: [PATCH 3/3] net: skb_queue_purge(): lock/unlock the list only once Stephen Hemminger <stephen@networkplumber.org> - 2017-09-08 19:00 +0200
[PATCH v1 3/3] net: skb_queue_purge(): lock/unlock the queue only once Michael Witten <mfwitten@gmail.com> - 2017-09-09 08:30 +0200
Re: [PATCH v1 3/3] net: skb_queue_purge(): lock/unlock the queue only once Eric Dumazet <eric.dumazet@gmail.com> - 2017-09-09 19:00 +0200
[PATCH 2/3] net: inet_recvmsg(): Remove unnecessary bitwise operation Michael Witten <mfwitten@gmail.com> - 2017-09-08 08:10 +0200
csiph-web