Skip to contentSkip to conversation

timer: add limitation note for sync stop and reset

PATCH Applied Erik Gabriel Carrillo 3 participants 6 messages Sep 9, 2020 – Oct 8, 2020

lore
Share & tools
lore
#0 lore raw

cover timer: add limitation note for sync stop and reset

Bugzilla ID 491 identifies a couple of scenarios in which calls to the rte_timer_reset_sync() and rte_timer_stop_sync() APIs could hang. Changing the function prototypes such that error codes are returned in these scenarios was considered, but rather than introducing another ABI change, it was proposed to document a usage limitation[1]. This patch adds the notes.

[1] https://patches.dpdk.org/patch/75142/

Erik Gabriel Carrillo (1):
timer: add limitation note for sync stop and reset

 lib/librte_timer/rte_timer.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
Signature · 1 line
2.6.4
#1 lore raw

PATCH 1/1 timer: add limitation note for sync stop and reset

If a timer's callback function calls rte_timer_reset_sync() or rte_timer_stop_sync() on another timer that is in the RUNNING state and owned by the current lcore, the *_sync() calls will loop indefinitely.

Relatedly, if a timer's callback function calls *_sync() on another timer that is in the RUNNING state and is owned by a different lcore, but a timer callback function runs on that different lcore and calls *_sync() on a timer that is in the RUNNING state and owned by the current lcore, the two lcores will loop indefinitely.

Add a note in the rte_timer_stop_sync and rte_timer_reset_sync documentation that indicates that these APIs should not be used inside timer callback functions in order to avoid the hangs described above, and suggests an alternative.

Bugzilla ID: 491
Cc: [email protected]

---
 lib/librte_timer/rte_timer.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
lib/librte_timer/rte_timer.h +12 -0
index c6b3d45..d7c3e03 100644
@@ -274,6 +274,12 @@ int rte_timer_reset(struct rte_timer *tim, uint64_t ticks,
  *   The callback function of the timer.
  * @param arg
  *   The user argument of the callback function.
+ *
+ * @note
+ *   This API should not be called inside a timer's callback function to
+ *   reset another timer; doing so could hang in certain scenarios. Instead,
+ *   the rte_timer_reset() API can be called directly and its return code
+ *   can be checked for success or failure.
  */
 void
 rte_timer_reset_sync(struct rte_timer *tim, uint64_t ticks,
@@ -313,6 +319,12 @@ int rte_timer_stop(struct rte_timer *tim);
  *
  * @param tim
  *   The timer handle.
+ *
+ * @note
+ *   This API should not be called inside a timer's callback function to
+ *   stop another timer; doing so could hang in certain scenarios. Instead, the
+ *   rte_timer_stop() API can be called directly and its return code can
+ *   be checked for success or failure.
  */
 void rte_timer_stop_sync(struct rte_timer *tim);
 
Signature · 1 line
2.6.4
Reviewed-by on v1 1/1
#2 lore raw

<snip>

Quoted 16 lines

If a timer's callback function calls rte_timer_reset_sync() or rte_timer_stop_sync() on another timer that is in the RUNNING state and owned by the current lcore, the *_sync() calls will loop indefinitely.

Relatedly, if a timer's callback function calls *_sync() on another timer that is in the RUNNING state and is owned by a different lcore, but a timer callback function runs on that different lcore and calls
*_sync() on a timer that is in the RUNNING state and owned by the current lcore, the two lcores will loop indefinitely.

Add a note in the rte_timer_stop_sync and rte_timer_reset_sync documentation that indicates that these APIs should not be used inside timer callback functions in order to avoid the hangs described above, and suggests an alternative.

Quoted 4 lines

Bugzilla ID: 491
Cc: [email protected]

Looks good.

Quoted 38 lines
---
 lib/librte_timer/rte_timer.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
lib/librte_timer/rte_timer.h index renamed from lib/librte_timer/rte_timer.h +0 -0

c6b3d45..d7c3e03 100644

lib/librte_timer/rte_timer.h +6 -0
@@ -274,6 +274,12 @@ int rte_timer_reset(struct rte_timer *tim, uint64_t
 ticks,
  *   The callback function of the timer.
  * @param arg
  *   The user argument of the callback function.
+ *
+ * @note
+ *   This API should not be called inside a timer's callback function to
+ *   reset another timer; doing so could hang in certain scenarios. Instead,
+ *   the rte_timer_reset() API can be called directly and its return code
+ *   can be checked for success or failure.
  */
 void

rte_timer_reset_sync(struct rte_timer *tim, uint64_t ticks, @@ -313,6
+319,12 @@ int rte_timer_stop(struct rte_timer *tim);
*
* @param tim
* The timer handle.
+ *
+ * @note
+ * This API should not be called inside a timer's callback function to
+ * stop another timer; doing so could hang in certain scenarios. Instead,
the
+ * rte_timer_stop() API can be called directly and its return code can
+ * be checked for success or failure.
*/
void rte_timer_stop_sync(struct rte_timer *tim);

--
2.6.4

#3 lore raw
Quoted 15 lines · Honnappa Nagarahalli
Quoted 15 lines

If a timer's callback function calls rte_timer_reset_sync() or rte_timer_stop_sync() on another timer that is in the RUNNING state and owned by the current lcore, the *_sync() calls will loop indefinitely.

Relatedly, if a timer's callback function calls *_sync() on another timer that is in the RUNNING state and is owned by a different lcore, but a timer callback function runs on that different lcore and calls
*_sync() on a timer that is in the RUNNING state and owned by the current lcore, the two lcores will loop indefinitely.

Add a note in the rte_timer_stop_sync and rte_timer_reset_sync documentation that indicates that these APIs should not be used inside timer callback functions in order to avoid the hangs described above, and suggests an alternative.

Quoted 5 lines
Quoted 4 lines

Bugzilla ID: 491
Cc: [email protected]

Applied, thanks.

Since we go with documenting a limitation, should we mark the original patches [1] and [2] as rejected instead of deferred?

1: https://patches.dpdk.org/patch/75156/
2: https://patches.dpdk.org/patch/73683/

Signature · 1 line
David Marchand
#4 lore raw
Quoted 34 lines

-----Original Message-----
From: David Marchand <[email protected]>
Sent: Thursday, October 8, 2020 5:28 AM
To: Carrillo, Erik G <[email protected]>
Cc: [email protected]; [email protected]; nd <[email protected]>; Honnappa Nagarahalli <[email protected]>; Sarosh Arif <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 1/1] timer: add limitation note for sync stop and reset

Quoted 16 lines · Honnappa Nagarahalli
Quoted 16 lines

If a timer's callback function calls rte_timer_reset_sync() or rte_timer_stop_sync() on another timer that is in the RUNNING state and owned by the current lcore, the *_sync() calls will loop indefinitely.

Relatedly, if a timer's callback function calls *_sync() on another timer that is in the RUNNING state and is owned by a different lcore, but a timer callback function runs on that different lcore and calls
*_sync() on a timer that is in the RUNNING state and owned by the current lcore, the two lcores will loop indefinitely.

Add a note in the rte_timer_stop_sync and rte_timer_reset_sync documentation that indicates that these APIs should not be used inside timer callback functions in order to avoid the hangs described above, and suggests an alternative.

Quoted 5 lines
Quoted 4 lines

Bugzilla ID: 491
Cc: [email protected]

Quoted 9 lines

Applied, thanks.

Since we go with documenting a limitation, should we mark the original patches [1] and [2] as rejected instead of deferred?

1: https://patches.dpdk.org/patch/75156/
2: https://patches.dpdk.org/patch/73683/

Thanks, David.

Yes, those patches should be moved to "rejected" - I tried to do it myself, but got permission errors. Sarosh, can you make these updates?

Thanks,
Erik

Quoted 2 lines

--
David Marchand

#5 lore raw
Quoted 10 lines · Erik G
Quoted 7 lines

Since we go with documenting a limitation, should we mark the original patches [1] and [2] as rejected instead of deferred?

1: https://patches.dpdk.org/patch/75156/
2: https://patches.dpdk.org/patch/73683/

Thanks, David.

Yes, those patches should be moved to "rejected" - I tried to do it myself, but got permission errors. Sarosh, can you make these updates?

I updated them.
Thanks Erik.

Signature · 1 line
David Marchand