Message ID | 20160201111313.GQ6357@twins.programming.kicks-ass.net (mailing list archive) |
---|---|
State | Rejected |
Delegated to: | Johannes Berg |
Headers | show |
On Mon, 2016-02-01 at 12:13 +0100, Peter Zijlstra wrote: > > Yeah, from the rfkill code, which you failed to CC. Thanks Peter :) > In any case, this is a fail in the rfkill code, which should be > sorted > with the below patch (but the rfkill people should double check), and > ideally they'd use list_empty_careful() instead of the mutex, but I > don't know their code well enough to say if that's safe or not. Even list_empty() is fine in this case since we go and recheck it anyway in the calling loop, while the mutex is held. I have commit 6736fde9672f on its way to mainline. johannes -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Mon, Feb 01, 2016 at 12:26:06PM +0100, Johannes Berg wrote: > On Mon, 2016-02-01 at 12:13 +0100, Peter Zijlstra wrote: > > > > Yeah, from the rfkill code, which you failed to CC. > > Thanks Peter :) > > > In any case, this is a fail in the rfkill code, which should be > > sorted > > with the below patch (but the rfkill people should double check), and > > ideally they'd use list_empty_careful() instead of the mutex, but I > > don't know their code well enough to say if that's safe or not. > > Even list_empty() is fine in this case since we go and recheck it > anyway in the calling loop, while the mutex is held. > > I have commit 6736fde9672f on its way to mainline. OK, that looks good. Thanks! -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/net/rfkill/core.c b/net/rfkill/core.c index f53bf3b6558b..74c99ad28a0c 100644 --- a/net/rfkill/core.c +++ b/net/rfkill/core.c @@ -1099,6 +1099,15 @@ static bool rfkill_readable(struct rfkill_data *data) { bool r; + /* + * The below mutex_lock() will destroy task::state when it blocks + * and cause the outer wait_event loop to not block. + * + * Assuming contention on this mutex is rare, an occasional extra loop + * in the wait_event code will not hurt. + */ + sched_annotate_sleep(); + mutex_lock(&data->mtx); r = !list_empty(&data->events); mutex_unlock(&data->mtx);