All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthias Schneider <ma30002000@yahoo.de>
To: Philippe Gerum <rpm@xenomai.org>,
	"xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: Re: [Xenomai] Issue in __threadobj_unlock_sched (forge/mercury)
Date: Thu, 1 May 2014 15:23:50 +0100 (BST)	[thread overview]
Message-ID: <1398954230.40374.YahooMailNeo@web171605.mail.ir2.yahoo.com> (raw)
In-Reply-To: <53624421.8090903@xenomai.org>

----- Original Message -----

> From: Philippe Gerum <rpm@xenomai.org>
> To: Matthias Schneider <ma30002000@yahoo.de>; "xenomai@xenomai.org" <xenomai@xenomai.org>
> Cc: 
> Sent: Thursday, May 1, 2014 2:54 PM
> Subject: Re: [Xenomai] Issue in __threadobj_unlock_sched (forge/mercury)
> 
> On 05/01/2014 01:42 PM, Matthias Schneider wrote:
> 
>>  Hi all,
>> 
>>  it seems __threadobj_unlock_sched has a slight bug
>>  and does not reset the current->policy value.
>>  This leads to the old policy being restored, but
>>  no longer being available for the next
>>  __threadobj_lock_sched / __threadobj_unlock_sched
>>  call pair.
>> 
> 
> That would mean that the client code switches between different 
> scheduling policies while holding the scheduler lock?
> 
> -- 
> Philippe.
> 

Consider the following scenario:

a) threads may hold SCHED_RT, SCHED_RR or SCHED_OTHER while not in 
threadobj_lock_sched(). (see e.g. threadobj_set_priority).

b) threadobj_lock_sched() saves prio and policy and sets it to 
SCHED_RT/threadobj_lock_prio

c) threadobj_unlock_sched() will restore (correctly) previous 
settings, but not update the threadobj's policy

d) next time threadobj_lock_sched() is called, it will save prio 
and priority, howver policy will always be SCHED_RT (which is 
not the currently set policy before upgrading it)

e) threadobj_unlock_sched() will restore prio and incorrectly saved
policy, which is always SCHED_RT -> threads that originally had
SCHED_RR or SCHED_OTHER now have SCHED_RT


Changing prio while holding the scheduler lock should be handled 
fine due to :

threadobj_set_priority():
if (thobj->schedlock_depth > 0) {
  thobj->core.prio_unlocked = prio;
  thobj->core.policy_unlocked = prio ? SCHED_RT : SCHED_OTHER;
  threadobj_unlock(thobj);
  return 0;
 }

Matthias



  reply	other threads:[~2014-05-01 14:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-01 11:42 [Xenomai] Issue in __threadobj_unlock_sched (forge/mercury) Matthias Schneider
2014-05-01 12:54 ` Philippe Gerum
2014-05-01 14:23   ` Matthias Schneider [this message]
2014-05-02  8:27     ` Philippe Gerum
2014-05-17 14:20       ` Matthias Schneider
2014-05-19 13:38         ` Philippe Gerum

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=1398954230.40374.YahooMailNeo@web171605.mail.ir2.yahoo.com \
    --to=ma30002000@yahoo.de \
    --cc=rpm@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.