Re: Stack traces in 2.6.9-rc2-mm4

From: Nick Piggin
Date: Tue Sep 28 2004 - 03:05:17 EST


Ingo Molnar wrote:
* J.A. Magallon <jamagallon@xxxxxxx> wrote:


I got the same on another place...

Sep 28 00:48:51 werewolf kernel: using smp_processor_id() in preemptible code: X/4012
Sep 28 00:48:51 werewolf kernel: [smp_processor_id+135/141] smp_processor_id+0x87/0x8d
Sep 28 00:48:51 werewolf kernel: [add_timer_randomness+314/365] add_timer_randomness+0x13a/0x16d
Sep 28 00:48:51 werewolf kernel: [<b0206733>] add_timer_randomness+0x13a/0x16d
Sep 28 00:48:51 werewolf kernel: [input_event+85/999] input_event+0x55/0x3e7


the one below should fix this: a certain codepath in the random driver
relied on vt_ioctl() being under the BKL and implicitly disabling
preemption. The code wasnt buggy upstream but it's slighly unrobust so i
think we want the fix upstream too, independently of the remove-bkl
patch. This change has been in the -VP patchset for some time so it
should work fine.

Ingo

--- linux/drivers/char/random.c.orig
+++ linux/drivers/char/random.c
@@ -807,10 +807,11 @@ static void add_timer_randomness(struct long delta, delta2, delta3;
int entropy = 0;
+ preempt_disable();
/* if over the trickle threshold, use only 1 in 4096 samples */
if ( random_state->entropy_count > trickle_thresh &&
(__get_cpu_var(trickle_count)++ & 0xfff))
- return;
+ goto out;

It looks like upstream code *is* buggy because that is a non-atomic
RMW operation on the per-cpu var, no? Hence you must disable preempt.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/