Skip to content

printk ratelimiting #472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: rust
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions rust/helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <linux/platform_device.h>
#include <linux/security.h>
#include <asm/io.h>
#include <linux/printk.h>

__noreturn void rust_helper_BUG(void)
{
Expand Down Expand Up @@ -278,6 +279,13 @@ void *rust_helper_dev_get_drvdata(struct device *dev)
}
EXPORT_SYMBOL_GPL(rust_helper_dev_get_drvdata);

void rust_helper_ratelimit_state_init(struct ratelimit_state *rs)
{
static DEFINE_RATELIMIT_STATE(rs_tmpl, DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST);
*rs = rs_tmpl;
}
EXPORT_SYMBOL_GPL(rust_helper_ratelimit_state_init);

/* We use bindgen's --size_t-is-usize option to bind the C size_t type
* as the Rust usize type, so we can use it in contexts where Rust
* expects a usize like slice (array) indices. usize is defined to be
Expand Down
6 changes: 5 additions & 1 deletion rust/kernel/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ pub use macros::{module, module_misc_device};

pub use super::build_assert;

pub use super::{dbg, pr_alert, pr_crit, pr_debug, pr_emerg, pr_err, pr_info, pr_notice, pr_warn};
pub use super::{
dbg, pr_alert, pr_alert_ratelimited, pr_crit, pr_crit_ratelimited, pr_debug, pr_emerg,
pr_emerg_ratelimited, pr_err, pr_err_ratelimited, pr_info, pr_info_ratelimited, pr_notice,
pr_notice_ratelimited, pr_warn, pr_warn_ratelimited, printk_ratelimit,
};

pub use super::static_assert;

Expand Down
Loading