lkml.org 
[lkml]   [2018]   [Dec]   [23]   [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 Sat, Dec 22, 2018 at 11:31 PM Eric Dumazet <eric.dumazet@gmail.com> wrote:
>
>
>
> On 12/21/2018 12:27 PM, Deepa Dinamani wrote:
> > Al Viro mentioned that there is probably a race condition
> > lurking in accesses of sk_tstamp on 32-bit machines.
> >
> > sock->sk_tstamp is of type ktime_t which is always an s64.
> > On a 32 bit architecture, we might run into situations of
> > unsafe access as the access to the field becomes non atomic.
> >
> > Use seqlocks for synchronization.
> > This allows us to avoid using spinlocks for readers as
> > readers do not need mutual exclusion.
> >
>
> Hi Deepa
>
> Please come up with something that has zero added costs for 64bit kernels.
>
> Most of us do not really care about 32bit kernels anymore, so we do not want to slow
> down 64bits kernels for such things.
>
> Look at include/linux/u64_stats_sync.h for initial thoughts.

This is similar to what I did here. But, I can add a few ifdef's to
make this code a noop on 64 bit arches.
I will include this in my next update.

I'm assuming there is no contention on whether writers need exclusive
access and hence requiring a lock here.
Let me know otherwise.

Thanks,
Deepa

\
 
 \ /
  Last update: 2018-12-23 19:50    [W:0.099 / U:2.888 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site