Skip to content

Commit

Permalink
driver-core: skip uevent generation when nobody is listening
Browse files Browse the repository at this point in the history
Most network namespaces unlikely have listeners to uevents, and should
benefit from skipping all the string copies.

Cc: Eric Biederman <ebiederm@xmission.com>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Kay Sievers authored and Greg Kroah-Hartman committed Dec 10, 2011
1 parent cf6a2ea commit 74099b1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/kobject_uevent.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
struct sk_buff *skb;
size_t len;

if (!netlink_has_listeners(uevent_sock, 1))
continue;

/* allocate message with the maximum possible size */
len = strlen(action_string) + strlen(devpath) + 2;
skb = alloc_skb(len + env->buflen, GFP_KERNEL);
Expand Down

0 comments on commit 74099b1

Please sign in to comment.