{"id":815104,"url":"http://patchwork.ozlabs.org/api/1.2/patches/815104/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20170918190733.26272-3-edumazet@google.com/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/1.2/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170918190733.26272-3-edumazet@google.com>","list_archive_url":null,"date":"2017-09-18T19:07:28","name":"[net-next,2/7] kobject: copy env blob in one go","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":true,"hash":"aba93f0bd0fe93324ebce9d9835cceb858124842","submitter":{"id":13357,"url":"http://patchwork.ozlabs.org/api/1.2/people/13357/?format=json","name":"Eric Dumazet","email":"edumazet@google.com"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/1.2/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20170918190733.26272-3-edumazet@google.com/mbox/","series":[{"id":3713,"url":"http://patchwork.ozlabs.org/api/1.2/series/3713/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=3713","date":"2017-09-18T19:07:26","name":"net: speedup netns create/delete time","version":1,"mbox":"http://patchwork.ozlabs.org/series/3713/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/815104/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/815104/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=google.com header.i=@google.com\n\theader.b=\"dDIAx1n5\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xwwWk3PYVz9s7G\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 19 Sep 2017 05:08:18 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751463AbdIRTIQ (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tMon, 18 Sep 2017 15:08:16 -0400","from mail-pf0-f180.google.com ([209.85.192.180]:44002 \"EHLO\n\tmail-pf0-f180.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1750990AbdIRTHn (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Mon, 18 Sep 2017 15:07:43 -0400","by mail-pf0-f180.google.com with SMTP id y29so716688pff.0\n\tfor <netdev@vger.kernel.org>; Mon, 18 Sep 2017 12:07:43 -0700 (PDT)","from localhost ([2620:15c:2cb:201:1d19:43e0:8828:6785])\n\tby smtp.gmail.com with ESMTPSA id\n\t13sm143391pfm.138.2017.09.18.12.07.41\n\t(version=TLS1_2 cipher=AES128-SHA bits=128/128);\n\tMon, 18 Sep 2017 12:07:41 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=google.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=tFysNG1j1v8Ye6nIGETS7prsMmymkIjgtNUD1BvE+qA=;\n\tb=dDIAx1n5yRn1BXbl4yP5EGrn/jARonP26vdSQvMhmIVL8b5qNOIk/EfFZ1i5HDCfnT\n\tb1RQhVa/Cz7CDwKeNG/J2K6RUShfHPBaRpi/DBi55fuzFHHktLb0oigyZJnVh6CJdmkX\n\tkcLqka9PQggtEoWIw2c35KTL9w4GPovMddfzlH1VI56Zjc4IbnVL0bBjNEbkTRfvBkNE\n\t8HTkFF4RqsNk/M0kBflq2FZJqDJ9Pu7QH8dfGwGq1TbXVeA7PL14CvttpblqXzUw0bzB\n\tvy4ZSy1rZ6fqZKEkO+UndY7Tz4D2nYdOyt47caH9TW7MUu6TT67zwohsqucSxmi3lBJE\n\tho7g==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=tFysNG1j1v8Ye6nIGETS7prsMmymkIjgtNUD1BvE+qA=;\n\tb=SFScqEcqh3plSf/RPmyGs6i+unx5Z1ndm8BCF8k0z3u4VOydYXR2y29s2SZ3lE0UkT\n\tn8qNLcveqPeb/aEJ3uZnB8D83v0tk/ZGVaHZoxwyuhpGBnvbMfJZTEeBtOMlzHhU936B\n\tDm+sB/+dC9w0NW0bqXCY8wTCdtRBx6XH4ueN12MH36T254dqjd5v2OBxWi/KaMITDq6E\n\tCSeeLmKoxsLX6Tsz3rVjFOpnp0ZN5ARAcle6cIXFU3ETikNb+mOSA2vOiKwOAmk3AQ0o\n\t3NP/wnuTZGX7t5PLaky8bcViDTOyMBdLIqyCWmIb/4KvCbA8kbP353aSrNs/YSwpmSAC\n\tvIzw==","X-Gm-Message-State":"AHPjjUjFm3Ii5yFjNP/x2pHbPVfvUq657Hv2aEgdV/yKL4rPLOhu2aP2\n\t7GpeePJQSZB0ukNf","X-Google-Smtp-Source":"ADKCNb7IY9TAdVwkJlFVjexaq2VN3aUgneh80P7bblmRqFaQDsxOPnqaK7oglDaxcftMbwaEq48QKQ==","X-Received":"by 10.84.130.108 with SMTP id 99mr37469454plc.343.1505761662301; \n\tMon, 18 Sep 2017 12:07:42 -0700 (PDT)","From":"Eric Dumazet <edumazet@google.com>","To":"\"David S . Miller\" <davem@davemloft.net>","Cc":"netdev <netdev@vger.kernel.org>,\n\t\"Eric W . Biederman\" <ebiederm@xmission.com>,\n\tEric Dumazet <edumazet@google.com>, Eric Dumazet <eric.dumazet@gmail.com>","Subject":"[PATCH net-next 2/7] kobject: copy env blob in one go","Date":"Mon, 18 Sep 2017 12:07:28 -0700","Message-Id":"<20170918190733.26272-3-edumazet@google.com>","X-Mailer":"git-send-email 2.14.1.690.gbb1197296e-goog","In-Reply-To":"<20170918190733.26272-1-edumazet@google.com>","References":"<20170918190733.26272-1-edumazet@google.com>","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"No need to iterate over strings, just copy in one efficient memcpy() call.\n\nTested:\ntime perf record \"(for f in `seq 1 3000` ; do ip netns add tast$f; done)\"\n[ perf record: Woken up 10 times to write data ]\n[ perf record: Captured and wrote 8.224 MB perf.data (~359301 samples) ]\n\nreal    0m52.554s  # instead of 1m7.492s\nuser    0m0.309s\nsys 0m51.375s # instead of 1m6.875s\n\n     9.88%       ip  [kernel.kallsyms]  [k] netlink_broadcast_filtered\n     8.86%       ip  [kernel.kallsyms]  [k] string\n     7.37%       ip  [kernel.kallsyms]  [k] __ip6addrlbl_add\n     5.68%       ip  [kernel.kallsyms]  [k] netlink_has_listeners\n     5.52%       ip  [kernel.kallsyms]  [k] memcpy_erms\n     4.76%       ip  [kernel.kallsyms]  [k] __alloc_skb\n     4.54%       ip  [kernel.kallsyms]  [k] vsnprintf\n     3.94%       ip  [kernel.kallsyms]  [k] format_decode\n     3.80%       ip  [kernel.kallsyms]  [k] kmem_cache_alloc_node_trace\n     3.71%       ip  [kernel.kallsyms]  [k] kmem_cache_alloc_node\n     3.66%       ip  [kernel.kallsyms]  [k] kobject_uevent_env\n     3.38%       ip  [kernel.kallsyms]  [k] strlen\n     2.65%       ip  [kernel.kallsyms]  [k] _raw_spin_lock_irqsave\n     2.20%       ip  [kernel.kallsyms]  [k] kfree\n     2.09%       ip  [kernel.kallsyms]  [k] memset_erms\n     2.07%       ip  [kernel.kallsyms]  [k] ___cache_free\n     1.95%       ip  [kernel.kallsyms]  [k] kmem_cache_free\n     1.91%       ip  [kernel.kallsyms]  [k] _raw_read_lock\n     1.45%       ip  [kernel.kallsyms]  [k] ksize\n     1.25%       ip  [kernel.kallsyms]  [k] _raw_spin_unlock_irqrestore\n     1.00%       ip  [kernel.kallsyms]  [k] widen_string\n\nSigned-off-by: Eric Dumazet <edumazet@google.com>\n---\n lib/kobject_uevent.c | 9 ++-------\n 1 file changed, 2 insertions(+), 7 deletions(-)","diff":"diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c\nindex 4f48cc3b11d566e44c4115cc7716bc3b1cdf96df..cb5102d638452ea6c03d12e61ea8c55c9dd72675 100644\n--- a/lib/kobject_uevent.c\n+++ b/lib/kobject_uevent.c\n@@ -317,18 +317,13 @@ static int kobject_uevent_net_broadcast(struct kobject *kobj,\n \t\tskb = alloc_skb(len + env->buflen, GFP_KERNEL);\n \t\tif (skb) {\n \t\t\tchar *scratch;\n-\t\t\tint i;\n \n \t\t\t/* add header */\n \t\t\tscratch = skb_put(skb, len);\n \t\t\tsprintf(scratch, \"%s@%s\", action_string, devpath);\n \n-\t\t\t/* copy keys to our continuous event payload buffer */\n-\t\t\tfor (i = 0; i < env->envp_idx; i++) {\n-\t\t\t\tlen = strlen(env->envp[i]) + 1;\n-\t\t\t\tscratch = skb_put(skb, len);\n-\t\t\t\tstrcpy(scratch, env->envp[i]);\n-\t\t\t}\n+\t\t\tscratch = skb_put(skb, env->buflen);\n+\t\t\tmemcpy(scratch, env->buf, env->buflen);\n \n \t\t\tNETLINK_CB(skb).dst_group = 1;\n \t\t\tretval = netlink_broadcast_filtered(uevent_sock, skb,\n","prefixes":["net-next","2/7"]}