Message ID | 1404830529-31373-1-git-send-email-maxim.uvarov@linaro.org |
---|---|
State | New |
Headers | show |
I have not tested this, but I think we need to apply this to unlock other work. The new timer implementation needs to be translated from C++ before it can be applied and Ola is on Vacation this month so it will be a while. Thus +1 form me. On 8 July 2014 10:42, Maxim Uvarov <maxim.uvarov@linaro.org> wrote: > Implement function to disarm all timers. Needed in case of > normal exit from application. > Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> > --- > One more call to apply this patch. This is needed for clean exit from > applications like tcpdump, snort odp accelerated. This can be replaced > with new implementation when it will be done. > > Best regards, > Maxim. > > platform/linux-generic/include/odp_internal.h | 1 + > platform/linux-generic/source/odp_timer.c | 24 > ++++++++++++++++++++++++ > 2 files changed, 25 insertions(+) > > diff --git a/platform/linux-generic/include/odp_internal.h > b/platform/linux-generic/include/odp_internal.h > index fb3be79..9b0769e 100644 > --- a/platform/linux-generic/include/odp_internal.h > +++ b/platform/linux-generic/include/odp_internal.h > @@ -38,6 +38,7 @@ int odp_schedule_init_global(void); > int odp_schedule_init_local(void); > > int odp_timer_init_global(void); > +int odp_timer_disarm_all(void); > > #ifdef __cplusplus > } > diff --git a/platform/linux-generic/source/odp_timer.c > b/platform/linux-generic/source/odp_timer.c > index 6fb5025..98ffde3 100644 > --- a/platform/linux-generic/source/odp_timer.c > +++ b/platform/linux-generic/source/odp_timer.c > @@ -217,6 +217,30 @@ int odp_timer_init_global(void) > return 0; > } > > +int odp_timer_disarm_all(void) > +{ > + int timers; > + struct itimerspec ispec; > + > + timers = odp_atomic_load_int(&odp_timer.num_timers); > + > + ispec.it_interval.tv_sec = 0; > + ispec.it_interval.tv_nsec = 0; > + ispec.it_value.tv_sec = 0; > + ispec.it_value.tv_nsec = 0; > + > + for (; timers >= 0; timers--) { > + if (timer_settime(odp_timer.timer[timers].timerid, > + 0, &ispec, NULL)) { > + ODP_DBG("Timer reset failed\n"); > + return -1; > + } > + odp_atomic_fetch_sub_int(&odp_timer.num_timers, 1); > + } > + > + return 0; > +} > + > odp_timer_t odp_timer_create(const char *name, odp_buffer_pool_t pool, > uint64_t resolution, uint64_t min_tmo, > uint64_t max_tmo) > -- > 1.8.5.1.163.gd7aced9 > > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org > http://lists.linaro.org/mailman/listinfo/lng-odp >
In the new Timer API and implementation, destroying a timer pool will disarm all timers and remove any corresponding usage of kernel functionality. On 8 July 2014 17:25, Mike Holmes <mike.holmes@linaro.org> wrote: > I have not tested this, but I think we need to apply this to unlock other > work. The new timer implementation needs to be translated from C++ before > it can be applied and Ola is on Vacation this month so it will be a while. > > Thus +1 form me. > > > On 8 July 2014 10:42, Maxim Uvarov <maxim.uvarov@linaro.org> wrote: > >> Implement function to disarm all timers. Needed in case of >> normal exit from application. >> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> >> --- >> One more call to apply this patch. This is needed for clean exit from >> applications like tcpdump, snort odp accelerated. This can be replaced >> with new implementation when it will be done. >> >> Best regards, >> Maxim. >> >> platform/linux-generic/include/odp_internal.h | 1 + >> platform/linux-generic/source/odp_timer.c | 24 >> ++++++++++++++++++++++++ >> 2 files changed, 25 insertions(+) >> >> diff --git a/platform/linux-generic/include/odp_internal.h >> b/platform/linux-generic/include/odp_internal.h >> index fb3be79..9b0769e 100644 >> --- a/platform/linux-generic/include/odp_internal.h >> +++ b/platform/linux-generic/include/odp_internal.h >> @@ -38,6 +38,7 @@ int odp_schedule_init_global(void); >> int odp_schedule_init_local(void); >> >> int odp_timer_init_global(void); >> +int odp_timer_disarm_all(void); >> >> #ifdef __cplusplus >> } >> diff --git a/platform/linux-generic/source/odp_timer.c >> b/platform/linux-generic/source/odp_timer.c >> index 6fb5025..98ffde3 100644 >> --- a/platform/linux-generic/source/odp_timer.c >> +++ b/platform/linux-generic/source/odp_timer.c >> @@ -217,6 +217,30 @@ int odp_timer_init_global(void) >> return 0; >> } >> >> +int odp_timer_disarm_all(void) >> +{ >> + int timers; >> + struct itimerspec ispec; >> + >> + timers = odp_atomic_load_int(&odp_timer.num_timers); >> + >> + ispec.it_interval.tv_sec = 0; >> + ispec.it_interval.tv_nsec = 0; >> + ispec.it_value.tv_sec = 0; >> + ispec.it_value.tv_nsec = 0; >> + >> + for (; timers >= 0; timers--) { >> + if (timer_settime(odp_timer.timer[timers].timerid, >> + 0, &ispec, NULL)) { >> + ODP_DBG("Timer reset failed\n"); >> + return -1; >> + } >> + odp_atomic_fetch_sub_int(&odp_timer.num_timers, 1); >> + } >> + >> + return 0; >> +} >> + >> odp_timer_t odp_timer_create(const char *name, odp_buffer_pool_t pool, >> uint64_t resolution, uint64_t min_tmo, >> uint64_t max_tmo) >> -- >> 1.8.5.1.163.gd7aced9 >> >> >> _______________________________________________ >> lng-odp mailing list >> lng-odp@lists.linaro.org >> http://lists.linaro.org/mailman/listinfo/lng-odp >> > > > > -- > *Mike Holmes* > Linaro Technical Manager / Lead > LNG - ODP > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org > http://lists.linaro.org/mailman/listinfo/lng-odp > >
diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h index fb3be79..9b0769e 100644 --- a/platform/linux-generic/include/odp_internal.h +++ b/platform/linux-generic/include/odp_internal.h @@ -38,6 +38,7 @@ int odp_schedule_init_global(void); int odp_schedule_init_local(void); int odp_timer_init_global(void); +int odp_timer_disarm_all(void); #ifdef __cplusplus } diff --git a/platform/linux-generic/source/odp_timer.c b/platform/linux-generic/source/odp_timer.c index 6fb5025..98ffde3 100644 --- a/platform/linux-generic/source/odp_timer.c +++ b/platform/linux-generic/source/odp_timer.c @@ -217,6 +217,30 @@ int odp_timer_init_global(void) return 0; } +int odp_timer_disarm_all(void) +{ + int timers; + struct itimerspec ispec; + + timers = odp_atomic_load_int(&odp_timer.num_timers); + + ispec.it_interval.tv_sec = 0; + ispec.it_interval.tv_nsec = 0; + ispec.it_value.tv_sec = 0; + ispec.it_value.tv_nsec = 0; + + for (; timers >= 0; timers--) { + if (timer_settime(odp_timer.timer[timers].timerid, + 0, &ispec, NULL)) { + ODP_DBG("Timer reset failed\n"); + return -1; + } + odp_atomic_fetch_sub_int(&odp_timer.num_timers, 1); + } + + return 0; +} + odp_timer_t odp_timer_create(const char *name, odp_buffer_pool_t pool, uint64_t resolution, uint64_t min_tmo, uint64_t max_tmo)
Implement function to disarm all timers. Needed in case of normal exit from application. Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> --- One more call to apply this patch. This is needed for clean exit from applications like tcpdump, snort odp accelerated. This can be replaced with new implementation when it will be done. Best regards, Maxim. platform/linux-generic/include/odp_internal.h | 1 + platform/linux-generic/source/odp_timer.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+)