Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: Richard Tollerton <rich.tollerton@ni.com>
Cc: otavio@ossystems.com.br, openembedded-core@lists.openembedded.org
Subject: Re: [PATCH v2 09/12] udev-cache: get system config immediately before cache
Date: Sat, 23 Aug 2014 12:11:14 +0100	[thread overview]
Message-ID: <1408792274.5457.18.camel@ted> (raw)
In-Reply-To: <7db18f933460f111085749ee49a70796eab4068a.1408742574.git.rich.tollerton@ni.com>

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



  reply	other threads:[~2014-08-23 11:11 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-22 21:30 [PATCH v2 00/12] udev-cache related changes Richard Tollerton
2014-08-22 21:30 ` [PATCH v2 01/12] udev-cache: Update cache tarball atomically Richard Tollerton
2014-08-22 21:30 ` [PATCH v2 02/12] udev-cache: Compress the cache Richard Tollerton
2014-08-22 21:30 ` [PATCH v2 03/12] udev-cache: choose a more descriptive cache filename Richard Tollerton
2014-08-22 21:30 ` [PATCH v2 04/12] busybox: enable `tar -m` Richard Tollerton
2014-08-22 21:30 ` [PATCH v2 05/12] udev-cache: strip timestamps on extract Richard Tollerton
2014-08-22 21:30 ` [PATCH v2 06/12] udev-cache: omit sockets and filesystems mounted under /dev Richard Tollerton
2014-08-22 21:30 ` [PATCH v2 07/12] udev-cache: Don't ignore error messages from cache extract Richard Tollerton
2014-08-22 21:30 ` [PATCH v2 08/12] udev-cache: parametrize sysconf file paths Richard Tollerton
2014-08-22 21:30 ` [PATCH v2 09/12] udev-cache: get system config immediately before cache Richard Tollerton
2014-08-23 11:11   ` Richard Purdie [this message]
2014-08-25 18:20     ` Richard Tollerton
2014-08-22 21:30 ` [PATCH v2 10/12] udev-cache: invalidate on rules.d changes Richard Tollerton
2014-08-22 21:30 ` [PATCH v2 11/12] udev-cache: Update cache asynchronously Richard Tollerton
2014-08-22 21:30 ` [PATCH v2 12/12] udev-cache: refactor; improve verbosity and error handling Richard Tollerton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1408792274.5457.18.camel@ted \
    --to=richard.purdie@linuxfoundation.org \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=otavio@ossystems.com.br \
    --cc=rich.tollerton@ni.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox