eal: switch to architecture specific pause function
[dpdk.git] / lib / librte_timer / rte_timer.c
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5  *   All rights reserved.
6  *
7  *   Redistribution and use in source and binary forms, with or without
8  *   modification, are permitted provided that the following conditions
9  *   are met:
10  *
11  *     * Redistributions of source code must retain the above copyright
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright
14  *       notice, this list of conditions and the following disclaimer in
15  *       the documentation and/or other materials provided with the
16  *       distribution.
17  *     * Neither the name of Intel Corporation nor the names of its
18  *       contributors may be used to endorse or promote products derived
19  *       from this software without specific prior written permission.
20  *
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 #include <string.h>
35 #include <stdio.h>
36 #include <stdint.h>
37 #include <inttypes.h>
38 #include <assert.h>
39 #include <sys/queue.h>
40
41 #include <rte_atomic.h>
42 #include <rte_common.h>
43 #include <rte_cycles.h>
44 #include <rte_per_lcore.h>
45 #include <rte_memory.h>
46 #include <rte_memzone.h>
47 #include <rte_launch.h>
48 #include <rte_eal.h>
49 #include <rte_per_lcore.h>
50 #include <rte_lcore.h>
51 #include <rte_branch_prediction.h>
52 #include <rte_spinlock.h>
53 #include <rte_random.h>
54 #include <rte_pause.h>
55
56 #include "rte_timer.h"
57
58 LIST_HEAD(rte_timer_list, rte_timer);
59
60 struct priv_timer {
61         struct rte_timer pending_head;  /**< dummy timer instance to head up list */
62         rte_spinlock_t list_lock;       /**< lock to protect list access */
63
64         /** per-core variable that true if a timer was updated on this
65          *  core since last reset of the variable */
66         int updated;
67
68         /** track the current depth of the skiplist */
69         unsigned curr_skiplist_depth;
70
71         unsigned prev_lcore;              /**< used for lcore round robin */
72
73         /** running timer on this lcore now */
74         struct rte_timer *running_tim;
75
76 #ifdef RTE_LIBRTE_TIMER_DEBUG
77         /** per-lcore statistics */
78         struct rte_timer_debug_stats stats;
79 #endif
80 } __rte_cache_aligned;
81
82 /** per-lcore private info for timers */
83 static struct priv_timer priv_timer[RTE_MAX_LCORE];
84
85 /* when debug is enabled, store some statistics */
86 #ifdef RTE_LIBRTE_TIMER_DEBUG
87 #define __TIMER_STAT_ADD(name, n) do {                                  \
88                 unsigned __lcore_id = rte_lcore_id();                   \
89                 if (__lcore_id < RTE_MAX_LCORE)                         \
90                         priv_timer[__lcore_id].stats.name += (n);       \
91         } while(0)
92 #else
93 #define __TIMER_STAT_ADD(name, n) do {} while(0)
94 #endif
95
96 /* Init the timer library. */
97 void
98 rte_timer_subsystem_init(void)
99 {
100         unsigned lcore_id;
101
102         /* since priv_timer is static, it's zeroed by default, so only init some
103          * fields.
104          */
105         for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id ++) {
106                 rte_spinlock_init(&priv_timer[lcore_id].list_lock);
107                 priv_timer[lcore_id].prev_lcore = lcore_id;
108         }
109 }
110
111 /* Initialize the timer handle tim for use */
112 void
113 rte_timer_init(struct rte_timer *tim)
114 {
115         union rte_timer_status status;
116
117         status.state = RTE_TIMER_STOP;
118         status.owner = RTE_TIMER_NO_OWNER;
119         tim->status.u32 = status.u32;
120 }
121
122 /*
123  * if timer is pending or stopped (or running on the same core than
124  * us), mark timer as configuring, and on success return the previous
125  * status of the timer
126  */
127 static int
128 timer_set_config_state(struct rte_timer *tim,
129                        union rte_timer_status *ret_prev_status)
130 {
131         union rte_timer_status prev_status, status;
132         int success = 0;
133         unsigned lcore_id;
134
135         lcore_id = rte_lcore_id();
136
137         /* wait that the timer is in correct status before update,
138          * and mark it as being configured */
139         while (success == 0) {
140                 prev_status.u32 = tim->status.u32;
141
142                 /* timer is running on another core
143                  * or ready to run on local core, exit
144                  */
145                 if (prev_status.state == RTE_TIMER_RUNNING &&
146                     (prev_status.owner != (uint16_t)lcore_id ||
147                      tim != priv_timer[lcore_id].running_tim))
148                         return -1;
149
150                 /* timer is being configured on another core */
151                 if (prev_status.state == RTE_TIMER_CONFIG)
152                         return -1;
153
154                 /* here, we know that timer is stopped or pending,
155                  * mark it atomically as being configured */
156                 status.state = RTE_TIMER_CONFIG;
157                 status.owner = (int16_t)lcore_id;
158                 success = rte_atomic32_cmpset(&tim->status.u32,
159                                               prev_status.u32,
160                                               status.u32);
161         }
162
163         ret_prev_status->u32 = prev_status.u32;
164         return 0;
165 }
166
167 /*
168  * if timer is pending, mark timer as running
169  */
170 static int
171 timer_set_running_state(struct rte_timer *tim)
172 {
173         union rte_timer_status prev_status, status;
174         unsigned lcore_id = rte_lcore_id();
175         int success = 0;
176
177         /* wait that the timer is in correct status before update,
178          * and mark it as running */
179         while (success == 0) {
180                 prev_status.u32 = tim->status.u32;
181
182                 /* timer is not pending anymore */
183                 if (prev_status.state != RTE_TIMER_PENDING)
184                         return -1;
185
186                 /* here, we know that timer is stopped or pending,
187                  * mark it atomically as being configured */
188                 status.state = RTE_TIMER_RUNNING;
189                 status.owner = (int16_t)lcore_id;
190                 success = rte_atomic32_cmpset(&tim->status.u32,
191                                               prev_status.u32,
192                                               status.u32);
193         }
194
195         return 0;
196 }
197
198 /*
199  * Return a skiplist level for a new entry.
200  * This probabalistically gives a level with p=1/4 that an entry at level n
201  * will also appear at level n+1.
202  */
203 static uint32_t
204 timer_get_skiplist_level(unsigned curr_depth)
205 {
206 #ifdef RTE_LIBRTE_TIMER_DEBUG
207         static uint32_t i, count = 0;
208         static uint32_t levels[MAX_SKIPLIST_DEPTH] = {0};
209 #endif
210
211         /* probability value is 1/4, i.e. all at level 0, 1 in 4 is at level 1,
212          * 1 in 16 at level 2, 1 in 64 at level 3, etc. Calculated using lowest
213          * bit position of a (pseudo)random number.
214          */
215         uint32_t rand = rte_rand() & (UINT32_MAX - 1);
216         uint32_t level = rand == 0 ? MAX_SKIPLIST_DEPTH : (rte_bsf32(rand)-1) / 2;
217
218         /* limit the levels used to one above our current level, so we don't,
219          * for instance, have a level 0 and a level 7 without anything between
220          */
221         if (level > curr_depth)
222                 level = curr_depth;
223         if (level >= MAX_SKIPLIST_DEPTH)
224                 level = MAX_SKIPLIST_DEPTH-1;
225 #ifdef RTE_LIBRTE_TIMER_DEBUG
226         count ++;
227         levels[level]++;
228         if (count % 10000 == 0)
229                 for (i = 0; i < MAX_SKIPLIST_DEPTH; i++)
230                         printf("Level %u: %u\n", (unsigned)i, (unsigned)levels[i]);
231 #endif
232         return level;
233 }
234
235 /*
236  * For a given time value, get the entries at each level which
237  * are <= that time value.
238  */
239 static void
240 timer_get_prev_entries(uint64_t time_val, unsigned tim_lcore,
241                 struct rte_timer **prev)
242 {
243         unsigned lvl = priv_timer[tim_lcore].curr_skiplist_depth;
244         prev[lvl] = &priv_timer[tim_lcore].pending_head;
245         while(lvl != 0) {
246                 lvl--;
247                 prev[lvl] = prev[lvl+1];
248                 while (prev[lvl]->sl_next[lvl] &&
249                                 prev[lvl]->sl_next[lvl]->expire <= time_val)
250                         prev[lvl] = prev[lvl]->sl_next[lvl];
251         }
252 }
253
254 /*
255  * Given a timer node in the skiplist, find the previous entries for it at
256  * all skiplist levels.
257  */
258 static void
259 timer_get_prev_entries_for_node(struct rte_timer *tim, unsigned tim_lcore,
260                 struct rte_timer **prev)
261 {
262         int i;
263         /* to get a specific entry in the list, look for just lower than the time
264          * values, and then increment on each level individually if necessary
265          */
266         timer_get_prev_entries(tim->expire - 1, tim_lcore, prev);
267         for (i = priv_timer[tim_lcore].curr_skiplist_depth - 1; i >= 0; i--) {
268                 while (prev[i]->sl_next[i] != NULL &&
269                                 prev[i]->sl_next[i] != tim &&
270                                 prev[i]->sl_next[i]->expire <= tim->expire)
271                         prev[i] = prev[i]->sl_next[i];
272         }
273 }
274
275 /*
276  * add in list, lock if needed
277  * timer must be in config state
278  * timer must not be in a list
279  */
280 static void
281 timer_add(struct rte_timer *tim, unsigned tim_lcore, int local_is_locked)
282 {
283         unsigned lcore_id = rte_lcore_id();
284         unsigned lvl;
285         struct rte_timer *prev[MAX_SKIPLIST_DEPTH+1];
286
287         /* if timer needs to be scheduled on another core, we need to
288          * lock the list; if it is on local core, we need to lock if
289          * we are not called from rte_timer_manage() */
290         if (tim_lcore != lcore_id || !local_is_locked)
291                 rte_spinlock_lock(&priv_timer[tim_lcore].list_lock);
292
293         /* find where exactly this element goes in the list of elements
294          * for each depth. */
295         timer_get_prev_entries(tim->expire, tim_lcore, prev);
296
297         /* now assign it a new level and add at that level */
298         const unsigned tim_level = timer_get_skiplist_level(
299                         priv_timer[tim_lcore].curr_skiplist_depth);
300         if (tim_level == priv_timer[tim_lcore].curr_skiplist_depth)
301                 priv_timer[tim_lcore].curr_skiplist_depth++;
302
303         lvl = tim_level;
304         while (lvl > 0) {
305                 tim->sl_next[lvl] = prev[lvl]->sl_next[lvl];
306                 prev[lvl]->sl_next[lvl] = tim;
307                 lvl--;
308         }
309         tim->sl_next[0] = prev[0]->sl_next[0];
310         prev[0]->sl_next[0] = tim;
311
312         /* save the lowest list entry into the expire field of the dummy hdr
313          * NOTE: this is not atomic on 32-bit*/
314         priv_timer[tim_lcore].pending_head.expire = priv_timer[tim_lcore].\
315                         pending_head.sl_next[0]->expire;
316
317         if (tim_lcore != lcore_id || !local_is_locked)
318                 rte_spinlock_unlock(&priv_timer[tim_lcore].list_lock);
319 }
320
321 /*
322  * del from list, lock if needed
323  * timer must be in config state
324  * timer must be in a list
325  */
326 static void
327 timer_del(struct rte_timer *tim, union rte_timer_status prev_status,
328                 int local_is_locked)
329 {
330         unsigned lcore_id = rte_lcore_id();
331         unsigned prev_owner = prev_status.owner;
332         int i;
333         struct rte_timer *prev[MAX_SKIPLIST_DEPTH+1];
334
335         /* if timer needs is pending another core, we need to lock the
336          * list; if it is on local core, we need to lock if we are not
337          * called from rte_timer_manage() */
338         if (prev_owner != lcore_id || !local_is_locked)
339                 rte_spinlock_lock(&priv_timer[prev_owner].list_lock);
340
341         /* save the lowest list entry into the expire field of the dummy hdr.
342          * NOTE: this is not atomic on 32-bit */
343         if (tim == priv_timer[prev_owner].pending_head.sl_next[0])
344                 priv_timer[prev_owner].pending_head.expire =
345                                 ((tim->sl_next[0] == NULL) ? 0 : tim->sl_next[0]->expire);
346
347         /* adjust pointers from previous entries to point past this */
348         timer_get_prev_entries_for_node(tim, prev_owner, prev);
349         for (i = priv_timer[prev_owner].curr_skiplist_depth - 1; i >= 0; i--) {
350                 if (prev[i]->sl_next[i] == tim)
351                         prev[i]->sl_next[i] = tim->sl_next[i];
352         }
353
354         /* in case we deleted last entry at a level, adjust down max level */
355         for (i = priv_timer[prev_owner].curr_skiplist_depth - 1; i >= 0; i--)
356                 if (priv_timer[prev_owner].pending_head.sl_next[i] == NULL)
357                         priv_timer[prev_owner].curr_skiplist_depth --;
358                 else
359                         break;
360
361         if (prev_owner != lcore_id || !local_is_locked)
362                 rte_spinlock_unlock(&priv_timer[prev_owner].list_lock);
363 }
364
365 /* Reset and start the timer associated with the timer handle (private func) */
366 static int
367 __rte_timer_reset(struct rte_timer *tim, uint64_t expire,
368                   uint64_t period, unsigned tim_lcore,
369                   rte_timer_cb_t fct, void *arg,
370                   int local_is_locked)
371 {
372         union rte_timer_status prev_status, status;
373         int ret;
374         unsigned lcore_id = rte_lcore_id();
375
376         /* round robin for tim_lcore */
377         if (tim_lcore == (unsigned)LCORE_ID_ANY) {
378                 if (lcore_id < RTE_MAX_LCORE) {
379                         /* EAL thread with valid lcore_id */
380                         tim_lcore = rte_get_next_lcore(
381                                 priv_timer[lcore_id].prev_lcore,
382                                 0, 1);
383                         priv_timer[lcore_id].prev_lcore = tim_lcore;
384                 } else
385                         /* non-EAL thread do not run rte_timer_manage(),
386                          * so schedule the timer on the first enabled lcore. */
387                         tim_lcore = rte_get_next_lcore(LCORE_ID_ANY, 0, 1);
388         }
389
390         /* wait that the timer is in correct status before update,
391          * and mark it as being configured */
392         ret = timer_set_config_state(tim, &prev_status);
393         if (ret < 0)
394                 return -1;
395
396         __TIMER_STAT_ADD(reset, 1);
397         if (prev_status.state == RTE_TIMER_RUNNING &&
398             lcore_id < RTE_MAX_LCORE) {
399                 priv_timer[lcore_id].updated = 1;
400         }
401
402         /* remove it from list */
403         if (prev_status.state == RTE_TIMER_PENDING) {
404                 timer_del(tim, prev_status, local_is_locked);
405                 __TIMER_STAT_ADD(pending, -1);
406         }
407
408         tim->period = period;
409         tim->expire = expire;
410         tim->f = fct;
411         tim->arg = arg;
412
413         __TIMER_STAT_ADD(pending, 1);
414         timer_add(tim, tim_lcore, local_is_locked);
415
416         /* update state: as we are in CONFIG state, only us can modify
417          * the state so we don't need to use cmpset() here */
418         rte_wmb();
419         status.state = RTE_TIMER_PENDING;
420         status.owner = (int16_t)tim_lcore;
421         tim->status.u32 = status.u32;
422
423         return 0;
424 }
425
426 /* Reset and start the timer associated with the timer handle tim */
427 int
428 rte_timer_reset(struct rte_timer *tim, uint64_t ticks,
429                 enum rte_timer_type type, unsigned tim_lcore,
430                 rte_timer_cb_t fct, void *arg)
431 {
432         uint64_t cur_time = rte_get_timer_cycles();
433         uint64_t period;
434
435         if (unlikely((tim_lcore != (unsigned)LCORE_ID_ANY) &&
436                         !rte_lcore_is_enabled(tim_lcore)))
437                 return -1;
438
439         if (type == PERIODICAL)
440                 period = ticks;
441         else
442                 period = 0;
443
444         return __rte_timer_reset(tim,  cur_time + ticks, period, tim_lcore,
445                           fct, arg, 0);
446 }
447
448 /* loop until rte_timer_reset() succeed */
449 void
450 rte_timer_reset_sync(struct rte_timer *tim, uint64_t ticks,
451                      enum rte_timer_type type, unsigned tim_lcore,
452                      rte_timer_cb_t fct, void *arg)
453 {
454         while (rte_timer_reset(tim, ticks, type, tim_lcore,
455                                fct, arg) != 0)
456                 rte_pause();
457 }
458
459 /* Stop the timer associated with the timer handle tim */
460 int
461 rte_timer_stop(struct rte_timer *tim)
462 {
463         union rte_timer_status prev_status, status;
464         unsigned lcore_id = rte_lcore_id();
465         int ret;
466
467         /* wait that the timer is in correct status before update,
468          * and mark it as being configured */
469         ret = timer_set_config_state(tim, &prev_status);
470         if (ret < 0)
471                 return -1;
472
473         __TIMER_STAT_ADD(stop, 1);
474         if (prev_status.state == RTE_TIMER_RUNNING &&
475             lcore_id < RTE_MAX_LCORE) {
476                 priv_timer[lcore_id].updated = 1;
477         }
478
479         /* remove it from list */
480         if (prev_status.state == RTE_TIMER_PENDING) {
481                 timer_del(tim, prev_status, 0);
482                 __TIMER_STAT_ADD(pending, -1);
483         }
484
485         /* mark timer as stopped */
486         rte_wmb();
487         status.state = RTE_TIMER_STOP;
488         status.owner = RTE_TIMER_NO_OWNER;
489         tim->status.u32 = status.u32;
490
491         return 0;
492 }
493
494 /* loop until rte_timer_stop() succeed */
495 void
496 rte_timer_stop_sync(struct rte_timer *tim)
497 {
498         while (rte_timer_stop(tim) != 0)
499                 rte_pause();
500 }
501
502 /* Test the PENDING status of the timer handle tim */
503 int
504 rte_timer_pending(struct rte_timer *tim)
505 {
506         return tim->status.state == RTE_TIMER_PENDING;
507 }
508
509 /* must be called periodically, run all timer that expired */
510 void rte_timer_manage(void)
511 {
512         union rte_timer_status status;
513         struct rte_timer *tim, *next_tim;
514         struct rte_timer *run_first_tim, **pprev;
515         unsigned lcore_id = rte_lcore_id();
516         struct rte_timer *prev[MAX_SKIPLIST_DEPTH + 1];
517         uint64_t cur_time;
518         int i, ret;
519
520         /* timer manager only runs on EAL thread with valid lcore_id */
521         assert(lcore_id < RTE_MAX_LCORE);
522
523         __TIMER_STAT_ADD(manage, 1);
524         /* optimize for the case where per-cpu list is empty */
525         if (priv_timer[lcore_id].pending_head.sl_next[0] == NULL)
526                 return;
527         cur_time = rte_get_timer_cycles();
528
529 #ifdef RTE_ARCH_X86_64
530         /* on 64-bit the value cached in the pending_head.expired will be
531          * updated atomically, so we can consult that for a quick check here
532          * outside the lock */
533         if (likely(priv_timer[lcore_id].pending_head.expire > cur_time))
534                 return;
535 #endif
536
537         /* browse ordered list, add expired timers in 'expired' list */
538         rte_spinlock_lock(&priv_timer[lcore_id].list_lock);
539
540         /* if nothing to do just unlock and return */
541         if (priv_timer[lcore_id].pending_head.sl_next[0] == NULL ||
542             priv_timer[lcore_id].pending_head.sl_next[0]->expire > cur_time) {
543                 rte_spinlock_unlock(&priv_timer[lcore_id].list_lock);
544                 return;
545         }
546
547         /* save start of list of expired timers */
548         tim = priv_timer[lcore_id].pending_head.sl_next[0];
549
550         /* break the existing list at current time point */
551         timer_get_prev_entries(cur_time, lcore_id, prev);
552         for (i = priv_timer[lcore_id].curr_skiplist_depth -1; i >= 0; i--) {
553                 if (prev[i] == &priv_timer[lcore_id].pending_head)
554                         continue;
555                 priv_timer[lcore_id].pending_head.sl_next[i] =
556                     prev[i]->sl_next[i];
557                 if (prev[i]->sl_next[i] == NULL)
558                         priv_timer[lcore_id].curr_skiplist_depth--;
559                 prev[i] ->sl_next[i] = NULL;
560         }
561
562         /* transition run-list from PENDING to RUNNING */
563         run_first_tim = tim;
564         pprev = &run_first_tim;
565
566         for ( ; tim != NULL; tim = next_tim) {
567                 next_tim = tim->sl_next[0];
568
569                 ret = timer_set_running_state(tim);
570                 if (likely(ret == 0)) {
571                         pprev = &tim->sl_next[0];
572                 } else {
573                         /* another core is trying to re-config this one,
574                          * remove it from local expired list
575                          */
576                         *pprev = next_tim;
577                 }
578         }
579
580         /* update the next to expire timer value */
581         priv_timer[lcore_id].pending_head.expire =
582             (priv_timer[lcore_id].pending_head.sl_next[0] == NULL) ? 0 :
583                 priv_timer[lcore_id].pending_head.sl_next[0]->expire;
584
585         rte_spinlock_unlock(&priv_timer[lcore_id].list_lock);
586
587         /* now scan expired list and call callbacks */
588         for (tim = run_first_tim; tim != NULL; tim = next_tim) {
589                 next_tim = tim->sl_next[0];
590                 priv_timer[lcore_id].updated = 0;
591                 priv_timer[lcore_id].running_tim = tim;
592
593                 /* execute callback function with list unlocked */
594                 tim->f(tim, tim->arg);
595
596                 __TIMER_STAT_ADD(pending, -1);
597                 /* the timer was stopped or reloaded by the callback
598                  * function, we have nothing to do here */
599                 if (priv_timer[lcore_id].updated == 1)
600                         continue;
601
602                 if (tim->period == 0) {
603                         /* remove from done list and mark timer as stopped */
604                         status.state = RTE_TIMER_STOP;
605                         status.owner = RTE_TIMER_NO_OWNER;
606                         rte_wmb();
607                         tim->status.u32 = status.u32;
608                 }
609                 else {
610                         /* keep it in list and mark timer as pending */
611                         rte_spinlock_lock(&priv_timer[lcore_id].list_lock);
612                         status.state = RTE_TIMER_PENDING;
613                         __TIMER_STAT_ADD(pending, 1);
614                         status.owner = (int16_t)lcore_id;
615                         rte_wmb();
616                         tim->status.u32 = status.u32;
617                         __rte_timer_reset(tim, tim->expire + tim->period,
618                                 tim->period, lcore_id, tim->f, tim->arg, 1);
619                         rte_spinlock_unlock(&priv_timer[lcore_id].list_lock);
620                 }
621         }
622         priv_timer[lcore_id].running_tim = NULL;
623 }
624
625 /* dump statistics about timers */
626 void rte_timer_dump_stats(FILE *f)
627 {
628 #ifdef RTE_LIBRTE_TIMER_DEBUG
629         struct rte_timer_debug_stats sum;
630         unsigned lcore_id;
631
632         memset(&sum, 0, sizeof(sum));
633         for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
634                 sum.reset += priv_timer[lcore_id].stats.reset;
635                 sum.stop += priv_timer[lcore_id].stats.stop;
636                 sum.manage += priv_timer[lcore_id].stats.manage;
637                 sum.pending += priv_timer[lcore_id].stats.pending;
638         }
639         fprintf(f, "Timer statistics:\n");
640         fprintf(f, "  reset = %"PRIu64"\n", sum.reset);
641         fprintf(f, "  stop = %"PRIu64"\n", sum.stop);
642         fprintf(f, "  manage = %"PRIu64"\n", sum.manage);
643         fprintf(f, "  pending = %"PRIu64"\n", sum.pending);
644 #else
645         fprintf(f, "No timer statistics, RTE_LIBRTE_TIMER_DEBUG is disabled\n");
646 #endif
647 }