lkml.org 
[lkml]   [2018]   [Dec]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] sock: Make sock->sk_tstamp thread-safe
On 12/21/18, Deepa Dinamani <deepa.kernel@gmail.com> wrote:
> diff --git a/include/net/sock.h b/include/net/sock.h
> index fe58aec00d09..2cb641606533 100644
> --- a/include/net/sock.h
> +++ b/include/net/sock.h
> @@ -2311,8 +2313,11 @@ sock_recv_timestamp(struct msghdr *msg, struct sock
> *sk, struct sk_buff *skb)
> (hwtstamps->hwtstamp &&
> (sk->sk_tsflags & SOF_TIMESTAMPING_RAW_HARDWARE)))
> __sock_recv_timestamp(msg, sk, skb);
> - else
> + else {
> + write_seqlock(&sk->sk_stamp_seq);
> sk->sk_stamp = kt;
> + write_sequnlock(&sk->sk_stamp_seq);
> + }
>
> if (sock_flag(sk, SOCK_WIFI_STATUS) && skb->wifi_acked_valid)
> __sock_recv_wifi_status(msg, sk, skb);
> @@ -2332,10 +2337,15 @@ static inline void sock_recv_ts_and_drops(struct
> msghdr *msg, struct sock *sk,
>
> if (sk->sk_flags & FLAGS_TS_OR_DROPS || sk->sk_tsflags & TSFLAGS_ANY)
> __sock_recv_ts_and_drops(msg, sk, skb);
> - else if (unlikely(sock_flag(sk, SOCK_TIMESTAMP)))
> + else if (unlikely(sock_flag(sk, SOCK_TIMESTAMP))) {
> + write_seqlock(&sk->sk_stamp_seq);
> sk->sk_stamp = skb->tstamp;
> - else if (unlikely(sk->sk_stamp == SK_DEFAULT_STAMP))
> + write_sequnlock(&sk->sk_stamp_seq);
> + } else if (unlikely(sk->sk_stamp == SK_DEFAULT_STAMP)) {
> + write_seqlock(&sk->sk_stamp_seq);
> sk->sk_stamp = 0;
> + write_sequnlock(&sk->sk_stamp_seq);
> + }
> }
>

Hi Deepa,

Thanks a lot for the follow-up to our earlier discussion here!

Are we actually worried about concurrent writers here? I thought the
only problem was a race between writer and reader, which would mean
that we could solve it using only a seqcount_t which is cheaper to
update than a seqlock_t.

Arnd

\
 
 \ /
  Last update: 2018-12-22 18:21    [W:0.069 / U:3.152 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site