Linux-Block Archive on lore.kernel.org
 help / color / Atom feed
From: Hrvoje Zeba <zeba.hrvoje@gmail.com>
To: Julia Suvorova <jusual@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>,
	Bart Van Assche <bvanassche@acm.org>,
	linux-block@vger.kernel.org, Stefan Hajnoczi <stefanha@gmail.com>,
	Aarushi Mehta <mehta.aaru20@gmail.com>
Subject: Re: [PATCH] liburing/barrier.h: Add prefix io_uring to barriers
Date: Thu, 15 Aug 2019 20:03:30 -0400
Message-ID: <CAEsUgYiAXkjSFHpUOfqd9rwSMhmG4OnK7fa-f=uHddZNGVuRzg@mail.gmail.com> (raw)
In-Reply-To: <CAMDeoFXJ3r_axyrDWwHkbz-9o42WyT-rcTfXZjrmmp7GK82brA@mail.gmail.com>

On Wed, Aug 14, 2019 at 11:24 AM Julia Suvorova <jusual@redhat.com> wrote:
>
> On Mon, Aug 12, 2019 at 6:03 PM Jens Axboe <axboe@kernel.dk> wrote:
> >
> > On 8/12/19 7:55 AM, Bart Van Assche wrote:
> > > On 8/12/19 5:39 AM, Julia Suvorova wrote:
> > >> -#define mb()        asm volatile("mfence" ::: "memory")
> > >> -#define rmb()       asm volatile("lfence" ::: "memory")
> > >> -#define wmb()       asm volatile("sfence" ::: "memory")
> > >> -#define smp_rmb() barrier()
> > >> -#define smp_wmb() barrier()
> > >> +#define io_uring_mb()               asm volatile("mfence" ::: "memory")
> > >> +#define io_uring_rmb()              asm volatile("lfence" ::: "memory")
> > >> +#define io_uring_wmb()              asm volatile("sfence" ::: "memory")
> > >> +#define io_uring_smp_rmb()  io_uring_barrier()
> > >> +#define io_uring_smp_wmb()  io_uring_barrier()
> > >
> > > Do users of liburing need these macros? If not, have you considered to
> > > move these macros to a new header file that is only used inside liburing
> > > and such that these macros are no longer visible to liburing users?
> >
> > The exposed API should not need any explicit barriers from the user,
> > so this suggestion makes a lot of sense to me.
>
> How about moving the definition of io_uring_cqe_seen() with whole
> io_uring_cq_advance() and io_uring_for_each_cqe() from liburing.h to
> queue.c? This way we can cover all barriers, and leave barrier.h local.
>
> Do you need io_uring_cq_advance and io_uring_for_each_cqe in the
> library?
>

This is one of the usage patterns:

io_uring_cqe* cqe;
int head;
int count = 0;

io_uring_for_each_cqe(&m_io_uring, head, cqe)
{
    /* ... */
    count++;
}

io_uring_cq_advance(&m_io_uring, count);


A little bit more performance is squeezed out this way.


Hrvoje Zeba

  reply index

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-12 12:39 Julia Suvorova
2019-08-12 13:40 ` Stefan Hajnoczi
2019-08-12 13:55 ` Bart Van Assche
2019-08-12 16:03   ` Jens Axboe
2019-08-14 15:23     ` Julia Suvorova
2019-08-16  0:03       ` Hrvoje Zeba [this message]
2019-08-19 14:46 ` Jens Axboe
2019-08-20 12:46   ` Julia Suvorova

Reply instructions:

You may reply publically 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='CAEsUgYiAXkjSFHpUOfqd9rwSMhmG4OnK7fa-f=uHddZNGVuRzg@mail.gmail.com' \
    --to=zeba.hrvoje@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=jusual@redhat.com \
    --cc=linux-block@vger.kernel.org \
    --cc=mehta.aaru20@gmail.com \
    --cc=stefanha@gmail.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

Linux-Block Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-block/0 linux-block/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-block linux-block/ https://lore.kernel.org/linux-block \
		linux-block@vger.kernel.org linux-block@archiver.kernel.org
	public-inbox-index linux-block


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-block


AGPL code for this site: git clone https://public-inbox.org/ public-inbox