* [dpdk-dev] [PATCH] eal: optimize timer routines
@ 2017-05-01 19:12 Jerin Jacob
2017-05-01 19:52 ` Thomas Monjalon
2017-05-02 5:19 ` [dpdk-dev] [PATCH v2] " Jerin Jacob
0 siblings, 2 replies; 4+ messages in thread
From: Jerin Jacob @ 2017-05-01 19:12 UTC (permalink / raw)
To: dev; +Cc: thomas, Jerin Jacob
Since DPDK has only two timer sources,
Avoid &eal_timer_source memory read and followed
by the switch case statement when
RTE_LIBEAL_USE_HPET is not defined.
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
lib/librte_eal/common/include/generic/rte_cycles.h | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/lib/librte_eal/common/include/generic/rte_cycles.h b/lib/librte_eal/common/include/generic/rte_cycles.h
index 00103ca9f..2f3dea06e 100644
--- a/lib/librte_eal/common/include/generic/rte_cycles.h
+++ b/lib/librte_eal/common/include/generic/rte_cycles.h
@@ -150,15 +150,17 @@ int rte_eal_hpet_init(int make_default);
static inline uint64_t
rte_get_timer_cycles(void)
{
+#ifdef RTE_LIBEAL_USE_HPET
switch(eal_timer_source) {
case EAL_TIMER_TSC:
return rte_get_tsc_cycles();
case EAL_TIMER_HPET:
-#ifdef RTE_LIBEAL_USE_HPET
return rte_get_hpet_cycles();
-#endif
default: rte_panic("Invalid timer source specified\n");
}
+#else
+ return rte_get_tsc_cycles();
+#endif
}
/**
@@ -170,15 +172,17 @@ rte_get_timer_cycles(void)
static inline uint64_t
rte_get_timer_hz(void)
{
+#ifdef RTE_LIBEAL_USE_HPET
switch(eal_timer_source) {
case EAL_TIMER_TSC:
return rte_get_tsc_hz();
case EAL_TIMER_HPET:
-#ifdef RTE_LIBEAL_USE_HPET
return rte_get_hpet_hz();
-#endif
default: rte_panic("Invalid timer source specified\n");
}
+#else
+ return rte_get_tsc_hz();
+#endif
}
/**
* Wait at least us microseconds.
--
2.12.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-dev] [PATCH] eal: optimize timer routines
2017-05-01 19:12 [dpdk-dev] [PATCH] eal: optimize timer routines Jerin Jacob
@ 2017-05-01 19:52 ` Thomas Monjalon
2017-05-02 5:19 ` [dpdk-dev] [PATCH v2] " Jerin Jacob
1 sibling, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2017-05-01 19:52 UTC (permalink / raw)
To: Jerin Jacob; +Cc: dev
01/05/2017 21:12, Jerin Jacob:
> Since DPDK has only two timer sources,
> Avoid &eal_timer_source memory read and followed
> by the switch case statement when
> RTE_LIBEAL_USE_HPET is not defined.
[...]
> static inline uint64_t
> rte_get_timer_cycles(void)
> {
> +#ifdef RTE_LIBEAL_USE_HPET
> switch(eal_timer_source) {
> case EAL_TIMER_TSC:
> return rte_get_tsc_cycles();
> case EAL_TIMER_HPET:
> -#ifdef RTE_LIBEAL_USE_HPET
> return rte_get_hpet_cycles();
> -#endif
> default: rte_panic("Invalid timer source specified\n");
> }
> +#else
> + return rte_get_tsc_cycles();
> +#endif
I think I would prefer avoiding the #else part by
"unifdef" the first occurence of rte_get_tsc_cycles:
static inline uint64_t
rte_get_timer_cycles(void)
{
#ifdef RTE_LIBEAL_USE_HPET
switch(eal_timer_source) {
case EAL_TIMER_TSC:
#endif
return rte_get_tsc_cycles();
#ifdef RTE_LIBEAL_USE_HPET
case EAL_TIMER_HPET:
return rte_get_hpet_cycles();
default: rte_panic("Invalid timer source specified\n");
}
#endif
^ permalink raw reply [flat|nested] 4+ messages in thread
* [dpdk-dev] [PATCH v2] eal: optimize timer routines
2017-05-01 19:12 [dpdk-dev] [PATCH] eal: optimize timer routines Jerin Jacob
2017-05-01 19:52 ` Thomas Monjalon
@ 2017-05-02 5:19 ` Jerin Jacob
2017-05-05 13:28 ` Thomas Monjalon
1 sibling, 1 reply; 4+ messages in thread
From: Jerin Jacob @ 2017-05-02 5:19 UTC (permalink / raw)
To: dev; +Cc: thomas, Jerin Jacob
Since DPDK has only two timer sources,
Avoid &eal_timer_source memory read and followed
by the switch case statement when
RTE_LIBEAL_USE_HPET is not defined.
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
v2:
- Rearrage the ifdef to avoiding the #else part by
"unifdef" the first occurence of rte_get_tsc_cycles(Thomas)
---
lib/librte_eal/common/include/generic/rte_cycles.h | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/lib/librte_eal/common/include/generic/rte_cycles.h b/lib/librte_eal/common/include/generic/rte_cycles.h
index 00103ca9f..0e645c2c4 100644
--- a/lib/librte_eal/common/include/generic/rte_cycles.h
+++ b/lib/librte_eal/common/include/generic/rte_cycles.h
@@ -150,15 +150,17 @@ int rte_eal_hpet_init(int make_default);
static inline uint64_t
rte_get_timer_cycles(void)
{
+#ifdef RTE_LIBEAL_USE_HPET
switch(eal_timer_source) {
case EAL_TIMER_TSC:
+#endif
return rte_get_tsc_cycles();
- case EAL_TIMER_HPET:
#ifdef RTE_LIBEAL_USE_HPET
+ case EAL_TIMER_HPET:
return rte_get_hpet_cycles();
-#endif
default: rte_panic("Invalid timer source specified\n");
}
+#endif
}
/**
@@ -170,15 +172,17 @@ rte_get_timer_cycles(void)
static inline uint64_t
rte_get_timer_hz(void)
{
+#ifdef RTE_LIBEAL_USE_HPET
switch(eal_timer_source) {
case EAL_TIMER_TSC:
+#endif
return rte_get_tsc_hz();
- case EAL_TIMER_HPET:
#ifdef RTE_LIBEAL_USE_HPET
+ case EAL_TIMER_HPET:
return rte_get_hpet_hz();
-#endif
default: rte_panic("Invalid timer source specified\n");
}
+#endif
}
/**
* Wait at least us microseconds.
--
2.12.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-dev] [PATCH v2] eal: optimize timer routines
2017-05-02 5:19 ` [dpdk-dev] [PATCH v2] " Jerin Jacob
@ 2017-05-05 13:28 ` Thomas Monjalon
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2017-05-05 13:28 UTC (permalink / raw)
To: Jerin Jacob; +Cc: dev
02/05/2017 07:19, Jerin Jacob:
> Since DPDK has only two timer sources,
> Avoid &eal_timer_source memory read and followed
> by the switch case statement when
> RTE_LIBEAL_USE_HPET is not defined.
>
> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
It is not a fix but it is simple and safe enough to be in 17.05-rc4.
Applied, thanks
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-05-05 13:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-01 19:12 [dpdk-dev] [PATCH] eal: optimize timer routines Jerin Jacob
2017-05-01 19:52 ` Thomas Monjalon
2017-05-02 5:19 ` [dpdk-dev] [PATCH v2] " Jerin Jacob
2017-05-05 13:28 ` Thomas Monjalon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).