summaryrefslogtreecommitdiff
path: root/c_src/linux/ratelimit.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-01-16 17:00:02 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2024-01-16 17:17:23 -0500
commitb5fd066153c40a70a29caa1ea7987723ab687763 (patch)
tree6d43a8b0a90d549a54c65565ac96c92b3e84b594 /c_src/linux/ratelimit.c
parent06ff8b55b70fda44d91b31b5511fafd1680a8934 (diff)
Move c_src dirs back to toplevel
We just wanted c sourcefiles out of the top level, not c source directories. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'c_src/linux/ratelimit.c')
-rw-r--r--c_src/linux/ratelimit.c69
1 files changed, 0 insertions, 69 deletions
diff --git a/c_src/linux/ratelimit.c b/c_src/linux/ratelimit.c
deleted file mode 100644
index 21a6d6c8..00000000
--- a/c_src/linux/ratelimit.c
+++ /dev/null
@@ -1,69 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * ratelimit.c - Do something with rate limit.
- *
- * Isolated from kernel/printk.c by Dave Young <hidave.darkstar@gmail.com>
- *
- * 2008-05-01 rewrite the function and use a ratelimit_state data struct as
- * parameter. Now every user can use their own standalone ratelimit_state.
- */
-
-#include <linux/ratelimit.h>
-#include <linux/jiffies.h>
-#include <linux/export.h>
-
-/*
- * __ratelimit - rate limiting
- * @rs: ratelimit_state data
- * @func: name of calling function
- *
- * This enforces a rate limit: not more than @rs->burst callbacks
- * in every @rs->interval
- *
- * RETURNS:
- * 0 means callbacks will be suppressed.
- * 1 means go ahead and do it.
- */
-int ___ratelimit(struct ratelimit_state *rs, const char *func)
-{
- int ret;
-
- if (!rs->interval)
- return 1;
-
- /*
- * If we contend on this state's lock then almost
- * by definition we are too busy to print a message,
- * in addition to the one that will be printed by
- * the entity that is holding the lock already:
- */
- if (!raw_spin_trylock(&rs->lock))
- return 0;
-
- if (!rs->begin)
- rs->begin = jiffies;
-
- if (time_is_before_jiffies(rs->begin + rs->interval)) {
- if (rs->missed) {
- if (!(rs->flags & RATELIMIT_MSG_ON_RELEASE)) {
- printk(KERN_WARNING
- "%s: %d callbacks suppressed\n",
- func, rs->missed);
- rs->missed = 0;
- }
- }
- rs->begin = jiffies;
- rs->printed = 0;
- }
- if (rs->burst && rs->burst > rs->printed) {
- rs->printed++;
- ret = 1;
- } else {
- rs->missed++;
- ret = 0;
- }
- raw_spin_unlock(&rs->lock);
-
- return ret;
-}
-EXPORT_SYMBOL(___ratelimit);