From: Alex Elder <elder@ieee.org>
To: Julia Lawall <julia.lawall@inria.fr>
Cc: Menna Mahmoud <eng.mennamahmoud.mm@gmail.com>,
gregkh@linuxfoundation.org, outreachy@lists.linux.dev,
johan@kernel.org, elder@kernel.org, linux-kernel@vger.kernel.org,
linux-staging@lists.linux.dev
Subject: Re: [PATCH v2] staging: greybus: use inline function for macros
Date: Wed, 22 Mar 2023 07:39:53 -0500 [thread overview]
Message-ID: <b1427fb9-1ec1-a5b7-8f1d-9751d4d13b77@ieee.org> (raw)
In-Reply-To: <eabacc6f-c7fb-ff33-26d1-271537fb4760@inria.fr>
On 3/22/23 5:00 AM, Julia Lawall wrote:
>
> Both seem to access the memory directly. Maybe the example is too simple,
> and the compiler is more likely to optimize aggressively?
Yes I think so. This is a little unrelated but the
"inline" keyword isn't very useful because the compiler
(at least when optimizing) already takes liberties of
inlining code that it "knows" will be better done that
way. Same thing here. This function is so trivial
that it's almost certainly going to be inlined.
So the benefit of a little helper function like this over
a macro is that its types are specified explicitly, and
there is no chance of macro arguments be duplicated or
improperly used in the right hand side. If it's not
inlined it also would normally generate stuff on the stack.
The benefit of the macro is you can do things with the
arguments because they're pass-by-name. But you can't
expect there to be any efficiency benefit.
-Alex
next prev parent reply other threads:[~2023-03-22 12:39 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-21 18:34 [PATCH v2] staging: greybus: use inline function for macros Menna Mahmoud
2023-03-21 18:50 ` Alex Elder
2023-03-21 20:43 ` Julia Lawall
2023-03-21 21:09 ` Alex Elder
2023-03-21 21:29 ` Julia Lawall
2023-03-21 22:42 ` Alex Elder
2023-03-22 10:00 ` Julia Lawall
2023-03-22 12:39 ` Alex Elder [this message]
2023-03-23 4:58 ` Greg KH
2023-03-23 5:05 ` Deepak R Varma
2023-03-23 5:22 ` Greg KH
2023-03-23 19:46 ` Deepak R Varma
2023-03-23 9:52 ` Julia Lawall
2023-03-25 8:49 ` Greg KH
2023-03-25 9:28 ` Julia Lawall
2023-03-22 9:13 ` Greg KH
-- strict thread matches above, loose matches on Subject: below --
2023-03-19 20:49 Menna Mahmoud
2023-03-19 20:56 ` Julia Lawall
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=b1427fb9-1ec1-a5b7-8f1d-9751d4d13b77@ieee.org \
--to=elder@ieee.org \
--cc=elder@kernel.org \
--cc=eng.mennamahmoud.mm@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=johan@kernel.org \
--cc=julia.lawall@inria.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=outreachy@lists.linux.dev \
/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