linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Leonardo Bras Soares Passos <leobras@redhat.com>
To: Andrea Parri <parri.andrea@gmail.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	 Albert Ou <aou@eecs.berkeley.edu>, Guo Ren <guoren@kernel.org>,
	 linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [RESEND RFC PATCH v2 1/6] riscv/cmpxchg: Deduplicate cmpxchg() asm functions
Date: Wed, 22 Mar 2023 00:50:45 -0300	[thread overview]
Message-ID: <CAJ6HWG46-an3r3WH+n8mHHge8SjqgMbohjTmmk=_EXVmwKZSeA@mail.gmail.com> (raw)
In-Reply-To: <ZBpPms0PGv4sWR1Y@andrea>

On Tue, Mar 21, 2023 at 9:45 PM Andrea Parri <parri.andrea@gmail.com> wrote:
>
> On Tue, Mar 21, 2023 at 04:42:44AM -0300, Leonardo Bras wrote:
> > In this header every cmpxchg define (_relaxed, _acquire, _release,
> > vanilla) contain it's own asm file, both for 4-byte variables an 8-byte
> > variables, on a total of 8 versions of mostly the same asm.
> >
> > This is usually bad, as it means any change may be done in up to 8
> > different places.
> >
> > Unify those versions by creating a new define with enough parameters to
> > generate any version of the previous 8.
> >
> > (This did not cause any change in generated asm)
> >
> > Signed-off-by: Leonardo Bras <leobras@redhat.com>
> > ---
> >  arch/riscv/include/asm/cmpxchg.h | 102 ++++++++-----------------------
> >  1 file changed, 24 insertions(+), 78 deletions(-)
>
> Diff looks nice,

Hello Andrea, thanks for reviewing!


> > +#define ___cmpxchg(lr_sfx, sc_sfx, prepend, append)                  \
> > +{                                                                    \
> > +     __asm__ __volatile__ (                                          \
> > +             prepend                                                 \
> > +             "0:     lr" lr_sfx " %0, %2\n"                          \
> > +             "       bne  %0, %z3, 1f\n"                             \
> > +             "       sc" sc_sfx " %1, %z4, %2\n"                     \
> > +             "       bnez %1, 0b\n"                                  \
> > +             append                                                  \
> > +             "1:\n"                                                  \
> > +             : "=&r" (__ret), "=&r" (__rc), "+A" (*__ptr)            \
> > +             : "rJ" ((long)__old), "rJ" (__new)                      \
> > +             : "memory");                                            \
> > +}
>
> Though I'm not really a fan of macros depending on local variables with
> "magic" names, can this be avoided?

You mean __ret, __rc, __ptr, __old and __new ?
If so, yes, we could add them to the macro signature, but it would
become quite big with not much to gain. To reduce impact it could be
something like:

+#define ___cmpxchg(lr_sfx, sc_sfx, prepend, append, ret, r, p, o, n)

Is this a possible fix?
>
> Thanks,
>   Andrea
>

Thank you!
Leo


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2023-03-22  3:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-21  7:42 [RESEND RFC PATCH v2 0/6] Deduplicating RISCV cmpxchg.h macros Leonardo Bras
2023-03-21  7:42 ` [RESEND RFC PATCH v2 1/6] riscv/cmpxchg: Deduplicate cmpxchg() asm functions Leonardo Bras
2023-03-22  0:45   ` Andrea Parri
2023-03-22  3:50     ` Leonardo Bras Soares Passos [this message]
2023-03-22  7:50       ` Andrea Parri
2023-03-21  7:42 ` [RESEND RFC PATCH v2 2/6] riscv/cmpxchg: Deduplicate cmpxchg() macros Leonardo Bras
2023-03-21  7:42 ` [RESEND RFC PATCH v2 3/6] riscv/cmpxchg: Deduplicate arch_cmpxchg() macros Leonardo Bras
2023-03-21  7:42 ` [RESEND RFC PATCH v2 4/6] riscv/cmpxchg: Deduplicate xchg() asm functions Leonardo Bras
2023-03-21  7:42 ` [RESEND RFC PATCH v2 5/6] riscv/cmpxchg: Deduplicate xchg() macros Leonardo Bras
2023-03-21  7:42 ` [RESEND RFC PATCH v2 6/6] riscv/cmpxchg: Deduplicate arch_xchg() macros Leonardo Bras

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='CAJ6HWG46-an3r3WH+n8mHHge8SjqgMbohjTmmk=_EXVmwKZSeA@mail.gmail.com' \
    --to=leobras@redhat.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=guoren@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=parri.andrea@gmail.com \
    --cc=paul.walmsley@sifive.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).