Yes, you are correct. Below mentioned change is enough. > + policy |= SCHED_RESET_ON_FORK;
Regards, Ramesh. ----- Original Message ----- From: [email protected] To: [email protected], [email protected] Cc: [email protected] Sent: Wednesday, September 18, 2013 5:34:05 PM GMT +05:30 Chennai, Kolkata, Mumbai, New Delhi Subject: RE: [devel] [PATCH 1 of 1] base: use SCHED_RESET_ON_FORK in daemonize [#532] OK I thought it was reverting back to defaults due to system limits or something. Not that some user had configured it wrong. I get it, should remove all changes in daemoniz() except: > > + policy |= SCHED_RESET_ON_FORK; Ok? Thanks, Hans > -----Original Message----- > From: Ramesh Betham [mailto:[email protected]] > Sent: den 18 september 2013 13:51 > To: Hans Feldt > Cc: [email protected] > Subject: Re: [devel] [PATCH 1 of 1] base: use SCHED_RESET_ON_FORK in > daemonize [#532] > > Hi Hans, > > The reason for code existing to the failure of "sched_setscheduler()" is > to continue with *default values* by any chance if it fails with the > user defined values given through env-var settings "*__SCHED_PRIORITY" > and "*_SCHED_POLICY". > > Thanks, > Ramesh. > > On 9/18/2013 2:49 PM, Hans Feldt wrote: > > osaf/libs/core/common/daemon.c | 23 ++++++++++++++++++----- > > osaf/libs/core/leap/os_defs.c | 8 -------- > > 2 files changed, 18 insertions(+), 13 deletions(-) > > > > > > In ncs_os_process_execute_timed() non async signal safe functions are used > > between fork() and exec(). That can cause undeterministic behaviour in the > > child and cause problems for AMF to provide service. > > > > The amfnd main thread runs with RT scheduling policy and > > ncs_os_process_execute_timed() needs to guarantee that child processes get > > normal scheduling policy and not just inherits the callers policy. > > > > By adding the SCHED_RESET_ON_FORK option to the sched_setscheduler system > > call > > it is guaranteed by the kernel that all child processes gets normal > > scheduling policy. No matter the policy of the parent process/thread. > > > > diff --git a/osaf/libs/core/common/daemon.c b/osaf/libs/core/common/daemon.c > > --- a/osaf/libs/core/common/daemon.c > > +++ b/osaf/libs/core/common/daemon.c > > @@ -40,6 +40,15 @@ > > #include <ncsgl_defs.h> > > #include <os_defs.h> > > > > +/* > > + * See "man 2 sched_setscheduler" > > + * SCHED_RESET_ON_FORK is supported from Linux 2.6.32 but is not in POSIX > > (yet) > > + * SCHED_RESET_ON_FORK is defined in <linux/sched.h> > > + * The above file cannot be included because it will break an LSB build > > + * We trust that the Linux kernel ABI will never change and is backwards > > + * compatible thus it is safe to define our own constant here. > > + */ > > +#define SCHED_RESET_ON_FORK 0x40000000 > > > > #define DEFAULT_RUNAS_USERNAME "opensaf" > > > > @@ -216,6 +225,7 @@ void daemonize(int argc, char *argv[]) > > { > > policy = SCHED_RR; > > prio_val = sched_get_priority_min(policy); > > + policy |= SCHED_RESET_ON_FORK; > > } > > > > strcpy(t_str, basename(argv[0])); > > @@ -235,14 +245,17 @@ void daemonize(int argc, char *argv[]) > > > > param.sched_priority = prio_val; > > if (sched_setscheduler(0, policy, ¶m) == -1) { > > - syslog(LOG_ERR, "Could not set scheduling class for %s", > > strerror(errno)); > > + syslog(LOG_ERR, "daemonize: could not set scheduling class - > > %s", strerror(errno)); > > if( (!strncmp("osafamfwd", basename(argv[0]), 9)) || > > (!strncmp("osafamfnd", basename(argv[0]), 9))) > > { > > - policy = SCHED_RR; > > + syslog(LOG_NOTICE, "daemonize: setting scheduler policy > > to OTHER"); > > + syslog(LOG_WARNING, "daemonize: this system is not > > correctly configured"); > > + policy = SCHED_OTHER; > > param.sched_priority = sched_get_priority_min(policy); > > - syslog(LOG_INFO, "setting to default values"); > > - if (sched_setscheduler(0, policy, ¶m) == -1) > > - syslog(LOG_ERR, "Could not set scheduling class > > for %s", strerror(errno)); > > + if (sched_setscheduler(0, policy, ¶m) == -1) { > > + syslog(LOG_ERR, "daemonize: could not set > > scheduling class, exiting"); > > + exit(EXIT_FAILURE); > > + } > > } > > } > > > > 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 > > @@ -999,14 +999,6 @@ uint32_t ncs_os_process_execute_timed(NC > > osaf_mutex_lock_ordie(&s_cloexec_mutex); > > > > if ((pid = fork()) == 0) { > > - /* > > - ** Make sure forked processes have default scheduling class > > - ** independent of the callers scheduling class. > > - */ > > - struct sched_param param = {.sched_priority = 0 }; > > - if (sched_setscheduler(0, SCHED_OTHER, ¶m) == -1) > > - syslog(LOG_ERR, "%s: Could not setscheduler: %s", > > __FUNCTION__, strerror(errno)); > > - > > /* set the environment variables */ > > for (; count > 0; count--) { > > setenv(node->name, node->value, node->overwrite); > > ------------------------------------------------------------------------------ > LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99! > 1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint > 2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes > Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13. > http://pubads.g.doubleclick.net/gampad/clk?id=58041151&iu=/4140/ostg.clktrk > _______________________________________________ > Opensaf-devel mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/opensaf-devel ------------------------------------------------------------------------------ LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99! 1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint 2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13. http://pubads.g.doubleclick.net/gampad/clk?id=58041151&iu=/4140/ostg.clktrk _______________________________________________ Opensaf-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/opensaf-devel
