linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc: Fix accumulate_stolen_time() vs. CONFIG_PREEMPT
@ 2011-01-13  5:57 Benjamin Herrenschmidt
  0 siblings, 0 replies; only message in thread
From: Benjamin Herrenschmidt @ 2011-01-13  5:57 UTC (permalink / raw)
  To: linuxppc-dev

The function accumulate_stolen_time() is called on pSeries to scan
the hypervisor event log every now and then. This happens very early
during the exception entry process, while the PACA soft/hard_enabled
fields don't properly reflect the state of the system, which is
basically hard irq disabled.

This causes various debug checks to trigger when CONFIG_PREEMPT is
enabled which can themselves cause the machine to crash due to the
unexpected context they are called from.

We fix that by temporarily setting the PACA fields to reflect the
hard disabled state in accumulate_stolen_time(). This keeps the
overhead to that function, hopefully called rarely and only on
those pSeries machines.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---

diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 0104069..714685c 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -265,11 +265,26 @@ void accumulate_stolen_time(void)
 {
 	u64 sst, ust;
 
-	sst = scan_dispatch_log(get_paca()->starttime_user);
-	ust = scan_dispatch_log(get_paca()->starttime);
-	get_paca()->system_time -= sst;
-	get_paca()->user_time -= ust;
-	get_paca()->stolen_time += ust + sst;
+	u8 save_soft_enabled = local_paca->soft_enabled;
+	u8 save_hard_enabled = local_paca->hard_enabled;
+
+	/* We are called early in the exception entry, before
+	 * soft/hard_enabled are sync'ed to the expected state
+	 * for the exception. We are hard disabled but the PACA
+	 * needs to reflect that so various debug stuff doesn't
+	 * complain
+	 */
+	local_paca->soft_enabled = 0;
+	local_paca->hard_enabled = 0;
+
+	sst = scan_dispatch_log(local_paca->starttime_user);
+	ust = scan_dispatch_log(local_paca->starttime);
+	local_paca->system_time -= sst;
+	local_paca->user_time -= ust;
+	local_paca->stolen_time += ust + sst;
+
+	local_paca->soft_enabled = save_soft_enabled;
+	local_paca->hard_enabled = save_hard_enabled;
 }
 
 static inline u64 calculate_stolen_time(u64 stop_tb)

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-01-13  5:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-13  5:57 [PATCH] powerpc: Fix accumulate_stolen_time() vs. CONFIG_PREEMPT Benjamin Herrenschmidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).