IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an
email to Administrator. User accounts are meant only to access repo
and report issues and/or generate pull requests.
This is a purpose-specific Git hosting for
BaseALT
projects. Thank you for your understanding!
Только зарегистрированные пользователи имеют доступ к сервису!
Для получения аккаунта, обратитесь к администратору.
The klibc implementation of getopt_long() behaves slightly different
from the glibc one - in particular, it treats the change of the option
string argument between invocations as start of parsing a different
command line, and resets its state. However, the udevadm code
expected getopt_long() invocations in subcommands to continue parsing
the rest of command line after initial options has been parsed at the
top level; with klibc this broke, causing all udevadm subcommands to
stop recognizing their options.
Instead of relying on the glibc behavior, reset the getopt_long()
state properly before invoking the subcommand handler: move argv to
point to the subcommand name, decrease argc appropriately, and set
optind = 0. This also fixes a minor bug visible with glibc - without
setting optind = 0 all getopt_long() calls in subcommand handlers were
behaving as if "+" was specified as the first character of the option
string (which disables option reordering), because that state was set
by the first getopt_long() call at the top level, and was not reset
when parsing subcommand options.
Signed-off-by: Sergey Vlasov <vsu@altlinux.ru>
On my Ubuntu installation this removes 15k of duplicate strings,
using a temporary index of about 25k.
Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
On Fri, Nov 7, 2008 at 13:07, Matthias Schwarzott <zzam@gentoo.org> wrote:
> I managed to let udev-131 segfault at startup.
>
> I configured it like this:
> CFLAGS="-Wall -ggdb" ./configure --prefix=/usr --sysconfdir=/etc --exec-prefix=
>
> Running it in gdb shows it segfaults at udev-rules.c:831
>
> (gdb) run
> Starting program: /tmp/udev-131/udev/udevd
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x0804ea06 in get_key (udev=0x9175008, line=0xafcdc8f0, key=0xafcdc5d8,
> op=0xafcdc5d0, value=0xafcdc5d4)
> at udev-rules.c:831
> 831 dbg(udev, "%s '%s'-'%s'\n", operation_str[*op], *key, *value);
If compiled without optimization, the dbg() macro dereferences variables
which are not available. Convert the string array to a function, which just
returns NULL if compiled without DEBUG.
I'm worried about what will happen with things like
KERNELS=="*" # pointless rule
KERNELS=="doesnt-match" # another pointless rule
Since TK_RULE < TK_M_PARENTS_MAX, we will try to match all three tokens
against parents of the current device. I can't think of a bad case,
but it's not exactly good either.
Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
LAST_RULE was broken, and I broke TK_END by making it do the same.
It used a "break" which exited the switch statement, but not the loop!
==2953== Invalid read of size 4
==2953== at 0x4081EE: dump_token (udev-rules.c:859)
==2953== by 0x40BADB: udev_rules_apply_to_event (udev-rules.c:1849)
==2953== by 0x403F17: udev_event_execute_rules (udev-event.c:554)
==2953== by 0x418626: main (test-udev.c:100)
==2953== Address 0x55ab1f8 is 0 bytes after a block of size 80 alloc'd
==2953== at 0x4C23082: realloc (vg_replace_malloc.c:429)
==2953== by 0x40B13B: udev_rules_new (udev-rules.c:1670)
==2953== by 0x418536: main (test-udev.c:84)
...
Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
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>
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>
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>
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>
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
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>
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>
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>
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>
"Hello world!" linked against libselinux parses /proc/mounts and
whatever else on startup, even when the lib is not needed at all.
Not funny! Get rid of that thing where it's not absolutely needed.
strerror() is not threadsafe. It uses a buffer to build messages of the form
"Unknown error 387689".
syslog() provides a %m format which is equivalent to strerror(errno).
As a GNU extension, this is also accepted by printf and friends.
At least in the current implementation, it is correctly threadsafe.
Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
The scans are now performed up-front at parse-time, instead of being
repeated for each event at run-time.
Cachegrind reports a 5% reduction in cpu cycles
(excluding the time spent in-kernel).
This was needed in the old days, where all the hotplug scripts did
nothing better than sleep for seconds to work around timing issues.
It made sure, that w continued to fork processes, while the machine
was doing nothing than sleeping, but the maximim number of childs
was already reached. This is no longer needed today, we do not run
many of these scripts anymore.
envp is not standardized, and may become invalid when environment variables
are modified. Since udev never actually uses it, we can simply remove it.
Should anyone miss it in future, they can use the standardized environ
variable - like udev_rules.c does already.
Running udevd under valgrind (and then udevtrigger):
==17705== Conditional jump or move depends on uninitialised value(s)
==17705== at 0x407BBB: udev_rules_run (udev_rules.c:522)
==17705== by 0x4109F0: udev_event_process (udevd.c:145)
==17705== by 0x410E2C: udev_event_run (udevd.c:251)
==17705== by 0x411A8D: msg_queue_manager (udevd.c:581)
==17705== by 0x41386B: main (udevd.c:1284)
Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>