All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Weinberger <richard@nod.at>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: xenomai <xenomai@xenomai.org>
Subject: Re: [PATCH] Alchemy: Fix rt_task_unblock() for RT_MUTEX
Date: Mon, 4 Apr 2022 14:17:47 +0200 (CEST)	[thread overview]
Message-ID: <169724307.214985.1649074667197.JavaMail.zimbra@nod.at> (raw)
In-Reply-To: <70be73c4-2b97-7a92-014d-5655a489a0b2@siemens.com>

----- Ursprüngliche Mail -----
> Von: "Jan Kiszka" <jan.kiszka@siemens.com>
> An: "richard" <richard@nod.at>, "xenomai" <xenomai@xenomai.org>
> Gesendet: Montag, 4. April 2022 13:21:45
> Betreff: Re: [PATCH] Alchemy: Fix rt_task_unblock() for RT_MUTEX

> On 30.03.22 22:16, Richard Weinberger via Xenomai wrote:
>> Starting with Xenomai 3, RT_MUTEX is based on libcobalt's pthread mutex
>> implementation.
>> POSIX requires that pthread_mutex_lock() shall not return EINTR,
>> this requirement breaks rt_task_unblock() if a RT_TASK blocks on
>> a RT_MUTEX.
>> 
>> To restore the functionality provide a new function,
>> pthread_mutex_lock_eintr_np().
>> It can get interrupted and will return EINTR to the caller.
>> 
>> Signed-off-by: Richard Weinberger <richard@nod.at>
>> ---
>>  include/cobalt/pthread.h |  2 ++
>>  lib/alchemy/mutex.c      |  2 +-
>>  lib/cobalt/mutex.c       | 14 ++++++++++++--
>>  3 files changed, 15 insertions(+), 3 deletions(-)
>> 
>> diff --git a/include/cobalt/pthread.h b/include/cobalt/pthread.h
>> index 3e9bd47053bc..2994c2467219 100644
>> --- a/include/cobalt/pthread.h
>> +++ b/include/cobalt/pthread.h
>> @@ -62,6 +62,8 @@ COBALT_DECL(int, pthread_mutex_destroy(pthread_mutex_t
>> *mutex));
>>  
>>  COBALT_DECL(int, pthread_mutex_lock(pthread_mutex_t *mutex));
>>  
>> +COBALT_DECL(int, pthread_mutex_lock_eintr_np(pthread_mutex_t *mutex));
>> +
>>  COBALT_DECL(int, pthread_mutex_timedlock(pthread_mutex_t *mutex,
>>  					 const struct timespec *to));
>>  
>> diff --git a/lib/alchemy/mutex.c b/lib/alchemy/mutex.c
>> index f8933858647a..bb97395142aa 100644
>> --- a/lib/alchemy/mutex.c
>> +++ b/lib/alchemy/mutex.c
>> @@ -327,7 +327,7 @@ int rt_mutex_acquire_timed(RT_MUTEX *mutex,
>>  
>>  	/* Slow path. */
>>  	if (abs_timeout == NULL) {
>> -		ret = -__RT(pthread_mutex_lock(&mcb->lock));
>> +		ret = -__RT(pthread_mutex_lock_eintr_np(&mcb->lock));
> 
> This won't build for mercury, will it?

Uff yes. Just tried building with --with-core=mercury and it failed. ;-\

So, when mercury is enabled, alchemy will use NPTL.
This means rt_task_unblock() cannot work on mercury because
pthread_mutex_lock() will not return EINTR either.

Fixing the build for mercury should be easy by adding an ifdef CONFIG_XENO_MERCURY.
But I'm not sure how to fix unblocking for the mercury case.

Thanks,
//richard


  reply	other threads:[~2022-04-04 12:17 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-30 20:16 [PATCH] Alchemy: Fix rt_task_unblock() for RT_MUTEX Richard Weinberger
2022-03-31  8:25 ` Bezdeka, Florian
2022-03-31  8:36   ` Richard Weinberger
2022-04-01  7:16     ` Bezdeka, Florian
2022-04-04  9:39       ` Richard Weinberger
2022-04-04 11:20         ` Jan Kiszka
2022-04-04 13:26           ` Richard Weinberger
2022-04-04 11:21 ` Jan Kiszka
2022-04-04 12:17   ` Richard Weinberger [this message]
2022-04-04 12:34     ` Jan Kiszka
2022-04-04 12:40       ` Richard Weinberger
2023-01-09 16:25 ` [PATCH v2] " Aaron Marcher
2023-01-10  5:52   ` Jan Kiszka
2023-01-10  7:54     ` Florian Bezdeka
2023-01-10  8:02       ` Jan Kiszka
2023-01-10  8:05         ` Richard Weinberger

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=169724307.214985.1649074667197.JavaMail.zimbra@nod.at \
    --to=richard@nod.at \
    --cc=jan.kiszka@siemens.com \
    --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.