From: Jan Kiszka <jan.kiszka@domain.hid>
To: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Cc: xenomai-core <xenomai@xenomai.org>
Subject: Re: [Xenomai-core] [PATCH 2/9] Switch to handle-based fast mutex owners - v2
Date: Fri, 05 Sep 2008 11:55:59 +0200 [thread overview]
Message-ID: <48C1022F.6040903@domain.hid> (raw)
In-Reply-To: <48C100FD.8020908@domain.hid>
Gilles Chanteperdrix wrote:
> Jan Kiszka wrote:
>> Gilles Chanteperdrix wrote:
>>> Jan Kiszka wrote:
>>>> @@ -230,18 +230,20 @@ static inline int mutex_save_count(xnthr
>>>>
>>>> mutex = shadow->mutex;
>>>>
>>>> - if (clear_claimed(xnarch_atomic_intptr_get(mutex->owner)) != cur)
>>>> + if (clear_claimed(xnarch_atomic_get(mutex->owner)) !=
>>>> + xnthread_handle(cur))
>>>> return EPERM;
>>>>
>>>> *count_ptr = shadow->lockcnt;
>>>>
>>>> - if (likely(xnarch_atomic_intptr_cmpxchg(mutex->owner, cur, NULL) == cur))
>>>> + if (likely(xnarch_atomic_cmpxchg(mutex->owner, cur, XN_NO_HANDLE) ==
>>>> + xnthread_handle(cur)))
>>>> return 0;
>>>>
>>>> owner = xnsynch_wakeup_one_sleeper(&mutex->synchbase);
>>>> - xnarch_atomic_intptr_set
>>>> - (mutex->owner,
>>>> - set_claimed(owner,xnsynch_nsleepers(&mutex->synchbase)));
>>>> + xnarch_atomic_set(mutex->owner,
>>>> + set_claimed(xnthread_handle(owner),
>>>> + xnsynch_nsleepers(&mutex->synchbase)));
>>> Ok. Can we avoid xnthread_handle() everywhere by storing its result in a
>>> local variable and reusing this local variable, here and in the other
>>> functions where xnthread_handle is used multiple times ?
>> True for 'cur' here (will fix), but the other case have already been
>> optimized as far as possible (i.e. within the respective scope).
>
> I have found several other spots where xnthread_handle is called
> multiple times in the same function. mutex_unlock comes to my mind.
Please point me to the concrete spot. I went again through all
xnthread_handle instances in this patch, checking that they aren't
needed due to owner changes, but only found the one above. Specifically
pthread_mutex_unlock, pse51_mutex_unlock_internal and
__pthread_mutex_unlock have only a single reference or reference
different threads.
Jan
--
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux
next prev parent reply other threads:[~2008-09-05 9:55 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-01 8:53 [Xenomai-core] [PATCH 0/9] Fast mutex rework, native support Jan Kiszka
2008-09-01 8:39 ` [Xenomai-core] [PATCH 1/9] Always register threads by their base Jan Kiszka
2008-09-01 8:44 ` [Xenomai-core] [PATCH 2/9] Switch to handle-based fast mutex owners Jan Kiszka
2008-09-01 11:58 ` Gilles Chanteperdrix
2008-09-01 13:48 ` Jan Kiszka
2008-09-01 14:00 ` Gilles Chanteperdrix
2008-09-01 14:03 ` Jan Kiszka
2008-09-01 14:08 ` Jan Kiszka
2008-09-02 12:31 ` Gilles Chanteperdrix
2008-09-05 8:34 ` [Xenomai-core] [PATCH 2/9] Switch to handle-based fast mutex owners - v2 Jan Kiszka
2008-09-05 9:40 ` Gilles Chanteperdrix
2008-09-05 9:46 ` Jan Kiszka
2008-09-05 9:50 ` Gilles Chanteperdrix
2008-09-05 9:55 ` Jan Kiszka [this message]
2008-09-05 9:57 ` Gilles Chanteperdrix
2008-09-01 8:45 ` [Xenomai-core] [PATCH 3/9] Remove xnarch_atomic_intptr wrappers Jan Kiszka
2008-09-01 8:47 ` [Xenomai-core] [PATCH 4/9] Spread xeno_set_current Jan Kiszka
2008-09-01 8:54 ` [Xenomai-core] [RFC][PATCH 5/9] Allow lock stealing via pthread_mutex_trylock Jan Kiszka
2008-09-01 9:58 ` Gilles Chanteperdrix
2008-09-01 8:57 ` [Xenomai-core] [RFC][PATCH 6/9] Add XNSYNCH_FWDROB Jan Kiszka
2008-09-01 10:00 ` Gilles Chanteperdrix
2008-09-01 9:01 ` [Xenomai-core] [RFC][PATCH 8/9] Native support for fast mutexes Jan Kiszka
2008-09-05 8:36 ` [Xenomai-core] [RFC][PATCH 8/9] Native support for fast mutexes - v2 Jan Kiszka
2008-09-01 9:06 ` [Xenomai-core] [RFC][PATCH 9/9] Optimize xnsynch_sleep_on for XN_NONBLOCK Jan Kiszka
2008-09-01 9:12 ` [Xenomai-core] [RFC][PATCH 7/9] Switch POSIX mutexes to XNSYNCH_FWDROB Jan Kiszka
2008-09-01 10:01 ` Gilles Chanteperdrix
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=48C1022F.6040903@domain.hid \
--to=jan.kiszka@domain.hid \
--cc=gilles.chanteperdrix@xenomai.org \
--cc=xenomai@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.