troglobit / finit

Fast init for Linux. Cookies included
https://troglobit.com/projects/finit/
MIT License
633 stars 64 forks source link

Fix filesystems not unmounted at shutdown #219

Closed liuming50 closed 2 years ago

liuming50 commented 2 years ago

Instead of unconditionally waiting 2 seconds for processes to die, check continuously for remaining processes, and break the loop when none remain.

Turn PID 1 to a RT process with highest priority 99 during shutdown, this ensures it would not be preempted by other RT processes.

Signed-off-by: Robert Andersson robert.m.andersson@atlascopco.com Signed-off-by: Mathias Thore mathias.thore@atlascopco.com Signed-off-by: Ming Liu liu.ming50@gmail.com

liuming50 commented 2 years ago

Hi, @troglobit

I mistakenly closed https://github.com/troglobit/finit/pull/209, I created this new MR, please help me review it.

Paste the answers to your question here:

Why not wait for, and kill, the console -sh tty process? They definitely sit on a mounted filesystem (and may have several open files from others), that prevent us from unmounting cleanly

The original author Robert Andersson said he does not remember the exact reason, so I dropped it in V2, it might be some specific requirements from our system.

Passing integers as void in the callbacks don't work on all archs, pointers and integers are no longer guaranteed to be of the same length. If you only ever want to pass an integer, use an int

Have changed as you suggested in this MR.

I'm really worried to see the change to SCHED_RR this late in the lifetime of Finit ... do we really need it? Please motivate.

Maybe I can explain this, this is basically for PREEMPT-RT kernel, finit during shutdown must run as a RT process to ensure it would not be scheduled out, so it must run at the highest priority 99. This part of change should also work on non-preempt-rt kernel.

Is the usleep() long enough for the kernel to schedule another task on an old Arm9 with no L2 cache? We have several targets at $DAYJOB that use an old NPX i.MX27 that is soooo slow.

I am not 100% sure about the answer, but we do deploy finit to NXP imx27 boards (maybe thousands of them), I have not seen error report about this change, so 2500 USECS should be long enough I guess.

liuming50 commented 2 years ago

@troglobit Please kindly help me review the V2.

Have fixed all issues as you suggested in V1.