[Devel] [PATCH RHEL COMMIT] ve/printk: per-CT printk helpers introduced
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Oct 1 18:24:50 MSK 2021
The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after ark-5.14
------>
commit 3c1d5ceee159759b4e83a162d7a45d18f62a7f1a
Author: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
Date: Mon Dec 4 17:00:11 2017 +0300
ve/printk: per-CT printk helpers introduced
https://jira.sw.ru/browse/PSBM-39077
https://jira.sw.ru/browse/PSBM-54183
https://jira.sw.ru/browse/PSBM-42313
Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
(cherry picked from vz8 commit 9a32046846c4fa272ec44e70fdbc3ebc09b10307)
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
include/linux/printk.h | 33 +++++++++++++++++++++++++++++++++
kernel/printk/printk.c | 2 +-
2 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/include/linux/printk.h b/include/linux/printk.h
index 6e14c410a2df..7c38dd438cc2 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -189,6 +189,8 @@ int ve_printk(int dst, const char *fmt, ...);
struct ve_struct;
int ve_log_init(struct ve_struct *ve);
void ve_log_destroy(struct ve_struct *ve);
+asmlinkage __printf(2, 3) __cold
+int ve_log_printk(struct ve_struct *ve, const char *s, ...);
/*
* Special printk facility for scheduler/timekeeping use only, _DO_NOT_USE_ !
@@ -255,6 +257,11 @@ static inline
void ve_log_destroy(struct ve_struct *ve)
{
}
+static inline __printf(2, 3) __cold
+int ve_log_printk(struct ve_struct *ve, const char *s, ...)
+{
+ return 0;
+}
static inline __printf(1, 2) __cold
int printk_deferred(const char *s, ...)
{
@@ -573,9 +580,21 @@ extern int kptr_restrict;
if (__ratelimit(&_rs)) \
printk(fmt, ##__VA_ARGS__); \
})
+
+#define ve_printk_ratelimited(dst, fmt, ...) \
+({ \
+ static DEFINE_RATELIMIT_STATE(_rs, \
+ DEFAULT_RATELIMIT_INTERVAL, \
+ DEFAULT_RATELIMIT_BURST); \
+ \
+ if (__ratelimit(&_rs)) \
+ ve_printk(dst, fmt, ##__VA_ARGS__); \
+})
#else
#define printk_ratelimited(fmt, ...) \
no_printk(fmt, ##__VA_ARGS__)
+#define ve_printk_ratelimited(dst, fmt, ...) \
+ no_printk(fmt, ##__VA_ARGS__)
#endif
#define pr_emerg_ratelimited(fmt, ...) \
@@ -593,6 +612,20 @@ extern int kptr_restrict;
#define pr_info_ratelimited(fmt, ...) \
printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
/* no pr_cont_ratelimited, don't do that... */
+#define ve_pr_emerg_ratelimited(dst, fmt, ...) \
+ ve_printk_ratelimited(dst, KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
+#define ve_pr_alert_ratelimited(dst, fmt, ...) \
+ ve_printk_ratelimited(dst, KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
+#define ve_pr_crit_ratelimited(dst, fmt, ...) \
+ ve_printk_ratelimited(dst, KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
+#define ve_pr_err_ratelimited(dst, fmt, ...) \
+ ve_printk_ratelimited(dst, KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
+#define ve_pr_warn_ratelimited(dst, fmt, ...) \
+ ve_printk_ratelimited(dst, KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
+#define ve_pr_notice_ratelimited(dst, fmt, ...) \
+ ve_printk_ratelimited(dst, KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
+#define ve_pr_info_ratelimited(dst, fmt, ...) \
+ ve_printk_ratelimited(dst, KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
#if defined(DEBUG)
#define pr_devel_ratelimited(fmt, ...) \
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index f3b5dbd9db6d..47ec962371ae 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -568,7 +568,7 @@ static int check_syslog_permissions(int type, int source)
goto ok;
if (syslog_action_restricted(type)) {
- if (capable(CAP_SYSLOG))
+ if (ve_capable(CAP_SYSLOG))
goto ok;
/*
* For historical reasons, accept CAP_SYS_ADMIN too, with
More information about the Devel
mailing list