All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: xenomai@xenomai.org
Cc: Jan Kiszka <jan.kiszka@siemens.com>, Philippe Gerum <rpm@xenomai.org>
Subject: [PATCH 11/12] net/stack: rtskb: do not run nop locking calls
Date: Thu, 24 Jan 2019 16:34:27 +0100	[thread overview]
Message-ID: <20190124153428.21006-12-rpm@xenomai.org> (raw)
In-Reply-To: <20190124153428.21006-1-rpm@xenomai.org>

Checking whether calling a lock operation is actually needed is better
wrt I-cache performance.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
 kernel/drivers/net/stack/rtskb.c | 25 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)

diff --git a/kernel/drivers/net/stack/rtskb.c b/kernel/drivers/net/stack/rtskb.c
index cc7563719..a19ef9f2d 100644
--- a/kernel/drivers/net/stack/rtskb.c
+++ b/kernel/drivers/net/stack/rtskb.c
@@ -156,10 +156,11 @@ static struct rtskb *__rtskb_pool_dequeue(struct rtskb_pool *pool)
     struct rtskb_queue *queue = &pool->queue;
     struct rtskb *skb;
 
-    if (!pool->lock_ops->trylock(pool->lock_cookie))
+    if (pool->lock_ops &&
+	!pool->lock_ops->trylock(pool->lock_cookie))
 	    return NULL;
     skb = __rtskb_dequeue(queue);
-    if (skb == NULL)
+    if (skb == NULL && pool->lock_ops)
 	    pool->lock_ops->unlock(pool->lock_cookie);
 
     return skb;
@@ -184,7 +185,8 @@ static void __rtskb_pool_queue_tail(struct rtskb_pool *pool, struct rtskb *skb)
     struct rtskb_queue *queue = &pool->queue;
 
     __rtskb_queue_tail(queue,skb);
-    pool->lock_ops->unlock(pool->lock_cookie);
+    if (pool->lock_ops)
+	    pool->lock_ops->unlock(pool->lock_cookie);
 }
 
 void rtskb_pool_queue_tail(struct rtskb_pool *pool, struct rtskb *skb)
@@ -292,21 +294,6 @@ void kfree_rtskb(struct rtskb *skb)
 EXPORT_SYMBOL_GPL(kfree_rtskb);
 
 
-static int rtskb_nop_pool_trylock(void *cookie)
-{
-    return 1;
-}
-
-static void rtskb_nop_pool_unlock(void *cookie)
-{
-}
-
-static const struct rtskb_pool_lock_ops rtskb_nop_pool_lock_ops = {
-    .trylock = rtskb_nop_pool_trylock,
-    .unlock = rtskb_nop_pool_unlock,
-};
-
-
 /***
  *  rtskb_pool_init
  *  @pool: pool to be initialized
@@ -328,7 +315,7 @@ unsigned int rtskb_pool_init(struct rtskb_pool *pool,
     if (rtskb_pools > rtskb_pools_max)
 	rtskb_pools_max = rtskb_pools;
 
-    pool->lock_ops = lock_ops ?: &rtskb_nop_pool_lock_ops;
+    pool->lock_ops = lock_ops;
     pool->lock_cookie = lock_cookie;
 
     return i;
-- 
2.17.2



  parent reply	other threads:[~2019-01-24 15:34 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-24 15:34 [PATCH 00/12] Assorted updates: RTnet, GPIO, smokey tests Philippe Gerum
2019-01-24 15:34 ` [PATCH 01/12] testsuite/smokey: posix_clock: prevent false positive in time-dependent test Philippe Gerum
2019-01-24 15:34 ` [PATCH 02/12] drivers/gpio: provide optional timestamped readouts Philippe Gerum
2019-01-24 18:17   ` Jan Kiszka
2019-01-25  9:15     ` Philippe Gerum
2019-01-25  9:23       ` Jan Kiszka
2019-01-25  9:31         ` Philippe Gerum
2019-01-25  9:33           ` Jan Kiszka
2019-01-25  9:38             ` Philippe Gerum
2019-01-25  9:48               ` Jan Kiszka
2019-01-25 10:11                 ` Philippe Gerum
2019-01-25 11:32                   ` Jan Kiszka
2019-01-25 11:42                     ` Philippe Gerum
2019-01-25 13:46                       ` Jan Kiszka
2019-01-24 15:34 ` [PATCH 03/12] testsuite/gpiotest: enable timestamping on 'timestamp' argument Philippe Gerum
2019-01-24 15:34 ` [PATCH 04/12] net/stack: allow initializing pre-allocated device structs Philippe Gerum
2019-01-24 15:34 ` [PATCH 05/12] net/stack: fresh rtskb should have ip_summed set to CHECKSUM_NONE Philippe Gerum
2019-01-24 18:21   ` Jan Kiszka
2019-01-25  9:26     ` Philippe Gerum
2019-01-24 15:34 ` [PATCH 06/12] net/rtdev: ensure per-device skbs get mapped at registration Philippe Gerum
2019-01-24 18:24   ` Jan Kiszka
2019-02-06  9:02     ` Philippe Gerum
2019-02-06  9:08       ` Jan Kiszka
2019-02-06  9:47         ` Philippe Gerum
2019-01-24 15:34 ` [PATCH 07/12] net/udp: getfrag: fix frag preparation status Philippe Gerum
2019-01-24 15:34 ` [PATCH 08/12] net/udp: getfrag: remove direct reference to user memory Philippe Gerum
2019-01-24 15:34 ` [PATCH 09/12] testsuite/smokey: net: do not unload pre-loaded modules Philippe Gerum
2019-01-24 15:34 ` [PATCH 10/12] testsuite/smokey: net: do not down a previously running test interface Philippe Gerum
2019-01-24 15:34 ` Philippe Gerum [this message]
2019-01-24 15:34 ` [PATCH 12/12] testsuite/smokey: net_client: improve stats readability Philippe Gerum
2019-01-24 18:10 ` [PATCH 00/12] Assorted updates: RTnet, GPIO, smokey tests Jan Kiszka
2019-01-25  9:12   ` Philippe Gerum
2019-01-25  9:20     ` Jan Kiszka

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=20190124153428.21006-12-rpm@xenomai.org \
    --to=rpm@xenomai.org \
    --cc=jan.kiszka@siemens.com \
    --cc=xenomai@xenomai.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.