linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Trond Myklebust <trondmy@hammerspace.com>
To: "anna.schumaker@netapp.com" <anna.schumaker@netapp.com>,
	"linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>,
	"paul.burton@mips.com" <paul.burton@mips.com>
Cc: "bfields@fieldses.org" <bfields@fieldses.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"pburton@wavecomp.com" <pburton@wavecomp.com>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"jlayton@kernel.org" <jlayton@kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [PATCH] SUNRPC: Use atomic(64)_t for seq_send(64)
Date: Thu, 1 Nov 2018 17:57:43 +0000	[thread overview]
Message-ID: <65bc05f9685faf5a29f47805e4675f229f32531c.camel@hammerspace.com> (raw)
In-Reply-To: <20181101175109.8621-1-paul.burton@mips.com>

On Thu, 2018-11-01 at 17:51 +0000, Paul Burton wrote:
> The seq_send & seq_send64 fields in struct krb5_ctx are used as
> atomically incrementing counters. This is implemented using cmpxchg()
> &
> cmpxchg64() to implement what amount to custom versions of
> atomic_fetch_inc() & atomic64_fetch_inc().
> 
> Besides the duplication, using cmpxchg64() has another major drawback
> in
> that some 32 bit architectures don't provide it. As such commit
> 571ed1fd2390 ("SUNRPC: Replace krb5_seq_lock with a lockless scheme")
> resulted in build failures for some architectures.
> 
> Change seq_send to be an atomic_t and seq_send64 to be an atomic64_t,
> then use atomic(64)_* functions to manipulate the values. The
> atomic64_t
> type & associated functions are provided even on architectures which
> lack real 64 bit atomic memory access via CONFIG_GENERIC_ATOMIC64
> which
> uses spinlocks to serialize access. This fixes the build failures for
> architectures lacking cmpxchg64().
> 
> A potential alternative that was raised would be to provide
> cmpxchg64()
> on the 32 bit architectures that currently lack it, using spinlocks.
> However this would provide a version of cmpxchg64() with semantics a
> little different to the implementations on architectures with real 64
> bit atomics - the spinlock-based implementation would only work if
> all
> access to the memory used with cmpxchg64() is *always* performed
> using
> cmpxchg64(). That is not currently a requirement for users of
> cmpxchg64(), and making it one seems questionable. As such avoiding
> cmpxchg64() outside of architecture-specific code seems best,
> particularly in cases where atomic64_t seems like a better fit
> anyway.
> 
> The CONFIG_GENERIC_ATOMIC64 implementation of atomic64_* functions
> will
> use spinlocks & so faces the same issue, but with the key difference
> that the memory backing an atomic64_t ought to always be accessed via
> the atomic64_* functions anyway making the issue moot.
> 
> Signed-off-by: Paul Burton <paul.burton@mips.com>
> Fixes: 571ed1fd2390 ("SUNRPC: Replace krb5_seq_lock with a lockless
> scheme")
> Cc: Trond Myklebust <trond.myklebust@hammerspace.com>
> Cc: Anna Schumaker <anna.schumaker@netapp.com>
> Cc: J. Bruce Fields <bfields@fieldses.org>
> Cc: Jeff Layton <jlayton@kernel.org>
> Cc: David S. Miller <davem@davemloft.net>
> Cc: linux-nfs@vger.kernel.org
> Cc: netdev@vger.kernel.org
> ---
>  include/linux/sunrpc/gss_krb5.h     |  7 ++-----
>  net/sunrpc/auth_gss/gss_krb5_mech.c | 16 ++++++++++------
>  net/sunrpc/auth_gss/gss_krb5_seal.c | 28 ++-------------------------
> -
>  net/sunrpc/auth_gss/gss_krb5_wrap.c |  4 ++--
>  4 files changed, 16 insertions(+), 39 deletions(-)
> 

Thanks Paul! ...and thanks for your patience in working out the
atomicity wraparound issues. Applied..

-- 
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trond.myklebust@hammerspace.com



  reply	other threads:[~2018-11-01 17:57 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-31 19:52 [RFC PATCH] lib: Introduce generic __cmpxchg_u64() and use it where needed Guenter Roeck
2018-10-31 21:32 ` Paul Burton
2018-10-31 22:02   ` Guenter Roeck
2018-10-31 23:32     ` Paul Burton
2018-11-01  0:17       ` Trond Myklebust
2018-11-01 13:18         ` Mark Rutland
2018-11-01 14:59           ` Peter Zijlstra
2018-11-01 15:22             ` Trond Myklebust
2018-11-01 16:32               ` Peter Zijlstra
2018-11-01 16:59                 ` Eric Dumazet
2018-11-01 17:14                   ` Peter Zijlstra
2018-11-01 17:27                     ` Peter Zijlstra
2018-11-01 20:29                       ` Paul E. McKenney
2018-11-01 21:38                         ` Peter Zijlstra
2018-11-01 22:26                           ` Paul E. McKenney
2018-11-01 17:43                     ` Paul E. McKenney
2018-11-01 17:01                 ` Paul E. McKenney
2018-11-01 17:18                   ` Peter Zijlstra
2018-11-01 17:34                     ` Paul E. McKenney
2018-11-01 17:46                     ` Dmitry Vyukov
2018-11-01 21:45                       ` Peter Zijlstra
2018-11-02 10:56                   ` David Laight
2018-11-02 12:23                     ` Peter Zijlstra
2018-11-02 13:38                       ` Paul E. McKenney
2018-11-02 13:37                     ` Paul E. McKenney
2018-11-02 16:19                 ` Andrey Ryabinin
2018-11-05 10:38                   ` Peter Zijlstra
2018-11-05 14:24                   ` Peter Zijlstra
2018-11-01 17:51             ` [PATCH] SUNRPC: Use atomic(64)_t for seq_send(64) Paul Burton
2018-11-01 17:57               ` Trond Myklebust [this message]
2018-11-01 17:54         ` [RFC PATCH] lib: Introduce generic __cmpxchg_u64() and use it where needed Paul Burton
2018-11-01  1:18       ` Guenter Roeck
2018-11-01  6:30         ` Trond Myklebust
2018-11-01 15:28           ` Guenter Roeck

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=65bc05f9685faf5a29f47805e4675f229f32531c.camel@hammerspace.com \
    --to=trondmy@hammerspace.com \
    --cc=anna.schumaker@netapp.com \
    --cc=bfields@fieldses.org \
    --cc=davem@davemloft.net \
    --cc=jlayton@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=paul.burton@mips.com \
    --cc=pburton@wavecomp.com \
    /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).