kexec: yield to scheduler when loading kimage segments
Subsystems (3)
PATCH 1/1 kexec: yield to scheduler when loading kimage segments
Without yielding while loading kimage segments, a large initrd will block all other work on the CPU performing the load until it is completed. For example loading an initrd of 200MB on a low power single core system will lock up the system for a few seconds.
To increase system responsiveness to other tasks at that time, call cond_resched() in both the crash kernel and normal kernel segment loading loops.
--- kernel/kexec_core.c | 4 ++++ 1 file changed, 4 insertions(+)
kernel/kexec_core.c +4 -0
@@ -783,6 +783,8 @@ static int kimage_load_normal_segment(struct kimage *image,else buf += mchunk; mbytes -= mchunk; + +cond_resched (); } out:return result;
@@ -847,6 +849,8 @@ static int kimage_load_crash_segment(struct kimage *image,else buf += mchunk; mbytes -= mchunk; + +cond_resched (); } out:return result;
Signature · 1 line
2.7.4
Quoted 9 lines · Jarrett Farnitano
Without yielding while loading kimage segments, a large initrd will block all other work on the CPU performing the load until it is completed. For example loading an initrd of 200MB on a low power single core system will lock up the system for a few seconds.
To increase system responsiveness to other tasks at that time, call
cond_resched()in both the crash kernel and normal kernel segment loading loops.
I remember years ago something like this was proposed and there was a reason we did not include it. I don't remember what that reason is right now. But I am reluctant to ack this until I remember.
Is there a practical problem with unresponsiveness? You are talking an embedded machine and rarely are there people in front of embedded computers these days.
Eric
Quoted 27 lines
Signed-off-by Jarrett Farnitano <[email protected]>--- kernel/kexec_core.c | 4 ++++ 1 file changed, 4 insertions(+)kernel/kexec_core.c +4
-0@@ -783,6 +783,8 @@ static int kimage_load_normal_segment(struct kimage *image,else buf += mchunk; mbytes -= mchunk; + +cond_resched (); } out:return result;@@ -847,6 +849,8 @@ static int kimage_load_crash_segment(struct kimage *image,else buf += mchunk; mbytes -= mchunk; + +cond_resched (); } out:return result;
Quoted 5 lines
On 6/11/18, 4:00 PM, "Eric W. Biederman" <[email protected]> wrote:
Is there a practical problem with unresponsiveness? You are talking an embedded machine and rarely are there people in front of embedded computers these days.
I did run into a practical problem. Hardware watchdogs on embedded systems can have short timers on the order of seconds. If the system is locked up for a few seconds with only a single core available, the watchdog may not be pet in a timely fashion. If this happens, the hardware watchdog will fire and reset the system.
This really only becomes a problem when you are working with a single core, a decently sized initrd, and have a constrained hardware watchdog.
Jarrett
Quoted 12 lines · Jarrett
Quoted 5 lines
On 6/11/18, 4:00 PM, "Eric W. Biederman" <[email protected]> wrote:
Is there a practical problem with unresponsiveness? You are talking an embedded machine and rarely are there people in front of embedded computers these days.
I did run into a practical problem. Hardware watchdogs on embedded systems can have short timers on the order of seconds. If the system is locked up for a few seconds with only a single core available, the watchdog may not be pet in a timely fashion. If this happens, the hardware watchdog will fire and reset the system.
Quoted 3 lines
This really only becomes a problem when you are working with a single core, a decently sized initrd, and have a constrained hardware watchdog.
That would do it.
My foggy memory says this was not included back in the days where cond_resched was spelled "if (need_resched) schedule();" There were concerns with spreading that too thin. cond_resched in this path seems as reasonable as anything.
Eric
Quoted 11 lines · Jarrett Farnitano
Without yielding while loading kimage segments, a large initrd will block all other work on the CPU performing the load until it is completed. For example loading an initrd of 200MB on a low power single core system will lock up the system for a few seconds.
To increase system responsiveness to other tasks at that time, call
cond_resched()in both the crash kernel and normal kernel segment loading loops.Signed-off-by Jarrett Farnitano <[email protected]>
Quoted 26 lines
--- kernel/kexec_core.c | 4 ++++ 1 file changed, 4 insertions(+)kernel/kexec_core.c +4
-0@@ -783,6 +783,8 @@ static int kimage_load_normal_segment(struct kimage *image,else buf += mchunk; mbytes -= mchunk; + +cond_resched (); } out:return result;@@ -847,6 +849,8 @@ static int kimage_load_crash_segment(struct kimage *image,else buf += mchunk; mbytes -= mchunk; + +cond_resched (); } out:return result;