netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Ben Hutchings <bhutchings-s/n/eUQHGBpZroRs9YW3xA@public.gmane.org>
Cc: linux-net-drivers
	<linux-net-drivers-s/n/eUQHGBpZroRs9YW3xA@public.gmane.org>,
	Alexey Kardashevskiy
	<aik-sLpHqDYs0B2HXe+LvDLADg@public.gmane.org>,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Nikolay Aleksandrov
	<naleksan-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Daniel Pieczko <dpieczko-s/n/eUQHGBpZroRs9YW3xA@public.gmane.org>,
	iommu
	<iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>
Subject: Re: [PATCH net-next 20/22] sfc: reuse pages to avoid DMA mapping/unmapping costs
Date: Wed, 22 May 2013 12:44:14 -0600	[thread overview]
Message-ID: <1369248254.2646.118.camel@ul30vt.home> (raw)
In-Reply-To: <1369244582.2670.32.camel-/LGg1Z1CJKQ+9kgCwbf1HqK4ta4zdZpAajtMo4Cw6ucAvxtiuMwx3w@public.gmane.org>

[adding cc iommu list + aik]

On Wed, 2013-05-22 at 18:43 +0100, Ben Hutchings wrote:
> On Wed, 2013-05-22 at 16:29 +0000, Alex Williamson wrote:
> > Ben Hutchings <bhutchings <at> solarflare.com> writes:
> > 
> > > 
> > > From:  Daniel Pieczko <dpieczko <at> solarflare.com>
> > > 
> > > On POWER systems, DMA mapping/unmapping operations are very expensive.
> > > These changes reduce these costs by trying to reuse DMA mapped pages.
> [...]
> > > When an IOMMU is not present, the recycle ring can be small to reduce
> > > memory usage, since DMA mapping operations are inexpensive.
> > 
> > I'm not sure I agree with the test for whether an IOMMU is present...
> > 
> > > diff --git a/drivers/net/ethernet/sfc/efx.c 
> > b/drivers/net/ethernet/sfc/efx.c
> > > index 1213af5..a70c458 100644
> > > --- a/drivers/net/ethernet/sfc/efx.c
> > > +++ b/drivers/net/ethernet/sfc/efx.c
> > [snip]
> > > +void efx_init_rx_recycle_ring(struct efx_nic *efx,
> > > +			      struct efx_rx_queue *rx_queue)
> > > +{
> > > +	unsigned int bufs_in_recycle_ring, page_ring_size;
> > > +
> > > +	/* Set the RX recycle ring size */
> > > +#ifdef CONFIG_PPC64
> > > +	bufs_in_recycle_ring = EFX_RECYCLE_RING_SIZE_IOMMU;
> > > +#else
> > > +	if (efx->pci_dev->dev.iommu_group)
> > > +		bufs_in_recycle_ring = EFX_RECYCLE_RING_SIZE_IOMMU;
> > > +	else
> > > +		bufs_in_recycle_ring = EFX_RECYCLE_RING_SIZE_NOIOMMU;
> > > +#endif /* CONFIG_PPC64 */
> > 
> > Testing for an iommu_group is more of a test of (is an iommu present && does 
> > it support the iommu api && does it support iommu groups && is the device 
> > isolatable).  That doesn't seem like what we want here (besides, it's kind 
> > of a hacky sidestep to the API which would suggest using iommu_group_get/put 
> > here).
> 
> Since we don't try to use the iommu_group itself, those functions don't
> seem to be appropriate.
> 
> > We could use iommu_present(&pci_bus_type), which reduces the test to (iommu 
> > present && supports iommu api (ie. iommu_ops)).
> 
> That's the test we use OOT for older kernel version.  However I advised
> Daniel, apparently wrongly, that testing iommu_group would now be more
> accurate.
> 
> > Better, but I think you 
> > really care about an iommu present with dma_ops.  I think we can assume that 
> > if an iommu supports iommu_ops, it supports dma_ops, but that still leaves 
> > out iommus that do not support iommu_ops.  Do we care about those?
> 
> Unfortunately the pSeries IOMMU code doesn't support iommu_ops yet, and
> that is precisely the case where DMA map/unmap operations are most
> expensive (that we've seen).

I think that's soon to change, at least for some POWER models, with the
work that Alexey is doing.  Hopefully that work will cover enough
platforms that we could remove the #ifdef here and just use
iommu_present(), even if not ideal.

> > Furthermore, what about cases where an iommu is present, but unused?  For 
> > example, iommu=pt (passthrough).  I'd think the driver would want to behave 
> > as it would in the non-iommu case in that configuration.  Anyway, I don't 
> > think iommu_group is the correct test here.  Thanks,
> 
> Right.  The real question the driver should ask is: 'will DMA-mapping/
> unmapping for this device be significantly slower than DMA-syncing?'  We
> don't yet have a way to ask that; maybe that should be added to the DMA
> API.

Right.  So maybe a better approximation is to ask whether sync has any
overhead.  Couldn't you get the dma_ops for the device (get_dma_ops())
and check whether the sync functions are implemented?  That's still not
perfect though as a bounce buffer iommu may also have no overhead
depending on the dma_mask of the device (or the address being mapped).
Thanks,

Alex

  parent reply	other threads:[~2013-05-22 18:44 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-11 19:33 Pull request: sfc-next 2013-03-11 Ben Hutchings
2013-03-11 19:53 ` [PATCH net-next 01/22] sfc: Allow efx_channel_type::receive_skb() to reject a packet Ben Hutchings
2013-03-11 19:53 ` [PATCH net-next 02/22] sfc: PTP changes to support improved UUID filtering mode Ben Hutchings
2013-03-11 19:53 ` [PATCH net-next 03/22] sfc: tidy up PTP synchronize function efx_ptp_process_times() Ben Hutchings
2013-03-11 19:54 ` [PATCH net-next 04/22] sfc: Remove rx_alloc_method SKB Ben Hutchings
2013-03-11 19:54 ` [PATCH net-next 05/22] sfc: More sensible semantics for efx_filter_insert_filter() replace flag Ben Hutchings
2013-03-11 19:54 ` [PATCH net-next 06/22] sfc: Remove redundant parameter to efx_filter_search() Ben Hutchings
2013-03-11 19:54 ` [PATCH net-next 07/22] sfc: Don't use efx_filter_{build,hash,increment}() for default MAC filters Ben Hutchings
2013-03-11 19:55 ` [PATCH net-next 08/22] sfc: Merge efx_filter_search() into efx_filter_insert() Ben Hutchings
2013-03-11 19:55 ` [PATCH net-next 09/22] sfc: Fix replacement detection in efx_filter_insert_filter() Ben Hutchings
2013-03-11 19:55 ` [PATCH net-next 10/22] sfc: Disable RSS when using SR-IOV and only 1 RX queue on the PF Ben Hutchings
2013-03-11 19:55 ` [PATCH net-next 11/22] sfc: Add AER and EEH support for Siena Ben Hutchings
2013-03-11 19:55 ` [PATCH net-next 12/22] sfc: Document current usage of efx_rx_buffer::len and efx_nic::rx_buffer_len Ben Hutchings
2013-03-11 19:56 ` [PATCH net-next 13/22] sfc: Properly distinguish RX buffer and DMA lengths Ben Hutchings
2013-03-11 19:56 ` [PATCH net-next 14/22] sfc: Make RX queue descriptor counts unsigned for consistency Ben Hutchings
2013-03-11 19:56 ` [PATCH net-next 15/22] sfc: Wrap __efx_rx_packet() with efx_rx_flush_packet() Ben Hutchings
2013-03-11 19:56 ` [PATCH net-next 16/22] sfc: Replace efx_rx_buf_eh() with simpler efx_rx_buf_va() Ben Hutchings
2013-03-11 19:56 ` [PATCH net-next 17/22] sfc: Explicitly prefetch RX hash prefix, not just Ethernet heade Ben Hutchings
2013-03-11 19:57 ` [PATCH net-next 18/22] sfc: Update RX buffer address together with length Ben Hutchings
2013-03-11 19:58 ` [PATCH net-next 19/22] sfc: Enable RX DMA scattering where possible Ben Hutchings
2013-03-11 19:59 ` [PATCH net-next 20/22] sfc: reuse pages to avoid DMA mapping/unmapping costs Ben Hutchings
2013-05-22 16:29   ` Alex Williamson
2013-05-22 17:43     ` Ben Hutchings
     [not found]       ` <1369244582.2670.32.camel-/LGg1Z1CJKQ+9kgCwbf1HqK4ta4zdZpAajtMo4Cw6ucAvxtiuMwx3w@public.gmane.org>
2013-05-22 18:44         ` Alex Williamson [this message]
2013-03-11 19:59 ` [PATCH net-next 21/22] sfc: Replace efx_rx_is_last_buffer() with a flag Ben Hutchings
2013-03-11 19:59 ` [PATCH net-next 22/22] sfc: allocate more RX buffers per page Ben Hutchings
2013-03-12  9:15 ` Pull request: sfc-next 2013-03-11 David Miller

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=1369248254.2646.118.camel@ul30vt.home \
    --to=alex.williamson-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=aik-sLpHqDYs0B2HXe+LvDLADg@public.gmane.org \
    --cc=bhutchings-s/n/eUQHGBpZroRs9YW3xA@public.gmane.org \
    --cc=dpieczko-s/n/eUQHGBpZroRs9YW3xA@public.gmane.org \
    --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=linux-net-drivers-s/n/eUQHGBpZroRs9YW3xA@public.gmane.org \
    --cc=naleksan-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.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).