Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1562661 > unrolled thread
| Started by | Jiri Slaby <jslaby@suse.cz> |
|---|---|
| First post | 2017-01-19 13:10 +0100 |
| Last post | 2017-01-22 10:20 +0100 |
| Articles | 5 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] x86: make delay work in earlier stages Jiri Slaby <jslaby@suse.cz> - 2017-01-19 13:10 +0100
Re: [PATCH] x86: make delay work in earlier stages Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-01-19 20:10 +0100
[tip:timers/core] x86/timer: Make delay() during early bootup tip-bot for Jiri Slaby <tipbot@zytor.com> - 2017-01-20 15:50 +0100
Re: [tip:timers/core] x86/timer: Make delay() during early bootup Jiri Slaby <jslaby@suse.cz> - 2017-01-21 08:40 +0100
[tip:timers/core] x86/timer: Make delay() work during early bootup tip-bot for Jiri Slaby <tipbot@zytor.com> - 2017-01-22 10:20 +0100
| From | Jiri Slaby <jslaby@suse.cz> |
|---|---|
| Date | 2017-01-19 13:10 +0100 |
| Subject | [PATCH] x86: make delay work in earlier stages |
| Message-ID | <t1jHs-1mS-43@gated-at.bofh.it> |
When a panic happens during bootup, "Rebooting in X seconds.." is
shown, but reboot happens immediatelly. It is because panic uses mdelay
and mdelay calls internally __const_udelay which is broken while booting.
The per_cpu cpu_info.loops_per_jiffy is not initialized yet, so
__const_udelay actually multiplies the number of loops by zero. This
results in __const_udelay to delay the execution only by a nanosecond or
so.
So check whether cpu_info.loops_per_jiffy is zero and use
loops_per_jiffy in that case. mdelay will not be so precise, but it
works relatively good. From the original (mdelay in rest_init):
[ 0.170039] delaying 100ms
[ 0.170828] done
I get:
[ 0.214042] delaying 100ms
[ 0.313974] done
I do not think the added check matters given we are about to spin the
processor in the next few hundred cycles.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: <x86@kernel.org>
---
arch/x86/lib/delay.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/x86/lib/delay.c b/arch/x86/lib/delay.c
index 073d1f1a620b..aca0988f0e14 100644
--- a/arch/x86/lib/delay.c
+++ b/arch/x86/lib/delay.c
@@ -156,13 +156,14 @@ EXPORT_SYMBOL(__delay);
inline void __const_udelay(unsigned long xloops)
{
+ unsigned long lpf = this_cpu_read(cpu_info.loops_per_jiffy) ? :
+ loops_per_jiffy;
int d0;
xloops *= 4;
asm("mull %%edx"
:"=d" (xloops), "=&a" (d0)
- :"1" (xloops), "0"
- (this_cpu_read(cpu_info.loops_per_jiffy) * (HZ/4)));
+ :"1" (xloops), "0" (lpf * (HZ / 4)));
__delay(++xloops);
}
--
2.11.0
[toc] | [next] | [standalone]
| From | Andy Shevchenko <andy.shevchenko@gmail.com> |
|---|---|
| Date | 2017-01-19 20:10 +0100 |
| Message-ID | <t1qfT-5uo-1@gated-at.bofh.it> |
| In reply to | #1562661 |
> + unsigned long lpf = this_cpu_read(cpu_info.loops_per_jiffy) ? : > + loops_per_jiffy; Perhaps lpj ? In any case FWIW: Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> -- With Best Regards, Andy Shevchenko
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Jiri Slaby <tipbot@zytor.com> |
|---|---|
| Date | 2017-01-20 15:50 +0100 |
| Subject | [tip:timers/core] x86/timer: Make delay() during early bootup |
| Message-ID | <t1IFQ-8tF-31@gated-at.bofh.it> |
| In reply to | #1562661 |
Commit-ID: bf3304d996fbb993bad6be09cafde39cc2db72bb
Gitweb: http://git.kernel.org/tip/bf3304d996fbb993bad6be09cafde39cc2db72bb
Author: Jiri Slaby <jslaby@suse.cz>
AuthorDate: Thu, 19 Jan 2017 12:47:30 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 20 Jan 2017 09:45:22 +0100
x86/timer: Make delay() during early bootup
When a panic happens during bootup, "Rebooting in X seconds.." is
shown, but reboot happens immediatelly. It is because panic() uses mdelay()
and mdelay() calls __const_udelay() immediately, which is does not
work while booting.
The per_cpu cpu_info.loops_per_jiffy is not initialized yet, so
__const_udelay() actually multiplies the number of loops by zero. This
results in __const_udelay() to delay the execution only by a nanosecond
or so.
So check whether cpu_info.loops_per_jiffy is zero and use
loops_per_jiffy in that case. mdelay() will not be so precise without
proper calibration, but it works relatively well.
Before:
[ 0.170039] delaying 100ms
[ 0.170828] done
After
[ 0.214042] delaying 100ms
[ 0.313974] done
I do not think the added check matters given we are about to spin the
processor in the next few hundred cycles.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20170119114730.2670-1-jslaby@suse.cz
[ Minor edits. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/lib/delay.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/lib/delay.c b/arch/x86/lib/delay.c
index 073d1f1..a8e91ae 100644
--- a/arch/x86/lib/delay.c
+++ b/arch/x86/lib/delay.c
@@ -156,13 +156,13 @@ EXPORT_SYMBOL(__delay);
inline void __const_udelay(unsigned long xloops)
{
+ unsigned long lpj = this_cpu_read(cpu_info.loops_per_jiffy) ? : loops_per_jiffy;
int d0;
xloops *= 4;
asm("mull %%edx"
:"=d" (xloops), "=&a" (d0)
- :"1" (xloops), "0"
- (this_cpu_read(cpu_info.loops_per_jiffy) * (HZ/4)));
+ :"1" (xloops), "0" (lpj * (HZ / 4)));
__delay(++xloops);
}
[toc] | [prev] | [next] | [standalone]
| From | Jiri Slaby <jslaby@suse.cz> |
|---|---|
| Date | 2017-01-21 08:40 +0100 |
| Subject | Re: [tip:timers/core] x86/timer: Make delay() during early bootup |
| Message-ID | <t1Yrg-1gy-11@gated-at.bofh.it> |
| In reply to | #1563684 |
On 01/20/2017, 03:40 PM, tip-bot for Jiri Slaby wrote:
> Commit-ID: bf3304d996fbb993bad6be09cafde39cc2db72bb
> Gitweb: http://git.kernel.org/tip/bf3304d996fbb993bad6be09cafde39cc2db72bb
> Author: Jiri Slaby <jslaby@suse.cz>
> AuthorDate: Thu, 19 Jan 2017 12:47:30 +0100
> Committer: Ingo Molnar <mingo@kernel.org>
> CommitDate: Fri, 20 Jan 2017 09:45:22 +0100
>
> x86/timer: Make delay() during early bootup
>
> When a panic happens during bootup, "Rebooting in X seconds.." is
> shown, but reboot happens immediatelly. It is because panic() uses mdelay()
> and mdelay() calls __const_udelay() immediately, which is does not
> work while booting.
The 'is' is superfluous after your edit now. But I guess, you cannot
change it given it is in the tree.
> --- a/arch/x86/lib/delay.c
> +++ b/arch/x86/lib/delay.c
> @@ -156,13 +156,13 @@ EXPORT_SYMBOL(__delay);
>
> inline void __const_udelay(unsigned long xloops)
> {
> + unsigned long lpj = this_cpu_read(cpu_info.loops_per_jiffy) ? : loops_per_jiffy;
And thanks for fixing the 'lpf' brain damage :).
--
js
suse labs
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Jiri Slaby <tipbot@zytor.com> |
|---|---|
| Date | 2017-01-22 10:20 +0100 |
| Subject | [tip:timers/core] x86/timer: Make delay() work during early bootup |
| Message-ID | <t2mtz-7q2-7@gated-at.bofh.it> |
| In reply to | #1562661 |
Commit-ID: 4c45c5167c9563b1a2eee3e2fe954621355e4ca8
Gitweb: http://git.kernel.org/tip/4c45c5167c9563b1a2eee3e2fe954621355e4ca8
Author: Jiri Slaby <jslaby@suse.cz>
AuthorDate: Thu, 19 Jan 2017 12:47:30 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Sun, 22 Jan 2017 10:03:12 +0100
x86/timer: Make delay() work during early bootup
When a panic happens during bootup, "Rebooting in X seconds.." is
shown, but reboot happens immediatelly. It is because panic() uses mdelay()
and mdelay() calls __const_udelay() immediately, which does not
work while booting.
The per_cpu cpu_info.loops_per_jiffy value is not initialized yet, so
__const_udelay() actually multiplies the number of loops by zero. This
results in __const_udelay() to delay the execution only by a nanosecond
or so.
So check whether cpu_info.loops_per_jiffy is zero and use
loops_per_jiffy in that case. mdelay() will not be so precise without
proper calibration, but it works relatively well.
Before:
[ 0.170039] delaying 100ms
[ 0.170828] done
After
[ 0.214042] delaying 100ms
[ 0.313974] done
I do not think the added check matters given we are about to spin the
processor in the next few hundred cycles.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20170119114730.2670-1-jslaby@suse.cz
[ Minor edits. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/lib/delay.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/lib/delay.c b/arch/x86/lib/delay.c
index 073d1f1..a8e91ae 100644
--- a/arch/x86/lib/delay.c
+++ b/arch/x86/lib/delay.c
@@ -156,13 +156,13 @@ EXPORT_SYMBOL(__delay);
inline void __const_udelay(unsigned long xloops)
{
+ unsigned long lpj = this_cpu_read(cpu_info.loops_per_jiffy) ? : loops_per_jiffy;
int d0;
xloops *= 4;
asm("mull %%edx"
:"=d" (xloops), "=&a" (d0)
- :"1" (xloops), "0"
- (this_cpu_read(cpu_info.loops_per_jiffy) * (HZ/4)));
+ :"1" (xloops), "0" (lpj * (HZ / 4)));
__delay(++xloops);
}
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web