* [PATCH v2 0/4] printk: some minor fixups
@ 2014-07-10 13:01 Alex Elder
2014-07-10 13:01 ` [PATCH v2 1/4] printk: rename DEFAULT_MESSAGE_LOGLEVEL Alex Elder
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Alex Elder @ 2014-07-10 13:01 UTC (permalink / raw)
To: akpm; +Cc: ak, bp, jack, john.stultz, pmladek, rostedt, linux-kernel
This series makes some minor changes to kernel/printk/printk.c.
I've been poking around that file and will have a few more
substantive changes to propose soon, but I've been carrying
around these little things for a bit and thought I should
just get them out there.
-Alex
History:
v2: - Renamed CONFIG_MESSAGE_LOGLEVEL_DEFAULT, as suggested
- Added Reviewed-by (etc.) annotations
This series, based on v3.16-rc4, is available here:
http://git.linaro.org/landing-teams/working/broadcom/kernel.git
Branch review/minor-printk-fixes-v2
Alex Elder (4):
printk: rename DEFAULT_MESSAGE_LOGLEVEL
printk: fix some comments
printk: use a clever macro
printk: miscellaneous cleanups
include/linux/printk.h | 2 +-
kernel/printk/printk.c | 63 ++++++++++++++++++++++----------------------------
lib/Kconfig.debug | 2 +-
3 files changed, 30 insertions(+), 37 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/4] printk: rename DEFAULT_MESSAGE_LOGLEVEL
2014-07-10 13:01 [PATCH v2 0/4] printk: some minor fixups Alex Elder
@ 2014-07-10 13:01 ` Alex Elder
2014-07-10 13:01 ` [PATCH v2 2/4] printk: fix some comments Alex Elder
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Alex Elder @ 2014-07-10 13:01 UTC (permalink / raw)
To: akpm; +Cc: ak, bp, jack, john.stultz, pmladek, rostedt, linux-kernel
This commit:
a8fe19eb kernel/printk: use symbolic defines for console loglevels
makes consistent use of symbolic values for printk() log levels.
The naming scheme used is different from the one used for
DEFAULT_MESSAGE_LOGLEVEL though. Change that symbol name to be
MESSAGE_LOGLEVEL_DEFAULT for consistency. And because the value
of that symbol comes from a similarly-named config option, rename
CONFIG_DEFAULT_MESSAGE_LOGLEVEL as well.
Signed-off-by: Alex Elder <elder@linaro.org>
---
include/linux/printk.h | 2 +-
kernel/printk/printk.c | 2 +-
lib/Kconfig.debug | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/linux/printk.h b/include/linux/printk.h
index 319ff7e..0990997 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -31,7 +31,7 @@ static inline const char *printk_skip_level(const char *buffer)
}
/* printk's without a loglevel use this.. */
-#define DEFAULT_MESSAGE_LOGLEVEL CONFIG_DEFAULT_MESSAGE_LOGLEVEL
+#define MESSAGE_LOGLEVEL_DEFAULT CONFIG_MESSAGE_LOGLEVEL_DEFAULT
/* We show everything that is MORE important than this.. */
#define CONSOLE_LOGLEVEL_SILENT 0 /* Mum's the word */
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 13e839d..ac2b64e 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -56,7 +56,7 @@
int console_printk[4] = {
CONSOLE_LOGLEVEL_DEFAULT, /* console_loglevel */
- DEFAULT_MESSAGE_LOGLEVEL, /* default_message_loglevel */
+ MESSAGE_LOGLEVEL_DEFAULT, /* default_message_loglevel */
CONSOLE_LOGLEVEL_MIN, /* minimum_console_loglevel */
CONSOLE_LOGLEVEL_DEFAULT, /* default_console_loglevel */
};
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 7a638aa..fd939e1 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -15,7 +15,7 @@ config PRINTK_TIME
The behavior is also controlled by the kernel command line
parameter printk.time=1. See Documentation/kernel-parameters.txt
-config DEFAULT_MESSAGE_LOGLEVEL
+config MESSAGE_LOGLEVEL_DEFAULT
int "Default message log level (1-7)"
range 1 7
default "4"
--
1.9.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 2/4] printk: fix some comments
2014-07-10 13:01 [PATCH v2 0/4] printk: some minor fixups Alex Elder
2014-07-10 13:01 ` [PATCH v2 1/4] printk: rename DEFAULT_MESSAGE_LOGLEVEL Alex Elder
@ 2014-07-10 13:01 ` Alex Elder
2014-07-10 13:01 ` [PATCH v2 3/4] printk: use a clever macro Alex Elder
2014-07-10 13:01 ` [PATCH v2 4/4] printk: miscellaneous cleanups Alex Elder
3 siblings, 0 replies; 5+ messages in thread
From: Alex Elder @ 2014-07-10 13:01 UTC (permalink / raw)
To: akpm; +Cc: ak, bp, jack, john.stultz, pmladek, rostedt, linux-kernel
This patch fixes a few comments that don't accurately describe their
corresponding code. It also fixes some minor typographical errors.
Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Petr Mladek <pmladek@suse.cz>
---
kernel/printk/printk.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index ac2b64e..646146c 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -113,9 +113,9 @@ static int __down_trylock_console_sem(unsigned long ip)
* This is used for debugging the mess that is the VT code by
* keeping track if we have the console semaphore held. It's
* definitely not the perfect debug tool (we don't know if _WE_
- * hold it are racing, but it helps tracking those weird code
- * path in the console code where we end up in places I want
- * locked without the console sempahore held
+ * hold it and are racing, but it helps tracking those weird code
+ * paths in the console code where we end up in places I want
+ * locked without the console sempahore held).
*/
static int console_locked, console_suspended;
@@ -146,8 +146,8 @@ static int console_may_schedule;
* the overall length of the record.
*
* The heads to the first and last entry in the buffer, as well as the
- * sequence numbers of these both entries are maintained when messages
- * are stored..
+ * sequence numbers of these entries are maintained when messages are
+ * stored.
*
* If the heads indicate available messages, the length in the header
* tells the start next message. A length == 0 for the next message
@@ -344,7 +344,7 @@ static int log_make_free_space(u32 msg_size)
while (log_first_seq < log_next_seq) {
if (logbuf_has_space(msg_size, false))
return 0;
- /* drop old messages until we have enough continuous space */
+ /* drop old messages until we have enough contiguous space */
log_first_idx = log_next(log_first_idx);
log_first_seq++;
}
@@ -1476,7 +1476,7 @@ static struct cont {
struct task_struct *owner; /* task of first print*/
u64 ts_nsec; /* time of first print */
u8 level; /* log level of first message */
- u8 facility; /* log level of first message */
+ u8 facility; /* log facility of first message */
enum log_flags flags; /* prefix, newline flags */
bool flushed:1; /* buffer sealed and committed */
} cont;
@@ -1881,11 +1881,12 @@ static int __add_preferred_console(char *name, int idx, char *options,
return 0;
}
/*
- * Set up a list of consoles. Called from init/main.c
+ * Set up a console. Called via do_early_param() in init/main.c
+ * for each "console=" parameter in the boot command line.
*/
static int __init console_setup(char *str)
{
- char buf[sizeof(console_cmdline[0].name) + 4]; /* 4 for index */
+ char buf[sizeof(console_cmdline[0].name) + 4]; /* 4 for "ttyS" */
char *s, *options, *brl_options = NULL;
int idx;
@@ -2045,8 +2046,8 @@ EXPORT_SYMBOL(console_lock);
/**
* console_trylock - try to lock the console system for exclusive use.
*
- * Tried to acquire a lock which guarantees that the caller has
- * exclusive access to the console system and the console_drivers list.
+ * Try to acquire a lock which guarantees that the caller has exclusive
+ * access to the console system and the console_drivers list.
*
* returns 1 on success, and 0 on failure to acquire the lock.
*/
--
1.9.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 3/4] printk: use a clever macro
2014-07-10 13:01 [PATCH v2 0/4] printk: some minor fixups Alex Elder
2014-07-10 13:01 ` [PATCH v2 1/4] printk: rename DEFAULT_MESSAGE_LOGLEVEL Alex Elder
2014-07-10 13:01 ` [PATCH v2 2/4] printk: fix some comments Alex Elder
@ 2014-07-10 13:01 ` Alex Elder
2014-07-10 13:01 ` [PATCH v2 4/4] printk: miscellaneous cleanups Alex Elder
3 siblings, 0 replies; 5+ messages in thread
From: Alex Elder @ 2014-07-10 13:01 UTC (permalink / raw)
To: akpm; +Cc: ak, bp, jack, john.stultz, pmladek, rostedt, linux-kernel
Use the IS_ENABLED() macro rather than #ifdef blocks to set certain
global values.
Signed-off-by: Alex Elder <elder@linaro.org>
Acked-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Petr Mladek <pmladek@suse.cz>
---
kernel/printk/printk.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 646146c..6f75e8a 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -453,11 +453,7 @@ static int log_store(int facility, int level,
return msg->text_len;
}
-#ifdef CONFIG_SECURITY_DMESG_RESTRICT
-int dmesg_restrict = 1;
-#else
-int dmesg_restrict;
-#endif
+int dmesg_restrict = IS_ENABLED(CONFIG_SECURITY_DMESG_RESTRICT);
static int syslog_action_restricted(int type)
{
@@ -947,11 +943,7 @@ static inline void boot_delay_msec(int level)
}
#endif
-#if defined(CONFIG_PRINTK_TIME)
-static bool printk_time = 1;
-#else
-static bool printk_time;
-#endif
+static bool printk_time = IS_ENABLED(CONFIG_PRINTK_TIME);
module_param_named(time, printk_time, bool, S_IRUGO | S_IWUSR);
static size_t print_time(u64 ts, char *buf)
--
1.9.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 4/4] printk: miscellaneous cleanups
2014-07-10 13:01 [PATCH v2 0/4] printk: some minor fixups Alex Elder
` (2 preceding siblings ...)
2014-07-10 13:01 ` [PATCH v2 3/4] printk: use a clever macro Alex Elder
@ 2014-07-10 13:01 ` Alex Elder
3 siblings, 0 replies; 5+ messages in thread
From: Alex Elder @ 2014-07-10 13:01 UTC (permalink / raw)
To: akpm; +Cc: ak, bp, jack, john.stultz, pmladek, rostedt, linux-kernel
This patch contains some small cleanups to kernel/printk/printk.c.
None of them should cause any change in behavior.
- When CONFIG_PRINTK is defined, parenthesize the value of LOG_LINE_MAX.
- When CONFIG_PRINTK is *not* defined, there is an extra LOG_LINE_MAX
definition; delete it.
- Pull an assignment out of a conditional expression in console_setup().
- Use isdigit() in console_setup() rather than open coding it.
- In update_console_cmdline(), drop a NUL-termination assignment;
the strlcpy() call that precedes it guarantees it's not needed.
- Simplify some logic in printk_timed_ratelimit().
Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Petr Mladek <pmladek@suse.cz>
---
kernel/printk/printk.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 6f75e8a..909029e 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -45,6 +45,7 @@
#include <linux/poll.h>
#include <linux/irq_work.h>
#include <linux/utsname.h>
+#include <linux/ctype.h>
#include <asm/uaccess.h>
@@ -257,7 +258,7 @@ static u64 clear_seq;
static u32 clear_idx;
#define PREFIX_MAX 32
-#define LOG_LINE_MAX 1024 - PREFIX_MAX
+#define LOG_LINE_MAX (1024 - PREFIX_MAX)
/* record buffer */
#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
@@ -1794,7 +1795,7 @@ EXPORT_SYMBOL(printk);
#define LOG_LINE_MAX 0
#define PREFIX_MAX 0
-#define LOG_LINE_MAX 0
+
static u64 syslog_seq;
static u32 syslog_idx;
static u64 console_seq;
@@ -1895,7 +1896,8 @@ static int __init console_setup(char *str)
strncpy(buf, str, sizeof(buf) - 1);
}
buf[sizeof(buf) - 1] = 0;
- if ((options = strchr(str, ',')) != NULL)
+ options = strchr(str, ',');
+ if (options)
*(options++) = 0;
#ifdef __sparc__
if (!strcmp(str, "ttya"))
@@ -1904,7 +1906,7 @@ static int __init console_setup(char *str)
strcpy(buf, "ttyS1");
#endif
for (s = buf; *s; s++)
- if ((*s >= '0' && *s <= '9') || *s == ',')
+ if (isdigit(*s) || *s == ',')
break;
idx = simple_strtoul(s, NULL, 10);
*s = 0;
@@ -1943,7 +1945,6 @@ int update_console_cmdline(char *name, int idx, char *name_new, int idx_new, cha
i++, c++)
if (strcmp(c->name, name) == 0 && c->index == idx) {
strlcpy(c->name, name_new, sizeof(c->name));
- c->name[sizeof(c->name) - 1] = 0;
c->options = options;
c->index = idx_new;
return i;
@@ -2611,14 +2612,13 @@ EXPORT_SYMBOL(__printk_ratelimit);
bool printk_timed_ratelimit(unsigned long *caller_jiffies,
unsigned int interval_msecs)
{
- if (*caller_jiffies == 0
- || !time_in_range(jiffies, *caller_jiffies,
- *caller_jiffies
- + msecs_to_jiffies(interval_msecs))) {
- *caller_jiffies = jiffies;
- return true;
- }
- return false;
+ unsigned long elapsed = jiffies - *caller_jiffies;
+
+ if (*caller_jiffies && elapsed <= msecs_to_jiffies(interval_msecs))
+ return false;
+
+ *caller_jiffies = jiffies;
+ return true;
}
EXPORT_SYMBOL(printk_timed_ratelimit);
--
1.9.1
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-07-10 13:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-10 13:01 [PATCH v2 0/4] printk: some minor fixups Alex Elder
2014-07-10 13:01 ` [PATCH v2 1/4] printk: rename DEFAULT_MESSAGE_LOGLEVEL Alex Elder
2014-07-10 13:01 ` [PATCH v2 2/4] printk: fix some comments Alex Elder
2014-07-10 13:01 ` [PATCH v2 3/4] printk: use a clever macro Alex Elder
2014-07-10 13:01 ` [PATCH v2 4/4] printk: miscellaneous cleanups Alex Elder
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome