1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-11-01 00:51:08 +03:00
Commit Graph

217 Commits

Author SHA1 Message Date
Kay Sievers
aeb53ca3d6 ATTR{}== always fails if the attribute does not exist 2008-10-29 22:22:12 +01:00
Kay Sievers
0bc74ea79f udevd: merge exec and run queue to minimize devpath string compares 2008-10-29 17:32:13 +01:00
Alan Jenkins
6270756cdc udevd: simplify rules execution loop
cur can't become NULL, and the check for TK_END
can be folded into the switch statement.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
2008-10-28 10:02:43 +01:00
Alan Jenkins
be7de4097a kerneldoc comment fixes
s/ressources/resources/

Also reduce commas per sentence and add a possessive apostrophe.
2008-10-26 15:55:47 +01:00
Kay Sievers
427e20b261 libudev: device - allocate envp array only once 2008-10-26 14:31:46 +01:00
Kay Sievers
c6243a414e test: add RUN+="socket: ..." to a test to run monitor code 2008-10-26 04:35:32 +01:00
Kay Sievers
6493e655f7 libudev: device - fill envp array while composing monitor buffer
Thanks to Alan Jenkins, for the idea.
2008-10-26 03:39:41 +01:00
Kay Sievers
dc4c7e463d fix $attr{[<subsystem>/<sysname>]<attribute>} substitution 2008-10-26 02:48:14 +01:00
Kay Sievers
1822e9b033 do not init string arrays, just clear first byte 2008-10-26 02:31:54 +01:00
Kay Sievers
21cfb0436c match_attr() - copy attr value only when needed 2008-10-26 02:16:54 +01:00
Alan Jenkins
cd94c04c51 udevd: avoid implicit memset in match_attr()
Initializing a char array to "" is equivalent to a memset()
call - which is exactly what it gets compiled to.

Fixing this one callsite reduced memset() _user_ cpu cycles
from 2-4% to 0.05% on the EeePC.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
2008-10-26 02:11:56 +01:00
Alan Jenkins
e25fa4faf5 udevd: use a tighter loop for compare_devpath()
This crops up in my threaded udevd profiles from time to time.
It's not consistent - probably due to variations in the number
of concurrent events - but it can hit 4% user time and higher.

The change halves the user time spent in compare_devpath().

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
2008-10-25 19:41:52 +02:00
Alan Jenkins
3e5c759543 fix handling of string_escape option 2008-10-25 15:19:48 +02:00
Kay Sievers
91a75e4ad4 match KEY="A|B" without temporary string copy 2008-10-25 03:00:03 +02:00
Kay Sievers
b62557daff remove debug printf 2008-10-24 18:09:13 +02:00
Kay Sievers
39a08013a2 fix "unused" warnings 2008-10-24 17:42:31 +02:00
Kay Sievers
c265440279 libudev: monitor - cache result of monitor send buffer 2008-10-24 16:36:27 +02:00
Kay Sievers
3c67f7d2df libudev: monitor - replace far too expensive snprintf() with strlcpy() 2008-10-24 15:09:43 +02:00
Kay Sievers
db463fd309 special-case "?*" match to skip fnmatch() 2008-10-24 14:19:42 +02:00
Kay Sievers
ac218d9cc8 determine at rule parse time if we need to call fnmatch()
This cuts down the large rule set's 120.000 calls to fnmatch() to
51.000, and we can just call strcmp for the simple matches.
2008-10-24 13:32:32 +02:00
Kay Sievers
b0f7409f24 distinguish "match" from "assign" by (op < OP_MATCH_MAX) 2008-10-24 11:38:05 +02:00
Kay Sievers
154a7b8428 cache uid/gid during rule parsing
This cuts down the number of parsing /etc/group from ~700 to 11,
with some large rule files installed.
2008-10-24 10:51:04 +02:00
Kay Sievers
f6bb9e981a fix uninitialized variable warnings 2008-10-24 09:37:37 +02:00
Kay Sievers
34d6a259dc rules: let empty strings added to buffer always return offset 0 2008-10-24 08:07:37 +02:00
Kay Sievers
548459e939 skip SYMLINK rules for devices without a device node 2008-10-23 21:42:23 +02:00
Alan Jenkins
7aeeaedc5f udevd: fix WAIT_FOR_SYSFS execution order
The wait should be ordered after matching KERNEL, ENV, etc.
but before ATTR.

Without this, WAIT_FOR_SYSFS rules will be applied unconditionally
to all events.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
2008-10-23 20:59:17 +02:00
Alan Jenkins
84629ccd85 udevd: fix memory leak
Re: b99028c963 shrink struct udev_event

TEST 136: test multi matches 2
device '/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0' expecting node 'right'
==15011==
==15011== 7 bytes in 1 blocks are definitely lost in loss record 1 of 1
==15011==    at 0x47F9AB8: malloc (vg_replace_malloc.c:207)
==15011==    by 0x489CB5F: strdup (in /lib32/libc-2.7.so)
==15011==    by 0x8050F40: udev_rules_apply_to_event (udev-rules.c:1973)
==15011==    by 0x804A658: udev_event_execute_rules (udev-event.c:549)
==15011==    by 0x805A636: main (test-udev.c:100)
add:         ok
==15012==
==15012== 7 bytes in 1 blocks are definitely lost in loss record 1 of 1
==15012==    at 0x47F1AB8: malloc (vg_replace_malloc.c:207)
==15012==    by 0x4898B5F: strdup (in /lib32/libc-2.7.so)
==15012==    by 0x8050F40: udev_rules_apply_to_event (udev-rules.c:1973)
==15012==    by 0x804A9DF: udev_event_execute_rules (udev-event.c:658)
==15012==    by 0x805A636: main (test-udev.c:100)
remove:      ok

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
2008-10-23 11:33:22 +02:00
Kay Sievers
b99028c963 shrink struct udev_event 2008-10-23 02:57:08 +02:00
Kay Sievers
40fd3bc837 shrink struct udev_event 2008-10-23 02:34:22 +02:00
Kay Sievers
5a05e120af do not create temporary node ($tempnode) if node already exists 2008-10-23 01:13:52 +02:00
Kay Sievers
6880b25d40 replace in-memory rules array with match/action token list
The in-memory rule array of a common desktop distro install took:
  1151088 bytes
with the token list:
  109232 bytes tokens (6827 * 16 bytes), 71302 bytes buffer
2008-10-23 00:13:59 +02:00
Kay Sievers
a391f49d7f handle numerical owner/group string in lookup_user/group() 2008-10-22 23:59:53 +02:00
Alan Jenkins
aaff3d023f use re-entrant variants of getpwnam and getgrnam
Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
2008-10-22 18:05:46 +02:00
Kay Sievers
14f4025607 add util_resolve_subsys_kernel() 2008-10-22 18:03:38 +02:00
Alan Jenkins
111e4f81ff replace strncpy() with strlcpy()
The problem was strncpy() doesn't stop after writing the terminating
NUL; by definition it goes on to zero the entire buffer.

I spy another use of strncpy in udev_device_add_property_from_string(),
which is responsible for another ~1% user cpu time...

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
2008-10-21 23:55:13 +02:00
Kay Sievers
9a23e9e775 libudev: device - 128 -> ENVP_SIZE 2008-10-21 13:58:19 +02:00
Alan Jenkins
be18918f65 libudev: allocate udev_device->envp[] dynamically
Measured 2% _user_ cpu time reduction on EeePC coldplug.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
2008-10-21 13:56:23 +02:00
Alan Jenkins
fa0e955a93 libudev: util - optimize path_encode()
Since we already know the length, use memcpy() instead.
Measured 2% _user_ cpu time reduction on EeePC coldplug.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
2008-10-21 13:09:31 +02:00
Alan Jenkins
b29a5e4ab9 use more appropriate alternatives to malloc()
Use calloc to request cleared memory instead.
Kernel and libc conspire to make this more efficient.

Also, replace one malloc() + strcpy() with strdup().

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
2008-10-21 12:54:57 +02:00
Kay Sievers
a8a8930072 do not use the new work-in-progress parser rule matcher 2008-10-21 12:45:54 +02:00
Kay Sievers
20254eb021 add "root" == 0 shortcuts to lookup_user/group() 2008-10-21 12:43:07 +02:00
Kay Sievers
94db05d288 replace missing get_attr_value() -> get_sysattr_value() 2008-10-21 12:42:13 +02:00
Kay Sievers
69239210be libudev: device - get_attr_value() -> get_sysattr_value() 2008-10-20 18:12:36 +02:00
Kay Sievers
54808d77a3 prefix udev-util.c functions with util_* 2008-10-18 20:12:55 +02:00
Kay Sievers
c3b1fa66d2 selinux_init(udev) -> udev_selinux_init(udev) 2008-10-18 19:30:42 +02:00
Kay Sievers
eb8837e15c udev_list_cleanup() -> udev_list_cleanup_entries() 2008-10-18 19:27:38 +02:00
Kay Sievers
f1128767cb move udev_rules_apply_format() to udev-event.c 2008-10-18 19:19:56 +02:00
Kay Sievers
2d73813ebc udev_rules_run() -> udev_event_execute_run(); 2008-10-18 15:50:16 +02:00
Kay Sievers
dcdcb8cc06 udev_event_run() -> udev_event_execute_rules() 2008-10-18 15:46:55 +02:00
Alan Jenkins
836dcf951c udevd: avoid overhead of calling rmdir on non-empty directories
Unfortunately the linux rmdir implementation unhashes the dentry
even when the directory is not removed.  This is apparently by
design (for filesystems that don't allow deleting open files).

Results from time(1) and oprofile follow.

Before:

0.35user 0.90system
samples  %        image name               symbol name
608       9.6738  vmlinux                  shrink_dcache_parent
293       4.6619  vmlinux                  copy_page_c
271       4.3119  vmlinux                  copy_page_range
257       4.0891  udevd                    udev_rules_iter_next

After:

0.31user 0.67system
samples  %        image name               symbol name
361       5.0419  vmlinux                  copy_page_range
322       4.4972  udevd                    udev_rules_iter_next
300       4.1899  vmlinux                  copy_page_c

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
2008-10-18 15:28:49 +02:00