DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jianbo Liu <jianbo.liu@linaro.org>
To: Olivier MATZ <olivier.matz@6wind.com>
Cc: Jerin Jacob <jerin.jacob@caviumnetworks.com>, dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] mbuf: extend rte_mbuf_prefetch_part* to support more prefetching methods
Date: Thu, 2 Jun 2016 17:12:49 +0800	[thread overview]
Message-ID: <CAP4Qi38i7Uq6r8o8dE-1fSboEGr0nBe8yz2c9wFPS2HrrqBmsQ@mail.gmail.com> (raw)
In-Reply-To: <574FDBED.8050003@6wind.com>

On 2 June 2016 at 15:10, Olivier MATZ <olivier.matz@6wind.com> wrote:
> Hi Jianbo,
>
> On 06/01/2016 05:29 AM, Jianbo Liu wrote:
>>> enum rte_mbuf_prefetch_type {
>>> >         PREFETCH0,
>>> >         PREFETCH1,
>>> > ...
>>> > };
>>> >
>>> > static inline void
>>> > rte_mbuf_prefetch_part1(enum rte_mbuf_prefetch_type type,
>>> >         struct rte_mbuf *m)
>>> > {
>>> >         switch (type) {
>>> >         case PREFETCH0:
>>> >                 rte_prefetch0(&m->cacheline0);
>>> >                 break;
>>> >         case PREFETCH1:
>>> >                 rte_prefetch1(&m->cacheline0);
>>> >                 break;
>>> >         ...
>>> > }
>>> >
>> How about adding these to forbid the illegal use of this macro?
>> enum rte_mbuf_prefetch_type {
>>          ENUM_prefetch0,
>>          ENUM_prefetch1,
>>  ...
>> };
>>
>> #define RTE_MBUF_PREFETCH_PART1(type, m) \
>>     if (ENUM_##type == ENUM_prefretch0) \
>>         rte_prefetch0(&(m)->cacheline0);   \
>>     else if (ENUM_##type == ENUM_prefetch1) \
>>         rte_prefetch1(&(m)->cacheline0); \
>>     ....
>>
>
> As Stephen stated, a static inline is better than a macro, mainly
> because it is understood by the compiler instead of beeing a dumb
> code replacement.
>
> Any reason why you would prefer a macro in that case?
>
For the simplicity reason. If not, we may have to write several
similar functions for different prefetchings.

  reply	other threads:[~2016-06-02  9:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-31  3:06 Jianbo Liu
2016-05-31 19:28 ` Olivier MATZ
2016-06-01  3:29   ` Jianbo Liu
2016-06-01  6:00     ` Jerin Jacob
2016-06-02  9:04       ` Jianbo Liu
2016-06-02  9:30         ` Jerin Jacob
2016-06-21 14:56           ` Olivier Matz
2016-06-02  7:10     ` Olivier MATZ
2016-06-02  9:12       ` Jianbo Liu [this message]
2016-05-31 20:00 ` Stephen Hemminger

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=CAP4Qi38i7Uq6r8o8dE-1fSboEGr0nBe8yz2c9wFPS2HrrqBmsQ@mail.gmail.com \
    --to=jianbo.liu@linaro.org \
    --cc=dev@dpdk.org \
    --cc=jerin.jacob@caviumnetworks.com \
    --cc=olivier.matz@6wind.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).