// SPDX-License-Identifier: GPL-2.0-or-later /* * Generic Timer-queue * * Manages a simple queue of timers, ordered by expiration time. * Uses rbtrees for quick list adds and expiration. * * NOTE: All of the following functions need to be serialized * to avoid races. No locking is done by this library code. */ #include #include #include #include #define __node_2_tq(_n) \ rb_entry((_n), struct timerqueue_node, node) static inline bool __timerqueue_less(struct rb_node *a, const struct rb_node *b) { return __node_2_tq(a)->expires < __node_2_tq(b)->expires; } /** * timerqueue_add - Adds timer to timerqueue. * * @head: head of timerqueue * @node: timer node to be added * * Adds the timer node to the timerqueue, sorted by the node's expires * value. Returns true if the newly added timer is the first expiring timer in * the queue. */ bool timerqueue_add(struct timerqueue_head *head, struct timerqueue_node *node) { /* Make sure we don't add nodes that are already added */ WARN_ON_ONCE(!RB_EMPTY_NODE(&node->node)); return rb_add_cached(&node->node, &head->rb_root, __timerqueue_less); } EXPORT_SYMBOL_GPL(timerqueue_add); /** * timerqueue_del - Removes a timer from the timerqueue. * * @head: head of timerqueue * @node: timer node to be removed * * Removes the timer node from the timerqueue. Returns true if the queue is * not empty after the remove. */ bool timerqueue_del(struct timerqueue_head *head, struct timerqueue_node *node) { WARN_ON_ONCE(RB_EMPTY_NODE(&node->node)); rb_erase_cached(&node->node, &head->rb_root); RB_CLEAR_NODE(&node->node); return !RB_EMPTY_ROOT(&head->rb_root.rb_root); } EXPORT_SYMBOL_GPL(timerqueue_del); /** * timerqueue_iterate_next - Returns the timer after the provided timer * * @node: Pointer to a timer. * * Provides the timer that is after the given node. This is used, when * necessary, to iterate through the list of timers in a timer list * without modifying the list. */ struct timerqueue_node *timerqueue_iterate_next(struct timerqueue_node *node) { struct rb_node *next; if (!node) return NULL; next = rb_next(&node->node); if (!next) return NULL; return container_of(next, struct timerqueue_node, node); } EXPORT_SYMBOL_GPL(timerqueue_iterate_next); 6.35.y Hosts the 0x221E linux distro kernel.Ubuntu
summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author
2011-09-29perf script: Add drop monitor scriptNeil Horman
2010-12-25perf script: Finish the rename from trace to scriptArnaldo Carvalho de Melo
2010-11-16perf: Rename 'perf trace' to 'perf script'Ingo Molnar
2010-11-10perf trace scripting: remove system-wide param from shell scriptsTom Zanussi
2010-10-26perf python scripting: Add futex-contention scriptArnaldo Carvalho de Melo
2010-10-26perf python scripting: Fixup cut'n'paste error in sctop scriptArnaldo Carvalho de Melo
2010-10-25perf python scripting: Support fedora 11 (audit 1.7.17)Arnaldo Carvalho de Melo
2010-10-25perf python scripting: Improve the syscalls-by-pid scriptArnaldo Carvalho de Melo
2010-10-25perf python scripting: print the syscall name on sctopArnaldo Carvalho de Melo
2010-10-25perf python scripting: Improve the syscalls-counts scriptArnaldo Carvalho de Melo
2010-10-25perf python scripting: Improve the failed-syscalls-by-pid scriptArnaldo Carvalho de Melo
2010-10-23perf trace: Use $PERF_EXEC_PATH in canned report scriptsBen Hutchings
2010-09-07perf: Add a script to show packets processingKoki Sanagi
2010-08-02perf, sched migration: Librarize task states and event headers helpersFrederic Weisbecker
2010-08-02perf, sched migration: Librarize the GUI classFrederic Weisbecker
2010-08-02perf, sched migration: Make the GUI class client agnosticFrederic Weisbecker
2010-08-02perf, sched migration: Make it vertically scrollableFrederic Weisbecker
2010-08-02perf, sched migration: Parameterize cpu height and spacingNikhil Rao
2010-08-02perf, sched migration: Fix key bindingsNikhil Rao
2010-08-02perf, sched migration: Ignore unhandled task statesFrederic Weisbecker
2010-08-02perf, sched migration: Handle ignored migrate out eventsFrederic Weisbecker
2010-08-02perf: New migration tool overviewFrederic Weisbecker
2010-06-01perf scripts python: Give field dict to unhandled callbackPierre Tardy
2010-05-10perf/trace/scripting: syscall-counts script cleanupTom Zanussi
2010-05-10perf/trace/scripting: syscall-counts-by-pid script cleanupTom Zanussi
2010-05-10perf/trace/scripting: failed-syscalls-by-pid script cleanupTom Zanussi
2010-04-30perf: Remove leftover useless options to record trace events from scriptsFrederic Weisbecker
2010-04-14perf trace/scripting: Enable scripting shell scripts for live modeTom Zanussi
2010-04-14perf trace/scripting: Add rwtop and sctop scriptsTom Zanussi
2010-02-25perf/scripts: Add syscall tracing scriptsTom Zanussi
2010-02-25perf/scripts: Add Python scripting engineTom Zanussi