Re: WARNING in __static_key_slow_dec

From: Willem de Bruijn
Date: Sun May 20 2018 - 18:12:35 EST


>
> -static void sock_disable_timestamp(struct sock *sk, unsigned long flags)
> +static void sock_disable_timestamp(struct sock *sk, unsigned long flag)
> {
> - if (sk->sk_flags & flags) {
> - sk->sk_flags &= ~flags;
> - if (sock_needs_netstamp(sk) &&
> - !(sk->sk_flags & SK_FLAGS_TIMESTAMP))
> - net_disable_timestamp();
> - }
> + unsigned long prev;
> +
> + do {
> + prev = READ_ONCE(sk->sk_flags);
> +
> + if (!(prev & flag))
> + return;
> +
> + if (cmpxchg(&sk->sk_flags, prev, prev & ~flag) == prev)
> + break;
> + } while (1);

and this can just use set_mask_bits