Re: Writable module parameters - should be volatile?

From: Rusty Russell
Date: Mon Sep 13 2004 - 12:59:49 EST


On Sun, 2004-09-12 at 21:57, Duncan Sands wrote:
> I declare a writable module parameter as follows:
>
> static unsigned int num_rcv_urbs = UDSL_DEFAULT_RCV_URBS;
>
> module_param (num_rcv_urbs, uint, S_IRUGO | S_IWUSR);
>
> Shouldn't I declare num_rcv_urbs volatile? Otherwise compiler
> optimizations could (for example) stick it in a register and miss
> any changes made by someone writing to it...

Sure. If it really matters, you're going to need something stronger
than that, eg module_param_call(). For debugging, it's not usually a
problem. For more complex parameters, you usually need locks anyway.

Cheers,
Rusty.
--
Anyone who quotes me in their signature is an idiot -- Rusty Russell

-
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/