All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jesper Dangaard Brouer <brouer@redhat.com>
To: Christoph Lameter <cl@linux.com>
Cc: akpm@linuxfoundation.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, penberg@kernel.org, iamjoonsoo@lge.com,
	brouer@redhat.com
Subject: Re: [PATCH 2/3] slub: Support for array operations
Date: Thu, 12 Feb 2015 10:43:16 +1300	[thread overview]
Message-ID: <20150212104316.2d5c32ea@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.11.1502111305520.7547@gentwo.org>

On Wed, 11 Feb 2015 13:07:24 -0600 (CST)
Christoph Lameter <cl@linux.com> wrote:

> On Wed, 11 Feb 2015, Jesper Dangaard Brouer wrote:
> 
> > > +
> > > +
> > > +	spin_lock_irqsave(&n->list_lock, flags);
> >
> > This is quite an expensive lock with irqsave.
> 
> Yes but we take it for all partial pages.

Sure, that is good, but this might be a contention point. In a micro
benchmark, this contention should be visible, but in real use-cases the
given subsystem also need to spend time to use these elements before
requesting a new batch (as long as NIC cleanup cycles don't get too
synchronized)


> > Yet another lock cost.
> 
> Yup the page access is shared but there is one per page. Contention is
> unlikely.

Yes, contention is unlikely, but every atomic operation is expensive.
On my system the measured cost is 8ns, and a lock/unlock does two, thus
16ns.  Which we then do per page freelist.


> > > +	spin_unlock_irqrestore(&n->list_lock, flags);
> > > +	return allocated;
> >
> > I estimate (on my CPU) the locking cost itself is more than 32ns, plus
> > the irqsave (which I've also found quite expensive, alone 14ns).  Thus,
> > estimated 46ns.  Single elem slub fast path cost is 18-19ns. Thus 3-4
> > elem bulking should be enough to amortized the cost, guess we are still
> > good :-)
> 
> We can require that interrupt are off when the functions are called. Then
> we can avoid the "save" part?

Yes, we could also do so with an "_irqoff" variant of the func call,
but given we are defining the API we can just require this from the
start.

I plan to use this in softirq, where I know interrupts are on, but I
can use the less-expensive "non-save" variant local_irq_{disable,enable}.

Measurements show (x86_64 E5-2695):
 *  2.860 ns cost for local_irq_{disable,enable}
 * 14.840 ns cost for local_irq_save()+local_irq_restore()

-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Sr. Network Kernel Developer at Red Hat
  Author of http://www.iptv-analyzer.org
  LinkedIn: http://www.linkedin.com/in/brouer

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

WARNING: multiple messages have this Message-ID (diff)
From: Jesper Dangaard Brouer <brouer@redhat.com>
To: Christoph Lameter <cl@linux.com>
Cc: akpm@linuxfoundation.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, penberg@kernel.org, iamjoonsoo@lge.com,
	brouer@redhat.com
Subject: Re: [PATCH 2/3] slub: Support for array operations
Date: Thu, 12 Feb 2015 10:43:16 +1300	[thread overview]
Message-ID: <20150212104316.2d5c32ea@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.11.1502111305520.7547@gentwo.org>

On Wed, 11 Feb 2015 13:07:24 -0600 (CST)
Christoph Lameter <cl@linux.com> wrote:

> On Wed, 11 Feb 2015, Jesper Dangaard Brouer wrote:
> 
> > > +
> > > +
> > > +	spin_lock_irqsave(&n->list_lock, flags);
> >
> > This is quite an expensive lock with irqsave.
> 
> Yes but we take it for all partial pages.

Sure, that is good, but this might be a contention point. In a micro
benchmark, this contention should be visible, but in real use-cases the
given subsystem also need to spend time to use these elements before
requesting a new batch (as long as NIC cleanup cycles don't get too
synchronized)


> > Yet another lock cost.
> 
> Yup the page access is shared but there is one per page. Contention is
> unlikely.

Yes, contention is unlikely, but every atomic operation is expensive.
On my system the measured cost is 8ns, and a lock/unlock does two, thus
16ns.  Which we then do per page freelist.


> > > +	spin_unlock_irqrestore(&n->list_lock, flags);
> > > +	return allocated;
> >
> > I estimate (on my CPU) the locking cost itself is more than 32ns, plus
> > the irqsave (which I've also found quite expensive, alone 14ns).  Thus,
> > estimated 46ns.  Single elem slub fast path cost is 18-19ns. Thus 3-4
> > elem bulking should be enough to amortized the cost, guess we are still
> > good :-)
> 
> We can require that interrupt are off when the functions are called. Then
> we can avoid the "save" part?

Yes, we could also do so with an "_irqoff" variant of the func call,
but given we are defining the API we can just require this from the
start.

I plan to use this in softirq, where I know interrupts are on, but I
can use the less-expensive "non-save" variant local_irq_{disable,enable}.

Measurements show (x86_64 E5-2695):
 *  2.860 ns cost for local_irq_{disable,enable}
 * 14.840 ns cost for local_irq_save()+local_irq_restore()

-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Sr. Network Kernel Developer at Red Hat
  Author of http://www.iptv-analyzer.org
  LinkedIn: http://www.linkedin.com/in/brouer

  reply	other threads:[~2015-02-11 21:43 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-10 19:48 [PATCH 0/3] Slab allocator array operations V2 Christoph Lameter
2015-02-10 19:48 ` Christoph Lameter
2015-02-10 19:48 ` [PATCH 1/3] Slab infrastructure for array operations Christoph Lameter
2015-02-10 19:48   ` Christoph Lameter
2015-02-10 22:43   ` Jesper Dangaard Brouer
2015-02-10 22:43     ` Jesper Dangaard Brouer
2015-02-10 23:58   ` David Rientjes
2015-02-10 23:58     ` David Rientjes
2015-02-11 18:47     ` Christoph Lameter
2015-02-11 18:47       ` Christoph Lameter
2015-02-11 20:18       ` David Rientjes
2015-02-11 20:18         ` David Rientjes
2015-02-11 22:04         ` Christoph Lameter
2015-02-11 22:04           ` Christoph Lameter
2015-02-12  0:35           ` David Rientjes
2015-02-12  0:35             ` David Rientjes
2015-02-13  2:35         ` Joonsoo Kim
2015-02-13  2:35           ` Joonsoo Kim
2015-02-13 15:47           ` Christoph Lameter
2015-02-13 15:47             ` Christoph Lameter
2015-02-13 21:20             ` David Rientjes
2015-02-13 21:20               ` David Rientjes
2015-02-17  5:15             ` Joonsoo Kim
2015-02-17  5:15               ` Joonsoo Kim
2015-02-17 16:03               ` Christoph Lameter
2015-02-17 16:03                 ` Christoph Lameter
2015-02-17 21:32                 ` Jesper Dangaard Brouer
2015-02-17 21:32                   ` Jesper Dangaard Brouer
2015-02-18 23:02                   ` Christoph Lameter
2015-02-18 23:02                     ` Christoph Lameter
2015-02-10 19:48 ` [PATCH 2/3] slub: Support " Christoph Lameter
2015-02-10 19:48   ` Christoph Lameter
2015-02-11  4:48   ` Jesper Dangaard Brouer
2015-02-11  4:48     ` Jesper Dangaard Brouer
2015-02-11 19:07     ` Christoph Lameter
2015-02-11 19:07       ` Christoph Lameter
2015-02-11 21:43       ` Jesper Dangaard Brouer [this message]
2015-02-11 21:43         ` Jesper Dangaard Brouer
2015-02-11 22:06         ` Christoph Lameter
2015-02-11 22:06           ` Christoph Lameter
2015-02-12  0:16           ` Jesper Dangaard Brouer
2015-02-12  0:16             ` Jesper Dangaard Brouer
2015-02-12  2:46             ` Christoph Lameter
2015-02-12  2:46               ` Christoph Lameter
2015-02-13  2:45   ` Joonsoo Kim
2015-02-13  2:45     ` Joonsoo Kim
2015-02-13 15:49     ` Christoph Lameter
2015-02-13 15:49       ` Christoph Lameter
2015-02-17  5:26       ` Joonsoo Kim
2015-02-17  5:26         ` Joonsoo Kim
2015-02-10 19:48 ` [PATCH 3/3] Array alloc test code Christoph Lameter
2015-02-10 19:48   ` Christoph Lameter

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=20150212104316.2d5c32ea@redhat.com \
    --to=brouer@redhat.com \
    --cc=akpm@linuxfoundation.org \
    --cc=cl@linux.com \
    --cc=iamjoonsoo@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=penberg@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.