netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Gregory Haskins <ghaskins@novell.com>
Cc: linux-kernel@vger.kernel.org,
	alacrityvm-devel@lists.sourceforge.net, netdev@vger.kernel.org
Subject: Re: [PATCH 1/7] shm-signal: shared-memory signals
Date: Thu, 6 Aug 2009 15:56:55 +0200	[thread overview]
Message-ID: <200908061556.55390.arnd@arndb.de> (raw)
In-Reply-To: <20090803171735.17268.37490.stgit@dev.haskins.net>

On Monday 03 August 2009, Gregory Haskins wrote:
> shm-signal provides a generic shared-memory based bidirectional
> signaling mechanism.  It is used in conjunction with an existing
> signal transport (such as posix-signals, interrupts, pipes, etc) to
> increase the efficiency of the transport since the state information
> is directly accessible to both sides of the link.  The shared-memory
> design provides very cheap access to features such as event-masking
> and spurious delivery mititgation, and is useful implementing higher
> level shared-memory constructs such as rings.

Looks like a very useful feature in general.

> +struct shm_signal_irq {
> +       __u8                  enabled;
> +       __u8                  pending;
> +       __u8                  dirty;
> +};

Won't this layout cause cache line ping pong? Other schemes I have
seen try to separate the bits so that each cache line is written to
by only one side. This gets much more interesting if the two sides
are on remote ends of an I/O link, e.g. using a nontransparent
PCI bridge, where you only want to send stores over the wire, but
never fetches or even read-modify-write cycles.

Your code is probably optimal if you only communicate between host
and guest code on the same CPU, but not so good if it crosses NUMA
nodes or worse.

> +struct shm_signal_desc {
> +       __u32                 magic;
> +       __u32                 ver;
> +       struct shm_signal_irq irq[2];
> +};

This data structure has implicit padding of two bytes at the end.
How about adding another '__u16 reserved' to make it explicit?

> +	/*
> +	 * We always mark the remote side as dirty regardless of whether
> +	 * they need to be notified.
> +	 */
> +	irq->dirty = 1;
> +	wmb();   /* dirty must be visible before we test the pending state */
> +
> +	if (irq->enabled && !irq->pending) {
> +		rmb();
> +
> +		/*
> +		 * If the remote side has enabled notifications, and we do
> +		 * not see a notification pending, we must inject a new one.
> +		 */
> +		irq->pending = 1;
> +		wmb(); /* make it visible before we do the injection */
> +
> +		s->ops->inject(s);
> +	}

Barriers always confuse me, but the rmb() looks slightly wrong. AFAIU
it only prevents reads after the barrier from being done before the
barrier, but you don't do any reads after it.

The (irq->enabled && !irq->pending) check could be done before the
irq->dirty = 1 arrives at the bus, but that does not seem to hurt, it
would at most cause a duplicate ->inject().

Regarding the scope of the barrier, did you intentionally use the
global versions (rmb()/wmb()) and not the lighter single-system
(smp_rmb()/smp_wmb()) versions? Your version should cope with remote
links over PCI but looks otherwise optimized for local use, as I
wrote above.

	Arnd <><

  reply	other threads:[~2009-08-06 13:57 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-03 17:17 [PATCH 0/7] AlacrityVM guest drivers Gregory Haskins
2009-08-03 17:17 ` [PATCH 1/7] shm-signal: shared-memory signals Gregory Haskins
2009-08-06 13:56   ` Arnd Bergmann [this message]
2009-08-06 15:11     ` Gregory Haskins
2009-08-06 20:51       ` Ira W. Snyder
2009-08-03 17:17 ` [PATCH 2/7] ioq: Add basic definitions for a shared-memory, lockless queue Gregory Haskins
2009-08-03 17:17 ` [PATCH 3/7] vbus: add a "vbus-proxy" bus model for vbus_driver objects Gregory Haskins
2009-08-03 17:17 ` [PATCH 4/7] vbus-proxy: add a pci-to-vbus bridge Gregory Haskins
2009-08-06 14:42   ` Arnd Bergmann
2009-08-06 15:59     ` Gregory Haskins
2009-08-06 17:03       ` Arnd Bergmann
2009-08-06 21:04         ` Gregory Haskins
2009-08-06 22:57           ` Arnd Bergmann
2009-08-07  4:42             ` Gregory Haskins
2009-08-07 14:57               ` Arnd Bergmann
2009-08-07 15:44                 ` Gregory Haskins
2009-08-07 15:55               ` Ira W. Snyder
2009-08-07 18:25                 ` Gregory Haskins
2009-08-03 17:17 ` [PATCH 5/7] ioq: add driver-side vbus helpers Gregory Haskins
2009-08-03 17:18 ` [PATCH 6/7] net: Add vbus_enet driver Gregory Haskins
2009-08-03 18:30   ` Stephen Hemminger
2009-08-03 20:10     ` Gregory Haskins
2009-08-03 20:19       ` Stephen Hemminger
2009-08-03 20:24         ` Gregory Haskins
2009-08-03 20:29           ` Stephen Hemminger
2009-08-04  1:14   ` [PATCH v2] " Gregory Haskins
2009-08-04  2:38     ` David Miller
2009-08-04 13:57       ` [Alacrityvm-devel] " Gregory Haskins
2009-10-02 15:33     ` [PATCH v3] " Gregory Haskins
2009-08-03 17:18 ` [PATCH 7/7] venet: add scatter-gather/GSO support Gregory Haskins
2009-08-03 18:32   ` Stephen Hemminger
2009-08-03 19:30     ` Gregory Haskins
2009-08-03 18:33   ` Stephen Hemminger
2009-08-03 19:57     ` Gregory Haskins
2009-08-06  8:19 ` [PATCH 0/7] AlacrityVM guest drivers Reply-To: Michael S. Tsirkin
2009-08-06 10:17   ` Michael S. Tsirkin
2009-08-06 12:09     ` Gregory Haskins
2009-08-06 12:08   ` Gregory Haskins
2009-08-06 12:24     ` Michael S. Tsirkin
2009-08-06 13:00       ` Gregory Haskins
2009-08-06 12:54     ` Avi Kivity
2009-08-06 13:03       ` Gregory Haskins
2009-08-06 13:44         ` Avi Kivity
2009-08-06 13:45           ` Gregory Haskins
2009-08-06 13:57             ` Avi Kivity
2009-08-06 14:06               ` Gregory Haskins
2009-08-06 15:40                 ` Arnd Bergmann
2009-08-06 15:45                   ` Michael S. Tsirkin
2009-08-06 15:50                   ` Avi Kivity
2009-08-06 16:55                     ` Gregory Haskins
2009-08-09  7:48                       ` Avi Kivity
2009-08-06 16:29                   ` Gregory Haskins
2009-08-06 23:23                     ` Ira W. Snyder
2009-08-06 13:59             ` Michael S. Tsirkin
2009-08-06 14:07               ` Gregory Haskins
2009-08-07 14:19   ` Anthony Liguori
2009-08-07 15:05     ` [PATCH 0/7] AlacrityVM guest drivers Gregory Haskins
2009-08-07 15:46       ` Anthony Liguori
2009-08-07 18:04         ` Gregory Haskins

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=200908061556.55390.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=alacrityvm-devel@lists.sourceforge.net \
    --cc=ghaskins@novell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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).