public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kexec: yield to scheduler when loading kimage segments
@ 2018-06-11 17:35 Jarrett Farnitano
  2018-06-11 22:59 ` Eric W. Biederman
  2018-06-12  0:45 ` Eric W. Biederman
  0 siblings, 2 replies; 5+ messages in thread
From: Jarrett Farnitano @ 2018-06-11 17:35 UTC (permalink / raw)
  To: Eric Biederman; +Cc: kexec, linux-kernel, 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 <jmf@amazon.com>
---
 kernel/kexec_core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
index 5616755..8ee07d6 100644
--- a/kernel/kexec_core.c
+++ b/kernel/kexec_core.c
@@ -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;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] kexec: yield to scheduler when loading kimage segments
  2018-06-11 17:35 [PATCH] kexec: yield to scheduler when loading kimage segments Jarrett Farnitano
@ 2018-06-11 22:59 ` Eric W. Biederman
  2018-06-11 23:47   ` Farnitano, Jarrett
  2018-06-12  0:45 ` Eric W. Biederman
  1 sibling, 1 reply; 5+ messages in thread
From: Eric W. Biederman @ 2018-06-11 22:59 UTC (permalink / raw)
  To: Jarrett Farnitano; +Cc: kexec, linux-kernel

Jarrett Farnitano <jmf@amazon.com> writes:

> 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

> Signed-off-by: Jarrett Farnitano <jmf@amazon.com>
> ---
>  kernel/kexec_core.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
> index 5616755..8ee07d6 100644
> --- a/kernel/kexec_core.c
> +++ b/kernel/kexec_core.c
> @@ -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;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] kexec: yield to scheduler when loading kimage segments
  2018-06-11 22:59 ` Eric W. Biederman
@ 2018-06-11 23:47   ` Farnitano, Jarrett
  2018-06-12  0:45     ` Eric W. Biederman
  0 siblings, 1 reply; 5+ messages in thread
From: Farnitano, Jarrett @ 2018-06-11 23:47 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: kexec@lists.infradead.org, linux-kernel@vger.kernel.org

> On 6/11/18, 4:00 PM, "Eric W. Biederman" <ebiederm@xmission.com> 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] kexec: yield to scheduler when loading kimage segments
  2018-06-11 23:47   ` Farnitano, Jarrett
@ 2018-06-12  0:45     ` Eric W. Biederman
  0 siblings, 0 replies; 5+ messages in thread
From: Eric W. Biederman @ 2018-06-12  0:45 UTC (permalink / raw)
  To: Farnitano, Jarrett
  Cc: kexec@lists.infradead.org, linux-kernel@vger.kernel.org

"Farnitano, Jarrett" <jmf@amazon.com> writes:

>> On 6/11/18, 4:00 PM, "Eric W. Biederman" <ebiederm@xmission.com> 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.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] kexec: yield to scheduler when loading kimage segments
  2018-06-11 17:35 [PATCH] kexec: yield to scheduler when loading kimage segments Jarrett Farnitano
  2018-06-11 22:59 ` Eric W. Biederman
@ 2018-06-12  0:45 ` Eric W. Biederman
  1 sibling, 0 replies; 5+ messages in thread
From: Eric W. Biederman @ 2018-06-12  0:45 UTC (permalink / raw)
  To: Jarrett Farnitano; +Cc: kexec, linux-kernel, Andrew Morton

Jarrett Farnitano <jmf@amazon.com> writes:

> 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 <jmf@amazon.com>

Reviewed-by: "Eric W. Biederman" <ebiederm@xmission.com>

> ---
>  kernel/kexec_core.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
> index 5616755..8ee07d6 100644
> --- a/kernel/kexec_core.c
> +++ b/kernel/kexec_core.c
> @@ -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;

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-06-12  0:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-11 17:35 [PATCH] kexec: yield to scheduler when loading kimage segments Jarrett Farnitano
2018-06-11 22:59 ` Eric W. Biederman
2018-06-11 23:47   ` Farnitano, Jarrett
2018-06-12  0:45     ` Eric W. Biederman
2018-06-12  0:45 ` Eric W. Biederman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox