From: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
To: Olivier Matz <olivier.matz@6wind.com>, "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [memnic PATCH] pmd: use memory barrier function instead of asm volatile
Date: Thu, 30 Jan 2014 11:42:59 +0000 [thread overview]
Message-ID: <7F861DC0615E0C47A872E6F3C5FCDDBD0102D11D@BPXM14GP.gisp.nec.co.jp> (raw)
In-Reply-To: <1390579157-23890-1-git-send-email-olivier.matz@6wind.com>
> Subject: [dpdk-dev] [memnic PATCH] pmd: use memory barrier function instead of asm volatile
>
> Use the DPDK specific function rte_mb() instead of
> the GCC statement asm volatile ("" ::: "memory").
Yes, that's preferred for DPDK, I think.
Looks okay to me.
By the way, I was also asked to use rte atomic function
instead of cmpxchg asm statement.
My re-submitted version in dpdk-ovs has such a change.
What do you think?
thanks,
Hiroshi
>
> Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
> ---
> common/memnic.h | 2 --
> pmd/pmd_memnic.c | 6 +++---
> 2 files changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/common/memnic.h b/common/memnic.h
> index 6ff38a0..fdc9fa3 100644
> --- a/common/memnic.h
> +++ b/common/memnic.h
> @@ -123,8 +123,6 @@ struct memnic_area {
> /* for userspace */
> #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
>
> -#define barrier() do { asm volatile("": : :"memory"); } while (0)
> -
> static inline uint32_t cmpxchg(uint32_t *dst, uint32_t old, uint32_t new)
> {
> volatile uint32_t *ptr = (volatile uint32_t *)dst;
> diff --git a/pmd/pmd_memnic.c b/pmd/pmd_memnic.c
> index bc01746..1586222 100644
> --- a/pmd/pmd_memnic.c
> +++ b/pmd/pmd_memnic.c
> @@ -100,7 +100,7 @@ static int memnic_dev_start(struct rte_eth_dev *dev)
>
> /* invalidate */
> adapter->nic->hdr.valid = 0;
> - barrier();
> + rte_mb();
> /* reset */
> adapter->nic->hdr.reset = 1;
> /* no need to wait here */
> @@ -242,7 +242,7 @@ static uint16_t memnic_recv_pkts(void *rx_queue,
> mb->pkt.data_len = p->len;
> rx_pkts[nr] = mb;
>
> - barrier();
> + rte_mb();
> p->status = MEMNIC_PKT_ST_FREE;
>
> if (++idx >= MEMNIC_NR_PACKET)
> @@ -290,7 +290,7 @@ retry:
>
> rte_memcpy(p->data, rte_pktmbuf_mtod(tx_pkts[nr], void *), len);
>
> - barrier();
> + rte_mb();
> p->status = MEMNIC_PKT_ST_FILLED;
>
> rte_pktmbuf_free(tx_pkts[nr]);
> --
> 1.8.4.rc3
next prev parent reply other threads:[~2014-01-30 11:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-24 15:59 Olivier Matz
2014-01-30 11:42 ` Hiroshi Shimamoto [this message]
2014-01-31 9:52 ` Olivier MATZ
2014-02-04 13:08 ` Thomas Monjalon
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=7F861DC0615E0C47A872E6F3C5FCDDBD0102D11D@BPXM14GP.gisp.nec.co.jp \
--to=h-shimamoto@ct.jp.nec.com \
--cc=dev@dpdk.org \
--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).