linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@redhat.com>
To: deepa.kernel@gmail.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-nfs@vger.kernel.org, viro@zeniv.linux.org.uk,
	arnd@arndb.de, eric.dumazet@gmail.com, y2038@lists.linaro.org
Subject: Re: [PATCH v3] sock: Make sock->sk_stamp thread-safe
Date: Tue, 01 Jan 2019 09:49:01 -0800 (PST)	[thread overview]
Message-ID: <20190101.094901.728478837131793069.davem@redhat.com> (raw)
In-Reply-To: <20181228025509.14194-1-deepa.kernel@gmail.com>

From: Deepa Dinamani <deepa.kernel@gmail.com>
Date: Thu, 27 Dec 2018 18:55:09 -0800

> Al Viro mentioned (Message-ID
> <20170626041334.GZ10672@ZenIV.linux.org.uk>)
> that there is probably a race condition
> lurking in accesses of sk_stamp on 32-bit machines.
> 
> sock->sk_stamp 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.
> 
> Another approach to solve this is to require sk_lock for all
> modifications of the timestamps. The current approach allows
> for timestamps to have their own lock: sk_stamp_lock.
> This allows for the patch to not compete with already
> existing critical sections, and side effects are limited
> to the paths in the patch.
> 
> The addition of the new field maintains the data locality
> optimizations from
> commit 9115e8cd2a0c ("net: reorganize struct sock for better data
> locality")
> 
> Note that all the instances of the sk_stamp accesses
> are either through the ioctl or the syscall recvmsg.
> 
> Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>

Ok, I'm fine with this, so applied and queued up for -stable.

I will note in passing that there are several 32-bit architectures
that have 64-bit loads.  Sparc is one such case.  And they would not
need these changes.

But I don't think it's practical or worthwhile to add that level of
consideration into your changes.  I'd rather the commit stay as simple
as possible.

Thanks!

      reply	other threads:[~2019-01-01 17:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-28  2:55 [PATCH v3] sock: Make sock->sk_stamp thread-safe Deepa Dinamani
2019-01-01 17:49 ` David Miller [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190101.094901.728478837131793069.davem@redhat.com \
    --to=davem@redhat.com \
    --cc=arnd@arndb.de \
    --cc=deepa.kernel@gmail.com \
    --cc=eric.dumazet@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=y2038@lists.linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).