From a303686fc1c919c6601fb7c10fdf9fdd7de19bfd Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 23 Nov 2020 22:30:09 +0100 Subject: [PATCH] man: document new ratelimiting APIs --- man/rules/meson.build | 4 + man/sd-event.xml | 2 + man/sd_event_source_set_enabled.xml | 3 +- man/sd_event_source_set_ratelimit.xml | 148 ++++++++++++++++++++++++++ 4 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 man/sd_event_source_set_ratelimit.xml diff --git a/man/rules/meson.build b/man/rules/meson.build index cacbbd75bc..97136fe758 100644 --- a/man/rules/meson.build +++ b/man/rules/meson.build @@ -582,6 +582,10 @@ manpages = [ 'SD_EVENT_PRIORITY_NORMAL', 'sd_event_source_get_priority'], ''], + ['sd_event_source_set_ratelimit', + '3', + ['sd_event_source_get_ratelimit', 'sd_event_source_is_ratelimited'], + ''], ['sd_event_source_set_userdata', '3', ['sd_event_source_get_userdata'], ''], ['sd_event_source_unref', '3', diff --git a/man/sd-event.xml b/man/sd-event.xml index a28c9b87ec..1bcf4e32a5 100644 --- a/man/sd-event.xml +++ b/man/sd-event.xml @@ -56,6 +56,7 @@ sd_event_source_get_pending3, sd_event_source_set_description3, sd_event_source_set_prepare3, + sd_event_source_set_ratelimit3, sd_event_wait3, sd_event_get_fd3, sd_event_set_watchdog3, @@ -147,6 +148,7 @@ sd_event_source_get_pending3, sd_event_source_set_description3, sd_event_source_set_prepare3, + sd_event_source_set_ratelimit3, sd_event_wait3, sd_event_get_fd3, sd_event_set_watchdog3, diff --git a/man/sd_event_source_set_enabled.xml b/man/sd_event_source_set_enabled.xml index cf00695fda..c8ae169c17 100644 --- a/man/sd_event_source_set_enabled.xml +++ b/man/sd_event_source_set_enabled.xml @@ -147,7 +147,8 @@ sd_event_add_child3, sd_event_add_inotify3, sd_event_add_defer3, - sd_event_source_unref3 + sd_event_source_unref3, + sd_event_source_set_ratelimit3 diff --git a/man/sd_event_source_set_ratelimit.xml b/man/sd_event_source_set_ratelimit.xml new file mode 100644 index 0000000000..754bfbe3b2 --- /dev/null +++ b/man/sd_event_source_set_ratelimit.xml @@ -0,0 +1,148 @@ + + + + + + + + sd_event_source_set_ratelimit + systemd + + + + sd_event_source_set_ratelimit + 3 + + + + sd_event_source_set_ratelimit + sd_event_source_get_ratelimit + sd_event_source_is_ratelimited + + Configure rate limiting on event sources + + + + + #include <systemd/sd-event.h> + + + int sd_event_source_set_ratelimit + sd_event_source *source + uint64_t interval_usec + unsigned burst + + + + int sd_event_source_get_ratelimit + sd_event_source *source + uint64_t* ret_interval_usec + unsigned* ret_burst + + + + int sd_event_source_is_ratelimited + sd_event_source *source + + + + + + + Description + + sd_event_source_set_ratelimit() may be used to enforce rate limiting on an + event source. When used an event source will be temporarily turned off when it fires more often then a + specified burst number within a specified time interval. This is useful as simple mechanism to avoid + event source starvation if high priority event sources fire very frequently. + + Pass the event source to operate on as first argument, a time interval in microseconds as second + argument and a maximum dispatch limit ("burst") as third parameter. Whenever the event source is + dispatched more often than the specified burst within the specified interval it is placed in a mode + similar to being disabled with + sd_event_source_set_enabled3 + and the SD_EVENT_OFF parameter. However it is disabled only temporarily – once the + specified interval is over regular operation resumes. It is again disabled temporarily once the specified rate + limiting is hit the next time. If either the interval or the burst value are specified as zero, rate + limiting is turned off. By default event sources do not have rate limiting enabled. Note that rate + limiting and disabling via sd_event_source_set_enabled() are independent of each + other, and an event source will only effect event loop wake-ups and is dispatched while it both is + enabled and rate limiting is not in effect. + + sd_event_source_get_ratelimit() may be used to query the current rate limiting + parameters set on the event source object source. The previously set interval and + burst vales are returned in the second and third argument. + + sd_event_source_is_ratelimited() may be used to query whether the event source + is currently affected by rate limiting, i.e. it has recently hit the rate limit and is currently + temporarily disabled due to that. + + Rate limiting is currently implemented for I/O, timer, signal, defer and inotify event + sources. + + + + Return Value + + On success, sd_event_source_set_ratelimit() and + sd_event_source_get_ratelimit() return a non-negative integer. On failure, they + return a negative errno-style error code. sd_event_source_is_ratelimited returns + zero if rate limiting is currently not in effect and greater than zero if it is in effect; it returns a + negative errno-style error code on failure. + + + Errors + + Returned errors may indicate the following problems: + + + + -EINVAL + + source is not a valid pointer to an + sd_event_source object. + + + + + -ECHILD + + The event loop has been created in a different process. + + + + -EDOM + + It was attempted to use the rate limiting feature on an event source type that does + not support rate limiting. + + + + -ENOEXEC + + sd_event_source_get_ratelimit() was called on a event source + that doesn't have rate limiting configured. + + + + + + + + + + See Also + + + sd-event3, + sd_event_add_io3, + sd_event_add_time3, + sd_event_add_signal3, + sd_event_add_inotify3, + sd_event_add_defer3, + sd_event_source_set_enabled3 + + + +