On Fri, May 02, 2008 at 02:59:29PM +0200, Peter Zijlstra wrote:
OK, so one approach would be to check for irqs being disabled,
perhaps as follows, on top of my previous patch:
struct call_single_data *data = NULL;
if (!wait) {
data = kmalloc(sizeof(*data), GFP_ATOMIC);
if (data)
data->flags = CSD_FLAG_ALLOC;
}
if (!data) {
if (unlikely(irqs_disabled())) {
put_cpu();
return -ENOMEM;
}
data = &d;
data->flags = CSD_FLAG_WAIT;
}
data->func = func;
data->info = info;
generic_exec_single(cpu, data);
That would prevent -ENOMEM unless you invoked the function with irqs
disabled. So normal callers would still see the current failure-free
semantics -- you really don't want to be inflicting failure when not
necessary, right?
There could only be one irq-disabled caller at a time, which could be
handled using a trylock, returning -EBUSY if the lock is already held.
Otherwise, you end up with the scenario called out above (which Keith
Ownens pointed out some years ago).
Does this approach make sense?
Thanx, Paul
--