From: Eric Dumazet <edumazet@google.com>
To: "David S . Miller" <davem@davemloft.net>
Cc: netdev <netdev@vger.kernel.org>,
"Eric W . Biederman" <ebiederm@xmission.com>,
Eric Dumazet <edumazet@google.com>,
Eric Dumazet <eric.dumazet@gmail.com>
Subject: [PATCH v2 net-next 2/7] kobject: copy env blob in one go
Date: Tue, 19 Sep 2017 16:27:04 -0700 [thread overview]
Message-ID: <20170919232709.14690-3-edumazet@google.com> (raw)
In-Reply-To: <20170919232709.14690-1-edumazet@google.com>
No need to iterate over strings, just copy in one efficient memcpy() call.
Tested:
time perf record "(for f in `seq 1 3000` ; do ip netns add tast$f; done)"
[ perf record: Woken up 10 times to write data ]
[ perf record: Captured and wrote 8.224 MB perf.data (~359301 samples) ]
real 0m52.554s # instead of 1m7.492s
user 0m0.309s
sys 0m51.375s # instead of 1m6.875s
9.88% ip [kernel.kallsyms] [k] netlink_broadcast_filtered
8.86% ip [kernel.kallsyms] [k] string
7.37% ip [kernel.kallsyms] [k] __ip6addrlbl_add
5.68% ip [kernel.kallsyms] [k] netlink_has_listeners
5.52% ip [kernel.kallsyms] [k] memcpy_erms
4.76% ip [kernel.kallsyms] [k] __alloc_skb
4.54% ip [kernel.kallsyms] [k] vsnprintf
3.94% ip [kernel.kallsyms] [k] format_decode
3.80% ip [kernel.kallsyms] [k] kmem_cache_alloc_node_trace
3.71% ip [kernel.kallsyms] [k] kmem_cache_alloc_node
3.66% ip [kernel.kallsyms] [k] kobject_uevent_env
3.38% ip [kernel.kallsyms] [k] strlen
2.65% ip [kernel.kallsyms] [k] _raw_spin_lock_irqsave
2.20% ip [kernel.kallsyms] [k] kfree
2.09% ip [kernel.kallsyms] [k] memset_erms
2.07% ip [kernel.kallsyms] [k] ___cache_free
1.95% ip [kernel.kallsyms] [k] kmem_cache_free
1.91% ip [kernel.kallsyms] [k] _raw_read_lock
1.45% ip [kernel.kallsyms] [k] ksize
1.25% ip [kernel.kallsyms] [k] _raw_spin_unlock_irqrestore
1.00% ip [kernel.kallsyms] [k] widen_string
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
lib/kobject_uevent.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 4f48cc3b11d566e44c4115cc7716bc3b1cdf96df..78b2a7e378c0deda3b32b1178d7f44203702c3f2 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -317,18 +317,12 @@ static int kobject_uevent_net_broadcast(struct kobject *kobj,
skb = alloc_skb(len + env->buflen, GFP_KERNEL);
if (skb) {
char *scratch;
- int i;
/* add header */
scratch = skb_put(skb, len);
sprintf(scratch, "%s@%s", action_string, devpath);
- /* copy keys to our continuous event payload buffer */
- for (i = 0; i < env->envp_idx; i++) {
- len = strlen(env->envp[i]) + 1;
- scratch = skb_put(skb, len);
- strcpy(scratch, env->envp[i]);
- }
+ skb_put_data(skb, env->buf, env->buflen);
NETLINK_CB(skb).dst_group = 1;
retval = netlink_broadcast_filtered(uevent_sock, skb,
--
2.14.1.690.gbb1197296e-goog
next prev parent reply other threads:[~2017-09-19 23:27 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-19 23:27 [PATCH v2 net-next 0/7] net: speedup netns create/delete time Eric Dumazet
2017-09-19 23:27 ` [PATCH v2 net-next 1/7] kobject: add kobject_uevent_net_broadcast() Eric Dumazet
2017-09-19 23:27 ` Eric Dumazet [this message]
2017-09-19 23:27 ` [PATCH v2 net-next 3/7] kobject: factorize skb setup in kobject_uevent_net_broadcast() Eric Dumazet
2017-09-19 23:27 ` [PATCH v2 net-next 4/7] ipv6: addrlabel: per netns list Eric Dumazet
2017-09-19 23:27 ` [PATCH v2 net-next 5/7] tcp: batch tcp_net_metrics_exit Eric Dumazet
2017-09-19 23:27 ` [PATCH v2 net-next 6/7] ipv6: speedup ipv6 tunnels dismantle Eric Dumazet
2017-09-19 23:27 ` [PATCH v2 net-next 7/7] ipv4: " Eric Dumazet
2017-09-19 23:32 ` [PATCH v2 net-next 0/7] net: speedup netns create/delete time David Miller
2017-09-26 11:21 ` Tariq Toukan
2017-09-26 12:51 ` Eric Dumazet
2017-09-26 15:04 ` Tariq Toukan
2017-09-26 15:13 ` Eric Dumazet
2017-09-26 15:22 ` Dmitry Torokhov
2017-09-26 15:30 ` Eric Dumazet
2017-10-19 11:48 ` Tariq Toukan
2017-10-19 14:11 ` Eric Dumazet
2017-12-13 21:43 ` Dmitry Torokhov
2017-12-13 21:52 ` Eric Dumazet
2017-12-13 22:24 ` Dmitry Torokhov
2017-09-26 15:26 ` Tariq Toukan
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=20170919232709.14690-3-edumazet@google.com \
--to=edumazet@google.com \
--cc=davem@davemloft.net \
--cc=ebiederm@xmission.com \
--cc=eric.dumazet@gmail.com \
--cc=netdev@vger.kernel.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.