Re: [RFC PATCH] tty, add kref to sysrq handlers

From: Prarit Bhargava
Date: Fri Apr 27 2012 - 15:47:05 EST




On 04/27/2012 01:39 PM, Alan Cox wrote:
>> If the lock were removed, however, there is one _unlikely_ circumstance in
>> which the array would be left unprotected. That would be the situation in
>> which a module was loaded and the sysrq handler was registered during the
>> execution of the module. Again, the possibility of the scenario is very
>> small and given the existing usage of unregister_sysrq_key() in the tree
>> it seems like removing the lock is sufficient.
>
> It's asking for later disasters I think.

Yeah, you're right.

>
> I'm not sure I see we need a kref - that looks like overkill, and its
> probably even more elegantly done with RCU ?

Possibly -- I'll look into it.

>
>> Of course, I'm more than willing to hear additional suggestions. A rw
>> lock still requires that it be taken with irqs disabled so IMO it is out
>> of the question.
>
> One approach would be to defer the work. Is there any reason a slow sysrq
> handler shouldn't be expected to behave itself and schedule work to run
> later.

The problem with this is, as lwoodman pointed out me privately, deferring a
sysrq-t is not the best idea. When sysrq-t is issued we're trying to take a
snapshot of the system as it is at that particular moment, not after some
indeterminate amount of time. And, if the work scheduler is somehow the problem
(and the reason you're doing a sysrq-t) you won't execute at all.

Thanks for the suggestion Alan -- as always it is much appreciated. I'll see if
RCU is the solution here.

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