All of lore.kernel.org
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Will Deacon <will@kernel.org>, Boqun Feng <boqun.feng@gmail.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	"the arch/x86 maintainers" <x86@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Marco Elver <elver@google.com>, Kees Cook <keescook@chromium.org>,
	Christoph Hellwig <hch@infradead.org>,
	Jens Axboe <axboe@kernel.dk>
Subject: Re: [PATCH v2 8/9] atomic,x86: Alternative atomic_*_overflow() scheme
Date: Mon, 13 Dec 2021 10:11:28 -0800	[thread overview]
Message-ID: <CAHk-=wjc+mr_Rh++5pPDkNFuceyPwFxCtzp124AppBLgbVVV0A@mail.gmail.com> (raw)
In-Reply-To: <20211213164334.GY16608@worktop.programming.kicks-ass.net>

On Mon, Dec 13, 2021 at 8:43 AM Peter Zijlstra <peterz@infradead.org> wrote:
>
> So Marco was expressing doubt about this exact interface for the
> atomic_*_overflow() functions, since it's extremely easy to get the
> whole ATOMIC_OVERFLOW_OFFSET thing wrong.

I missed that discussion (maybe it was on irc? Or maybe I just get too
much email).

Anyway, my preferred solution would simply be to make the ref-counting
atomics use a different type.

Voilà, problem solved. You can't really misuse them by mistake,
because you can't access it by mistake.

Sure, it could be a wrapper around 'atomic_t' on architectures that
end up using the generic fallback, so it might be as simple as

   typedef atomic_t atomic_ref_t;

in some asm-generic implementation, although I suspect that you'd want
type safety even there, and do

  typedef struct { atomic_t atomic_val; } atomic_ref_t;

But then on x86 - and other architectures that might prefer to use
that offset trick because they have flags - I'm not sure it even makes
sense to have anything to do with 'atomic_t' at all, since there would
basically be zero overlap with the regular atomic operations (partly
due to the offset, but partly simply because the 'ref' operations are
simply different).

(Wrt naming: I do think this is more about the "ref" part than the
"overflow" part - thus I'd suggest the "atomic_ref_t" rather than your
ofl naming).

            Linus

  parent reply	other threads:[~2021-12-13 18:11 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-10 16:16 [PATCH v2 0/9] refcount: Improve code-gen Peter Zijlstra
2021-12-10 16:16 ` [PATCH v2 1/9] atomic: Prepare scripts for macro ops Peter Zijlstra
2021-12-10 17:27   ` Mark Rutland
2021-12-10 17:43   ` Marco Elver
2021-12-10 16:16 ` [PATCH v2 2/9] atomic: Add xchg.tbl Peter Zijlstra
2021-12-13  9:50   ` Mark Rutland
2021-12-10 16:16 ` [PATCH v2 3/9] atomic: Introduce atomic_{inc,dec,dec_and_test}_overflow() Peter Zijlstra
2021-12-13 10:06   ` Mark Rutland
2021-12-13 10:57     ` Peter Zijlstra
2021-12-13 10:59     ` Peter Zijlstra
2021-12-13 11:09       ` Mark Rutland
2021-12-10 16:16 ` [PATCH v2 4/9] refcount: Use atomic_*_overflow() Peter Zijlstra
2021-12-13 10:35   ` Mark Rutland
2021-12-10 16:16 ` [PATCH v2 5/9] atomic,x86: Implement atomic_dec_and_test_overflow() Peter Zijlstra
2021-12-13 11:04   ` Mark Rutland
2021-12-10 16:16 ` [PATCH v2 6/9] refcount: Fix refcount_dec_not_one() Peter Zijlstra
2021-12-10 16:16 ` [PATCH v2 7/9] refcount: Prepare for atomic_*_overflow() offsets Peter Zijlstra
2021-12-10 16:16 ` [PATCH v2 8/9] atomic,x86: Alternative atomic_*_overflow() scheme Peter Zijlstra
2021-12-10 16:53   ` Linus Torvalds
2021-12-10 17:27     ` Linus Torvalds
2021-12-17  3:38     ` Herbert Xu
2021-12-13 16:43   ` Peter Zijlstra
2021-12-13 17:29     ` Marco Elver
2021-12-13 18:11     ` Linus Torvalds [this message]
2021-12-13 18:18       ` Marco Elver
2021-12-13 18:24         ` Linus Torvalds
2021-12-13 19:35           ` Marco Elver
2021-12-13 18:21       ` Linus Torvalds
2021-12-10 16:16 ` [PATCH v2 9/9] refcount: Optimize __refcount_add_not_zero(.i=1) Peter Zijlstra
2021-12-10 19:37 ` [PATCH v2 0/9] refcount: Improve code-gen Peter Zijlstra
2021-12-13 12:15 ` [PATCH v2 10/9] atomic: Document the atomic_{}_overflow() functions Peter Zijlstra
2021-12-13 12:20 ` [PATCH v2 0/9] refcount: Improve code-gen Peter Zijlstra
2021-12-13 14:42   ` Marco Elver
2021-12-13 16:11     ` Peter Zijlstra

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='CAHk-=wjc+mr_Rh++5pPDkNFuceyPwFxCtzp124AppBLgbVVV0A@mail.gmail.com' \
    --to=torvalds@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=boqun.feng@gmail.com \
    --cc=elver@google.com \
    --cc=hch@infradead.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=peterz@infradead.org \
    --cc=will@kernel.org \
    --cc=x86@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.