Re: [devel] [PATCH 1 of 1] base: Use default scheduling policy when configured policy is invalid [#690]
Ack. Thanks, Ramesh. On 1/17/2014 8:20 PM, Anders Widell wrote: > osaf/libs/core/leap/os_defs.c | 13 +++-- > 1 files changed, 7 insertions(+), 6 deletions(-) > > > OpenSAF would fail to start when an invalid thread scheduling policy has been > configured, e.g. using the following configuration options for one of the > OpenSAF services: > > export OSAF_MDS_SCHED_PRIORITY=0 > export OSAF_MDS_SCHED_POLICY=3 > > The OpenSAF services fail with the following messages: > > Dec 24 14:40:02 SLES_NEW2 opensafd[15010]: ER Timed-out for response from RDE > Dec 24 14:40:02 SLES_NEW2 opensafd[15010]: ER > Dec 24 14:40:02 SLES_NEW2 opensafd[15010]: ER Going for recovery > Dec 24 14:40:02 SLES_NEW2 opensafd[15010]: ER Trying To RESPAWN > /usr/lib64/opensaf/clc-cli/osaf-rded attempt #1 > Dec 24 14:40:02 SLES_NEW2 opensafd[15010]: ER Sending SIGKILL to RDE, > pid=15031 > > The reason is that scheduling policy 3 (SCHED_BATCH) is not a valid parameter > to > the pthread_attr_setschedpolicy() function, and OpenSAF passes the configured > policy to this function without whecking that it is valid. > > A check for this case has been added, so that we fall back to the default > scheduling policy when an invalid policy has been configured. > > diff --git a/osaf/libs/core/leap/os_defs.c b/osaf/libs/core/leap/os_defs.c > --- a/osaf/libs/core/leap/os_defs.c > +++ b/osaf/libs/core/leap/os_defs.c > @@ -164,15 +164,16 @@ unsigned int ncs_os_task(NCS_OS_TASK *ta > min_prio = sched_get_priority_min(policy); > max_prio = sched_get_priority_max(policy); > > - if((sp.sched_priority < min_prio) || (sp.sched_priority > > max_prio)) { > + if ((sp.sched_priority < min_prio) || > (sp.sched_priority > max_prio) || > + pthread_attr_setschedpolicy(&attr, policy) != 0) { > /* Set to defaults */ > - syslog(LOG_NOTICE, "scheduling priority %d for > given policy %d to the task %s is not \ > - within > the range, setting to default \ > - values ", > sp.sched_priority, policy, task->info.create.i_name); > + syslog(LOG_NOTICE, "scheduling priority %d or > policy %d for the " > +"task %s is invalid, setting to default > values", > +sp.sched_priority, policy, > task->info.create.i_name); > policy = task->info.create.i_policy; > sp.sched_priority = > task->info.create.i_priority; > - syslog(LOG_INFO, "%s task default policy is %d, > \ > - priority is %d", task->info.create.i_name, > policy, sp.sched_priority); > + syslog(LOG_INFO, "%s task default policy is %d, > priority is %d", > +task->info.create.i_name, policy, > sp.sched_priority); > } > > #ifdef RLIMIT_RTPRIO -- CenturyLink Cloud: The Leader in Enterprise Cloud Services. Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical Workloads, Development Environments & Everything In Between. Get a Quote or Start a Free Trial Today. http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel
[devel] [PATCH 1 of 1] base: Use default scheduling policy when configured policy is invalid [#690]
osaf/libs/core/leap/os_defs.c | 13 +++-- 1 files changed, 7 insertions(+), 6 deletions(-) OpenSAF would fail to start when an invalid thread scheduling policy has been configured, e.g. using the following configuration options for one of the OpenSAF services: export OSAF_MDS_SCHED_PRIORITY=0 export OSAF_MDS_SCHED_POLICY=3 The OpenSAF services fail with the following messages: Dec 24 14:40:02 SLES_NEW2 opensafd[15010]: ER Timed-out for response from RDE Dec 24 14:40:02 SLES_NEW2 opensafd[15010]: ER Dec 24 14:40:02 SLES_NEW2 opensafd[15010]: ER Going for recovery Dec 24 14:40:02 SLES_NEW2 opensafd[15010]: ER Trying To RESPAWN /usr/lib64/opensaf/clc-cli/osaf-rded attempt #1 Dec 24 14:40:02 SLES_NEW2 opensafd[15010]: ER Sending SIGKILL to RDE, pid=15031 The reason is that scheduling policy 3 (SCHED_BATCH) is not a valid parameter to the pthread_attr_setschedpolicy() function, and OpenSAF passes the configured policy to this function without whecking that it is valid. A check for this case has been added, so that we fall back to the default scheduling policy when an invalid policy has been configured. diff --git a/osaf/libs/core/leap/os_defs.c b/osaf/libs/core/leap/os_defs.c --- a/osaf/libs/core/leap/os_defs.c +++ b/osaf/libs/core/leap/os_defs.c @@ -164,15 +164,16 @@ unsigned int ncs_os_task(NCS_OS_TASK *ta min_prio = sched_get_priority_min(policy); max_prio = sched_get_priority_max(policy); - if((sp.sched_priority < min_prio) || (sp.sched_priority > max_prio)) { + if ((sp.sched_priority < min_prio) || (sp.sched_priority > max_prio) || + pthread_attr_setschedpolicy(&attr, policy) != 0) { /* Set to defaults */ - syslog(LOG_NOTICE, "scheduling priority %d for given policy %d to the task %s is not \ - within the range, setting to default \ - values ", sp.sched_priority, policy, task->info.create.i_name); + syslog(LOG_NOTICE, "scheduling priority %d or policy %d for the " + "task %s is invalid, setting to default values", + sp.sched_priority, policy, task->info.create.i_name); policy = task->info.create.i_policy; sp.sched_priority = task->info.create.i_priority; - syslog(LOG_INFO, "%s task default policy is %d, \ - priority is %d", task->info.create.i_name, policy, sp.sched_priority); + syslog(LOG_INFO, "%s task default policy is %d, priority is %d", + task->info.create.i_name, policy, sp.sched_priority); } #ifdef RLIMIT_RTPRIO -- CenturyLink Cloud: The Leader in Enterprise Cloud Services. Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical Workloads, Development Environments & Everything In Between. Get a Quote or Start a Free Trial Today. http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel