[OE-core] [PATCH v2 09/12] udev-cache: get system config immediately before cache

Richard Purdie richard.purdie at linuxfoundation.org
Sat Aug 23 11:11:14 UTC 2014


On Fri, 2014-08-22 at 16:30 -0500, Richard Tollerton wrote:
> The system device configuration -- /proc/devices, /proc/cmdline, etc. --
> and the contents of /dev must be stored as simultaneously as possible.
> Otherwise, hotplug events could be processed between the time we get the
> system config and the time we archive /dev, and the udev cache may be
> incorrect.
> 
> To solve this, update the cached system configuration inside the
> udev-cache initscript, not the udev initscript. Also, run it before
> archiving /dev, because it should execute nearly instantaneously.
> 
> We still need to compute the system configuration inside the udev
> initscript, to detect if it changed, so refactor it into a new function
> sysconf_cmd(). This also allows administrators to modify it for
> machine-specific requirements.
> 
> Evaluating the system configuration requires a shell function
> readfiles() defined in the udev initscript. The only salient differences
> between readfiles() and just using `cat` directly are a) readfiles()
> skips files without error if they don't exist, which is necessary
> because /proc/atags is in CMP_FILE_LIST but does not exist on all
> targets; and b) input lines are concatenated into an output shell
> variable with newlines stripped. (a) can be eliminated by not including
> /proc/atags in CMP_FILE_LIST if it doesn't exist. (b) is O(n^2) anyway,
> and makes $NEWDATA, $OLDDATA etc. very hard to read, and we don't need
> to strip newlines anyway. So make sysconf_cmd() use `cat` and remove
> readfiles().

The reason this was done was actually c) avoid having to execute cat as
a new process.

> Instead of storing system configuration in shell variables ($NEWDATA,
> $OLDDATA), store them directly in files: redirect to $SYSCONF_TMP
> instead of storing in $NEWDATA; read from $SYSCONF_CACHED directly
> instead of reading it into $OLDDATA. This turns comparing $NEWDATA vs.
> $OLDDATA into a call to `cmp`. However, busybox lacks `cmp -q`, so
> instead, redirect cmp's output to /dev/null.

The above reason c) is also why we don't use cmp. It turned out to be
faster to read into a variable than fork/exec cmp.

Cheers,

Richard




More information about the Openembedded-core mailing list