[arch-projects] [PATCH 4/7] udev: exit on shutdown

Dave Reisner d at falconindy.com
Fri Oct 28 22:04:45 EDT 2011


On Thu, Oct 27, 2011 at 09:12:19AM -0400, Dave Reisner wrote:
> On Wed, Oct 26, 2011 at 11:03:52PM -0500, Dan McGee wrote:
> > On Wed, Oct 26, 2011 at 10:51 PM, Dave Reisner <d at falconindy.com> wrote:
> > > On Wed, Oct 26, 2011 at 07:12:13PM -0500, Dan McGee wrote:
> > >> On Wed, Oct 26, 2011 at 6:38 PM, Tom Gundersen <teg at jklm.no> wrote:
> > >> > udev was receiving some events (due to e.g. swapoff) on shutdown
> > >> > that caused it to fork new processes. These then receivde TERM before
> > >> s/received/
> > >> > they could finish, and complained on the console.
> > >> >
> > >> > In principle, I'm worried that, with the right ammonut of bad luck,
> > >> s/amount/
> > >> > we could fork off some process at exactly the wrong time which escapes
> > >> > the killall logic.
> > >> >
> > >> > This, by the way, highlights the frailty of the killall stuff.
> > >> Two quick thoughts here
> > >> 1. Is there a need to even call swapoff? I can't believe it is
> > >> essential for swap partitions. It unfortunately does makes sense for
> > >> swap files so we can later unmount the file system they live on, but
> > >> it looks like there is no way to differentiate. Dave, I know you want
> > >> to submit a patch to util-linux for this... :)
> > >
> > > I'm such a tool. Preliminary patchwork for this now exists:
> > >
> > > http://code.falconindy.com/cgit/util-linux.git/log/?h=swapon
> > >
> > > If anyone wants to give it a once over from a user or developer
> > > perspective, that'd be awesome.
> > 
> > Wow, you're awesome. I guess my first question would be- does it
> > actually work? :) Just hotpatch the old initscripts to only swapoff
> > file partitions and try shutting down and make sure it actually goes
> > off without a hitch. This could definitely save some shutdown time on
> > machines that have paged a non-trivial amount to swap.
> > 
> > -Dan
> 
> Of course it works!
> 
> It's far from useable, though. The swapon code is a mess and hasn't
> really been touched in years. I'm going to track down Karel Zak at some
> point and ask him if this is even something that's wanted and maybe get
> some guidance as to what else should be cleaned up in the process.
> 
> d

So, I sort of agree with Tom that perhaps this isn't the right thing to
do because of situations such as LVM. Additionally, the swapon code is a
real farking mess and I'm not sure upstream wants the addition (waiting
to hear back as I want to do a bit of refactoring along with it). In the
meantime, just for grins, we can already do this in shell:

  if [[ -r /proc/swaps ]]; then
    {
      read _
      while read -r swap type _; do
        [[ $type = 'file' ]] && swaps+=("$(printf '%b\n' "$swap")")
      done
      (( ${#swaps[*]} )) && swapoff "${swaps[@]}"
    } </proc/swaps
  fi

d


More information about the arch-projects mailing list