All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@domain.hid>
To: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Cc: Xenomai-core@domain.hid
Subject: Re: [Xenomai-core] [PATCH 3/4] Uninline heavy locking functions
Date: Sat, 23 Feb 2008 19:58:53 +0100	[thread overview]
Message-ID: <47C06CED.6020301@domain.hid> (raw)
In-Reply-To: <18368.26367.809400.757141@domain.hid>

[-- Attachment #1: Type: text/plain, Size: 2314 bytes --]

Gilles Chanteperdrix wrote:
> Jan Kiszka wrote:
>  > Gilles Chanteperdrix wrote:
>  > > Jan Kiszka wrote:
>  > >  > At least when SMP is enable, already __xnlock_get becomes far too
>  > >  > heavy-weighted for being inlined. xnlock_put is fine now, but looking
>  > >  > closer at the disassembly still revealed a lot of redundancy related to
>  > >  > acquiring and releasing xnlocks. In fact, we are mostly using
>  > >  > xnlock_get_irqsave and xnlock_put_irqrestore. Both include fiddling with
>  > >  > rthal_local_irq_save/restore, also heavy-weighted on SMP.
>  > >  > 
>  > >  > So this patch turns the latter two into uninlined functions which
>  > >  > reduces the text size or nucleus and skins significantly on x86-64/SMP
>  > >  > (XENO_OPT_DEBUG_NUCLEUS disabled):
>  > > 
>  > > I think the human idea of how long an inline function can be is far more
>  > > restrictive than what a processor can take. When looking at assembly
>  > > code, you always find the code long, whereas in reality it is not that
>  > > long for a processor. 
>  > > 
>  > > Besides, IMO, the proper way to uninline xnlock operations is to leave
>  > > the non contended case inline, and to move the spinning out of line.
>  > 
>  > This patch is not just about uninlining xnlock, that's only one half of
>  > the savings. The other one is irq-disabling via i-pipe. The problem with
>  > our case is that we have no simple single check to find out that we are
>  > on a fast ride. Rather, we have to do quite some calculations/lookups
>  > before the first check, and we have to perform multiple checks even in
>  > the best case.
> 
> This is my fault, a tradeoff I made, I thought that the atomic_cmpxchg
> could be heavy on SMP systems, so I made a first check to see if we are
> not recursing. But we can do the two operations in one move if we accept
> to have a failing atomic_cmpxchg when recursing.

I'm unsure about the cache pressure of cmpxchg vs. plain read. I guess
the existing variant is already better.

Moreover, the spinning code is only a fraction of the fraction. We
cannot eliminate the recursion check, and we still have all the
local_irq_save code. And _all_ this code mostly comes together, thus we
save so much by uninlining those two functions.

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 254 bytes --]

  reply	other threads:[~2008-02-23 18:58 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-23 13:33 [Xenomai-core] [PATCH 0/4] Fixes and improvements around xnlock Jan Kiszka
2008-02-23 13:36 ` [Xenomai-core] [PATCH 2/4] Fix and optimize xnlock_put Jan Kiszka
2008-02-23 17:41   ` Gilles Chanteperdrix
2008-02-23 18:05     ` Jan Kiszka
2008-02-23 18:29       ` Gilles Chanteperdrix
2008-02-23 18:57         ` Jan Kiszka
2008-02-23 19:41           ` Gilles Chanteperdrix
2008-02-23 23:50           ` Philippe Gerum
2008-02-23 13:37 ` [Xenomai-core] [PATCH 1/4] Refactor generic system.h Jan Kiszka
2008-02-23 17:38   ` Gilles Chanteperdrix
2008-02-23 18:03     ` Jan Kiszka
2008-02-23 18:59       ` Gilles Chanteperdrix
2008-03-01 18:54       ` Gilles Chanteperdrix
2008-03-01 19:22         ` Jan Kiszka
2008-02-23 13:38 ` [Xenomai-core] [PATCH 3/4] Uninline heavy locking functions Jan Kiszka
2008-02-23 17:51   ` Gilles Chanteperdrix
2008-02-23 18:13     ` Jan Kiszka
2008-02-23 18:33       ` Gilles Chanteperdrix
2008-02-23 18:58         ` Jan Kiszka [this message]
2008-02-23 21:36   ` Jeroen Van den Keybus
2008-02-23 13:50 ` [Xenomai-core] [RFC][PATCH 4/4] Recursive FIFO ticket xnlock Jan Kiszka
2008-02-23 17:54   ` Gilles Chanteperdrix
2008-02-23 18:20     ` Jan Kiszka
2008-02-23 18:43       ` Gilles Chanteperdrix
2008-02-23 19:13         ` Jan Kiszka

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=47C06CED.6020301@domain.hid \
    --to=jan.kiszka@domain.hid \
    --cc=Xenomai-core@domain.hid \
    --cc=gilles.chanteperdrix@xenomai.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.