2018-05-10 15:47:06

by Joe Perches

[permalink] [raw]
Subject: [PATCH 00/18] Convert default pr_fmt from empty to KBUILD_MODNAME

pr_<level> logging uses allow a prefix to be specified with a
specific #define pr_fmt

The default of pr_fmt in printk.h is #define pr_fmt(fmt) fmt
so no prefixing of logging output is generically done.

There are several output logging uses like dump_stack() that are
unprefixed and should remain unprefixed.

This patch series attempts to convert the default #define of pr_fmt to
KBUILD_MODNAME ": " fmt and as well update the various bits of the kernel
that should _not_ be prefixed by adding #define pr_fmt(fmt) fmt to those
compilation units that do not want output message prefixing.

There are about 1200 uses of #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
that could be removed if the default is changed.

A script that does this removal (and removes any blank lines that follow)
for the linux-kernel tree is included below:

$ git grep -P --name-only "define\s+pr_fmt\b" | \
grep -v include/linux/printk.h | \
xargs perl -i -e 'local $/; while (<>) {s/(\n)*[ \t]*#[ \t]*define[ \t]+pr_fmt[ \t]*\([ \t]*(\w+)[ \t]*\)[ \t]*KBUILD_MODNAME[ \t]*\": \"[ \t]*\2[ \t]*\n\s*/\1\n/; s/^\n//; print;}'

This script should be run after this patch series is applied.

The above script output diff is currently:

1198 files changed, 70 insertions(+), 2241 deletions(-)

Joe Perches (18):
kernel: Use pr_fmt
lib: Use pr_fmt
printk: Convert pr_fmt from blank define to KBUILD_MODNAME
x86: Remove pr_fmt duplicate logging prefixes
x86/mtrr: Rename main.c to mtrr.c and remove duplicate prefixes
net: Remove pr_fmt duplicate logging prefixes
blk-mq: Remove pr_fmt duplicate logging prefixes
random: Remove pr_fmt duplicate logging prefixes
ptp: Remove pr_fmt duplicate logging prefixes
efifb: Remove pr_fmt duplicate logging prefixes
proc: Remove pr_fmt duplicate logging prefixes
uprobes: Remove pr_fmt duplicate logging prefixes
printk: Remove pr_fmt duplicate logging prefixes
lib/mpi: Remove pr_fmt duplicate logging prefixes
security: Remove pr_fmt duplicate logging prefixes
aoe: Remove pr_fmt duplicate logging prefixes
security: encrypted-keys: Remove pr_fmt duplicate logging prefixes
rcu: Use pr_fmt to prefix "rcu: " to logging output

arch/x86/events/amd/ibs.c | 2 +-
arch/x86/kernel/cpu/mtrr/Makefile | 2 +-
arch/x86/kernel/cpu/mtrr/{main.c => mtrr.c} | 33 ++++++-------
arch/x86/kernel/e820.c | 32 ++++++------
arch/x86/kernel/hpet.c | 5 +-
arch/x86/kernel/uprobes.c | 4 +-
arch/x86/mm/numa.c | 22 ++++-----
block/blk-mq.c | 9 ++--
drivers/block/aoe/aoeblk.c | 29 ++++++-----
drivers/block/aoe/aoechr.c | 11 ++---
drivers/block/aoe/aoecmd.c | 34 ++++++-------
drivers/block/aoe/aoedev.c | 19 +++-----
drivers/block/aoe/aoemain.c | 6 +--
drivers/block/aoe/aoenet.c | 19 +++-----
drivers/char/hw_random/via-rng.c | 10 ++--
drivers/char/random.c | 16 +++---
drivers/ptp/ptp_clock.c | 4 +-
drivers/video/fbdev/efifb.c | 48 +++++++++---------
fs/proc/root.c | 6 +--
include/linux/printk.h | 2 +-
kernel/acct.c | 2 +
kernel/async.c | 14 +++---
kernel/audit_tree.c | 2 +-
kernel/backtracetest.c | 8 +--
kernel/crash_core.c | 29 ++++++-----
kernel/events/uprobes.c | 3 +-
kernel/exit.c | 2 +
kernel/hung_task.c | 13 +++--
kernel/kprobes.c | 20 +++++---
kernel/module.c | 59 +++++++++++------------
kernel/panic.c | 3 ++
kernel/params.c | 13 +++--
kernel/pid.c | 2 +
kernel/printk/printk.c | 2 +-
kernel/profile.c | 2 +
kernel/range.c | 2 +-
kernel/rcu/rcu_segcblist.c | 2 +
kernel/rcu/rcuperf.c | 10 ++--
kernel/rcu/rcutorture.c | 46 +++++++++---------
kernel/rcu/srcutiny.c | 2 +
kernel/rcu/srcutree.c | 5 +-
kernel/rcu/tiny.c | 3 ++
kernel/rcu/tree.c | 8 +--
kernel/rcu/tree_plugin.h | 67 +++++++++++++++-----------
kernel/rcu/update.c | 19 +++++---
kernel/relay.c | 5 +-
kernel/seccomp.c | 4 +-
kernel/signal.c | 10 ++--
kernel/smpboot.c | 5 +-
kernel/taskstats.c | 4 +-
kernel/torture.c | 6 ++-
kernel/tracepoint.c | 3 ++
kernel/workqueue.c | 2 +
lib/cpu_rmap.c | 15 +++---
lib/crc32test.c | 2 +
lib/earlycpio.c | 5 +-
lib/find_bit_benchmark.c | 2 +
lib/kobject.c | 36 +++++++-------
lib/kobject_uevent.c | 27 +++++------
lib/mpi/mpicoder.c | 10 ++--
lib/nmi_backtrace.c | 3 ++
lib/percpu_ida.c | 4 +-
lib/percpu_test.c | 2 +
lib/random32.c | 10 ++--
lib/stmp_device.c | 2 +
lib/string.c | 2 +
lib/swiotlb.c | 4 +-
lib/test_debug_virtual.c | 2 +
lib/test_rhashtable.c | 44 +++++++++--------
lib/test_sort.c | 2 +
lib/ubsan.c | 61 ++++++++++++-----------
net/ipv4/ipconfig.c | 59 ++++++++++-------------
net/ipv4/ipmr.c | 2 +-
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 9 ++--
net/ipv6/ip6mr.c | 2 +-
net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c | 6 +--
net/ipv6/netfilter/nf_defrag_ipv6_hooks.c | 4 +-
net/netfilter/nf_conntrack_helper.c | 11 ++---
net/netfilter/nf_conntrack_standalone.c | 2 +-
net/socket.c | 2 +-
security/keys/encrypted-keys/encrypted.c | 63 +++++++++++-------------
security/selinux/selinuxfs.c | 29 ++++++-----
82 files changed, 580 insertions(+), 532 deletions(-)
rename arch/x86/kernel/cpu/mtrr/{main.c => mtrr.c} (96%)

--
2.15.0



2018-05-10 15:47:27

by Joe Perches

[permalink] [raw]
Subject: [PATCH 18/18] rcu: Use pr_fmt to prefix "rcu: " to logging output

Use a consistent logging prefix for all rcu related output.

Signed-off-by: Joe Perches <[email protected]>
---
kernel/rcu/rcu_segcblist.c | 2 ++
kernel/rcu/rcuperf.c | 10 ++++---
kernel/rcu/rcutorture.c | 46 +++++++++++++++----------------
kernel/rcu/srcutiny.c | 2 ++
kernel/rcu/srcutree.c | 5 +++-
kernel/rcu/tiny.c | 3 +++
kernel/rcu/tree.c | 8 +++---
kernel/rcu/tree_plugin.h | 67 +++++++++++++++++++++++++++-------------------
kernel/rcu/update.c | 19 ++++++++-----
9 files changed, 96 insertions(+), 66 deletions(-)

diff --git a/kernel/rcu/rcu_segcblist.c b/kernel/rcu/rcu_segcblist.c
index 5aff271adf1e..b5f0e7234c4b 100644
--- a/kernel/rcu/rcu_segcblist.c
+++ b/kernel/rcu/rcu_segcblist.c
@@ -20,6 +20,8 @@
* Authors: Paul E. McKenney <[email protected]>
*/

+#define pr_fmt(fmt) "rcu: " fmt
+
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/interrupt.h>
diff --git a/kernel/rcu/rcuperf.c b/kernel/rcu/rcuperf.c
index 076a50fb22ad..ebdd77b45470 100644
--- a/kernel/rcu/rcuperf.c
+++ b/kernel/rcu/rcuperf.c
@@ -19,6 +19,9 @@
*
* Authors: Paul E. McKenney <[email protected]>
*/
+
+#define pr_fmt(fmt) "rcu: " fmt
+
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/init.h>
@@ -663,12 +666,11 @@ rcu_perf_init(void)
break;
}
if (i == ARRAY_SIZE(perf_ops)) {
- pr_alert("rcu-perf: invalid perf type: \"%s\"\n",
- perf_type);
+ pr_alert("rcu-perf: invalid perf type: \"%s\"\n", perf_type);
pr_alert("rcu-perf types:");
for (i = 0; i < ARRAY_SIZE(perf_ops); i++)
- pr_alert(" %s", perf_ops[i]->name);
- pr_alert("\n");
+ pr_cont(" %s", perf_ops[i]->name);
+ pr_cont("\n");
firsterr = -EINVAL;
goto unwind;
}
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index 648e1c25707d..45d98ff0d5b8 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -22,6 +22,7 @@
*
* See also: Documentation/RCU/torture.txt
*/
+
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/init.h>
@@ -908,7 +909,7 @@ rcu_torture_writer(void *arg)
VERBOSE_TOROUT_STRING("rcu_torture_writer task started");
if (!can_expedite)
pr_alert("%s" TORTURE_FLAG
- " GP expediting controlled from boot/sysfs for %s.\n",
+ " GP expediting controlled from boot/sysfs for %s\n",
torture_type, cur_ops->name);

/* Initialize synctype[] array. If none set, take default. */
@@ -916,27 +917,27 @@ rcu_torture_writer(void *arg)
gp_cond1 = gp_exp1 = gp_normal1 = gp_sync1 = true;
if (gp_cond1 && cur_ops->get_state && cur_ops->cond_sync) {
synctype[nsynctypes++] = RTWS_COND_GET;
- pr_info("%s: Testing conditional GPs.\n", __func__);
+ pr_info("%s: Testing conditional GPs\n", __func__);
} else if (gp_cond && (!cur_ops->get_state || !cur_ops->cond_sync)) {
- pr_alert("%s: gp_cond without primitives.\n", __func__);
+ pr_alert("%s: gp_cond without primitives\n", __func__);
}
if (gp_exp1 && cur_ops->exp_sync) {
synctype[nsynctypes++] = RTWS_EXP_SYNC;
- pr_info("%s: Testing expedited GPs.\n", __func__);
+ pr_info("%s: Testing expedited GPs\n", __func__);
} else if (gp_exp && !cur_ops->exp_sync) {
- pr_alert("%s: gp_exp without primitives.\n", __func__);
+ pr_alert("%s: gp_exp without primitives\n", __func__);
}
if (gp_normal1 && cur_ops->deferred_free) {
synctype[nsynctypes++] = RTWS_DEF_FREE;
- pr_info("%s: Testing asynchronous GPs.\n", __func__);
+ pr_info("%s: Testing asynchronous GPs\n", __func__);
} else if (gp_normal && !cur_ops->deferred_free) {
- pr_alert("%s: gp_normal without primitives.\n", __func__);
+ pr_alert("%s: gp_normal without primitives\n", __func__);
}
if (gp_sync1 && cur_ops->sync) {
synctype[nsynctypes++] = RTWS_SYNC;
- pr_info("%s: Testing normal GPs.\n", __func__);
+ pr_info("%s: Testing normal GPs\n", __func__);
} else if (gp_sync && !cur_ops->sync) {
- pr_alert("%s: gp_sync without primitives.\n", __func__);
+ pr_alert("%s: gp_sync without primitives\n", __func__);
}
if (WARN_ONCE(nsynctypes == 0,
"rcu_torture_writer: No update-side primitives.\n")) {
@@ -1027,7 +1028,7 @@ rcu_torture_writer(void *arg)
WARN_ON_ONCE(can_expedite && rcu_gp_is_expedited());
if (!can_expedite)
pr_alert("%s" TORTURE_FLAG
- " Dynamic grace-period expediting was disabled.\n",
+ " Dynamic grace-period expediting was disabled\n",
torture_type);
rcu_torture_writer_state = RTWS_STOPPING;
torture_kthread_stopping("rcu_torture_writer");
@@ -1436,7 +1437,7 @@ static int rcu_torture_stall(void *args)
local_irq_disable();
else
preempt_disable();
- pr_alert("rcu_torture_stall start on CPU %d.\n",
+ pr_alert("rcu_torture_stall start on CPU %d\n",
smp_processor_id());
while (ULONG_CMP_LT(get_seconds(), stop_at))
continue; /* Induce RCU CPU stall warning. */
@@ -1445,7 +1446,7 @@ static int rcu_torture_stall(void *args)
else
preempt_enable();
rcu_read_unlock();
- pr_alert("rcu_torture_stall end.\n");
+ pr_alert("rcu_torture_stall end\n");
}
torture_shutdown_absorb("rcu_torture_stall");
while (!kthread_should_stop())
@@ -1547,10 +1548,10 @@ static int rcu_torture_barrier_init(void)
return 0;
if (cur_ops->call == NULL || cur_ops->cb_barrier == NULL) {
pr_alert("%s" TORTURE_FLAG
- " Call or barrier ops missing for %s,\n",
+ " Call or barrier ops missing for %s\n",
torture_type, cur_ops->name);
pr_alert("%s" TORTURE_FLAG
- " RCU barrier testing omitted from run.\n",
+ " RCU barrier testing omitted from run\n",
torture_type);
return 0;
}
@@ -1679,7 +1680,7 @@ static void rcu_torture_err_cb(struct rcu_head *rhp)
* next grace period. Unlikely, but can happen. If it
* does happen, the debug-objects subsystem won't have splatted.
*/
- pr_alert("%s: duplicated callback was invoked.\n", KBUILD_MODNAME);
+ pr_alert("duplicated callback was invoked\n");
}
#endif /* #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */

@@ -1696,7 +1697,7 @@ static void rcu_test_debug_objects(void)

init_rcu_head_on_stack(&rh1);
init_rcu_head_on_stack(&rh2);
- pr_alert("%s: WARN: Duplicate call_rcu() test starting.\n", KBUILD_MODNAME);
+ pr_alert("WARN: Duplicate call_rcu() test starting\n");

/* Try to queue the rh2 pair of callbacks for the same grace period. */
preempt_disable(); /* Prevent preemption from interrupting test. */
@@ -1711,11 +1712,11 @@ static void rcu_test_debug_objects(void)

/* Wait for them all to get done so we can safely return. */
rcu_barrier();
- pr_alert("%s: WARN: Duplicate call_rcu() test complete.\n", KBUILD_MODNAME);
+ pr_alert("WARN: Duplicate call_rcu() test complete\n");
destroy_rcu_head_on_stack(&rh1);
destroy_rcu_head_on_stack(&rh2);
#else /* #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */
- pr_alert("%s: !CONFIG_DEBUG_OBJECTS_RCU_HEAD, not testing duplicate call_rcu()\n", KBUILD_MODNAME);
+ pr_alert("!CONFIG_DEBUG_OBJECTS_RCU_HEAD, not testing duplicate call_rcu()\n");
#endif /* #else #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */
}

@@ -1740,17 +1741,16 @@ rcu_torture_init(void)
break;
}
if (i == ARRAY_SIZE(torture_ops)) {
- pr_alert("rcu-torture: invalid torture type: \"%s\"\n",
- torture_type);
+ pr_alert("invalid torture type: \"%s\"\n", torture_type);
pr_alert("rcu-torture types:");
for (i = 0; i < ARRAY_SIZE(torture_ops); i++)
- pr_alert(" %s", torture_ops[i]->name);
- pr_alert("\n");
+ pr_cont(" %s", torture_ops[i]->name);
+ pr_cont("\n");
firsterr = -EINVAL;
goto unwind;
}
if (cur_ops->fqs == NULL && fqs_duration != 0) {
- pr_alert("rcu-torture: ->fqs NULL and non-zero fqs_duration, fqs disabled.\n");
+ pr_alert("->fqs NULL and non-zero fqs_duration, fqs disabled\n");
fqs_duration = 0;
}
if (cur_ops->init)
diff --git a/kernel/rcu/srcutiny.c b/kernel/rcu/srcutiny.c
index 622792abe41a..9392404cd0fb 100644
--- a/kernel/rcu/srcutiny.c
+++ b/kernel/rcu/srcutiny.c
@@ -21,6 +21,8 @@
* Author: Paul McKenney <[email protected]>
*/

+#define pr_fmt(fmt) "rcu: " fmt
+
#include <linux/export.h>
#include <linux/mutex.h>
#include <linux/preempt.h>
diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index ff894ae6d386..031d2713701f 100644
--- a/kernel/rcu/srcutree.c
+++ b/kernel/rcu/srcutree.c
@@ -26,6 +26,8 @@
*
*/

+#define pr_fmt(fmt) "rcu: " fmt
+
#include <linux/export.h>
#include <linux/mutex.h>
#include <linux/percpu.h>
@@ -390,7 +392,8 @@ void _cleanup_srcu_struct(struct srcu_struct *sp, bool quiesced)
}
if (WARN_ON(rcu_seq_state(READ_ONCE(sp->srcu_gp_seq)) != SRCU_STATE_IDLE) ||
WARN_ON(srcu_readers_active(sp))) {
- pr_info("%s: Active srcu_struct %p state: %d\n", __func__, sp, rcu_seq_state(READ_ONCE(sp->srcu_gp_seq)));
+ pr_info("%s: Active srcu_struct %p state: %d\n",
+ __func__, sp, rcu_seq_state(READ_ONCE(sp->srcu_gp_seq)));
return; /* Caller forgot to stop doing call_srcu()? */
}
free_percpu(sp->sda);
diff --git a/kernel/rcu/tiny.c b/kernel/rcu/tiny.c
index a64eee0db39e..52ab205db6e6 100644
--- a/kernel/rcu/tiny.c
+++ b/kernel/rcu/tiny.c
@@ -22,6 +22,9 @@
* For detailed explanation of Read-Copy Update mechanism see -
* Documentation/RCU
*/
+
+#define pr_fmt(fmt) "rcu: " fmt
+
#include <linux/completion.h>
#include <linux/interrupt.h>
#include <linux/notifier.h>
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index effcb898acca..fac633b3aa5e 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -27,6 +27,9 @@
* For detailed explanation of Read-Copy Update mechanism see -
* Documentation/RCU
*/
+
+#define pr_fmt(fmt) "rcu: " fmt
+
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/init.h>
@@ -1360,8 +1363,7 @@ static void print_other_cpu_stall(struct rcu_state *rsp, unsigned long gp_seq)
* See Documentation/RCU/stallwarn.txt for info on how to debug
* RCU CPU stall warnings.
*/
- pr_err("INFO: %s detected stalls on CPUs/tasks:",
- rsp->name);
+ pr_err("INFO: %s detected stalls on CPUs/tasks:", rsp->name);
print_cpu_stall_info_begin();
rcu_for_each_leaf_node(rsp, rnp) {
raw_spin_lock_irqsave_rcu_node(rnp, flags);
@@ -3984,7 +3986,7 @@ static void __init rcu_init_geometry(void)
if (rcu_fanout_leaf == RCU_FANOUT_LEAF &&
nr_cpu_ids == NR_CPUS)
return;
- pr_info("RCU: Adjusting geometry for rcu_fanout_leaf=%d, nr_cpu_ids=%u\n",
+ pr_info("Adjusting geometry for rcu_fanout_leaf=%d, nr_cpu_ids=%u\n",
rcu_fanout_leaf, nr_cpu_ids);

/*
diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index f2dae728c446..7aafff8590d7 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -71,51 +71,62 @@ static bool __read_mostly rcu_nocb_poll; /* Offload kthread are to poll. */
static void __init rcu_bootup_announce_oddness(void)
{
if (IS_ENABLED(CONFIG_RCU_TRACE))
- pr_info("\tRCU event tracing is enabled.\n");
+ pr_info("\tRCU event tracing is enabled\n");
if ((IS_ENABLED(CONFIG_64BIT) && RCU_FANOUT != 64) ||
(!IS_ENABLED(CONFIG_64BIT) && RCU_FANOUT != 32))
pr_info("\tCONFIG_RCU_FANOUT set to non-default value of %d\n",
- RCU_FANOUT);
+ RCU_FANOUT);
if (rcu_fanout_exact)
- pr_info("\tHierarchical RCU autobalancing is disabled.\n");
+ pr_info("\tHierarchical RCU autobalancing is disabled\n");
if (IS_ENABLED(CONFIG_RCU_FAST_NO_HZ))
- pr_info("\tRCU dyntick-idle grace-period acceleration is enabled.\n");
+ pr_info("\tRCU dyntick-idle grace-period acceleration is enabled\n");
if (IS_ENABLED(CONFIG_PROVE_RCU))
- pr_info("\tRCU lockdep checking is enabled.\n");
+ pr_info("\tRCU lockdep checking is enabled\n");
if (RCU_NUM_LVLS >= 4)
- pr_info("\tFour(or more)-level hierarchy is enabled.\n");
+ pr_info("\tFour(or more)-level hierarchy is enabled\n");
if (RCU_FANOUT_LEAF != 16)
- pr_info("\tBuild-time adjustment of leaf fanout to %d.\n",
+ pr_info("\tBuild-time adjustment of leaf fanout to %d\n",
RCU_FANOUT_LEAF);
if (rcu_fanout_leaf != RCU_FANOUT_LEAF)
- pr_info("\tBoot-time adjustment of leaf fanout to %d.\n", rcu_fanout_leaf);
+ pr_info("\tBoot-time adjustment of leaf fanout to %d\n",
+ rcu_fanout_leaf);
if (nr_cpu_ids != NR_CPUS)
- pr_info("\tRCU restricting CPUs from NR_CPUS=%d to nr_cpu_ids=%u.\n", NR_CPUS, nr_cpu_ids);
+ pr_info("\tRCU restricting CPUs from NR_CPUS=%d to nr_cpu_ids=%u\n",
+ NR_CPUS, nr_cpu_ids);
#ifdef CONFIG_RCU_BOOST
- pr_info("\tRCU priority boosting: priority %d delay %d ms.\n", kthread_prio, CONFIG_RCU_BOOST_DELAY);
+ pr_info("\tRCU priority boosting: priority %d delay %d ms\n",
+ kthread_prio, CONFIG_RCU_BOOST_DELAY);
#endif
if (blimit != DEFAULT_RCU_BLIMIT)
- pr_info("\tBoot-time adjustment of callback invocation limit to %ld.\n", blimit);
+ pr_info("\tBoot-time adjustment of callback invocation limit to %ld\n",
+ blimit);
if (qhimark != DEFAULT_RCU_QHIMARK)
- pr_info("\tBoot-time adjustment of callback high-water mark to %ld.\n", qhimark);
+ pr_info("\tBoot-time adjustment of callback high-water mark to %ld\n",
+ qhimark);
if (qlowmark != DEFAULT_RCU_QLOMARK)
- pr_info("\tBoot-time adjustment of callback low-water mark to %ld.\n", qlowmark);
+ pr_info("\tBoot-time adjustment of callback low-water mark to %ld\n",
+ qlowmark);
if (jiffies_till_first_fqs != ULONG_MAX)
- pr_info("\tBoot-time adjustment of first FQS scan delay to %ld jiffies.\n", jiffies_till_first_fqs);
+ pr_info("\tBoot-time adjustment of first FQS scan delay to %ld jiffies\n",
+ jiffies_till_first_fqs);
if (jiffies_till_next_fqs != ULONG_MAX)
- pr_info("\tBoot-time adjustment of subsequent FQS scan delay to %ld jiffies.\n", jiffies_till_next_fqs);
+ pr_info("\tBoot-time adjustment of subsequent FQS scan delay to %ld jiffies\n",
+ jiffies_till_next_fqs);
if (rcu_kick_kthreads)
- pr_info("\tKick kthreads if too-long grace period.\n");
+ pr_info("\tKick kthreads if too-long grace period\n");
if (IS_ENABLED(CONFIG_DEBUG_OBJECTS_RCU_HEAD))
- pr_info("\tRCU callback double-/use-after-free debug enabled.\n");
+ pr_info("\tRCU callback double-/use-after-free debug enabled\n");
if (gp_preinit_delay)
- pr_info("\tRCU debug GP pre-init slowdown %d jiffies.\n", gp_preinit_delay);
+ pr_info("\tRCU debug GP pre-init slowdown %d jiffies\n",
+ gp_preinit_delay);
if (gp_init_delay)
- pr_info("\tRCU debug GP init slowdown %d jiffies.\n", gp_init_delay);
+ pr_info("\tRCU debug GP init slowdown %d jiffies\n",
+ gp_init_delay);
if (gp_cleanup_delay)
- pr_info("\tRCU debug GP init slowdown %d jiffies.\n", gp_cleanup_delay);
+ pr_info("\tRCU debug GP init slowdown %d jiffies\n",
+ gp_cleanup_delay);
if (IS_ENABLED(CONFIG_RCU_EQS_DEBUG))
- pr_info("\tRCU debug extended QS entry/exit.\n");
+ pr_info("\tRCU debug extended QS entry/exit\n");
rcupdate_announce_bootup_oddness();
}

@@ -133,7 +144,7 @@ static void rcu_report_exp_rnp(struct rcu_state *rsp, struct rcu_node *rnp,
*/
static void __init rcu_bootup_announce(void)
{
- pr_info("Preemptible hierarchical RCU implementation.\n");
+ pr_info("Preemptible hierarchical RCU implementation\n");
rcu_bootup_announce_oddness();
}

@@ -885,7 +896,7 @@ static struct rcu_state *const rcu_state_p = &rcu_sched_state;
*/
static void __init rcu_bootup_announce(void)
{
- pr_info("Hierarchical RCU implementation.\n");
+ pr_info("Hierarchical RCU implementation\n");
rcu_bootup_announce_oddness();
}

@@ -2374,7 +2385,7 @@ void __init rcu_init_nohz(void)

if (!cpumask_available(rcu_nocb_mask) && need_rcu_nocb_mask) {
if (!zalloc_cpumask_var(&rcu_nocb_mask, GFP_KERNEL)) {
- pr_info("rcu_nocb_mask allocation failed, callback offloading disabled.\n");
+ pr_info("rcu_nocb_mask allocation failed, callback offloading disabled\n");
return;
}
}
@@ -2387,17 +2398,17 @@ void __init rcu_init_nohz(void)
#endif /* #if defined(CONFIG_NO_HZ_FULL) */

if (!cpumask_subset(rcu_nocb_mask, cpu_possible_mask)) {
- pr_info("\tNote: kernel parameter 'rcu_nocbs=', 'nohz_full', or 'isolcpus=' contains nonexistent CPUs.\n");
+ pr_info("\tNote: kernel parameter 'rcu_nocbs=', 'nohz_full', or 'isolcpus=' contains nonexistent CPUs\n");
cpumask_and(rcu_nocb_mask, cpu_possible_mask,
rcu_nocb_mask);
}
if (cpumask_empty(rcu_nocb_mask))
- pr_info("\tOffload RCU callbacks from CPUs: (none).\n");
+ pr_info("\tOffload RCU callbacks from CPUs: (none)\n");
else
- pr_info("\tOffload RCU callbacks from CPUs: %*pbl.\n",
+ pr_info("\tOffload RCU callbacks from CPUs: %*pbl\n",
cpumask_pr_args(rcu_nocb_mask));
if (rcu_nocb_poll)
- pr_info("\tPoll for callbacks from no-CBs CPUs.\n");
+ pr_info("\tPoll for callbacks from no-CBs CPUs\n");

for_each_rcu_flavor(rsp) {
for_each_cpu(cpu, rcu_nocb_mask)
diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c
index 4c230a60ece4..e6ccf4864fe6 100644
--- a/kernel/rcu/update.c
+++ b/kernel/rcu/update.c
@@ -30,6 +30,9 @@
* http://lse.sourceforge.net/locking/rcupdate.html
*
*/
+
+#define pr_fmt(fmt) "rcu: " fmt
+
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/init.h>
@@ -844,9 +847,10 @@ static void __init rcu_tasks_bootup_oddness(void)
{
#ifdef CONFIG_TASKS_RCU
if (rcu_task_stall_timeout != RCU_TASK_STALL_TIMEOUT)
- pr_info("\tTasks-RCU CPU stall warnings timeout set to %d (rcu_task_stall_timeout).\n", rcu_task_stall_timeout);
+ pr_info("\tTasks-RCU CPU stall warnings timeout set to %d (rcu_task_stall_timeout)\n",
+ rcu_task_stall_timeout);
else
- pr_info("\tTasks RCU enabled.\n");
+ pr_info("\tTasks RCU enabled\n");
#endif /* #ifdef CONFIG_TASKS_RCU */
}

@@ -945,15 +949,16 @@ void rcu_early_boot_tests(void) {}
void __init rcupdate_announce_bootup_oddness(void)
{
if (rcu_normal)
- pr_info("\tNo expedited grace period (rcu_normal).\n");
+ pr_info("\tNo expedited grace period (rcu_normal)\n");
else if (rcu_normal_after_boot)
- pr_info("\tNo expedited grace period (rcu_normal_after_boot).\n");
+ pr_info("\tNo expedited grace period (rcu_normal_after_boot)\n");
else if (rcu_expedited)
- pr_info("\tAll grace periods are expedited (rcu_expedited).\n");
+ pr_info("\tAll grace periods are expedited (rcu_expedited)\n");
if (rcu_cpu_stall_suppress)
- pr_info("\tRCU CPU stall warnings suppressed (rcu_cpu_stall_suppress).\n");
+ pr_info("\tRCU CPU stall warnings suppressed (rcu_cpu_stall_suppress)\n");
if (rcu_cpu_stall_timeout != CONFIG_RCU_CPU_STALL_TIMEOUT)
- pr_info("\tRCU CPU stall warnings timeout set to %d (rcu_cpu_stall_timeout).\n", rcu_cpu_stall_timeout);
+ pr_info("\tRCU CPU stall warnings timeout set to %d (rcu_cpu_stall_timeout)\n",
+ rcu_cpu_stall_timeout);
rcu_tasks_bootup_oddness();
}

--
2.15.0


2018-05-10 15:47:41

by Joe Perches

[permalink] [raw]
Subject: [PATCH 16/18] aoe: Remove pr_fmt duplicate logging prefixes

Converting pr_fmt from a simple define to use KBUILD_MODNAME added
some duplicate logging prefixes to existing uses.

Remove them.

Signed-off-by: Joe Perches <[email protected]>
---
drivers/block/aoe/aoeblk.c | 29 ++++++++++++++---------------
drivers/block/aoe/aoechr.c | 11 +++++------
drivers/block/aoe/aoecmd.c | 34 ++++++++++++++++------------------
drivers/block/aoe/aoedev.c | 19 +++++++------------
drivers/block/aoe/aoemain.c | 6 +++---
drivers/block/aoe/aoenet.c | 19 ++++++++-----------
6 files changed, 53 insertions(+), 65 deletions(-)

diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
index 6797e6c23c8a..d008cc46c0bd 100644
--- a/drivers/block/aoe/aoeblk.c
+++ b/drivers/block/aoe/aoeblk.c
@@ -205,7 +205,7 @@ aoedisk_add_debugfs(struct aoedev *d)
entry = debugfs_create_file(p, 0444, aoe_debugfs_dir, d,
&aoe_debugfs_fops);
if (IS_ERR_OR_NULL(entry)) {
- pr_info("aoe: cannot create debugfs file for %s\n",
+ pr_info("cannot create debugfs file for %s\n",
d->gd->disk_name);
return;
}
@@ -237,8 +237,7 @@ aoeblk_open(struct block_device *bdev, fmode_t mode)
ulong flags;

if (!virt_addr_valid(d)) {
- pr_crit("aoe: invalid device pointer in %s\n",
- __func__);
+ pr_crit("invalid device pointer in %s\n", __func__);
WARN_ON(1);
return -ENODEV;
}
@@ -282,8 +281,8 @@ aoeblk_request(struct request_queue *q)

d = q->queuedata;
if ((d->flags & DEVFL_UP) == 0) {
- pr_info_ratelimited("aoe: device %ld.%d is not up\n",
- d->aoemajor, d->aoeminor);
+ pr_info_ratelimited("device %ld.%d is not up\n",
+ d->aoemajor, d->aoeminor);
while ((rq = blk_peek_request(q))) {
blk_start_request(rq);
aoe_end_request(d, rq, 1);
@@ -299,7 +298,7 @@ aoeblk_getgeo(struct block_device *bdev, struct hd_geometry *geo)
struct aoedev *d = bdev->bd_disk->private_data;

if ((d->flags & DEVFL_UP) == 0) {
- printk(KERN_ERR "aoe: disk not up\n");
+ pr_err("disk not up\n");
return -ENODEV;
}

@@ -319,7 +318,7 @@ aoeblk_ioctl(struct block_device *bdev, fmode_t mode, uint cmd, ulong arg)

d = bdev->bd_disk->private_data;
if ((d->flags & DEVFL_UP) == 0) {
- pr_err("aoe: disk not up\n");
+ pr_err("disk not up\n");
return -ENODEV;
}

@@ -332,7 +331,7 @@ aoeblk_ioctl(struct block_device *bdev, fmode_t mode, uint cmd, ulong arg)

/* udev calls scsi_id, which uses SG_IO, resulting in noise */
if (cmd != SG_IO)
- pr_info("aoe: unknown ioctl 0x%x\n", cmd);
+ pr_info("unknown ioctl 0x%x\n", cmd);

return -ENOTTY;
}
@@ -370,22 +369,22 @@ aoeblk_gdalloc(void *vp)

gd = alloc_disk(AOE_PARTITIONS);
if (gd == NULL) {
- pr_err("aoe: cannot allocate disk structure for %ld.%d\n",
- d->aoemajor, d->aoeminor);
+ pr_err("cannot allocate disk structure for %ld.%d\n",
+ d->aoemajor, d->aoeminor);
goto err;
}

mp = mempool_create(MIN_BUFS, mempool_alloc_slab, mempool_free_slab,
buf_pool_cache);
if (mp == NULL) {
- printk(KERN_ERR "aoe: cannot allocate bufpool for %ld.%d\n",
- d->aoemajor, d->aoeminor);
+ pr_err("cannot allocate bufpool for %ld.%d\n",
+ d->aoemajor, d->aoeminor);
goto err_disk;
}
q = blk_init_queue(aoeblk_request, &d->lock);
if (q == NULL) {
- pr_err("aoe: cannot allocate block queue for %ld.%d\n",
- d->aoemajor, d->aoeminor);
+ pr_err("cannot allocate block queue for %ld.%d\n",
+ d->aoemajor, d->aoeminor);
goto err_mempool;
}
blk_queue_bounce_limit(q, BLK_BOUNCE_HIGH);
@@ -457,7 +456,7 @@ aoeblk_init(void)
return -ENOMEM;
aoe_debugfs_dir = debugfs_create_dir("aoe", NULL);
if (IS_ERR_OR_NULL(aoe_debugfs_dir)) {
- pr_info("aoe: cannot create debugfs directory\n");
+ pr_info("cannot create debugfs directory\n");
aoe_debugfs_dir = NULL;
}
return 0;
diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c
index ab41be625a53..57553ee1375c 100644
--- a/drivers/block/aoe/aoechr.c
+++ b/drivers/block/aoe/aoechr.c
@@ -69,8 +69,7 @@ static int
interfaces(const char __user *str, size_t size)
{
if (set_aoe_iflist(str, size)) {
- printk(KERN_ERR
- "aoe: could not set interface list: too many interfaces\n");
+ pr_err("could not set interface list: too many interfaces\n");
return -EINVAL;
}
return 0;
@@ -93,7 +92,7 @@ revalidate(const char __user *str, size_t size)

n = sscanf(buf, "e%d.%d", &major, &minor);
if (n != 2) {
- pr_err("aoe: invalid device specification %s\n", buf);
+ pr_err("invalid device specification %s\n", buf);
return -EINVAL;
}
d = aoedev_by_aoeaddr(major, minor, 0);
@@ -141,7 +140,7 @@ bail: spin_unlock_irqrestore(&emsgs_lock, flags);

mp = kmemdup(msg, n, GFP_ATOMIC);
if (mp == NULL) {
- printk(KERN_ERR "aoe: allocation failure, len=%ld\n", n);
+ pr_err("allocation failure, len=%ld\n", n);
goto bail;
}

@@ -165,7 +164,7 @@ aoechr_write(struct file *filp, const char __user *buf, size_t cnt, loff_t *offp

switch ((unsigned long) filp->private_data) {
default:
- printk(KERN_INFO "aoe: can't write to that file.\n");
+ pr_info("can't write to that file\n");
break;
case MINOR_DISCOVER:
ret = discover();
@@ -287,7 +286,7 @@ aoechr_init(void)

n = register_chrdev(AOE_MAJOR, "aoechr", &aoe_fops);
if (n < 0) {
- printk(KERN_ERR "aoe: can't register char device\n");
+ pr_err("can't register char device\n");
return n;
}
init_completion(&emsgs_comp);
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index 540bb60cd071..e75a0ed67d92 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -256,7 +256,7 @@ newframe(struct aoedev *d)
int has_untainted;

if (!d->targets || !d->targets[0]) {
- printk(KERN_ERR "aoe: NULL TARGETS!\n");
+ pr_err("NULL TARGETS!\n");
return NULL;
}
tt = d->tgt; /* last used target */
@@ -425,7 +425,7 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff_head *qu

skb = new_skb(sizeof *h + sizeof *ch);
if (skb == NULL) {
- printk(KERN_INFO "aoe: skb alloc failure\n");
+ pr_info("skb alloc failure\n");
goto cont;
}
skb_put(skb, sizeof *h + sizeof *ch);
@@ -463,7 +463,7 @@ resend(struct aoedev *d, struct frame *f)
skb = f->skb;
if (ifrotate(t) == NULL) {
/* probably can't happen, but set it up to fail anyway */
- pr_info("aoe: resend: no interfaces to rotate to.\n");
+ pr_info("resend: no interfaces to rotate to\n");
ktcomplete(f, NULL);
return;
}
@@ -867,7 +867,7 @@ nextbuf(struct aoedev *d)
}
buf = mempool_alloc(d->bufpool, GFP_ATOMIC);
if (buf == NULL) {
- pr_err("aoe: nextbuf: unable to mempool_alloc!\n");
+ pr_err("nextbuf: unable to mempool_alloc!\n");
return NULL;
}
bio = d->ip.nxbio;
@@ -968,8 +968,7 @@ ataid_complete(struct aoedev *d, struct aoetgt *t, unsigned char *id)
memcpy(d->ident, id, sizeof(d->ident));

if (d->ssize != ssize)
- printk(KERN_INFO
- "aoe: %pm e%ld.%d v%04x has %llu sectors\n",
+ pr_info("%pm e%ld.%d v%04x has %llu sectors\n",
t->addr,
d->aoemajor, d->aoeminor,
d->fw_ver, (long long)ssize);
@@ -1107,9 +1106,9 @@ ktiocomplete(struct frame *f)
ahin = (struct aoe_atahdr *) skb->data;
skb_pull(skb, sizeof(*ahin));
if (ahin->cmdstat & 0xa9) { /* these bits cleared on success */
- pr_err("aoe: ata error cmd=%2.2Xh stat=%2.2Xh from e%ld.%d\n",
- ahout->cmdstat, ahin->cmdstat,
- d->aoemajor, d->aoeminor);
+ pr_err("ata error cmd=%2.2Xh stat=%2.2Xh from e%ld.%d\n",
+ ahout->cmdstat, ahin->cmdstat,
+ d->aoemajor, d->aoeminor);
noskb: if (buf)
buf->bio->bi_status = BLK_STS_IOERR;
goto out;
@@ -1159,7 +1158,7 @@ noskb: if (buf)
spin_unlock_irq(&d->lock);
break;
default:
- pr_info("aoe: unrecognized ata command %2.2Xh for %d.%d\n",
+ pr_info("unrecognized ata command %2.2Xh for %d.%d\n",
ahout->cmdstat,
be16_to_cpu(get_unaligned(&hin->major)),
hin->minor);
@@ -1466,7 +1465,7 @@ addtgt(struct aoedev *d, char *addr, ulong nframes)
return *tt = t;

nomem:
- pr_info("aoe: cannot allocate memory to add target\n");
+ pr_info("cannot allocate memory to add target\n");
return NULL;
}

@@ -1483,7 +1482,7 @@ setdbcnt(struct aoedev *d)
bcnt = (*t)->minbcnt;
if (bcnt != d->maxbcnt) {
d->maxbcnt = bcnt;
- pr_info("aoe: e%ld.%d: setting %d byte data frames\n",
+ pr_info("e%ld.%d: setting %d byte data frames\n",
d->aoemajor, d->aoeminor, bcnt);
}
}
@@ -1510,7 +1509,7 @@ setifbcnt(struct aoetgt *t, struct net_device *nd, int bcnt)
}
if (nd) {
if (p == e) {
- pr_err("aoe: device setifbcnt failure; too many interfaces.\n");
+ pr_err("device setifbcnt failure; too many interfaces\n");
return;
}
dev_hold(nd);
@@ -1543,17 +1542,16 @@ aoecmd_cfg_rsp(struct sk_buff *skb)
*/
aoemajor = get_unaligned_be16(&h->major);
if (aoemajor == 0xfff) {
- printk(KERN_ERR "aoe: Warning: shelf address is all ones. "
- "Check shelf dip switches.\n");
+ pr_err("Warning: shelf address is all ones. Check shelf dip switches.\n");
return;
}
if (aoemajor == 0xffff) {
- pr_info("aoe: e%ld.%d: broadcast shelf number invalid\n",
+ pr_info("e%ld.%d: broadcast shelf number invalid\n",
aoemajor, (int) h->minor);
return;
}
if (h->minor == 0xff) {
- pr_info("aoe: e%ld.%d: broadcast slot number invalid\n",
+ pr_info("e%ld.%d: broadcast slot number invalid\n",
aoemajor, (int) h->minor);
return;
}
@@ -1564,7 +1562,7 @@ aoecmd_cfg_rsp(struct sk_buff *skb)

d = aoedev_by_aoeaddr(aoemajor, h->minor, 1);
if (d == NULL) {
- pr_info("aoe: device allocation failure\n");
+ pr_info("device allocation failure\n");
return;
}

diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c
index 697f735b07a4..1ef8ff0ef312 100644
--- a/drivers/block/aoe/aoedev.c
+++ b/drivers/block/aoe/aoedev.c
@@ -69,8 +69,7 @@ minor_get_static(ulong *sysminor, ulong aoemaj, int aoemin)
};

if (aoemin >= NPERSHELF) {
- pr_err("aoe: %s %d slots per shelf\n",
- "static minor device numbers support only",
+ pr_err("static minor device numbers support only %d slots per shelf\n",
NPERSHELF);
error = -1;
goto out;
@@ -78,18 +77,16 @@ minor_get_static(ulong *sysminor, ulong aoemaj, int aoemin)

n = aoemaj * NPERSHELF + aoemin;
if (n >= N_DEVS) {
- pr_err("aoe: %s with e%ld.%d\n",
- "cannot use static minor device numbers",
- aoemaj, aoemin);
+ pr_err("cannot use static minor device numbers with e%ld.%d\n",
+ aoemaj, aoemin);
error = -1;
goto out;
}

spin_lock_irqsave(&used_minors_lock, flags);
if (test_bit(n, used_minors)) {
- pr_err("aoe: %s %lu\n",
- "existing device already has static minor number",
- n);
+ pr_err("existing device already has static minor number %lu\n",
+ n);
error = -1;
} else
set_bit(n, used_minors);
@@ -404,10 +401,8 @@ skbfree(struct sk_buff *skb)
while (atomic_read(&skb_shinfo(skb)->dataref) != 1 && i-- > 0)
msleep(Sms);
if (i < 0) {
- printk(KERN_ERR
- "aoe: %s holds ref: %s\n",
- skb->dev ? skb->dev->name : "netif",
- "cannot free skb -- memory leaked.");
+ pr_err("%s holds ref: cannot free skb -- memory leaked\n",
+ skb->dev ? skb->dev->name : "netif");
return;
}
skb->truesize -= skb->data_len;
diff --git a/drivers/block/aoe/aoemain.c b/drivers/block/aoe/aoemain.c
index 251482066977..5995832a2596 100644
--- a/drivers/block/aoe/aoemain.c
+++ b/drivers/block/aoe/aoemain.c
@@ -59,10 +59,10 @@ aoe_init(void)
goto cmd_fail;
ret = register_blkdev(AOE_MAJOR, DEVICE_NAME);
if (ret < 0) {
- printk(KERN_ERR "aoe: can't register major\n");
+ pr_err("can't register major\n");
goto blkreg_fail;
}
- printk(KERN_INFO "aoe: AoE v%s initialised.\n", VERSION);
+ pr_info("AoE v%s initialised\n", VERSION);

timer_setup(&timer, discover_timer, 0);
discover_timer(&timer);
@@ -78,7 +78,7 @@ aoe_init(void)
chr_fail:
aoedev_exit();

- printk(KERN_INFO "aoe: initialisation failure.\n");
+ pr_info("initialisation failure\n");
return ret;
}

diff --git a/drivers/block/aoe/aoenet.c b/drivers/block/aoe/aoenet.c
index 63773a90581d..454edea1b517 100644
--- a/drivers/block/aoe/aoenet.c
+++ b/drivers/block/aoe/aoenet.c
@@ -61,9 +61,8 @@ tx(int id) __must_hold(&txlock)
spin_unlock_irq(&txlock);
ifp = skb->dev;
if (dev_queue_xmit(skb) == NET_XMIT_DROP && net_ratelimit())
- pr_warn("aoe: packet could not be sent on %s. %s\n",
- ifp ? ifp->name : "netif",
- "consider increasing tx_queue_len");
+ pr_warn("packet could not be sent on %s - consider increasing tx_queue_len\n",
+ ifp ? ifp->name : "netif");
spin_lock_irq(&txlock);
}
return 0;
@@ -102,7 +101,7 @@ set_aoe_iflist(const char __user *user_str, size_t size)
return -EINVAL;

if (copy_from_user(aoe_iflist, user_str, size)) {
- printk(KERN_INFO "aoe: copy from user failed\n");
+ pr_info("copy from user failed\n");
return -EFAULT;
}
aoe_iflist[size] = 0x00;
@@ -160,12 +159,10 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt,
if (n > NECODES)
n = 0;
if (net_ratelimit())
- printk(KERN_ERR
- "%s%d.%d@%s; ecode=%d '%s'\n",
- "aoe: error packet from ",
- get_unaligned_be16(&h->major),
- h->minor, skb->dev->name,
- h->err, aoe_errlist[n]);
+ pr_err("error packet from %d.%d@%s; ecode=%d '%s'\n",
+ get_unaligned_be16(&h->major),
+ h->minor, skb->dev->name,
+ h->err, aoe_errlist[n]);
goto exit;
}

@@ -180,7 +177,7 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt,
default:
if (h->cmd >= AOECMD_VEND_MIN)
break; /* don't complain about vendor commands */
- pr_info("aoe: unknown AoE command type 0x%02x\n", h->cmd);
+ pr_info("unknown AoE command type 0x%02x\n", h->cmd);
break;
}

--
2.15.0


2018-05-10 15:47:53

by Joe Perches

[permalink] [raw]
Subject: [PATCH 15/18] security: Remove pr_fmt duplicate logging prefixes

Converting pr_fmt from a simple define to use KBUILD_MODNAME added
some duplicate logging prefixes to existing uses.

Remove them.

Signed-off-by: Joe Perches <[email protected]>
---
security/selinux/selinuxfs.c | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index c0cadbc5f85c..be8f186a6256 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -515,19 +515,19 @@ static int sel_make_policy_nodes(struct selinux_fs_info *fsi)

ret = sel_make_bools(fsi);
if (ret) {
- pr_err("SELinux: failed to load policy booleans\n");
+ pr_err("failed to load policy booleans\n");
return ret;
}

ret = sel_make_classes(fsi);
if (ret) {
- pr_err("SELinux: failed to load policy classes\n");
+ pr_err("failed to load policy classes\n");
return ret;
}

ret = sel_make_policycap(fsi);
if (ret) {
- pr_err("SELinux: failed to load policy capabilities\n");
+ pr_err("failed to load policy capabilities\n");
return ret;
}

@@ -570,7 +570,7 @@ static ssize_t sel_write_load(struct file *file, const char __user *buf,

length = security_load_policy(fsi->state, data, count);
if (length) {
- pr_warn_ratelimited("SELinux: failed to load policy\n");
+ pr_warn_ratelimited("failed to load policy\n");
goto out;
}

@@ -620,8 +620,8 @@ static ssize_t sel_write_context(struct file *file, char *buf, size_t size)

length = -ERANGE;
if (len > SIMPLE_TRANSACTION_LIMIT) {
- printk(KERN_ERR "SELinux: %s: context size (%u) exceeds "
- "payload max\n", __func__, len);
+ pr_err("%s: context size (%u) exceeds payload max\n",
+ __func__, len);
goto out;
}

@@ -956,8 +956,8 @@ static ssize_t sel_write_create(struct file *file, char *buf, size_t size)

length = -ERANGE;
if (len > SIMPLE_TRANSACTION_LIMIT) {
- printk(KERN_ERR "SELinux: %s: context size (%u) exceeds "
- "payload max\n", __func__, len);
+ pr_err("%s: context size (%u) exceeds payload max\n",
+ __func__, len);
goto out;
}

@@ -1147,8 +1147,8 @@ static ssize_t sel_write_member(struct file *file, char *buf, size_t size)

length = -ERANGE;
if (len > SIMPLE_TRANSACTION_LIMIT) {
- printk(KERN_ERR "SELinux: %s: context size (%u) exceeds "
- "payload max\n", __func__, len);
+ pr_err("%s: context size (%u) exceeds payload max\n",
+ __func__, len);
goto out;
}

@@ -1389,8 +1389,8 @@ static int sel_make_bools(struct selinux_fs_info *fsi)
ret = security_genfs_sid(fsi->state, "selinuxfs", page,
SECCLASS_FILE, &sid);
if (ret) {
- pr_warn_ratelimited("SELinux: no sid found, defaulting to security isid for %s\n",
- page);
+ pr_warn_ratelimited("no sid found, defaulting to security isid for %s\n",
+ page);
sid = SECINITSID_SECURITY;
}

@@ -1996,8 +1996,7 @@ static int sel_fill_super(struct super_block *sb, void *data, int silent)
goto err;
return 0;
err:
- printk(KERN_ERR "SELinux: %s: failed while creating inodes\n",
- __func__);
+ pr_err("%s: failed while creating inodes\n", __func__);

selinux_fs_info_free(sb);

@@ -2046,7 +2045,7 @@ static int __init init_sel_fs(void)

selinux_null.mnt = selinuxfs_mount = kern_mount(&sel_fs_type);
if (IS_ERR(selinuxfs_mount)) {
- printk(KERN_ERR "selinuxfs: could not mount!\n");
+ pr_err("selinuxfs: could not mount!\n");
err = PTR_ERR(selinuxfs_mount);
selinuxfs_mount = NULL;
}
--
2.15.0


2018-05-10 15:48:06

by Joe Perches

[permalink] [raw]
Subject: [PATCH 17/18] security: encrypted-keys: Remove pr_fmt duplicate logging prefixes

Converting pr_fmt from a simple define to use KBUILD_MODNAME added
some duplicate logging prefixes to existing uses.

Remove them.

Signed-off-by: Joe Perches <[email protected]>
---
security/keys/encrypted-keys/encrypted.c | 63 ++++++++++++++------------------
1 file changed, 28 insertions(+), 35 deletions(-)

diff --git a/security/keys/encrypted-keys/encrypted.c b/security/keys/encrypted-keys/encrypted.c
index d92cbf9687c3..40a14d5c6ae5 100644
--- a/security/keys/encrypted-keys/encrypted.c
+++ b/security/keys/encrypted-keys/encrypted.c
@@ -84,8 +84,7 @@ static int aes_get_sizes(void)

tfm = crypto_alloc_skcipher(blkcipher_alg, 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(tfm)) {
- pr_err("encrypted_key: failed to alloc_cipher (%ld)\n",
- PTR_ERR(tfm));
+ pr_err("failed to alloc_cipher (%ld)\n", PTR_ERR(tfm));
return PTR_ERR(tfm);
}
ivsize = crypto_skcipher_ivsize(tfm);
@@ -106,15 +105,14 @@ static int valid_ecryptfs_desc(const char *ecryptfs_desc)
int i;

if (strlen(ecryptfs_desc) != KEY_ECRYPTFS_DESC_LEN) {
- pr_err("encrypted_key: key description must be %d hexadecimal "
- "characters long\n", KEY_ECRYPTFS_DESC_LEN);
+ pr_err("key description must be %d hexadecimal characters long\n",
+ KEY_ECRYPTFS_DESC_LEN);
return -EINVAL;
}

for (i = 0; i < KEY_ECRYPTFS_DESC_LEN; i++) {
if (!isxdigit(ecryptfs_desc[i])) {
- pr_err("encrypted_key: key description must contain "
- "only hexadecimal characters\n");
+ pr_err("key description must contain only hexadecimal characters\n");
return -EINVAL;
}
}
@@ -180,7 +178,7 @@ static int datablob_parse(char *datablob, const char **format,

keyword = strsep(&datablob, " \t");
if (!keyword) {
- pr_info("encrypted_key: insufficient parameters specified\n");
+ pr_info("insufficient parameters specified\n");
return ret;
}
key_cmd = match_token(keyword, key_tokens, args);
@@ -188,7 +186,7 @@ static int datablob_parse(char *datablob, const char **format,
/* Get optional format: default | ecryptfs */
p = strsep(&datablob, " \t");
if (!p) {
- pr_err("encrypted_key: insufficient parameters specified\n");
+ pr_err("insufficient parameters specified\n");
return ret;
}

@@ -205,20 +203,20 @@ static int datablob_parse(char *datablob, const char **format,
}

if (!*master_desc) {
- pr_info("encrypted_key: master key parameter is missing\n");
+ pr_info("master key parameter is missing\n");
goto out;
}

if (valid_master_desc(*master_desc, NULL) < 0) {
- pr_info("encrypted_key: master key parameter \'%s\' "
- "is invalid\n", *master_desc);
+ pr_info("master key parameter \'%s\' is invalid\n",
+ *master_desc);
goto out;
}

if (decrypted_datalen) {
*decrypted_datalen = strsep(&datablob, " \t");
if (!*decrypted_datalen) {
- pr_info("encrypted_key: keylen parameter is missing\n");
+ pr_info("keylen parameter is missing\n");
goto out;
}
}
@@ -226,37 +224,35 @@ static int datablob_parse(char *datablob, const char **format,
switch (key_cmd) {
case Opt_new:
if (!decrypted_datalen) {
- pr_info("encrypted_key: keyword \'%s\' not allowed "
- "when called from .update method\n", keyword);
+ pr_info("keyword \'%s\' not allowed when called from .update method\n",
+ keyword);
break;
}
ret = 0;
break;
case Opt_load:
if (!decrypted_datalen) {
- pr_info("encrypted_key: keyword \'%s\' not allowed "
- "when called from .update method\n", keyword);
+ pr_info("keyword \'%s\' not allowed when called from .update method\n",
+ keyword);
break;
}
*hex_encoded_iv = strsep(&datablob, " \t");
if (!*hex_encoded_iv) {
- pr_info("encrypted_key: hex blob is missing\n");
+ pr_info("hex blob is missing\n");
break;
}
ret = 0;
break;
case Opt_update:
if (decrypted_datalen) {
- pr_info("encrypted_key: keyword \'%s\' not allowed "
- "when called from .instantiate method\n",
+ pr_info("keyword \'%s\' not allowed when called from .instantiate method\n",
keyword);
break;
}
ret = 0;
break;
case Opt_err:
- pr_info("encrypted_key: keyword \'%s\' not recognized\n",
- keyword);
+ pr_info("keyword \'%s\' not recognized\n", keyword);
break;
}
out:
@@ -344,7 +340,7 @@ static int calc_hmac(u8 *digest, const u8 *key, unsigned int keylen,

tfm = crypto_alloc_shash(hmac_alg, 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(tfm)) {
- pr_err("encrypted_key: can't alloc %s transform: %ld\n",
+ pr_err("can't alloc %s transform: %ld\n",
hmac_alg, PTR_ERR(tfm));
return PTR_ERR(tfm);
}
@@ -395,22 +391,21 @@ static struct skcipher_request *init_skcipher_req(const u8 *key,

tfm = crypto_alloc_skcipher(blkcipher_alg, 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(tfm)) {
- pr_err("encrypted_key: failed to load %s transform (%ld)\n",
+ pr_err("failed to load %s transform (%ld)\n",
blkcipher_alg, PTR_ERR(tfm));
return ERR_CAST(tfm);
}

ret = crypto_skcipher_setkey(tfm, key, key_len);
if (ret < 0) {
- pr_err("encrypted_key: failed to setkey (%d)\n", ret);
+ pr_err("failed to setkey (%d)\n", ret);
crypto_free_skcipher(tfm);
return ERR_PTR(ret);
}

req = skcipher_request_alloc(tfm, GFP_KERNEL);
if (!req) {
- pr_err("encrypted_key: failed to allocate request for %s\n",
- blkcipher_alg);
+ pr_err("failed to allocate request for %s\n", blkcipher_alg);
crypto_free_skcipher(tfm);
return ERR_PTR(-ENOMEM);
}
@@ -441,11 +436,10 @@ static struct key *request_master_key(struct encrypted_key_payload *epayload,
int ret = PTR_ERR(mkey);

if (ret == -ENOTSUPP)
- pr_info("encrypted_key: key %s not supported",
+ pr_info("key %s not supported\n",
epayload->master_desc);
else
- pr_info("encrypted_key: key %s not found",
- epayload->master_desc);
+ pr_info("key %s not found\n", epayload->master_desc);
goto out;
}

@@ -490,7 +484,7 @@ static int derived_key_encrypt(struct encrypted_key_payload *epayload,
skcipher_request_free(req);
crypto_free_skcipher(tfm);
if (ret < 0)
- pr_err("encrypted_key: failed to encrypt (%d)\n", ret);
+ pr_err("failed to encrypt (%d)\n", ret);
else
dump_encrypted_data(epayload, encrypted_datalen);
out:
@@ -627,8 +621,7 @@ static struct encrypted_key_payload *encrypted_key_alloc(struct key *key,
payload_datalen = decrypted_datalen;
if (format && !strcmp(format, key_format_ecryptfs)) {
if (dlen != ECRYPTFS_MAX_KEY_BYTES) {
- pr_err("encrypted_key: keylen for the ecryptfs format "
- "must be equal to %d bytes\n",
+ pr_err("keylen for the ecryptfs format must be equal to %d bytes\n",
ECRYPTFS_MAX_KEY_BYTES);
return ERR_PTR(-EINVAL);
}
@@ -696,7 +689,7 @@ static int encrypted_key_decrypt(struct encrypted_key_payload *epayload,

ret = datablob_hmac_verify(epayload, format, master_key, master_keylen);
if (ret < 0) {
- pr_err("encrypted_key: bad hmac (%d)\n", ret);
+ pr_err("bad hmac (%d)\n", ret);
goto out;
}

@@ -706,7 +699,7 @@ static int encrypted_key_decrypt(struct encrypted_key_payload *epayload,

ret = derived_key_decrypt(epayload, derived_key, sizeof derived_key);
if (ret < 0)
- pr_err("encrypted_key: failed to decrypt key (%d)\n", ret);
+ pr_err("failed to decrypt key (%d)\n", ret);
out:
up_read(&mkey->sem);
key_put(mkey);
@@ -986,7 +979,7 @@ static int __init init_encrypted(void)

hash_tfm = crypto_alloc_shash(hash_alg, 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(hash_tfm)) {
- pr_err("encrypted_key: can't allocate %s transform: %ld\n",
+ pr_err("can't allocate %s transform: %ld\n",
hash_alg, PTR_ERR(hash_tfm));
return PTR_ERR(hash_tfm);
}
--
2.15.0


2018-05-10 15:48:34

by Joe Perches

[permalink] [raw]
Subject: [PATCH 10/18] efifb: Remove pr_fmt duplicate logging prefixes

Converting pr_fmt from a simple define to use KBUILD_MODNAME added
some duplicate logging prefixes to existing uses.

Remove them.

Signed-off-by: Joe Perches <[email protected]>
---
drivers/video/fbdev/efifb.c | 48 ++++++++++++++++++++++-----------------------
1 file changed, 23 insertions(+), 25 deletions(-)

diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c
index 46a4484e3da7..3a11174f194b 100644
--- a/drivers/video/fbdev/efifb.c
+++ b/drivers/video/fbdev/efifb.c
@@ -250,13 +250,13 @@ static int efifb_probe(struct platform_device *dev)
} else {
/* We cannot make this fatal. Sometimes this comes from magic
spaces our resource handlers simply don't know about */
- pr_warn("efifb: cannot reserve video memory at 0x%lx\n",
+ pr_warn("cannot reserve video memory at 0x%lx\n",
efifb_fix.smem_start);
}

info = framebuffer_alloc(sizeof(u32) * 16, &dev->dev);
if (!info) {
- pr_err("efifb: cannot allocate framebuffer\n");
+ pr_err("cannot allocate framebuffer\n");
err = -ENOMEM;
goto err_release_mem;
}
@@ -277,23 +277,23 @@ static int efifb_probe(struct platform_device *dev)
else
info->screen_base = ioremap_wc(efifb_fix.smem_start, efifb_fix.smem_len);
if (!info->screen_base) {
- pr_err("efifb: abort, cannot ioremap video memory 0x%x @ 0x%lx\n",
- efifb_fix.smem_len, efifb_fix.smem_start);
+ pr_err("abort, cannot ioremap video memory 0x%x @ 0x%lx\n",
+ efifb_fix.smem_len, efifb_fix.smem_start);
err = -EIO;
goto err_release_fb;
}

- pr_info("efifb: framebuffer at 0x%lx, using %dk, total %dk\n",
- efifb_fix.smem_start, size_remap/1024, size_total/1024);
- pr_info("efifb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
- efifb_defined.xres, efifb_defined.yres,
- efifb_defined.bits_per_pixel, efifb_fix.line_length,
- screen_info.pages);
+ pr_info("framebuffer at 0x%lx, using %dk, total %dk\n",
+ efifb_fix.smem_start, size_remap/1024, size_total/1024);
+ pr_info("mode is %dx%dx%d, linelength=%d, pages=%d\n",
+ efifb_defined.xres, efifb_defined.yres,
+ efifb_defined.bits_per_pixel, efifb_fix.line_length,
+ screen_info.pages);

efifb_defined.xres_virtual = efifb_defined.xres;
efifb_defined.yres_virtual = efifb_fix.smem_len /
efifb_fix.line_length;
- pr_info("efifb: scrolling: redraw\n");
+ pr_info("scrolling: redraw\n");
efifb_defined.yres_virtual = efifb_defined.yres;

/* some dummy values for timing to make fbset happy */
@@ -311,17 +311,15 @@ static int efifb_probe(struct platform_device *dev)
efifb_defined.transp.offset = screen_info.rsvd_pos;
efifb_defined.transp.length = screen_info.rsvd_size;

- pr_info("efifb: %s: "
- "size=%d:%d:%d:%d, shift=%d:%d:%d:%d\n",
- "Truecolor",
- screen_info.rsvd_size,
- screen_info.red_size,
- screen_info.green_size,
- screen_info.blue_size,
- screen_info.rsvd_pos,
- screen_info.red_pos,
- screen_info.green_pos,
- screen_info.blue_pos);
+ pr_info("Truecolor: size=%d:%d:%d:%d, shift=%d:%d:%d:%d\n",
+ screen_info.rsvd_size,
+ screen_info.red_size,
+ screen_info.green_size,
+ screen_info.blue_size,
+ screen_info.rsvd_pos,
+ screen_info.red_pos,
+ screen_info.green_pos,
+ screen_info.blue_pos);

efifb_fix.ypanstep = 0;
efifb_fix.ywrapstep = 0;
@@ -350,17 +348,17 @@ static int efifb_probe(struct platform_device *dev)

err = sysfs_create_groups(&dev->dev.kobj, efifb_groups);
if (err) {
- pr_err("efifb: cannot add sysfs attrs\n");
+ pr_err("cannot add sysfs attrs\n");
goto err_unmap;
}
err = fb_alloc_cmap(&info->cmap, 256, 0);
if (err < 0) {
- pr_err("efifb: cannot allocate colormap\n");
+ pr_err("cannot allocate colormap\n");
goto err_groups;
}
err = register_framebuffer(info);
if (err < 0) {
- pr_err("efifb: cannot register framebuffer\n");
+ pr_err("cannot register framebuffer\n");
goto err_fb_dealoc;
}
fb_info(info, "%s frame buffer device\n", info->fix.id);
--
2.15.0


2018-05-10 15:48:36

by Joe Perches

[permalink] [raw]
Subject: [PATCH 14/18] lib/mpi: Remove pr_fmt duplicate logging prefixes

Converting pr_fmt from a simple define to use KBUILD_MODNAME added
some duplicate logging prefixes to existing uses.

Remove them.

Signed-off-by: Joe Perches <[email protected]>
---
lib/mpi/mpicoder.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/mpi/mpicoder.c b/lib/mpi/mpicoder.c
index eead4b339466..8cd6ea3fbb3d 100644
--- a/lib/mpi/mpicoder.c
+++ b/lib/mpi/mpicoder.c
@@ -47,7 +47,7 @@ MPI mpi_read_raw_data(const void *xbuffer, size_t nbytes)

nbits = nbytes * 8;
if (nbits > MAX_EXTERN_MPI_BITS) {
- pr_info("MPI: mpi too large (%u bits)\n", nbits);
+ pr_info("mpi too large (%u bits)\n", nbits);
return NULL;
}
if (nbytes > 0)
@@ -89,14 +89,14 @@ MPI mpi_read_from_buffer(const void *xbuffer, unsigned *ret_nread)
nbits = buffer[0] << 8 | buffer[1];

if (nbits > MAX_EXTERN_MPI_BITS) {
- pr_info("MPI: mpi too large (%u bits)\n", nbits);
+ pr_info("mpi too large (%u bits)\n", nbits);
return ERR_PTR(-EINVAL);
}

nbytes = DIV_ROUND_UP(nbits, 8);
if (nbytes + 2 > *ret_nread) {
- pr_info("MPI: mpi larger than buffer nbytes=%u ret_nread=%u\n",
- nbytes, *ret_nread);
+ pr_info("mpi larger than buffer nbytes=%u ret_nread=%u\n",
+ nbytes, *ret_nread);
return ERR_PTR(-EINVAL);
}

@@ -369,7 +369,7 @@ MPI mpi_read_raw_from_sgl(struct scatterlist *sgl, unsigned int nbytes)
nbits = nbytes * 8;
if (nbits > MAX_EXTERN_MPI_BITS) {
sg_miter_stop(&miter);
- pr_info("MPI: mpi too large (%u bits)\n", nbits);
+ pr_info("mpi too large (%u bits)\n", nbits);
return NULL;
}

--
2.15.0


2018-05-10 15:49:08

by Joe Perches

[permalink] [raw]
Subject: [PATCH 11/18] proc: Remove pr_fmt duplicate logging prefixes

Converting pr_fmt from a simple define to use KBUILD_MODNAME added
some duplicate logging prefixes to existing uses.

Remove them.

Signed-off-by: Joe Perches <[email protected]>
---
fs/proc/root.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/proc/root.c b/fs/proc/root.c
index 61b7340b357a..78399fa8cf38 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -63,14 +63,14 @@ int proc_parse_options(char *options, struct pid_namespace *pid)
return 0;
if (option < HIDEPID_OFF ||
option > HIDEPID_INVISIBLE) {
- pr_err("proc: hidepid value must be between 0 and 2.\n");
+ pr_err("hidepid value must be between 0 and 2\n");
return 0;
}
pid->hide_pid = option;
break;
default:
- pr_err("proc: unrecognized mount option \"%s\" "
- "or missing value\n", p);
+ pr_err("unrecognized mount option \"%s\" or missing value\n",
+ p);
return 0;
}
}
--
2.15.0


2018-05-10 15:49:08

by Joe Perches

[permalink] [raw]
Subject: [PATCH 13/18] printk: Remove pr_fmt duplicate logging prefixes

Converting pr_fmt from a simple define to use KBUILD_MODNAME added
some duplicate logging prefixes to existing uses.

Remove them.

Signed-off-by: Joe Perches <[email protected]>
---
kernel/printk/printk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 247808333ba4..2ee979c30aa0 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2673,7 +2673,7 @@ void register_console(struct console *newcon)

if (newcon->flags & CON_EXTENDED)
if (!nr_ext_console_drivers++)
- pr_info("printk: continuation disabled due to ext consoles, expect more fragments in /dev/kmsg\n");
+ pr_info("continuation disabled due to ext consoles, expect more fragments in /dev/kmsg\n");

if (newcon->flags & CON_PRINTBUFFER) {
/*
--
2.15.0


2018-05-10 15:49:38

by Joe Perches

[permalink] [raw]
Subject: [PATCH 05/18] x86/mtrr: Rename main.c to mtrr.c and remove duplicate prefixes

Kbuild uses the first file as the name for KBUILD_MODNAME.
mtrr uses main.c as its first file, so rename that file to mtrr.c
and fixup the Makefile.

Remove the now duplicate "mtrr: " prefixes from the logging calls.

Signed-off-by: Joe Perches <[email protected]>
---
arch/x86/kernel/cpu/mtrr/Makefile | 2 +-
arch/x86/kernel/cpu/mtrr/{main.c => mtrr.c} | 33 ++++++++++++++---------------
2 files changed, 17 insertions(+), 18 deletions(-)
rename arch/x86/kernel/cpu/mtrr/{main.c => mtrr.c} (96%)

diff --git a/arch/x86/kernel/cpu/mtrr/Makefile b/arch/x86/kernel/cpu/mtrr/Makefile
index ad9e5ed81181..2ad9107ee980 100644
--- a/arch/x86/kernel/cpu/mtrr/Makefile
+++ b/arch/x86/kernel/cpu/mtrr/Makefile
@@ -1,3 +1,3 @@
-obj-y := main.o if.o generic.o cleanup.o
+obj-y := mtrr.o if.o generic.o cleanup.o
obj-$(CONFIG_X86_32) += amd.o cyrix.o centaur.o

diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/mtrr.c
similarity index 96%
rename from arch/x86/kernel/cpu/mtrr/main.c
rename to arch/x86/kernel/cpu/mtrr/mtrr.c
index 7468de429087..0c4f4fba9ec1 100644
--- a/arch/x86/kernel/cpu/mtrr/main.c
+++ b/arch/x86/kernel/cpu/mtrr/mtrr.c
@@ -100,7 +100,7 @@ static int have_wrcomb(void)
if (dev->vendor == PCI_VENDOR_ID_SERVERWORKS &&
dev->device == PCI_DEVICE_ID_SERVERWORKS_LE &&
dev->revision <= 5) {
- pr_info("mtrr: Serverworks LE rev < 6 detected. Write-combining disabled.\n");
+ pr_info("Serverworks LE rev < 6 detected. Write-combining disabled.\n");
pci_dev_put(dev);
return 0;
}
@@ -110,7 +110,7 @@ static int have_wrcomb(void)
*/
if (dev->vendor == PCI_VENDOR_ID_INTEL &&
dev->device == PCI_DEVICE_ID_INTEL_82451NX) {
- pr_info("mtrr: Intel 450NX MMC detected. Write-combining disabled.\n");
+ pr_info("Intel 450NX MMC detected. Write-combining disabled.\n");
pci_dev_put(dev);
return 0;
}
@@ -312,24 +312,24 @@ int mtrr_add_page(unsigned long base, unsigned long size,
return error;

if (type >= MTRR_NUM_TYPES) {
- pr_warn("mtrr: type: %u invalid\n", type);
+ pr_warn("type: %u invalid\n", type);
return -EINVAL;
}

/* If the type is WC, check that this processor supports it */
if ((type == MTRR_TYPE_WRCOMB) && !have_wrcomb()) {
- pr_warn("mtrr: your processor doesn't support write-combining\n");
+ pr_warn("your processor doesn't support write-combining\n");
return -ENOSYS;
}

if (!size) {
- pr_warn("mtrr: zero sized request\n");
+ pr_warn("zero sized request\n");
return -EINVAL;
}

if ((base | (base + size - 1)) >>
(boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) {
- pr_warn("mtrr: base or size exceeds the MTRR width\n");
+ pr_warn("base or size exceeds the MTRR width\n");
return -EINVAL;
}

@@ -360,8 +360,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
} else if (types_compatible(type, ltype))
continue;
}
- pr_warn("mtrr: 0x%lx000,0x%lx000 overlaps existing"
- " 0x%lx000,0x%lx000\n", base, size, lbase,
+ pr_warn("0x%lx000,0x%lx000 overlaps existing 0x%lx000,0x%lx000\n", base, size, lbase,
lsize);
goto out;
}
@@ -369,7 +368,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
if (ltype != type) {
if (types_compatible(type, ltype))
continue;
- pr_warn("mtrr: type mismatch for %lx000,%lx000 old: %s new: %s\n",
+ pr_warn("type mismatch for %lx000,%lx000 old: %s new: %s\n",
base, size, mtrr_attrib_to_str(ltype),
mtrr_attrib_to_str(type));
goto out;
@@ -395,7 +394,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
}
}
} else {
- pr_info("mtrr: no more MTRRs available\n");
+ pr_info("no more MTRRs available\n");
}
error = i;
out:
@@ -407,8 +406,8 @@ int mtrr_add_page(unsigned long base, unsigned long size,
static int mtrr_check(unsigned long base, unsigned long size)
{
if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) {
- pr_warn("mtrr: size and base must be multiples of 4 kiB\n");
- pr_debug("mtrr: size: 0x%lx base: 0x%lx\n", size, base);
+ pr_warn("size and base must be multiples of 4 kiB\n");
+ pr_debug("size: 0x%lx base: 0x%lx\n", size, base);
dump_stack();
return -1;
}
@@ -499,22 +498,22 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
}
}
if (reg < 0) {
- pr_debug("mtrr: no MTRR for %lx000,%lx000 found\n",
+ pr_debug("no MTRR for %lx000,%lx000 found\n",
base, size);
goto out;
}
}
if (reg >= max) {
- pr_warn("mtrr: register: %d too big\n", reg);
+ pr_warn("register: %d too big\n", reg);
goto out;
}
mtrr_if->get(reg, &lbase, &lsize, &ltype);
if (lsize < 1) {
- pr_warn("mtrr: MTRR %d not used\n", reg);
+ pr_warn("MTRR %d not used\n", reg);
goto out;
}
if (mtrr_usage_table[reg] < 1) {
- pr_warn("mtrr: reg: %d has count=0\n", reg);
+ pr_warn("reg: %d has count=0\n", reg);
goto out;
}
if (--mtrr_usage_table[reg] < 1)
@@ -775,7 +774,7 @@ void __init mtrr_bp_init(void)
}

if (!mtrr_enabled()) {
- pr_info("MTRR: Disabled\n");
+ pr_info("Disabled\n");

/*
* PAT initialization relies on MTRR's rendezvous handler.
--
2.15.0


2018-05-10 15:49:48

by Joe Perches

[permalink] [raw]
Subject: [PATCH 09/18] ptp: Remove pr_fmt duplicate logging prefixes

Converting pr_fmt from a simple define to use KBUILD_MODNAME added
some duplicate logging prefixes to existing uses.

Remove them.

Signed-off-by: Joe Perches <[email protected]>
---
drivers/ptp/ptp_clock.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
index 7eacc1c4b3b1..35d9e1aa6564 100644
--- a/drivers/ptp/ptp_clock.c
+++ b/drivers/ptp/ptp_clock.c
@@ -396,13 +396,13 @@ static int __init ptp_init(void)

ptp_class = class_create(THIS_MODULE, "ptp");
if (IS_ERR(ptp_class)) {
- pr_err("ptp: failed to allocate class\n");
+ pr_err("failed to allocate class\n");
return PTR_ERR(ptp_class);
}

err = alloc_chrdev_region(&ptp_devt, 0, MINORMASK + 1, "ptp");
if (err < 0) {
- pr_err("ptp: failed to allocate device region\n");
+ pr_err("failed to allocate device region\n");
goto no_region;
}

--
2.15.0


2018-05-10 15:50:04

by Joe Perches

[permalink] [raw]
Subject: [PATCH 08/18] random: Remove pr_fmt duplicate logging prefixes

Converting pr_fmt from a simple define to use KBUILD_MODNAME added
some duplicate logging prefixes to existing uses.

Remove them.

Signed-off-by: Joe Perches <[email protected]>
---
drivers/char/hw_random/via-rng.c | 10 +++++-----
drivers/char/random.c | 16 +++++++---------
2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/char/hw_random/via-rng.c b/drivers/char/hw_random/via-rng.c
index ffe9b0c6c647..b9367e055468 100644
--- a/drivers/char/hw_random/via-rng.c
+++ b/drivers/char/hw_random/via-rng.c
@@ -24,6 +24,8 @@
* warranty of any kind, whether express or implied.
*/

+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <crypto/padlock.h>
#include <linux/module.h>
#include <linux/kernel.h>
@@ -137,8 +139,7 @@ static int via_rng_init(struct hwrng *rng)
* register */
if (((c->x86 == 6) && (c->x86_model >= 0x0f)) || (c->x86 > 6)){
if (!boot_cpu_has(X86_FEATURE_XSTORE_EN)) {
- pr_err(PFX "can't enable hardware RNG "
- "if XSTORE is not enabled\n");
+ pr_err("can't enable hardware RNG if XSTORE is not enabled\n");
return -ENODEV;
}
return 0;
@@ -176,7 +177,7 @@ static int via_rng_init(struct hwrng *rng)
unneeded */
rdmsr(MSR_VIA_RNG, lo, hi);
if ((lo & VIA_RNG_ENABLE) == 0) {
- pr_err(PFX "cannot enable VIA C3 RNG, aborting\n");
+ pr_err("cannot enable VIA C3 RNG, aborting\n");
return -ENODEV;
}

@@ -202,8 +203,7 @@ static int __init mod_init(void)
pr_info("VIA RNG detected\n");
err = hwrng_register(&via_rng);
if (err) {
- pr_err(PFX "RNG registering failed (%d)\n",
- err);
+ pr_err("RNG registering failed (%d)\n", err);
goto out;
}
out:
diff --git a/drivers/char/random.c b/drivers/char/random.c
index cd888d4ee605..d1e35cfcce8e 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -693,7 +693,7 @@ static void credit_entropy_bits(struct entropy_store *r, int nbits)
}

if (unlikely(entropy_count < 0)) {
- pr_warn("random: negative entropy/overflow: pool %s count %d\n",
+ pr_warn("negative entropy/overflow: pool %s count %d\n",
r->name, entropy_count);
WARN_ON(1);
entropy_count = 0;
@@ -857,7 +857,7 @@ static int crng_fast_load(const char *cp, size_t len)
invalidate_batched_entropy();
crng_init = 1;
wake_up_interruptible(&crng_init_wait);
- pr_notice("random: fast init done\n");
+ pr_notice("fast init done\n");
}
return 1;
}
@@ -942,16 +942,14 @@ static void crng_reseed(struct crng_state *crng, struct entropy_store *r)
crng_init = 2;
process_random_ready_list();
wake_up_interruptible(&crng_init_wait);
- pr_notice("random: crng init done\n");
+ pr_notice("crng init done\n");
if (unseeded_warning.missed) {
- pr_notice("random: %d get_random_xx warning(s) missed "
- "due to ratelimiting\n",
+ pr_notice("%d get_random_xx warning(s) missed due to ratelimiting\n",
unseeded_warning.missed);
unseeded_warning.missed = 0;
}
if (urandom_warning.missed) {
- pr_notice("random: %d urandom warning(s) missed "
- "due to ratelimiting\n",
+ pr_notice("%d urandom warning(s) missed due to ratelimiting\n",
urandom_warning.missed);
urandom_warning.missed = 0;
}
@@ -1380,7 +1378,7 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
ibytes = 0;

if (unlikely(entropy_count < 0)) {
- pr_warn("random: negative entropy count: pool %s count %d\n",
+ pr_warn("negative entropy count: pool %s count %d\n",
r->name, entropy_count);
WARN_ON(1);
entropy_count = 0;
@@ -1596,7 +1594,7 @@ static void _warn_unseeded_randomness(const char *func_name, void *caller,
print_once = true;
#endif
if (__ratelimit(&unseeded_warning))
- pr_notice("random: %s called from %pS with crng_init=%d\n",
+ pr_notice("%s called from %pS with crng_init=%d\n",
func_name, caller, crng_init);
}

--
2.15.0


2018-05-10 15:50:12

by Joe Perches

[permalink] [raw]
Subject: [PATCH 04/18] x86: Remove pr_fmt duplicate logging prefixes

Converting pr_fmt from a default simple #define to use KBUILD_MODNAME
added some duplicate prefixes.

Remove the duplicate prefixes.

Signed-off-by: Joe Perches <[email protected]>
---
arch/x86/events/amd/ibs.c | 2 +-
arch/x86/kernel/e820.c | 32 +++++++++++++++++---------------
arch/x86/kernel/hpet.c | 5 ++---
arch/x86/kernel/uprobes.c | 4 ++--
arch/x86/mm/numa.c | 22 +++++++++++-----------
5 files changed, 33 insertions(+), 32 deletions(-)

diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
index 786fd875de92..4b98101209a1 100644
--- a/arch/x86/events/amd/ibs.c
+++ b/arch/x86/events/amd/ibs.c
@@ -889,7 +889,7 @@ static void force_ibs_eilvt_setup(void)
if (!ibs_eilvt_valid())
goto out;

- pr_info("IBS: LVT offset %d assigned\n", offset);
+ pr_info("LVT offset %d assigned\n", offset);

return;
out:
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 6a2cb1442e05..d1f25c831447 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -155,7 +155,8 @@ static void __init __e820__range_add(struct e820_table *table, u64 start, u64 si
int x = table->nr_entries;

if (x >= ARRAY_SIZE(table->entries)) {
- pr_err("e820: too many entries; ignoring [mem %#010llx-%#010llx]\n", start, start + size - 1);
+ pr_err("too many entries; ignoring [mem %#010llx-%#010llx]\n",
+ start, start + size - 1);
return;
}

@@ -190,9 +191,10 @@ void __init e820__print_table(char *who)
int i;

for (i = 0; i < e820_table->nr_entries; i++) {
- pr_info("%s: [mem %#018Lx-%#018Lx] ", who,
- e820_table->entries[i].addr,
- e820_table->entries[i].addr + e820_table->entries[i].size - 1);
+ pr_info("%s: [mem %#018Lx-%#018Lx] ",
+ who,
+ e820_table->entries[i].addr,
+ e820_table->entries[i].addr + e820_table->entries[i].size - 1);

e820_print_type(e820_table->entries[i].type);
pr_cont("\n");
@@ -574,7 +576,7 @@ void __init e820__update_table_print(void)
if (e820__update_table(e820_table))
return;

- pr_info("e820: modified physical RAM map:\n");
+ pr_info("modified physical RAM map:\n");
e820__print_table("modified");
}

@@ -636,9 +638,8 @@ __init void e820__setup_pci_gap(void)
if (!found) {
#ifdef CONFIG_X86_64
gapstart = (max_pfn << PAGE_SHIFT) + 1024*1024;
- pr_err(
- "e820: Cannot find an available gap in the 32-bit address range\n"
- "e820: PCI devices with unassigned 32-bit BARs may not work!\n");
+ pr_err("Cannot find an available gap in the 32-bit address range\n");
+ pr_err("PCI devices with unassigned 32-bit BARs may not work!\n");
#else
gapstart = 0x10000000;
#endif
@@ -649,7 +650,8 @@ __init void e820__setup_pci_gap(void)
*/
pci_mem_start = gapstart;

- pr_info("e820: [mem %#010lx-%#010lx] available for PCI devices\n", gapstart, gapstart + gapsize - 1);
+ pr_info("[mem %#010lx-%#010lx] available for PCI devices\n",
+ gapstart, gapstart + gapsize - 1);
}

/*
@@ -711,7 +713,7 @@ void __init e820__memory_setup_extended(u64 phys_addr, u32 data_len)
memcpy(e820_table_firmware, e820_table, sizeof(*e820_table_firmware));

early_memunmap(sdata, data_len);
- pr_info("e820: extended physical RAM map:\n");
+ pr_info("extended physical RAM map:\n");
e820__print_table("extended");
}

@@ -780,7 +782,7 @@ u64 __init e820__memblock_alloc_reserved(u64 size, u64 align)
addr = __memblock_alloc_base(size, align, MEMBLOCK_ALLOC_ACCESSIBLE);
if (addr) {
e820__range_update_kexec(addr, size, E820_TYPE_RAM, E820_TYPE_RESERVED);
- pr_info("e820: update e820_table_kexec for e820__memblock_alloc_reserved()\n");
+ pr_info("update e820_table_kexec for e820__memblock_alloc_reserved()\n");
e820__update_table_kexec();
}

@@ -830,8 +832,8 @@ static unsigned long __init e820_end_pfn(unsigned long limit_pfn, enum e820_type
if (last_pfn > max_arch_pfn)
last_pfn = max_arch_pfn;

- pr_info("e820: last_pfn = %#lx max_arch_pfn = %#lx\n",
- last_pfn, max_arch_pfn);
+ pr_info("last_pfn = %#lx max_arch_pfn = %#lx\n",
+ last_pfn, max_arch_pfn);
return last_pfn;
}

@@ -1005,7 +1007,7 @@ void __init e820__finish_early_params(void)
if (e820__update_table(e820_table) < 0)
early_panic("Invalid user supplied memory map");

- pr_info("e820: user-defined physical RAM map:\n");
+ pr_info("user-defined physical RAM map:\n");
e820__print_table("user");
}
}
@@ -1238,7 +1240,7 @@ void __init e820__memory_setup(void)
memcpy(e820_table_kexec, e820_table, sizeof(*e820_table_kexec));
memcpy(e820_table_firmware, e820_table, sizeof(*e820_table_firmware));

- pr_info("e820: BIOS-provided physical RAM map:\n");
+ pr_info("BIOS-provided physical RAM map:\n");
e820__print_table(who);
}

diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index 8ce4212e2b8d..b6be34ee88e9 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -975,8 +975,7 @@ int __init hpet_enable(void)
cfg &= ~(HPET_CFG_ENABLE | HPET_CFG_LEGACY);
hpet_writel(cfg, HPET_CFG);
if (cfg)
- pr_warn("HPET: Unrecognized bits %#x set in global cfg\n",
- cfg);
+ pr_warn("Unrecognized bits %#x set in global cfg\n", cfg);

for (i = 0; i <= last; ++i) {
cfg = hpet_readl(HPET_Tn_CFG(i));
@@ -988,7 +987,7 @@ int __init hpet_enable(void)
| HPET_TN_64BIT_CAP | HPET_TN_32BIT | HPET_TN_ROUTE
| HPET_TN_FSB | HPET_TN_FSB_CAP);
if (cfg)
- pr_warn("HPET: Unrecognized bits %#x set in cfg#%u\n",
+ pr_warn("Unrecognized bits %#x set in cfg#%u\n",
cfg, i);
}
hpet_print_config();
diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
index 85c7ef23d99f..d1c468741915 100644
--- a/arch/x86/kernel/uprobes.c
+++ b/arch/x86/kernel/uprobes.c
@@ -1079,8 +1079,8 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
return orig_ret_vaddr;

if (nleft != rasize) {
- pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
- "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
+ pr_err("return address clobbered: pid=%d, %%sp=%#lx, %%ip=%#lx\n",
+ current->pid, regs->sp, regs->ip);

force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
}
diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index 25504d5aa816..fa150855647c 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -136,13 +136,13 @@ static int __init numa_add_memblk_to(int nid, u64 start, u64 end,

/* whine about and ignore invalid blks */
if (start > end || nid < 0 || nid >= MAX_NUMNODES) {
- pr_warning("NUMA: Warning: invalid memblk node %d [mem %#010Lx-%#010Lx]\n",
- nid, start, end - 1);
+ pr_warn("Warning: invalid memblk node %d [mem %#010Lx-%#010Lx]\n",
+ nid, start, end - 1);
return 0;
}

if (mi->nr_blks >= NR_NODE_MEMBLKS) {
- pr_err("NUMA: too many memblk ranges\n");
+ pr_err("too many memblk ranges\n");
return -EINVAL;
}

@@ -267,14 +267,14 @@ int __init numa_cleanup_meminfo(struct numa_meminfo *mi)
*/
if (bi->end > bj->start && bi->start < bj->end) {
if (bi->nid != bj->nid) {
- pr_err("NUMA: node %d [mem %#010Lx-%#010Lx] overlaps with node %d [mem %#010Lx-%#010Lx]\n",
+ pr_err("node %d [mem %#010Lx-%#010Lx] overlaps with node %d [mem %#010Lx-%#010Lx]\n",
bi->nid, bi->start, bi->end - 1,
bj->nid, bj->start, bj->end - 1);
return -EINVAL;
}
- pr_warning("NUMA: Warning: node %d [mem %#010Lx-%#010Lx] overlaps with itself [mem %#010Lx-%#010Lx]\n",
- bi->nid, bi->start, bi->end - 1,
- bj->start, bj->end - 1);
+ pr_warn("Warning: node %d [mem %#010Lx-%#010Lx] overlaps with itself [mem %#010Lx-%#010Lx]\n",
+ bi->nid, bi->start, bi->end - 1,
+ bj->start, bj->end - 1);
}

/*
@@ -364,7 +364,7 @@ static int __init numa_alloc_distance(void)
phys = memblock_find_in_range(0, PFN_PHYS(max_pfn_mapped),
size, PAGE_SIZE);
if (!phys) {
- pr_warning("NUMA: Warning: can't allocate distance table!\n");
+ pr_warn("Warning: can't allocate distance table!\n");
/* don't retry until explicitly reset */
numa_distance = (void *)1LU;
return -ENOMEM;
@@ -410,14 +410,14 @@ void __init numa_set_distance(int from, int to, int distance)

if (from >= numa_distance_cnt || to >= numa_distance_cnt ||
from < 0 || to < 0) {
- pr_warn_once("NUMA: Warning: node ids are out of bound, from=%d to=%d distance=%d\n",
- from, to, distance);
+ pr_warn_once("Warning: node ids are out of bound, from=%d to=%d distance=%d\n",
+ from, to, distance);
return;
}

if ((u8)distance != distance ||
(from == to && distance != LOCAL_DISTANCE)) {
- pr_warn_once("NUMA: Warning: invalid distance parameter, from=%d to=%d distance=%d\n",
+ pr_warn_once("Warning: invalid distance parameter, from=%d to=%d distance=%d\n",
from, to, distance);
return;
}
--
2.15.0


2018-05-10 15:50:19

by Joe Perches

[permalink] [raw]
Subject: [PATCH 12/18] uprobes: Remove pr_fmt duplicate logging prefixes

Converting pr_fmt from a simple define to use KBUILD_MODNAME added
some duplicate logging prefixes to existing uses.

Remove them.

Signed-off-by: Joe Perches <[email protected]>
---
kernel/events/uprobes.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 1725b902983f..a7448ddaa302 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -1469,8 +1469,7 @@ static int dup_utask(struct task_struct *t, struct uprobe_task *o_utask)

static void uprobe_warn(struct task_struct *t, const char *msg)
{
- pr_warn("uprobe: %s:%d failed to %s\n",
- current->comm, current->pid, msg);
+ pr_warn("%s:%d failed to %s\n", current->comm, current->pid, msg);
}

static void dup_xol_work(struct callback_head *work)
--
2.15.0


2018-05-10 15:50:21

by Joe Perches

[permalink] [raw]
Subject: [PATCH 07/18] blk-mq: Remove pr_fmt duplicate logging prefixes

Converting pr_fmt from a simple define to use KBUILD_MODNAME added
some duplicate logging prefixes to existing uses.

Remove them.

Signed-off-by: Joe Perches <[email protected]>
---
block/blk-mq.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 9ce9cac16c3f..37e6206e745c 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2782,13 +2782,13 @@ static int blk_mq_alloc_rq_maps(struct blk_mq_tag_set *set)
} while (set->queue_depth);

if (!set->queue_depth || err) {
- pr_err("blk-mq: failed to allocate request map\n");
+ pr_err("failed to allocate request map\n");
return -ENOMEM;
}

if (depth != set->queue_depth)
- pr_info("blk-mq: reduced tag depth (%u -> %u)\n",
- depth, set->queue_depth);
+ pr_info("reduced tag depth (%u -> %u)\n",
+ depth, set->queue_depth);

return 0;
}
@@ -2845,8 +2845,7 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
return -EINVAL;

if (set->queue_depth > BLK_MQ_MAX_DEPTH) {
- pr_info("blk-mq: reduced tag depth to %u\n",
- BLK_MQ_MAX_DEPTH);
+ pr_info("reduced tag depth to %u\n", BLK_MQ_MAX_DEPTH);
set->queue_depth = BLK_MQ_MAX_DEPTH;
}

--
2.15.0


2018-05-10 15:50:35

by Joe Perches

[permalink] [raw]
Subject: [PATCH 01/18] kernel: Use pr_fmt

Sometime in the future, it would be useful to convert pr_fmt from a
default simple define to use a default prefix with KBUILD_MODNAME.

There are files in kernel/ that use pr_<level>, some with an embedded
prefix, that also do not have a specific pr_fmt define.

Add pr_fmt for those files.

There are some differences in output as some messages are now prefixed
with their KBUILD_MODNAME.

Miscellanea:

o Align multiline statements to open parenthesis
o Wrap and realign arguments to 80 columns where sensible
o Coalesce formats

Signed-off-by: Joe Perches <[email protected]>
---
kernel/acct.c | 2 ++
kernel/async.c | 14 ++++++------
kernel/audit_tree.c | 2 +-
kernel/backtracetest.c | 8 +++----
kernel/crash_core.c | 29 ++++++++++++++-----------
kernel/exit.c | 2 ++
kernel/hung_task.c | 13 +++++------
kernel/kprobes.c | 20 ++++++++++-------
kernel/module.c | 59 +++++++++++++++++++++++---------------------------
kernel/panic.c | 3 +++
kernel/params.c | 13 ++++++-----
kernel/pid.c | 2 ++
kernel/profile.c | 2 ++
kernel/range.c | 2 +-
kernel/relay.c | 5 ++++-
kernel/seccomp.c | 4 +++-
kernel/signal.c | 10 +++++----
kernel/smpboot.c | 5 ++++-
kernel/taskstats.c | 4 +++-
kernel/torture.c | 6 +++--
kernel/tracepoint.c | 3 +++
kernel/workqueue.c | 2 ++
22 files changed, 122 insertions(+), 88 deletions(-)

diff --git a/kernel/acct.c b/kernel/acct.c
index addf7732fb56..c3d393655f11 100644
--- a/kernel/acct.c
+++ b/kernel/acct.c
@@ -44,6 +44,8 @@
* a struct file opened for write. Fixed. 2/6/2000, AV.
*/

+#define pr_fmt(fmt) fmt
+
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/acct.h>
diff --git a/kernel/async.c b/kernel/async.c
index a893d6170944..9a6ab6016713 100644
--- a/kernel/async.c
+++ b/kernel/async.c
@@ -120,8 +120,8 @@ static void async_run_entry_fn(struct work_struct *work)
/* 1) run (and print duration) */
if (initcall_debug && system_state < SYSTEM_RUNNING) {
pr_debug("calling %lli_%pF @ %i\n",
- (long long)entry->cookie,
- entry->func, task_pid_nr(current));
+ (long long)entry->cookie,
+ entry->func, task_pid_nr(current));
calltime = ktime_get();
}
entry->func(entry->data, entry->cookie);
@@ -129,9 +129,9 @@ static void async_run_entry_fn(struct work_struct *work)
rettime = ktime_get();
delta = ktime_sub(rettime, calltime);
pr_debug("initcall %lli_%pF returned 0 after %lld usecs\n",
- (long long)entry->cookie,
- entry->func,
- (long long)ktime_to_ns(delta) >> 10);
+ (long long)entry->cookie,
+ entry->func,
+ (long long)ktime_to_ns(delta) >> 10);
}

/* 2) remove self from the pending queues */
@@ -300,8 +300,8 @@ void async_synchronize_cookie_domain(async_cookie_t cookie, struct async_domain
delta = ktime_sub(endtime, starttime);

pr_debug("async_continuing @ %i after %lli usec\n",
- task_pid_nr(current),
- (long long)ktime_to_ns(delta) >> 10);
+ task_pid_nr(current),
+ (long long)ktime_to_ns(delta) >> 10);
}
}
EXPORT_SYMBOL_GPL(async_synchronize_cookie_domain);
diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
index 67e6956c0b61..f34f90b4a346 100644
--- a/kernel/audit_tree.c
+++ b/kernel/audit_tree.c
@@ -739,7 +739,7 @@ static int audit_launch_prune(void)
prune_thread = kthread_run(prune_tree_thread, NULL,
"audit_prune_tree");
if (IS_ERR(prune_thread)) {
- pr_err("cannot start thread audit_prune_tree");
+ pr_err("cannot start thread audit_prune_tree\n");
prune_thread = NULL;
return -ENOMEM;
}
diff --git a/kernel/backtracetest.c b/kernel/backtracetest.c
index 1323360d90e3..d10cc39b0134 100644
--- a/kernel/backtracetest.c
+++ b/kernel/backtracetest.c
@@ -19,7 +19,7 @@

static void backtrace_test_normal(void)
{
- pr_info("Testing a backtrace from process context.\n");
+ pr_info("Testing a backtrace from process context\n");
pr_info("The following trace is a kernel self test and not a bug!\n");

dump_stack();
@@ -37,7 +37,7 @@ static DECLARE_TASKLET(backtrace_tasklet, &backtrace_test_irq_callback, 0);

static void backtrace_test_irq(void)
{
- pr_info("Testing a backtrace from irq context.\n");
+ pr_info("Testing a backtrace from irq context\n");
pr_info("The following trace is a kernel self test and not a bug!\n");

init_completion(&backtrace_work);
@@ -51,7 +51,7 @@ static void backtrace_test_saved(void)
struct stack_trace trace;
unsigned long entries[8];

- pr_info("Testing a saved backtrace.\n");
+ pr_info("Testing a saved backtrace\n");
pr_info("The following trace is a kernel self test and not a bug!\n");

trace.nr_entries = 0;
@@ -65,7 +65,7 @@ static void backtrace_test_saved(void)
#else
static void backtrace_test_saved(void)
{
- pr_info("Saved backtrace test skipped.\n");
+ pr_info("Saved backtrace test skipped\n");
}
#endif

diff --git a/kernel/crash_core.c b/kernel/crash_core.c
index f7674d676889..4eda1ee9da8c 100644
--- a/kernel/crash_core.c
+++ b/kernel/crash_core.c
@@ -6,6 +6,8 @@
* Version 2. See the file COPYING for more details.
*/

+#define pr_fmt(fmt) "crashkernel: " fmt
+
#include <linux/crash_core.h>
#include <linux/utsname.h>
#include <linux/vmalloc.h>
@@ -49,12 +51,12 @@ static int __init parse_crashkernel_mem(char *cmdline,
/* get the start of the range */
start = memparse(cur, &tmp);
if (cur == tmp) {
- pr_warn("crashkernel: Memory value expected\n");
+ pr_warn("Memory value expected\n");
return -EINVAL;
}
cur = tmp;
if (*cur != '-') {
- pr_warn("crashkernel: '-' expected\n");
+ pr_warn("'-' expected\n");
return -EINVAL;
}
cur++;
@@ -63,18 +65,18 @@ static int __init parse_crashkernel_mem(char *cmdline,
if (*cur != ':') {
end = memparse(cur, &tmp);
if (cur == tmp) {
- pr_warn("crashkernel: Memory value expected\n");
+ pr_warn("Memory value expected\n");
return -EINVAL;
}
cur = tmp;
if (end <= start) {
- pr_warn("crashkernel: end <= start\n");
+ pr_warn("end <= start\n");
return -EINVAL;
}
}

if (*cur != ':') {
- pr_warn("crashkernel: ':' expected\n");
+ pr_warn("':' expected\n");
return -EINVAL;
}
cur++;
@@ -86,7 +88,7 @@ static int __init parse_crashkernel_mem(char *cmdline,
}
cur = tmp;
if (size >= system_ram) {
- pr_warn("crashkernel: invalid size\n");
+ pr_warn("invalid size\n");
return -EINVAL;
}

@@ -108,8 +110,9 @@ static int __init parse_crashkernel_mem(char *cmdline,
return -EINVAL;
}
}
- } else
- pr_info("crashkernel size resulted in zero bytes\n");
+ } else {
+ pr_info("size resulted in zero bytes\n");
+ }

return 0;
}
@@ -129,14 +132,14 @@ static int __init parse_crashkernel_simple(char *cmdline,

*crash_size = memparse(cmdline, &cur);
if (cmdline == cur) {
- pr_warn("crashkernel: memory value expected\n");
+ pr_warn("memory value expected\n");
return -EINVAL;
}

if (*cur == '@')
*crash_base = memparse(cur+1, &cur);
else if (*cur != ' ' && *cur != '\0') {
- pr_warn("crashkernel: unrecognized char: %c\n", *cur);
+ pr_warn("unrecognized char: %c\n", *cur);
return -EINVAL;
}

@@ -167,18 +170,18 @@ static int __init parse_crashkernel_suffix(char *cmdline,

*crash_size = memparse(cmdline, &cur);
if (cmdline == cur) {
- pr_warn("crashkernel: memory value expected\n");
+ pr_warn("memory value expected\n");
return -EINVAL;
}

/* check with suffix */
if (strncmp(cur, suffix, strlen(suffix))) {
- pr_warn("crashkernel: unrecognized char: %c\n", *cur);
+ pr_warn("unrecognized char: %c\n", *cur);
return -EINVAL;
}
cur += strlen(suffix);
if (*cur != ' ' && *cur != '\0') {
- pr_warn("crashkernel: unrecognized char: %c\n", *cur);
+ pr_warn("unrecognized char: %c\n", *cur);
return -EINVAL;
}

diff --git a/kernel/exit.c b/kernel/exit.c
index 68e1598d7931..679d4de9a5fa 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -4,6 +4,8 @@
* Copyright (C) 1991, 1992 Linus Torvalds
*/

+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/sched/autogroup.h>
diff --git a/kernel/hung_task.c b/kernel/hung_task.c
index 32b479468e4d..c66278415811 100644
--- a/kernel/hung_task.c
+++ b/kernel/hung_task.c
@@ -113,14 +113,13 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout)
if (sysctl_hung_task_warnings) {
if (sysctl_hung_task_warnings > 0)
sysctl_hung_task_warnings--;
- pr_err("INFO: task %s:%d blocked for more than %ld seconds.\n",
- t->comm, t->pid, timeout);
+ pr_err("INFO: task %s:%d blocked for more than %ld seconds\n",
+ t->comm, t->pid, timeout);
pr_err(" %s %s %.*s\n",
- print_tainted(), init_utsname()->release,
- (int)strcspn(init_utsname()->version, " "),
- init_utsname()->version);
- pr_err("\"echo 0 > /proc/sys/kernel/hung_task_timeout_secs\""
- " disables this message.\n");
+ print_tainted(), init_utsname()->release,
+ (int)strcspn(init_utsname()->version, " "),
+ init_utsname()->version);
+ pr_err("\"echo 0 > /proc/sys/kernel/hung_task_timeout_secs\" disables this message\n");
sched_show_task(t);
hung_task_show_lock = true;
}
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index ea619021d901..0b8facde8dd0 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -31,6 +31,9 @@
* <[email protected]> and Prasanna S Panchamukhi
* <[email protected]> added function-return probes.
*/
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/kprobes.h>
#include <linux/hash.h>
#include <linux/init.h>
@@ -985,7 +988,8 @@ static int arm_kprobe_ftrace(struct kprobe *p)
ret = ftrace_set_filter_ip(&kprobe_ftrace_ops,
(unsigned long)p->addr, 0, 0);
if (ret) {
- pr_debug("Failed to arm kprobe-ftrace at %p (%d)\n", p->addr, ret);
+ pr_debug("Failed to arm kprobe-ftrace at %p (%d)\n",
+ p->addr, ret);
return ret;
}

@@ -2198,7 +2202,7 @@ static int __init populate_kprobe_blacklist(unsigned long *start,
if (!kernel_text_address(entry) ||
!kallsyms_lookup_size_offset(entry, &size, &offset)) {
pr_err("Failed to find blacklist at %p\n",
- (void *)entry);
+ (void *)entry);
continue;
}

@@ -2281,8 +2285,8 @@ static int __init init_kprobes(void)
err = populate_kprobe_blacklist(__start_kprobe_blacklist,
__stop_kprobe_blacklist);
if (err) {
- pr_err("kprobes: failed to populate blacklist: %d\n", err);
- pr_err("Please take care of using kprobes.\n");
+ pr_err("failed to populate blacklist: %d\n", err);
+ pr_err("Please take care of using kprobes\n");
}

if (kretprobe_blacklist_size) {
@@ -2488,10 +2492,10 @@ static int arm_all_kprobes(void)
}

if (errors)
- pr_warn("Kprobes globally enabled, but failed to arm %d out of %d probes\n",
+ pr_warn("globally enabled, but failed to arm %d out of %d probes\n",
errors, total);
else
- pr_info("Kprobes globally enabled\n");
+ pr_info("globally enabled\n");

already_enabled:
mutex_unlock(&kprobe_mutex);
@@ -2531,10 +2535,10 @@ static int disarm_all_kprobes(void)
}

if (errors)
- pr_warn("Kprobes globally disabled, but failed to disarm %d out of %d probes\n",
+ pr_warn("globally disabled, but failed to disarm %d out of %d probes\n",
errors, total);
else
- pr_info("Kprobes globally disabled\n");
+ pr_info("globally disabled\n");

mutex_unlock(&kprobe_mutex);

diff --git a/kernel/module.c b/kernel/module.c
index 36543e382389..94624b46c9bd 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -16,6 +16,9 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/export.h>
#include <linux/extable.h>
#include <linux/moduleloader.h>
@@ -523,21 +526,17 @@ static bool check_symbol(const struct symsearch *syms,
if (syms->licence == GPL_ONLY)
return false;
if (syms->licence == WILL_BE_GPL_ONLY && fsa->warn) {
- pr_warn("Symbol %s is being used by a non-GPL module, "
- "which will not be allowed in the future\n",
+ pr_warn("Symbol %s is being used by a non-GPL module, which will not be allowed in the future.\n",
fsa->name);
}
}

#ifdef CONFIG_UNUSED_SYMBOLS
if (syms->unused && fsa->warn) {
- pr_warn("Symbol %s is marked as UNUSED, however this module is "
- "using it.\n", fsa->name);
+ pr_warn("Symbol %s is marked as UNUSED, however this module is using it.\n",
+ fsa->name);
pr_warn("This symbol will go away in the future.\n");
- pr_warn("Please evaluate if this is the right api to use and "
- "if it really is, submit a report to the linux kernel "
- "mailing list together with submitting your code for "
- "inclusion.\n");
+ pr_warn("Please evaluate if this is the right api to use and if it really is, submit a report to the linux kernel mailing list together with submitting your code for inclusion.\n");
}
#endif

@@ -843,7 +842,7 @@ static int add_module_usage(struct module *a, struct module *b)
{
struct module_use *use;

- pr_debug("Allocating new usage for %s.\n", a->name);
+ pr_debug("Allocating new usage for %s\n", a->name);
use = kmalloc(sizeof(*use), GFP_ATOMIC);
if (!use)
return -ENOMEM;
@@ -1265,7 +1264,7 @@ static int try_to_force_load(struct module *mod, const char *reason)
{
#ifdef CONFIG_MODULE_FORCE_LOAD
if (!test_taint(TAINT_FORCED_MODULE))
- pr_warn("%s: %s: kernel tainted.\n", mod->name, reason);
+ pr_warn("%s: %s: kernel tainted\n", mod->name, reason);
add_taint_module(mod, TAINT_FORCED_MODULE, LOCKDEP_NOW_UNRELIABLE);
return 0;
#else
@@ -1435,7 +1434,7 @@ resolve_symbol_wait(struct module *mod,
!IS_ERR(ksym = resolve_symbol(mod, info, name, owner))
|| PTR_ERR(ksym) != -EBUSY,
30 * HZ) <= 0) {
- pr_warn("%s: gave up waiting for init of module %s.\n",
+ pr_warn("%s: gave up waiting for init of module %s\n",
mod->name, owner);
}
return ksym;
@@ -2224,8 +2223,7 @@ static int verify_export_symbols(struct module *mod)
for (i = 0; i < ARRAY_SIZE(arr); i++) {
for (s = arr[i].sym; s < arr[i].sym + arr[i].num; s++) {
if (find_symbol(s->name, &owner, NULL, true, false)) {
- pr_err("%s: exports duplicate symbol %s"
- " (owned by %s)\n",
+ pr_err("%s: exports duplicate symbol %s (owned by %s)\n",
mod->name, s->name, module_name(owner));
return -ENOEXEC;
}
@@ -2257,14 +2255,14 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
supposed to happen. */
pr_debug("Common symbol: %s\n", name);
pr_warn("%s: please compile with -fno-common\n",
- mod->name);
+ mod->name);
ret = -ENOEXEC;
break;

case SHN_ABS:
/* Don't need to do anything */
pr_debug("Absolute symbol: 0x%08lx\n",
- (long)sym[i].st_value);
+ (long)sym[i].st_value);
break;

case SHN_LIVEPATCH:
@@ -2454,7 +2452,7 @@ static void set_license(struct module *mod, const char *license)

if (!license_is_gpl_compatible(license)) {
if (!test_taint(TAINT_PROPRIETARY_MODULE))
- pr_warn("%s: module license '%s' taints kernel.\n",
+ pr_warn("%s: module license '%s' taints kernel\n",
mod->name, license);
add_taint_module(mod, TAINT_PROPRIETARY_MODULE,
LOCKDEP_NOW_UNRELIABLE);
@@ -2717,7 +2715,7 @@ static void dynamic_debug_setup(struct module *mod, struct _ddebug *debug, unsig
#ifdef CONFIG_DYNAMIC_DEBUG
if (ddebug_add_module(debug, num, mod->name))
pr_err("dynamic debug error adding module: %s\n",
- debug->modname);
+ debug->modname);
#endif
}

@@ -2849,7 +2847,7 @@ static int check_modinfo_livepatch(struct module *mod, struct load_info *info)
static int check_modinfo_livepatch(struct module *mod, struct load_info *info)
{
if (get_modinfo(info, "livepatch")) {
- pr_err("%s: module is marked as livepatch module, but livepatch support is disabled",
+ pr_err("%s: module is marked as livepatch module, but livepatch support is disabled\n",
mod->name);
return -ENOEXEC;
}
@@ -2863,7 +2861,7 @@ static void check_modinfo_retpoline(struct module *mod, struct load_info *info)
if (retpoline_module_ok(get_modinfo(info, "retpoline")))
return;

- pr_warn("%s: loading module not compiled with retpoline compiler.\n",
+ pr_warn("%s: loading module not compiled with retpoline compiler\n",
mod->name);
}

@@ -3037,8 +3035,8 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)

if (get_modinfo(info, "staging")) {
add_taint_module(mod, TAINT_CRAP, LOCKDEP_STILL_OK);
- pr_warn("%s: module is from the staging directory, the quality "
- "is unknown, you have been warned.\n", mod->name);
+ pr_warn("%s: module is from the staging directory, the quality is unknown, you have been warned\n",
+ mod->name);
}

err = check_modinfo_livepatch(mod, info);
@@ -3089,8 +3087,8 @@ static int find_module_sections(struct module *mod, struct load_info *info)
* This shouldn't happen with same compiler and binutils
* building all parts of the module.
*/
- pr_warn("%s: has both .ctors and .init_array.\n",
- mod->name);
+ pr_warn("%s: has both .ctors and .init_array\n",
+ mod->name);
return -EINVAL;
}
#endif
@@ -3227,7 +3225,7 @@ static int check_module_license_and_versions(struct module *mod)
LOCKDEP_NOW_UNRELIABLE);

if (!prev_taint && test_taint(TAINT_PROPRIETARY_MODULE))
- pr_warn("%s: module license taints kernel.\n", mod->name);
+ pr_warn("%s: module license taints kernel\n", mod->name);

#ifdef CONFIG_MODVERSIONS
if ((mod->num_syms && !mod->crcs)
@@ -3459,8 +3457,7 @@ static noinline int do_init_module(struct module *mod)
goto fail_free_freeinit;
}
if (ret > 0) {
- pr_warn("%s: '%s'->init suspiciously returned %d, it should "
- "follow 0/-E convention\n"
+ pr_warn("%s: '%s'->init suspiciously returned %d, it should follow 0/-E convention\n"
"%s: loading module anyway...\n",
__func__, mod->name, ret, __func__);
dump_stack();
@@ -3686,9 +3683,8 @@ static int load_module(struct load_info *info, const char __user *uargs,
#ifdef CONFIG_MODULE_SIG
mod->sig_ok = info->sig_ok;
if (!mod->sig_ok) {
- pr_notice_once("%s: module verification failed: signature "
- "and/or required key missing - tainting "
- "kernel\n", mod->name);
+ pr_notice_once("%s: module verification failed: signature and/or required key missing - tainting kernel\n",
+ mod->name);
add_taint_module(mod, TAINT_UNSIGNED_MODULE, LOCKDEP_STILL_OK);
}
#endif
@@ -3763,7 +3759,7 @@ static int load_module(struct load_info *info, const char __user *uargs,
goto coming_cleanup;
} else if (after_dashes) {
pr_warn("%s: parameters '%s' after `--' ignored\n",
- mod->name, after_dashes);
+ mod->name, after_dashes);
}

/* Link in to sysfs. */
@@ -3843,8 +3839,7 @@ SYSCALL_DEFINE3(init_module, void __user *, umod,
if (err)
return err;

- pr_debug("init_module: umod=%p, len=%lu, uargs=%p\n",
- umod, len, uargs);
+ pr_debug("init_module: umod=%p, len=%lu, uargs=%p\n", umod, len, uargs);

err = copy_module_from_user(umod, len, &info);
if (err)
diff --git a/kernel/panic.c b/kernel/panic.c
index 42e487488554..e34631818bb7 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -8,6 +8,9 @@
* This function is used through-out the kernel (including mm and fs)
* to indicate a major problem.
*/
+
+#define pr_fmt(fmt) fmt
+
#include <linux/debug_locks.h>
#include <linux/sched/debug.h>
#include <linux/interrupt.h>
diff --git a/kernel/params.c b/kernel/params.c
index ce89f757e6da..757049bfa346 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -15,6 +15,9 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/errno.h>
@@ -141,8 +144,8 @@ static int parse_one(char *param,
if (!val &&
!(params[i].ops->flags & KERNEL_PARAM_OPS_FL_NOARG))
return -EINVAL;
- pr_debug("handling %s with %p\n", param,
- params[i].ops->set);
+ pr_debug("handling %s with %p\n",
+ param, params[i].ops->set);
kernel_param_lock(params[i].mod);
param_check_unsafe(&params[i]);
err = params[i].ops->set(val, &params[i]);
@@ -496,8 +499,8 @@ int param_set_copystring(const char *val, const struct kernel_param *kp)
const struct kparam_string *kps = kp->str;

if (strlen(val)+1 > kps->maxlen) {
- pr_err("%s: string doesn't fit in %u chars.\n",
- kp->name, kps->maxlen-1);
+ pr_err("%s: string doesn't fit in %u chars\n",
+ kp->name, kps->maxlen - 1);
return -ENOSPC;
}
strcpy(kps->string, val);
@@ -763,7 +766,7 @@ static struct module_kobject * __init locate_module_kobject(const char *name)
#endif
if (err) {
kobject_put(&mk->kobj);
- pr_crit("Adding module '%s' to sysfs failed (%d), the system may be unstable.\n",
+ pr_crit("Adding module '%s' to sysfs failed (%d), the system may be unstable\n",
name, err);
return NULL;
}
diff --git a/kernel/pid.c b/kernel/pid.c
index 157fe4b19971..2ddd7adfa77d 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -26,6 +26,8 @@
*
*/

+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/mm.h>
#include <linux/export.h>
#include <linux/slab.h>
diff --git a/kernel/profile.c b/kernel/profile.c
index 9aa2a4445b0d..e5cc8f360236 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -14,6 +14,8 @@
* Oracle, 2004
*/

+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/export.h>
#include <linux/profile.h>
#include <linux/bootmem.h>
diff --git a/kernel/range.c b/kernel/range.c
index d84de6766472..e828c950d401 100644
--- a/kernel/range.c
+++ b/kernel/range.c
@@ -102,7 +102,7 @@ void subtract_range(struct range *range, int az, u64 start, u64 end)
range[i].start = end;
} else {
pr_err("%s: run out of slot in ranges\n",
- __func__);
+ __func__);
}
range[j].end = start;
continue;
diff --git a/kernel/relay.c b/kernel/relay.c
index c955b10c973c..02f3790af754 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -12,6 +12,9 @@
*
* This file is released under the GPL.
*/
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/errno.h>
#include <linux/stddef.h>
#include <linux/slab.h>
@@ -527,7 +530,7 @@ int relay_prepare_cpu(unsigned int cpu)
continue;
buf = relay_open_buf(chan, cpu);
if (!buf) {
- pr_err("relay: cpu %d buffer creation failed\n", cpu);
+ pr_err("cpu %d buffer creation failed\n", cpu);
mutex_unlock(&relay_channels_mutex);
return -ENOMEM;
}
diff --git a/kernel/seccomp.c b/kernel/seccomp.c
index 5386749cdd21..de696bc574b4 100644
--- a/kernel/seccomp.c
+++ b/kernel/seccomp.c
@@ -14,6 +14,8 @@
* of Berkeley Packet Filters/Linux Socket Filters.
*/

+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/refcount.h>
#include <linux/audit.h>
#include <linux/compat.h>
@@ -1323,7 +1325,7 @@ static int __init seccomp_sysctl_init(void)

hdr = register_sysctl_paths(seccomp_sysctl_path, seccomp_sysctl_table);
if (!hdr)
- pr_warn("seccomp: sysctl registration failed\n");
+ pr_warn("sysctl registration failed\n");
else
kmemleak_not_leak(hdr);

diff --git a/kernel/signal.c b/kernel/signal.c
index 0f865d67415d..4b93feddcdcd 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -10,6 +10,8 @@
* to allow signals to be sent reliably.
*/

+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/slab.h>
#include <linux/export.h>
#include <linux/init.h>
@@ -235,7 +237,7 @@ static inline void print_dropped_signal(int sig)
return;

pr_info("%s/%d: reached RLIMIT_SIGPENDING, dropped signal %d\n",
- current->comm, current->pid, sig);
+ current->comm, current->pid, sig);
}

/**
@@ -1118,10 +1120,10 @@ static int send_signal(int sig, struct siginfo *info, struct task_struct *t,
static void print_fatal_signal(int signr)
{
struct pt_regs *regs = signal_pt_regs();
- pr_info("potentially unexpected fatal signal %d.\n", signr);
+ pr_info("potentially unexpected fatal signal %d\n", signr);

#if defined(__i386__) && !defined(__arch_um__)
- pr_info("code at %08lx: ", regs->ip);
+ pr_info("code at %08lx:", regs->ip);
{
int i;
for (i = 0; i < 16; i++) {
@@ -1129,7 +1131,7 @@ static void print_fatal_signal(int signr)

if (get_user(insn, (unsigned char *)(regs->ip + i)))
break;
- pr_cont("%02x ", insn);
+ pr_cont(" %02x", insn);
}
}
pr_cont("\n");
diff --git a/kernel/smpboot.c b/kernel/smpboot.c
index 5043e7433f4b..17e129faf498 100644
--- a/kernel/smpboot.c
+++ b/kernel/smpboot.c
@@ -1,6 +1,9 @@
/*
* Common SMP CPU bringup/teardown functions
*/
+
+#define pr_fmt(fmt) "SMP: " fmt
+
#include <linux/cpu.h>
#include <linux/err.h>
#include <linux/smp.h>
@@ -54,7 +57,7 @@ static inline void idle_init(unsigned int cpu)
if (!tsk) {
tsk = fork_idle(cpu);
if (IS_ERR(tsk))
- pr_err("SMP: fork_idle() failed for CPU %u\n", cpu);
+ pr_err("fork_idle() failed for CPU %u\n", cpu);
else
per_cpu(idle_threads, cpu) = tsk;
}
diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index 4e62a4a8fa91..8973cb0a1eab 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -16,6 +16,8 @@
*
*/

+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/kernel.h>
#include <linux/taskstats_kern.h>
#include <linux/tsacct_kern.h>
@@ -690,7 +692,7 @@ static int __init taskstats_init(void)
return rc;

family_registered = 1;
- pr_info("registered taskstats version %d\n", TASKSTATS_GENL_VERSION);
+ pr_info("registered version %d\n", TASKSTATS_GENL_VERSION);
return 0;
}

diff --git a/kernel/torture.c b/kernel/torture.c
index 3de1efbecd6a..da4f95c11bf9 100644
--- a/kernel/torture.c
+++ b/kernel/torture.c
@@ -20,6 +20,9 @@
* Author: Paul E. McKenney <[email protected]>
* Based on kernel/rcu/torture.c.
*/
+
+#define pr_fmt(fmt) fmt
+
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/init.h>
@@ -99,8 +102,7 @@ bool torture_offline(int cpu, long *n_offl_attempts, long *n_offl_successes,
return false;

if (verbose)
- pr_alert("%s" TORTURE_FLAG
- "torture_onoff task: offlining %d\n",
+ pr_alert("%s" TORTURE_FLAG "torture_onoff task: offlining %d\n",
torture_type, cpu);
starttime = jiffies;
(*n_offl_attempts)++;
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index 1e37da2e0c25..d4753ff47738 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -15,6 +15,9 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/types.h>
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index ca7959be8aaa..7f1f75abcf7c 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -24,6 +24,8 @@
* Please read Documentation/core-api/workqueue.rst for details.
*/

+#define pr_fmt(fmt) fmt
+
#include <linux/export.h>
#include <linux/kernel.h>
#include <linux/sched.h>
--
2.15.0


2018-05-10 15:50:37

by Joe Perches

[permalink] [raw]
Subject: [PATCH 06/18] net: Remove pr_fmt duplicate logging prefixes

Using KBUILD_MODNAME as the default pr_fmt prefix caused some
duplication on logging prefixes in net/.

Remove the duplicate prefixes.

Signed-off-by: Joe Perches <[email protected]>
---
net/ipv4/ipconfig.c | 59 ++++++++++++--------------
net/ipv4/ipmr.c | 2 +-
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 9 ++--
net/ipv6/ip6mr.c | 2 +-
net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c | 6 +--
net/ipv6/netfilter/nf_defrag_ipv6_hooks.c | 4 +-
net/netfilter/nf_conntrack_helper.c | 11 ++---
net/netfilter/nf_conntrack_standalone.c | 2 +-
net/socket.c | 2 +-
9 files changed, 43 insertions(+), 54 deletions(-)

diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index d839d74853fc..fcf7a4f1b09a 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -224,7 +224,7 @@ static int __init ic_open_devs(void)
if (!(dev->flags & IFF_LOOPBACK) && !netdev_uses_dsa(dev))
continue;
if (dev_change_flags(dev, dev->flags | IFF_UP) < 0)
- pr_err("IP-Config: Failed to open %s\n", dev->name);
+ pr_err("Failed to open %s\n", dev->name);
}

for_each_netdev(&init_net, dev) {
@@ -242,8 +242,7 @@ static int __init ic_open_devs(void)
continue;
oflags = dev->flags;
if (dev_change_flags(dev, oflags | IFF_UP) < 0) {
- pr_err("IP-Config: Failed to open %s\n",
- dev->name);
+ pr_err("Failed to open %s\n", dev->name);
continue;
}
if (!(d = kmalloc(sizeof(struct ic_device), GFP_KERNEL))) {
@@ -260,7 +259,7 @@ static int __init ic_open_devs(void)
else
d->xid = 0;
ic_proto_have_if |= able;
- pr_debug("IP-Config: %s UP (able=%d, xid=%08x)\n",
+ pr_debug("%s UP (able=%d, xid=%08x)\n",
dev->name, able, d->xid);
}
}
@@ -287,7 +286,7 @@ static int __init ic_open_devs(void)

elapsed = jiffies_to_msecs(jiffies - start);
wait = (CONF_CARRIER_TIMEOUT - elapsed + 500)/1000;
- pr_info("Waiting up to %d more seconds for network.\n", wait);
+ pr_info("Waiting up to %d more seconds for network\n", wait);
next_msg = jiffies + msecs_to_jiffies(CONF_CARRIER_TIMEOUT/12);
}
have_carrier:
@@ -297,10 +296,9 @@ static int __init ic_open_devs(void)

if (!ic_first_dev) {
if (user_dev_name[0])
- pr_err("IP-Config: Device `%s' not found\n",
- user_dev_name);
+ pr_err("Device `%s' not found\n", user_dev_name);
else
- pr_err("IP-Config: No network devices available\n");
+ pr_err("No network devices available\n");
return -ENODEV;
}
return 0;
@@ -317,7 +315,7 @@ static void __init ic_close_devs(void)
next = d->next;
dev = d->dev;
if (d != ic_dev && !netdev_uses_dsa(dev)) {
- pr_debug("IP-Config: Downing %s\n", dev->name);
+ pr_debug("Downing %s\n", dev->name);
dev_change_flags(dev, d->flags);
}
kfree(d);
@@ -351,20 +349,17 @@ static int __init ic_setup_if(void)
strcpy(ir.ifr_ifrn.ifrn_name, ic_dev->dev->name);
set_sockaddr(sin, ic_myaddr, 0);
if ((err = devinet_ioctl(&init_net, SIOCSIFADDR, &ir)) < 0) {
- pr_err("IP-Config: Unable to set interface address (%d)\n",
- err);
+ pr_err("Unable to set interface address (%d)\n", err);
return -1;
}
set_sockaddr(sin, ic_netmask, 0);
if ((err = devinet_ioctl(&init_net, SIOCSIFNETMASK, &ir)) < 0) {
- pr_err("IP-Config: Unable to set interface netmask (%d)\n",
- err);
+ pr_err("Unable to set interface netmask (%d)\n", err);
return -1;
}
set_sockaddr(sin, ic_myaddr | ~ic_netmask, 0);
if ((err = devinet_ioctl(&init_net, SIOCSIFBRDADDR, &ir)) < 0) {
- pr_err("IP-Config: Unable to set interface broadcast address (%d)\n",
- err);
+ pr_err("Unable to set interface broadcast address (%d)\n", err);
return -1;
}
/* Handle the case where we need non-standard MTU on the boot link (a network
@@ -374,7 +369,7 @@ static int __init ic_setup_if(void)
if (ic_dev_mtu != 0) {
rtnl_lock();
if ((err = dev_set_mtu(ic_dev->dev, ic_dev_mtu)) < 0)
- pr_err("IP-Config: Unable to set interface mtu to %d (%d)\n",
+ pr_err("Unable to set interface mtu to %d (%d)\n",
ic_dev_mtu, err);
rtnl_unlock();
}
@@ -391,7 +386,7 @@ static int __init ic_setup_routes(void)

memset(&rm, 0, sizeof(rm));
if ((ic_gateway ^ ic_myaddr) & ic_netmask) {
- pr_err("IP-Config: Gateway not on directly connected network\n");
+ pr_err("Gateway not on directly connected network\n");
return -1;
}
set_sockaddr((struct sockaddr_in *) &rm.rt_dst, 0, 0);
@@ -399,8 +394,7 @@ static int __init ic_setup_routes(void)
set_sockaddr((struct sockaddr_in *) &rm.rt_gateway, ic_gateway, 0);
rm.rt_flags = RTF_UP | RTF_GATEWAY;
if ((err = ip_rt_ioctl(&init_net, SIOCADDRT, &rm)) < 0) {
- pr_err("IP-Config: Cannot add default route (%d)\n",
- err);
+ pr_err("Cannot add default route (%d)\n", err);
return -1;
}
}
@@ -433,12 +427,11 @@ static int __init ic_defaults(void)
else if (IN_CLASSC(ntohl(ic_myaddr)))
ic_netmask = htonl(IN_CLASSC_NET);
else {
- pr_err("IP-Config: Unable to guess netmask for address %pI4\n",
+ pr_err("Unable to guess netmask for address %pI4\n",
&ic_myaddr);
return -1;
}
- pr_notice("IP-Config: Guessing netmask %pI4\n",
- &ic_netmask);
+ pr_notice("Guessing netmask %pI4\n", &ic_netmask);
}

return 0;
@@ -834,8 +827,8 @@ static void __init ic_bootp_send_if(struct ic_device *d, unsigned long jiffies_d
else if (dev->type == ARPHRD_FDDI)
b->htype = ARPHRD_ETHER;
else {
- pr_warn("Unknown ARP type 0x%04x for device %s\n", dev->type,
- dev->name);
+ pr_warn("Unknown ARP type 0x%04x for device %s\n",
+ dev->type, dev->name);
b->htype = dev->type; /* can cause undefined behavior */
}

@@ -1169,7 +1162,7 @@ static int __init ic_dynamic(void)
* are missing, and without DHCP/BOOTP/RARP we are unable to get it.
*/
if (!ic_proto_enabled) {
- pr_err("IP-Config: Incomplete network configuration information\n");
+ pr_err("Incomplete network configuration information\n");
return -1;
}

@@ -1281,7 +1274,7 @@ static int __init ic_dynamic(void)
return -1;
}

- pr_info("IP-Config: Got %s answer from %pI4, my address is %pI4\n",
+ pr_info("Got %s answer from %pI4, my address is %pI4\n",
((ic_got_reply & IC_RARP) ? "RARP"
: (ic_proto_enabled & IC_USE_DHCP) ? "DHCP" : "BOOTP"),
&ic_addrservaddr, &ic_myaddr);
@@ -1479,7 +1472,7 @@ static int __init ip_auto_config(void)
if (!ic_enable)
return 0;

- pr_debug("IP-Config: Entered.\n");
+ pr_debug("Entered\n");
#ifdef IPCONFIG_DYNAMIC
try_try_again:
#endif
@@ -1529,22 +1522,22 @@ static int __init ip_auto_config(void)
*/
#ifdef CONFIG_ROOT_NFS
if (ROOT_DEV == Root_NFS) {
- pr_err("IP-Config: Retrying forever (NFS root)...\n");
+ pr_err("Retrying forever (NFS root)...\n");
goto try_try_again;
}
#endif

if (--retries) {
- pr_err("IP-Config: Reopening network devices...\n");
+ pr_err("Reopening network devices...\n");
goto try_try_again;
}

/* Oh, well. At least we tried. */
- pr_err("IP-Config: Auto-configuration of network failed\n");
+ pr_err("Auto-configuration of network failed\n");
return -1;
}
#else /* !DYNAMIC */
- pr_err("IP-Config: Incomplete network configuration information\n");
+ pr_err("Incomplete network configuration information\n");
ic_close_devs();
return -1;
#endif /* IPCONFIG_DYNAMIC */
@@ -1574,7 +1567,7 @@ static int __init ip_auto_config(void)
/*
* Clue in the operator.
*/
- pr_info("IP-Config: Complete:\n");
+ pr_info("Complete:\n");

pr_info(" device=%s, hwaddr=%*phC, ipaddr=%pI4, mask=%pI4, gw=%pI4\n",
ic_dev->dev->name, ic_dev->dev->addr_len, ic_dev->dev->dev_addr,
@@ -1718,7 +1711,7 @@ static int __init ip_auto_config_setup(char *addrs)
if ((cp = strchr(ip, ':')))
*cp++ = '\0';
if (strlen(ip) > 0) {
- pr_debug("IP-Config: Parameter #%d: `%s'\n", num, ip);
+ pr_debug("Parameter #%d: `%s'\n", num, ip);
switch (num) {
case 0:
if ((ic_myaddr = in_aton(ip)) == ANY)
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 38e092eafc97..3c39f526c770 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1259,7 +1259,7 @@ static int ipmr_mfc_add(struct net *net, struct mr_table *mrt,
ret = rhltable_insert_key(&mrt->mfc_hash, &c->cmparg, &c->_c.mnode,
ipmr_rht_params);
if (ret) {
- pr_err("ipmr: rhtable insert error %d\n", ret);
+ pr_err("rhtable insert error %d\n", ret);
ipmr_cache_free(c);
return ret;
}
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
index 9db988f9a4d7..5bcd97269093 100644
--- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
+++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
@@ -83,8 +83,7 @@ static int ipv4_get_l4proto(const struct sk_buff *skb, unsigned int nhoff,

/* Check bogus IP headers */
if (*dataoff > skb->len) {
- pr_debug("nf_conntrack_ipv4: bogus IPv4 packet: "
- "nhoff %u, ihl %u, skblen %u\n",
+ pr_debug("bogus IPv4 packet: nhoff %u, ihl %u, skblen %u\n",
nhoff, iph->ihl << 2, skb->len);
return -NF_ACCEPT;
}
@@ -268,7 +267,7 @@ getorigdst(struct sock *sk, int optval, void __user *user, int *len)
else
return 0;
}
- pr_debug("SO_ORIGINAL_DST: Can't find %pI4/%u-%pI4/%u.\n",
+ pr_debug("SO_ORIGINAL_DST: Can't find %pI4/%u-%pI4/%u\n",
&tuple.src.u3.ip, ntohs(tuple.src.u.tcp.port),
&tuple.dst.u3.ip, ntohs(tuple.dst.u.tcp.port));
return -ENOENT;
@@ -432,7 +431,7 @@ static int __init nf_conntrack_l3proto_ipv4_init(void)

ret = register_pernet_subsys(&ipv4_net_ops);
if (ret < 0) {
- pr_err("nf_conntrack_ipv4: can't register pernet ops\n");
+ pr_err("can't register pernet ops\n");
goto cleanup_sockopt;
}

@@ -443,7 +442,7 @@ static int __init nf_conntrack_l3proto_ipv4_init(void)

ret = nf_ct_l3proto_register(&nf_conntrack_l3proto_ipv4);
if (ret < 0) {
- pr_err("nf_conntrack_ipv4: can't register ipv4 proto.\n");
+ pr_err("can't register ipv4 proto\n");
goto cleanup_l4proto;
}

diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index 20a419ee8000..95cc0e8634cb 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -1458,7 +1458,7 @@ static int ip6mr_mfc_add(struct net *net, struct mr_table *mrt,
err = rhltable_insert_key(&mrt->mfc_hash, &c->cmparg, &c->_c.mnode,
ip6mr_rht_params);
if (err) {
- pr_err("ip6mr: rhtable insert error %d\n", err);
+ pr_err("rhtable insert error %d\n", err);
ip6mr_cache_free(c);
return err;
}
diff --git a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
index 663827ee3cf8..b15cc05dedd7 100644
--- a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
@@ -77,7 +77,7 @@ static int ipv6_get_l4proto(const struct sk_buff *skb, unsigned int nhoff,

if (skb_copy_bits(skb, nhoff + offsetof(struct ipv6hdr, nexthdr),
&nexthdr, sizeof(nexthdr)) != 0) {
- pr_debug("ip6_conntrack_core: can't get nexthdr\n");
+ pr_debug("can't get nexthdr\n");
return -NF_ACCEPT;
}
protoff = ipv6_skip_exthdr(skb, extoff, &nexthdr, &frag_off);
@@ -86,7 +86,7 @@ static int ipv6_get_l4proto(const struct sk_buff *skb, unsigned int nhoff,
* IPv6 and possibly extensions headers, but it is tracked anyway
*/
if (protoff < 0 || (frag_off & htons(~0x7)) != 0) {
- pr_debug("ip6_conntrack_core: can't find proto in pkt\n");
+ pr_debug("can't find proto in pkt\n");
return -NF_ACCEPT;
}

@@ -432,7 +432,7 @@ static int __init nf_conntrack_l3proto_ipv6_init(void)

ret = nf_ct_l3proto_register(&nf_conntrack_l3proto_ipv6);
if (ret < 0) {
- pr_err("nf_conntrack_ipv6: can't register ipv6 proto.\n");
+ pr_err("can't register ipv6 proto\n");
goto cleanup_l4proto;
}
return ret;
diff --git a/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c b/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c
index c87b48359e8f..b0d42797d003 100644
--- a/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c
+++ b/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c
@@ -111,12 +111,12 @@ static int __init nf_defrag_init(void)

ret = nf_ct_frag6_init();
if (ret < 0) {
- pr_err("nf_defrag_ipv6: can't initialize frag6.\n");
+ pr_err("can't initialize frag6\n");
return ret;
}
ret = register_pernet_subsys(&defrag6_net_ops);
if (ret < 0) {
- pr_err("nf_defrag_ipv6: can't register pernet ops\n");
+ pr_err("can't register pernet ops\n");
goto cleanup_frag6;
}
return ret;
diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
index 551a1eddf0fa..716017f4131b 100644
--- a/net/netfilter/nf_conntrack_helper.c
+++ b/net/netfilter/nf_conntrack_helper.c
@@ -74,7 +74,7 @@ static int nf_conntrack_helper_init_sysctl(struct net *net)
register_net_sysctl(net, "net/netfilter", table);

if (!net->ct.helper_sysctl_header) {
- pr_err("nf_conntrack_helper: can't register to sysctl.\n");
+ pr_err("can't register to sysctl\n");
goto out_register;
}
return 0;
@@ -202,7 +202,7 @@ nf_ct_helper_ext_add(struct nf_conn *ct,
if (help)
INIT_HLIST_HEAD(&help->expectations);
else
- pr_debug("failed to add helper extension area");
+ pr_debug("failed to add helper extension area\n");
return help;
}
EXPORT_SYMBOL_GPL(nf_ct_helper_ext_add);
@@ -215,10 +215,7 @@ nf_ct_lookup_helper(struct nf_conn *ct, struct net *net)
return NULL;
if (!__nf_ct_helper_find(&ct->tuplehash[IP_CT_DIR_REPLY].tuple))
return NULL;
- pr_info("nf_conntrack: default automatic helper assignment "
- "has been turned off for security reasons and CT-based "
- " firewall rule not found. Use the iptables CT target "
- "to attach helpers instead.\n");
+ pr_info("default automatic helper assignment has been turned off for security reasons and CT-based firewall rule not found. Use the iptables CT target to attach helpers instead.\n");
net->ct.auto_assign_helper_warned = 1;
return NULL;
}
@@ -553,7 +550,7 @@ int nf_conntrack_helper_init(void)

ret = nf_ct_extend_register(&helper_extend);
if (ret < 0) {
- pr_err("nf_ct_helper: Unable to register helper extension.\n");
+ pr_err("Unable to register helper extension\n");
goto out_extend;
}

diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
index 037fec54c850..e5de8d609135 100644
--- a/net/netfilter/nf_conntrack_standalone.c
+++ b/net/netfilter/nf_conntrack_standalone.c
@@ -720,7 +720,7 @@ static int __init nf_conntrack_standalone_init(void)
nf_ct_netfilter_header =
register_net_sysctl(&init_net, "net", nf_ct_netfilter_table);
if (!nf_ct_netfilter_header) {
- pr_err("nf_conntrack: can't register to sysctl.\n");
+ pr_err("can't register to sysctl\n");
ret = -ENOMEM;
goto out_sysctl;
}
diff --git a/net/socket.c b/net/socket.c
index 667a7b397134..0b7ce9fd9d35 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1248,7 +1248,7 @@ int __sock_create(struct net *net, int family, int type, int protocol,
*/
sock = sock_alloc();
if (!sock) {
- net_warn_ratelimited("socket: no more sockets\n");
+ net_warn_ratelimited("no more sockets\n");
return -ENFILE; /* Not exactly a match, but its the
closest posix thing */
}
--
2.15.0


2018-05-10 15:50:55

by Joe Perches

[permalink] [raw]
Subject: [PATCH 03/18] printk: Convert pr_fmt from blank define to KBUILD_MODNAME

There are more than 1000 uses of #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
Make that the default define so these uses can be removed later via script.

Signed-off-by: Joe Perches <[email protected]>
---
include/linux/printk.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/printk.h b/include/linux/printk.h
index 6d7e800affd8..172dce24e1b6 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -285,7 +285,7 @@ static inline void printk_safe_flush_on_panic(void)
extern int kptr_restrict;

#ifndef pr_fmt
-#define pr_fmt(fmt) fmt
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#endif

/*
--
2.15.0


2018-05-10 15:51:12

by Joe Perches

[permalink] [raw]
Subject: [PATCH 02/18] lib: Use pr_fmt

Sometime in the future, it would be useful to convert pr_fmt from a
default simple define to use a default prefix with KBUILD_MODNAME.

There are files in lib/ that use pr_<level>, some with an embedded
prefix, that also do not have a specific pr_fmt define.

Add pr_fmt for those files.

There are some differences in output as some logging output now is
prefixed with the appropriate KBUILD_MODNAME.

Miscellanea:

o Simplify debugging macros to only require a single function definition
by moving #define DEBUG into the definition and removing the empty
function definition
o Function alignment neatening
o Use %s, __func__ instead of embedding function names as strings
o Add missing newline terminations

Signed-off-by: Joe Perches <[email protected]>
---
lib/cpu_rmap.c | 15 +++++-------
lib/crc32test.c | 2 ++
lib/earlycpio.c | 5 ++--
lib/find_bit_benchmark.c | 2 ++
lib/kobject.c | 36 ++++++++++++++--------------
lib/kobject_uevent.c | 27 ++++++++++-----------
lib/nmi_backtrace.c | 3 +++
lib/percpu_ida.c | 4 +++-
lib/percpu_test.c | 2 ++
lib/random32.c | 10 ++++----
lib/stmp_device.c | 2 ++
lib/string.c | 2 ++
lib/swiotlb.c | 4 +++-
lib/test_debug_virtual.c | 2 ++
lib/test_rhashtable.c | 44 ++++++++++++++++++----------------
lib/test_sort.c | 2 ++
lib/ubsan.c | 61 ++++++++++++++++++++++++------------------------
17 files changed, 122 insertions(+), 101 deletions(-)

diff --git a/lib/cpu_rmap.c b/lib/cpu_rmap.c
index f610b2a10b3e..2d7204928c60 100644
--- a/lib/cpu_rmap.c
+++ b/lib/cpu_rmap.c
@@ -7,6 +7,8 @@
* by the Free Software Foundation, incorporated herein by reference.
*/

+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/cpu_rmap.h>
#include <linux/interrupt.h>
#include <linux/export.h>
@@ -110,26 +112,21 @@ static bool cpu_rmap_copy_neigh(struct cpu_rmap *rmap, unsigned int cpu,
return false;
}

-#ifdef DEBUG
static void debug_print_rmap(const struct cpu_rmap *rmap, const char *prefix)
{
+#ifdef DEBUG
unsigned index;
unsigned int cpu;

- pr_info("cpu_rmap %p, %s:\n", rmap, prefix);
+ pr_info("%p, %s:\n", rmap, prefix);

for_each_possible_cpu(cpu) {
index = rmap->near[cpu].index;
pr_info("cpu %d -> obj %u (distance %u)\n",
cpu, index, rmap->near[cpu].dist);
}
-}
-#else
-static inline void
-debug_print_rmap(const struct cpu_rmap *rmap, const char *prefix)
-{
-}
#endif
+}

/**
* cpu_rmap_add - add object to a rmap
@@ -258,7 +255,7 @@ irq_cpu_rmap_notify(struct irq_affinity_notify *notify, const cpumask_t *mask)

rc = cpu_rmap_update(glue->rmap, glue->index, mask);
if (rc)
- pr_warning("irq_cpu_rmap_notify: update failed: %d\n", rc);
+ pr_warn("%s: update failed: %d\n", __func__, rc);
}

/**
diff --git a/lib/crc32test.c b/lib/crc32test.c
index 97d6a57cefcc..63bb08ccb6f3 100644
--- a/lib/crc32test.c
+++ b/lib/crc32test.c
@@ -24,6 +24,8 @@
* Version 2. See the file COPYING for more details.
*/

+#define pr_fmt(fmt) fmt
+
#include <linux/crc32.h>
#include <linux/module.h>
#include <linux/sched.h>
diff --git a/lib/earlycpio.c b/lib/earlycpio.c
index db283ba4d2c1..e98816b13719 100644
--- a/lib/earlycpio.c
+++ b/lib/earlycpio.c
@@ -130,9 +130,8 @@ struct cpio_data find_cpio_data(const char *path, void *data,
*nextoff = (long)nptr - (long)data;

if (ch[C_NAMESIZE] - mypathsize >= MAX_CPIO_FILE_NAME) {
- pr_warn(
- "File %s exceeding MAX_CPIO_FILE_NAME [%d]\n",
- p, MAX_CPIO_FILE_NAME);
+ pr_warn("File %s exceeding MAX_CPIO_FILE_NAME [%d]\n",
+ p, MAX_CPIO_FILE_NAME);
}
strlcpy(cd.name, p + mypathsize, MAX_CPIO_FILE_NAME);

diff --git a/lib/find_bit_benchmark.c b/lib/find_bit_benchmark.c
index 5367ffa5c18f..d59d92c9e73e 100644
--- a/lib/find_bit_benchmark.c
+++ b/lib/find_bit_benchmark.c
@@ -24,6 +24,8 @@
* - sparse bitmap with few set bits at random positions.
*/

+#define pr_fmt(fmt) fmt
+
#include <linux/bitops.h>
#include <linux/kernel.h>
#include <linux/list.h>
diff --git a/lib/kobject.c b/lib/kobject.c
index 18989b5b3b56..2bb9a50da4b0 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -10,6 +10,8 @@
* about using the kobject interface.
*/

+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/kobject.h>
#include <linux/string.h>
#include <linux/export.h>
@@ -129,8 +131,8 @@ static void fill_kobj_path(struct kobject *kobj, char *path, int length)
*(path + --length) = '/';
}

- pr_debug("kobject: '%s' (%p): %s: path = '%s'\n", kobject_name(kobj),
- kobj, __func__, path);
+ pr_debug("'%s' (%p): %s: path = '%s'\n",
+ kobject_name(kobj), kobj, __func__, path);
}

/**
@@ -220,7 +222,7 @@ static int kobject_add_internal(struct kobject *kobj)
kobj->parent = parent;
}

- pr_debug("kobject: '%s' (%p): %s: parent: '%s', set: '%s'\n",
+ pr_debug("'%s' (%p): %s: parent: '%s', set: '%s'\n",
kobject_name(kobj), kobj, __func__,
parent ? kobject_name(parent) : "<NULL>",
kobj->kset ? kobject_name(&kobj->kset->kobj) : "<NULL>");
@@ -333,7 +335,7 @@ void kobject_init(struct kobject *kobj, struct kobj_type *ktype)
}
if (kobj->state_initialized) {
/* do not error out as sometimes we can recover */
- pr_err("kobject (%p): tried to init an initialized object, something is seriously wrong.\n",
+ pr_err("(%p): tried to init an initialized object, something is seriously wrong\n",
kobj);
dump_stack();
}
@@ -343,7 +345,7 @@ void kobject_init(struct kobject *kobj, struct kobj_type *ktype)
return;

error:
- pr_err("kobject (%p): %s\n", kobj, err_str);
+ pr_err("(%p): %s\n", kobj, err_str);
dump_stack();
}
EXPORT_SYMBOL(kobject_init);
@@ -356,7 +358,7 @@ static __printf(3, 0) int kobject_add_varg(struct kobject *kobj,

retval = kobject_set_name_vargs(kobj, fmt, vargs);
if (retval) {
- pr_err("kobject: can not set name properly!\n");
+ pr_err("can not set name properly!\n");
return retval;
}
kobj->parent = parent;
@@ -398,7 +400,7 @@ int kobject_add(struct kobject *kobj, struct kobject *parent,
return -EINVAL;

if (!kobj->state_initialized) {
- pr_err("kobject '%s' (%p): tried to add an uninitialized object, something is seriously wrong.\n",
+ pr_err("'%s' (%p): tried to add an uninitialized object, something is seriously wrong.n",
kobject_name(kobj), kobj);
dump_stack();
return -EINVAL;
@@ -616,36 +618,36 @@ static void kobject_cleanup(struct kobject *kobj)
struct kobj_type *t = get_ktype(kobj);
const char *name = kobj->name;

- pr_debug("kobject: '%s' (%p): %s, parent %p\n",
+ pr_debug("'%s' (%p): %s, parent %p\n",
kobject_name(kobj), kobj, __func__, kobj->parent);

if (t && !t->release)
- pr_debug("kobject: '%s' (%p): does not have a release() function, it is broken and must be fixed.\n",
+ pr_debug("'%s' (%p): does not have a release() function, it is broken and must be fixed.\n",
kobject_name(kobj), kobj);

/* send "remove" if the caller did not do it but sent "add" */
if (kobj->state_add_uevent_sent && !kobj->state_remove_uevent_sent) {
- pr_debug("kobject: '%s' (%p): auto cleanup 'remove' event\n",
+ pr_debug("'%s' (%p): auto cleanup 'remove' event\n",
kobject_name(kobj), kobj);
kobject_uevent(kobj, KOBJ_REMOVE);
}

/* remove from sysfs if the caller did not do it */
if (kobj->state_in_sysfs) {
- pr_debug("kobject: '%s' (%p): auto cleanup kobject_del\n",
+ pr_debug("'%s' (%p): auto cleanup kobject_del\n",
kobject_name(kobj), kobj);
kobject_del(kobj);
}

if (t && t->release) {
- pr_debug("kobject: '%s' (%p): calling ktype release\n",
+ pr_debug("'%s' (%p): calling ktype release\n",
kobject_name(kobj), kobj);
t->release(kobj);
}

/* free name if we allocated it */
if (name) {
- pr_debug("kobject: '%s': free name\n", name);
+ pr_debug("'%s': free name\n", name);
kfree_const(name);
}
}
@@ -663,8 +665,8 @@ static void kobject_release(struct kref *kref)
struct kobject *kobj = container_of(kref, struct kobject, kref);
#ifdef CONFIG_DEBUG_KOBJECT_RELEASE
unsigned long delay = HZ + HZ * (get_random_int() & 0x3);
- pr_info("kobject: '%s' (%p): %s, parent %p (delayed %ld)\n",
- kobject_name(kobj), kobj, __func__, kobj->parent, delay);
+ pr_info("'%s' (%p): %s, parent %p (delayed %ld)\n",
+ kobject_name(kobj), kobj, __func__, kobj->parent, delay);
INIT_DELAYED_WORK(&kobj->release, kobject_delayed_cleanup);

schedule_delayed_work(&kobj->release, delay);
@@ -693,7 +695,7 @@ EXPORT_SYMBOL(kobject_put);

static void dynamic_kobj_release(struct kobject *kobj)
{
- pr_debug("kobject: (%p): %s\n", kobj, __func__);
+ pr_debug("(%p): %s\n", kobj, __func__);
kfree(kobj);
}

@@ -863,7 +865,7 @@ EXPORT_SYMBOL_GPL(kset_find_obj);
static void kset_release(struct kobject *kobj)
{
struct kset *kset = container_of(kobj, struct kset, kobj);
- pr_debug("kobject: '%s' (%p): %s\n",
+ pr_debug("'%s' (%p): %s\n",
kobject_name(kobj), kobj, __func__);
kfree(kset);
}
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 63d0816ab23b..c4b2453f7c16 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -13,6 +13,8 @@
* Greg Kroah-Hartman <[email protected]>
*/

+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/spinlock.h>
#include <linux/string.h>
#include <linux/kobject.h>
@@ -464,8 +466,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
int i = 0;
int retval = 0;

- pr_debug("kobject: '%s' (%p): %s\n",
- kobject_name(kobj), kobj, __func__);
+ pr_debug("'%s' (%p): %s\n", kobject_name(kobj), kobj, __func__);

/* search the kset we belong to */
top_kobj = kobj;
@@ -473,9 +474,8 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
top_kobj = top_kobj->parent;

if (!top_kobj->kset) {
- pr_debug("kobject: '%s' (%p): %s: attempted to send uevent "
- "without kset!\n", kobject_name(kobj), kobj,
- __func__);
+ pr_debug("'%s' (%p): %s: attempted to send uevent without kset!\n",
+ kobject_name(kobj), kobj, __func__);
return -EINVAL;
}

@@ -484,16 +484,14 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,

/* skip the event, if uevent_suppress is set*/
if (kobj->uevent_suppress) {
- pr_debug("kobject: '%s' (%p): %s: uevent_suppress "
- "caused the event to drop!\n",
- kobject_name(kobj), kobj, __func__);
+ pr_debug("'%s' (%p): %s: uevent_suppress caused the event to drop!\n",
+ kobject_name(kobj), kobj, __func__);
return 0;
}
/* skip the event, if the filter returns zero. */
if (uevent_ops && uevent_ops->filter)
if (!uevent_ops->filter(kset, kobj)) {
- pr_debug("kobject: '%s' (%p): %s: filter function "
- "caused the event to drop!\n",
+ pr_debug("'%s' (%p): %s: filter function caused the event to drop!\n",
kobject_name(kobj), kobj, __func__);
return 0;
}
@@ -504,8 +502,8 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
else
subsystem = kobject_name(&kset->kobj);
if (!subsystem) {
- pr_debug("kobject: '%s' (%p): %s: unset subsystem caused the "
- "event to drop!\n", kobject_name(kobj), kobj,
+ pr_debug("'%s' (%p): %s: unset subsystem caused the event to drop!\n",
+ kobject_name(kobj), kobj,
__func__);
return 0;
}
@@ -546,9 +544,8 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
if (uevent_ops && uevent_ops->uevent) {
retval = uevent_ops->uevent(kset, kobj, env);
if (retval) {
- pr_debug("kobject: '%s' (%p): %s: uevent() returned "
- "%d\n", kobject_name(kobj), kobj,
- __func__, retval);
+ pr_debug("'%s' (%p): %s: uevent() returned %d\n",
+ kobject_name(kobj), kobj, __func__, retval);
goto exit;
}
}
diff --git a/lib/nmi_backtrace.c b/lib/nmi_backtrace.c
index 61a6b5aab07e..5141d7072c99 100644
--- a/lib/nmi_backtrace.c
+++ b/lib/nmi_backtrace.c
@@ -13,6 +13,9 @@
*
* Bits copied from original nmi.c file
*/
+
+#define pr_fmt(fmt) fmt
+
#include <linux/cpumask.h>
#include <linux/delay.h>
#include <linux/kprobes.h>
diff --git a/lib/percpu_ida.c b/lib/percpu_ida.c
index 6016f1deb1f5..4283e4f9092e 100644
--- a/lib/percpu_ida.c
+++ b/lib/percpu_ida.c
@@ -14,6 +14,8 @@
* General Public License for more details.
*/

+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/mm.h>
#include <linux/bitmap.h>
#include <linux/bitops.h>
@@ -299,7 +301,7 @@ int __percpu_ida_init(struct percpu_ida *pool, unsigned long nr_tags,

/* Guard against overflow */
if (nr_tags > (unsigned) INT_MAX + 1) {
- pr_err("percpu_ida_init(): nr_tags too large\n");
+ pr_err("%s: nr_tags too large\n", __func__);
return -EINVAL;
}

diff --git a/lib/percpu_test.c b/lib/percpu_test.c
index 0b5d14dadd1a..349ef717a0d9 100644
--- a/lib/percpu_test.c
+++ b/lib/percpu_test.c
@@ -1,3 +1,5 @@
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/module.h>

/* validate @native and @pcp counter values match @expected */
diff --git a/lib/random32.c b/lib/random32.c
index 4aaa76404d56..8de1ac412588 100644
--- a/lib/random32.c
+++ b/lib/random32.c
@@ -32,6 +32,8 @@
* s1 > 1, s2 > 7, s3 > 15, s4 > 127.
*/

+#define pr_fmt(fmt) "prandom: " fmt
+
#include <linux/types.h>
#include <linux/percpu.h>
#include <linux/export.h>
@@ -437,9 +439,9 @@ static void __init prandom_state_selftest(void)
}

if (error)
- pr_warn("prandom: seed boundary self test failed\n");
+ pr_warn("seed boundary self test failed\n");
else
- pr_info("prandom: seed boundary self test passed\n");
+ pr_info("seed boundary self test passed\n");

for (i = 0; i < ARRAY_SIZE(test2); i++) {
struct rnd_state state;
@@ -458,8 +460,8 @@ static void __init prandom_state_selftest(void)
}

if (errors)
- pr_warn("prandom: %d/%d self tests failed\n", errors, runs);
+ pr_warn("%d/%d self tests failed\n", errors, runs);
else
- pr_info("prandom: %d self tests passed\n", runs);
+ pr_info("%d self tests passed\n", runs);
}
#endif
diff --git a/lib/stmp_device.c b/lib/stmp_device.c
index a904656f4fd7..e06dea3c9a7a 100644
--- a/lib/stmp_device.c
+++ b/lib/stmp_device.c
@@ -12,6 +12,8 @@
* (at your option) any later version.
*/

+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/io.h>
#include <linux/errno.h>
#include <linux/delay.h>
diff --git a/lib/string.c b/lib/string.c
index 2c0900a5d51a..19c032243185 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -20,6 +20,8 @@
* - Kissed strtok() goodbye
*/

+#define pr_fmt(fmt) fmt
+
#include <linux/types.h>
#include <linux/string.h>
#include <linux/ctype.h>
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index bd1e0c5ba1b8..ca70b081bf3c 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -17,6 +17,8 @@
* 08/12/11 beckyb Add highmem support
*/

+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/cache.h>
#include <linux/dma-direct.h>
#include <linux/mm.h>
@@ -165,7 +167,7 @@ void swiotlb_print_info(void)
unsigned char *vstart, *vend;

if (no_iotlb_memory) {
- pr_warn("software IO TLB: No low mem\n");
+ pr_warn("No low mem\n");
return;
}

diff --git a/lib/test_debug_virtual.c b/lib/test_debug_virtual.c
index b9cdeecc19dc..97b9ecfc6a83 100644
--- a/lib/test_debug_virtual.c
+++ b/lib/test_debug_virtual.c
@@ -1,3 +1,5 @@
+#define pr_fmt(fmt) fmt
+
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/export.h>
diff --git a/lib/test_rhashtable.c b/lib/test_rhashtable.c
index f4000c137dbe..cd5a3cea1ac3 100644
--- a/lib/test_rhashtable.c
+++ b/lib/test_rhashtable.c
@@ -13,6 +13,8 @@
* Self Test
**************************************************************************/

+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/init.h>
#include <linux/jhash.h>
#include <linux/kernel.h>
@@ -132,7 +134,7 @@ static int insert_retry(struct rhashtable *ht, struct test_obj *obj,
} while (err == -EBUSY);

if (enomem_retries)
- pr_info(" %u insertions retried after -ENOMEM\n",
+ pr_info("%u insertions retried after -ENOMEM\n",
enomem_retries);

return err ? : retries;
@@ -184,7 +186,7 @@ static void test_bucket_stats(struct rhashtable *ht, unsigned int entries)

err = rhashtable_walk_init(ht, &hti, GFP_KERNEL);
if (err) {
- pr_warn("Test failed: allocation error");
+ pr_warn("Test failed: allocation error\n");
return;
}

@@ -207,11 +209,11 @@ static void test_bucket_stats(struct rhashtable *ht, unsigned int entries)
rhashtable_walk_stop(&hti);
rhashtable_walk_exit(&hti);

- pr_info(" Traversal complete: counted=%u, nelems=%u, entries=%d, table-jumps=%u\n",
+ pr_info("Traversal complete: counted=%u, nelems=%u, entries=%d, table-jumps=%u\n",
total, atomic_read(&ht->nelems), entries, chain_len);

if (total != atomic_read(&ht->nelems) || total != entries)
- pr_warn("Test failed: Total count mismatch ^^^");
+ pr_warn("Test failed: Total count mismatch ^^^\n");
}

static s64 __init test_rhashtable(struct rhashtable *ht, struct test_obj *array,
@@ -226,7 +228,7 @@ static s64 __init test_rhashtable(struct rhashtable *ht, struct test_obj *array,
* Insertion Test:
* Insert entries into table with all keys even numbers
*/
- pr_info(" Adding %d keys\n", entries);
+ pr_info("Adding %d keys\n", entries);
start = ktime_get_ns();
for (i = 0; i < entries; i++) {
struct test_obj *obj = &array[i];
@@ -240,7 +242,7 @@ static s64 __init test_rhashtable(struct rhashtable *ht, struct test_obj *array,
}

if (insert_retries)
- pr_info(" %u insertions retried due to memory pressure\n",
+ pr_info("%u insertions retried due to memory pressure\n",
insert_retries);

test_bucket_stats(ht, entries);
@@ -250,7 +252,7 @@ static s64 __init test_rhashtable(struct rhashtable *ht, struct test_obj *array,

test_bucket_stats(ht, entries);

- pr_info(" Deleting %d keys\n", entries);
+ pr_info("Deleting %d keys\n", entries);
for (i = 0; i < entries; i++) {
struct test_obj_val key = {
.id = i * 2,
@@ -267,7 +269,7 @@ static s64 __init test_rhashtable(struct rhashtable *ht, struct test_obj *array,
}

end = ktime_get_ns();
- pr_info(" Duration of test: %lld ns\n", end - start);
+ pr_info("Duration of test: %lld ns\n", end - start);

return end - start;
}
@@ -481,7 +483,7 @@ static int __init test_rhashtable_max(struct test_obj *array,
err = 0;
} else {
pr_info("insert element %u should have failed with %d, got %d\n",
- ht.max_elems, -E2BIG, err);
+ ht.max_elems, -E2BIG, err);
if (err == 0)
err = -1;
}
@@ -611,13 +613,14 @@ static int thread_lookup_test(struct thread_data *tdata)

obj = rhashtable_lookup_fast(&ht, &key, test_rht_params);
if (obj && (tdata->objs[i].value.id == TEST_INSERT_FAIL)) {
- pr_err(" found unexpected object %d-%d\n", key.tid, key.id);
+ pr_err("found unexpected object %d-%d\n",
+ key.tid, key.id);
err++;
} else if (!obj && (tdata->objs[i].value.id != TEST_INSERT_FAIL)) {
- pr_err(" object %d-%d not found!\n", key.tid, key.id);
+ pr_err("object %d-%d not found!\n", key.tid, key.id);
err++;
} else if (obj && memcmp(&obj->value, &key, sizeof(key))) {
- pr_err(" wrong object returned (got %d-%d, expected %d-%d)\n",
+ pr_err("wrong object returned (got %d-%d, expected %d-%d)\n",
obj->value.tid, obj->value.id, key.tid, key.id);
err++;
}
@@ -634,7 +637,7 @@ static int threadfunc(void *data)

up(&prestart_sem);
if (down_interruptible(&startup_sem))
- pr_err(" thread[%d]: down_interruptible failed\n", tdata->id);
+ pr_err("thread[%d]: down_interruptible failed\n", tdata->id);

for (i = 0; i < tdata->entries; i++) {
tdata->objs[i].value.id = i;
@@ -643,18 +646,18 @@ static int threadfunc(void *data)
if (err > 0) {
insert_retries += err;
} else if (err) {
- pr_err(" thread[%d]: rhashtable_insert_fast failed\n",
+ pr_err("thread[%d]: rhashtable_insert_fast failed\n",
tdata->id);
goto out;
}
}
if (insert_retries)
- pr_info(" thread[%d]: %u insertions retried due to memory pressure\n",
+ pr_info("thread[%d]: %u insertions retried due to memory pressure\n",
tdata->id, insert_retries);

err = thread_lookup_test(tdata);
if (err) {
- pr_err(" thread[%d]: rhashtable_lookup_test failed\n",
+ pr_err("thread[%d]: rhashtable_lookup_test failed\n",
tdata->id);
goto out;
}
@@ -666,7 +669,7 @@ static int threadfunc(void *data)
err = rhashtable_remove_fast(&ht, &tdata->objs[i].node,
test_rht_params);
if (err) {
- pr_err(" thread[%d]: rhashtable_remove_fast failed\n",
+ pr_err("thread[%d]: rhashtable_remove_fast failed\n",
tdata->id);
goto out;
}
@@ -676,7 +679,7 @@ static int threadfunc(void *data)
}
err = thread_lookup_test(tdata);
if (err) {
- pr_err(" thread[%d]: rhashtable_lookup_test (2) failed\n",
+ pr_err("thread[%d]: rhashtable_lookup_test (2) failed\n",
tdata->id);
goto out;
}
@@ -738,7 +741,8 @@ static int __init test_rht_init(void)
}

pr_info("test if its possible to exceed max_size %d: %s\n",
- test_rht_params.max_size, test_rhashtable_max(objs, entries) == 0 ?
+ test_rht_params.max_size,
+ test_rhashtable_max(objs, entries) == 0 ?
"no, ok" : "YES, failed");
vfree(objs);

@@ -784,7 +788,7 @@ static int __init test_rht_init(void)
started_threads++;
}
if (down_interruptible(&prestart_sem))
- pr_err(" down interruptible failed\n");
+ pr_err("down interruptible failed\n");
for (i = 0; i < tcount; i++)
up(&startup_sem);
for (i = 0; i < tcount; i++) {
diff --git a/lib/test_sort.c b/lib/test_sort.c
index 385c0ed5202f..4ee9b64a34ef 100644
--- a/lib/test_sort.c
+++ b/lib/test_sort.c
@@ -1,3 +1,5 @@
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/sort.h>
#include <linux/slab.h>
#include <linux/module.h>
diff --git a/lib/ubsan.c b/lib/ubsan.c
index 59fee96c29a0..c16fccf5277d 100644
--- a/lib/ubsan.c
+++ b/lib/ubsan.c
@@ -10,6 +10,8 @@
*
*/

+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/bitops.h>
#include <linux/bug.h>
#include <linux/ctype.h>
@@ -49,10 +51,11 @@ static bool was_reported(struct source_location *location)
}

static void print_source_location(const char *prefix,
- struct source_location *loc)
+ struct source_location *loc)
{
- pr_err("%s %s:%d:%d\n", prefix, loc->file_name,
- loc->line & LINE_MASK, loc->column & COLUMN_MASK);
+ pr_err("%s %s:%d:%d\n",
+ prefix, loc->file_name,
+ loc->line & LINE_MASK, loc->column & COLUMN_MASK);
}

static bool suppress_report(struct source_location *loc)
@@ -149,16 +152,14 @@ static void ubsan_prologue(struct source_location *location,
current->in_ubsan++;
spin_lock_irqsave(&report_lock, *flags);

- pr_err("========================================"
- "========================================\n");
- print_source_location("UBSAN: Undefined behaviour in", location);
+ pr_err("================================================================================\n");
+ print_source_location("Undefined behaviour in", location);
}

static void ubsan_epilogue(unsigned long *flags)
{
dump_stack();
- pr_err("========================================"
- "========================================\n");
+ pr_err("================================================================================\n");
spin_unlock_irqrestore(&report_lock, *flags);
current->in_ubsan--;
}
@@ -182,9 +183,9 @@ static void handle_overflow(struct overflow_data *data, unsigned long lhs,
pr_err("%s integer overflow:\n",
type_is_signed(type) ? "signed" : "unsigned");
pr_err("%s %c %s cannot be represented in type %s\n",
- lhs_val_str,
- op,
- rhs_val_str,
+ lhs_val_str,
+ op,
+ rhs_val_str,
type->type_name);

ubsan_epilogue(&flags);
@@ -229,7 +230,7 @@ void __ubsan_handle_negate_overflow(struct overflow_data *data,
val_to_string(old_val_str, sizeof(old_val_str), data->type, old_val);

pr_err("negation of %s cannot be represented in type %s:\n",
- old_val_str, data->type->type_name);
+ old_val_str, data->type->type_name);

ubsan_epilogue(&flags);
}
@@ -252,7 +253,7 @@ void __ubsan_handle_divrem_overflow(struct overflow_data *data,

if (type_is_signed(data->type) && get_signed_val(data->type, rhs) == -1)
pr_err("division of %s by -1 cannot be represented in type %s\n",
- rhs_val_str, data->type->type_name);
+ rhs_val_str, data->type->type_name);
else
pr_err("division by zero\n");

@@ -270,8 +271,8 @@ static void handle_null_ptr_deref(struct type_mismatch_data_common *data)
ubsan_prologue(data->location, &flags);

pr_err("%s null pointer of type %s\n",
- type_check_kinds[data->type_check_kind],
- data->type->type_name);
+ type_check_kinds[data->type_check_kind],
+ data->type->type_name);

ubsan_epilogue(&flags);
}
@@ -287,8 +288,8 @@ static void handle_misaligned_access(struct type_mismatch_data_common *data,
ubsan_prologue(data->location, &flags);

pr_err("%s misaligned address %p for type %s\n",
- type_check_kinds[data->type_check_kind],
- (void *)ptr, data->type->type_name);
+ type_check_kinds[data->type_check_kind],
+ (void *)ptr, data->type->type_name);
pr_err("which requires %ld byte alignment\n", data->alignment);

ubsan_epilogue(&flags);
@@ -304,8 +305,8 @@ static void handle_object_size_mismatch(struct type_mismatch_data_common *data,

ubsan_prologue(data->location, &flags);
pr_err("%s address %p with insufficient space\n",
- type_check_kinds[data->type_check_kind],
- (void *) ptr);
+ type_check_kinds[data->type_check_kind],
+ (void *)ptr);
pr_err("for an object of type %s\n", data->type->type_name);
ubsan_epilogue(&flags);
}
@@ -381,8 +382,8 @@ void __ubsan_handle_out_of_bounds(struct out_of_bounds_data *data,
ubsan_prologue(&data->location, &flags);

val_to_string(index_str, sizeof(index_str), data->index_type, index);
- pr_err("index %s is out of range for type %s\n", index_str,
- data->array_type->type_name);
+ pr_err("index %s is out of range for type %s\n",
+ index_str, data->array_type->type_name);
ubsan_epilogue(&flags);
}
EXPORT_SYMBOL(__ubsan_handle_out_of_bounds);
@@ -410,17 +411,15 @@ void __ubsan_handle_shift_out_of_bounds(struct shift_out_of_bounds_data *data,
else if (get_unsigned_val(rhs_type, rhs) >=
type_bit_width(lhs_type))
pr_err("shift exponent %s is too large for %u-bit type %s\n",
- rhs_str,
- type_bit_width(lhs_type),
- lhs_type->type_name);
+ rhs_str,
+ type_bit_width(lhs_type),
+ lhs_type->type_name);
else if (val_is_negative(lhs_type, lhs))
- pr_err("left shift of negative value %s\n",
- lhs_str);
+ pr_err("left shift of negative value %s\n", lhs_str);
else
- pr_err("left shift of %s by %s places cannot be"
- " represented in type %s\n",
- lhs_str, rhs_str,
- lhs_type->type_name);
+ pr_err("left shift of %s by %s places cannot be represented in type %s\n",
+ lhs_str, rhs_str,
+ lhs_type->type_name);

ubsan_epilogue(&flags);
}
@@ -453,7 +452,7 @@ void __ubsan_handle_load_invalid_value(struct invalid_value_data *data,
val_to_string(val_str, sizeof(val_str), data->type, val);

pr_err("load of value %s is not a valid value for type %s\n",
- val_str, data->type->type_name);
+ val_str, data->type->type_name);

ubsan_epilogue(&flags);
}
--
2.15.0


2018-05-10 16:16:25

by Paul Moore

[permalink] [raw]
Subject: Re: [PATCH 01/18] kernel: Use pr_fmt

On Thu, May 10, 2018 at 11:45 AM, Joe Perches <[email protected]> wrote:
> Sometime in the future, it would be useful to convert pr_fmt from a
> default simple define to use a default prefix with KBUILD_MODNAME.
>
> There are files in kernel/ that use pr_<level>, some with an embedded
> prefix, that also do not have a specific pr_fmt define.
>
> Add pr_fmt for those files.
>
> There are some differences in output as some messages are now prefixed
> with their KBUILD_MODNAME.
>
> Miscellanea:
>
> o Align multiline statements to open parenthesis
> o Wrap and realign arguments to 80 columns where sensible
> o Coalesce formats
>
> Signed-off-by: Joe Perches <[email protected]>
> ---
> kernel/acct.c | 2 ++
> kernel/async.c | 14 ++++++------
> kernel/audit_tree.c | 2 +-
> kernel/backtracetest.c | 8 +++----
> kernel/crash_core.c | 29 ++++++++++++++-----------
> kernel/exit.c | 2 ++
> kernel/hung_task.c | 13 +++++------
> kernel/kprobes.c | 20 ++++++++++-------
> kernel/module.c | 59 +++++++++++++++++++++++---------------------------
> kernel/panic.c | 3 +++
> kernel/params.c | 13 ++++++-----
> kernel/pid.c | 2 ++
> kernel/profile.c | 2 ++
> kernel/range.c | 2 +-
> kernel/relay.c | 5 ++++-
> kernel/seccomp.c | 4 +++-
> kernel/signal.c | 10 +++++----
> kernel/smpboot.c | 5 ++++-
> kernel/taskstats.c | 4 +++-
> kernel/torture.c | 6 +++--
> kernel/tracepoint.c | 3 +++
> kernel/workqueue.c | 2 ++
> 22 files changed, 122 insertions(+), 88 deletions(-)

The audit_tree.c changes look fine to me.

Acked-by: Paul Moore <[email protected]>

> diff --git a/kernel/acct.c b/kernel/acct.c
> index addf7732fb56..c3d393655f11 100644
> --- a/kernel/acct.c
> +++ b/kernel/acct.c
> @@ -44,6 +44,8 @@
> * a struct file opened for write. Fixed. 2/6/2000, AV.
> */
>
> +#define pr_fmt(fmt) fmt
> +
> #include <linux/mm.h>
> #include <linux/slab.h>
> #include <linux/acct.h>
> diff --git a/kernel/async.c b/kernel/async.c
> index a893d6170944..9a6ab6016713 100644
> --- a/kernel/async.c
> +++ b/kernel/async.c
> @@ -120,8 +120,8 @@ static void async_run_entry_fn(struct work_struct *work)
> /* 1) run (and print duration) */
> if (initcall_debug && system_state < SYSTEM_RUNNING) {
> pr_debug("calling %lli_%pF @ %i\n",
> - (long long)entry->cookie,
> - entry->func, task_pid_nr(current));
> + (long long)entry->cookie,
> + entry->func, task_pid_nr(current));
> calltime = ktime_get();
> }
> entry->func(entry->data, entry->cookie);
> @@ -129,9 +129,9 @@ static void async_run_entry_fn(struct work_struct *work)
> rettime = ktime_get();
> delta = ktime_sub(rettime, calltime);
> pr_debug("initcall %lli_%pF returned 0 after %lld usecs\n",
> - (long long)entry->cookie,
> - entry->func,
> - (long long)ktime_to_ns(delta) >> 10);
> + (long long)entry->cookie,
> + entry->func,
> + (long long)ktime_to_ns(delta) >> 10);
> }
>
> /* 2) remove self from the pending queues */
> @@ -300,8 +300,8 @@ void async_synchronize_cookie_domain(async_cookie_t cookie, struct async_domain
> delta = ktime_sub(endtime, starttime);
>
> pr_debug("async_continuing @ %i after %lli usec\n",
> - task_pid_nr(current),
> - (long long)ktime_to_ns(delta) >> 10);
> + task_pid_nr(current),
> + (long long)ktime_to_ns(delta) >> 10);
> }
> }
> EXPORT_SYMBOL_GPL(async_synchronize_cookie_domain);
> diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
> index 67e6956c0b61..f34f90b4a346 100644
> --- a/kernel/audit_tree.c
> +++ b/kernel/audit_tree.c
> @@ -739,7 +739,7 @@ static int audit_launch_prune(void)
> prune_thread = kthread_run(prune_tree_thread, NULL,
> "audit_prune_tree");
> if (IS_ERR(prune_thread)) {
> - pr_err("cannot start thread audit_prune_tree");
> + pr_err("cannot start thread audit_prune_tree\n");
> prune_thread = NULL;
> return -ENOMEM;
> }
> diff --git a/kernel/backtracetest.c b/kernel/backtracetest.c
> index 1323360d90e3..d10cc39b0134 100644
> --- a/kernel/backtracetest.c
> +++ b/kernel/backtracetest.c
> @@ -19,7 +19,7 @@
>
> static void backtrace_test_normal(void)
> {
> - pr_info("Testing a backtrace from process context.\n");
> + pr_info("Testing a backtrace from process context\n");
> pr_info("The following trace is a kernel self test and not a bug!\n");
>
> dump_stack();
> @@ -37,7 +37,7 @@ static DECLARE_TASKLET(backtrace_tasklet, &backtrace_test_irq_callback, 0);
>
> static void backtrace_test_irq(void)
> {
> - pr_info("Testing a backtrace from irq context.\n");
> + pr_info("Testing a backtrace from irq context\n");
> pr_info("The following trace is a kernel self test and not a bug!\n");
>
> init_completion(&backtrace_work);
> @@ -51,7 +51,7 @@ static void backtrace_test_saved(void)
> struct stack_trace trace;
> unsigned long entries[8];
>
> - pr_info("Testing a saved backtrace.\n");
> + pr_info("Testing a saved backtrace\n");
> pr_info("The following trace is a kernel self test and not a bug!\n");
>
> trace.nr_entries = 0;
> @@ -65,7 +65,7 @@ static void backtrace_test_saved(void)
> #else
> static void backtrace_test_saved(void)
> {
> - pr_info("Saved backtrace test skipped.\n");
> + pr_info("Saved backtrace test skipped\n");
> }
> #endif
>
> diff --git a/kernel/crash_core.c b/kernel/crash_core.c
> index f7674d676889..4eda1ee9da8c 100644
> --- a/kernel/crash_core.c
> +++ b/kernel/crash_core.c
> @@ -6,6 +6,8 @@
> * Version 2. See the file COPYING for more details.
> */
>
> +#define pr_fmt(fmt) "crashkernel: " fmt
> +
> #include <linux/crash_core.h>
> #include <linux/utsname.h>
> #include <linux/vmalloc.h>
> @@ -49,12 +51,12 @@ static int __init parse_crashkernel_mem(char *cmdline,
> /* get the start of the range */
> start = memparse(cur, &tmp);
> if (cur == tmp) {
> - pr_warn("crashkernel: Memory value expected\n");
> + pr_warn("Memory value expected\n");
> return -EINVAL;
> }
> cur = tmp;
> if (*cur != '-') {
> - pr_warn("crashkernel: '-' expected\n");
> + pr_warn("'-' expected\n");
> return -EINVAL;
> }
> cur++;
> @@ -63,18 +65,18 @@ static int __init parse_crashkernel_mem(char *cmdline,
> if (*cur != ':') {
> end = memparse(cur, &tmp);
> if (cur == tmp) {
> - pr_warn("crashkernel: Memory value expected\n");
> + pr_warn("Memory value expected\n");
> return -EINVAL;
> }
> cur = tmp;
> if (end <= start) {
> - pr_warn("crashkernel: end <= start\n");
> + pr_warn("end <= start\n");
> return -EINVAL;
> }
> }
>
> if (*cur != ':') {
> - pr_warn("crashkernel: ':' expected\n");
> + pr_warn("':' expected\n");
> return -EINVAL;
> }
> cur++;
> @@ -86,7 +88,7 @@ static int __init parse_crashkernel_mem(char *cmdline,
> }
> cur = tmp;
> if (size >= system_ram) {
> - pr_warn("crashkernel: invalid size\n");
> + pr_warn("invalid size\n");
> return -EINVAL;
> }
>
> @@ -108,8 +110,9 @@ static int __init parse_crashkernel_mem(char *cmdline,
> return -EINVAL;
> }
> }
> - } else
> - pr_info("crashkernel size resulted in zero bytes\n");
> + } else {
> + pr_info("size resulted in zero bytes\n");
> + }
>
> return 0;
> }
> @@ -129,14 +132,14 @@ static int __init parse_crashkernel_simple(char *cmdline,
>
> *crash_size = memparse(cmdline, &cur);
> if (cmdline == cur) {
> - pr_warn("crashkernel: memory value expected\n");
> + pr_warn("memory value expected\n");
> return -EINVAL;
> }
>
> if (*cur == '@')
> *crash_base = memparse(cur+1, &cur);
> else if (*cur != ' ' && *cur != '\0') {
> - pr_warn("crashkernel: unrecognized char: %c\n", *cur);
> + pr_warn("unrecognized char: %c\n", *cur);
> return -EINVAL;
> }
>
> @@ -167,18 +170,18 @@ static int __init parse_crashkernel_suffix(char *cmdline,
>
> *crash_size = memparse(cmdline, &cur);
> if (cmdline == cur) {
> - pr_warn("crashkernel: memory value expected\n");
> + pr_warn("memory value expected\n");
> return -EINVAL;
> }
>
> /* check with suffix */
> if (strncmp(cur, suffix, strlen(suffix))) {
> - pr_warn("crashkernel: unrecognized char: %c\n", *cur);
> + pr_warn("unrecognized char: %c\n", *cur);
> return -EINVAL;
> }
> cur += strlen(suffix);
> if (*cur != ' ' && *cur != '\0') {
> - pr_warn("crashkernel: unrecognized char: %c\n", *cur);
> + pr_warn("unrecognized char: %c\n", *cur);
> return -EINVAL;
> }
>
> diff --git a/kernel/exit.c b/kernel/exit.c
> index 68e1598d7931..679d4de9a5fa 100644
> --- a/kernel/exit.c
> +++ b/kernel/exit.c
> @@ -4,6 +4,8 @@
> * Copyright (C) 1991, 1992 Linus Torvalds
> */
>
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> #include <linux/mm.h>
> #include <linux/slab.h>
> #include <linux/sched/autogroup.h>
> diff --git a/kernel/hung_task.c b/kernel/hung_task.c
> index 32b479468e4d..c66278415811 100644
> --- a/kernel/hung_task.c
> +++ b/kernel/hung_task.c
> @@ -113,14 +113,13 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout)
> if (sysctl_hung_task_warnings) {
> if (sysctl_hung_task_warnings > 0)
> sysctl_hung_task_warnings--;
> - pr_err("INFO: task %s:%d blocked for more than %ld seconds.\n",
> - t->comm, t->pid, timeout);
> + pr_err("INFO: task %s:%d blocked for more than %ld seconds\n",
> + t->comm, t->pid, timeout);
> pr_err(" %s %s %.*s\n",
> - print_tainted(), init_utsname()->release,
> - (int)strcspn(init_utsname()->version, " "),
> - init_utsname()->version);
> - pr_err("\"echo 0 > /proc/sys/kernel/hung_task_timeout_secs\""
> - " disables this message.\n");
> + print_tainted(), init_utsname()->release,
> + (int)strcspn(init_utsname()->version, " "),
> + init_utsname()->version);
> + pr_err("\"echo 0 > /proc/sys/kernel/hung_task_timeout_secs\" disables this message\n");
> sched_show_task(t);
> hung_task_show_lock = true;
> }
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index ea619021d901..0b8facde8dd0 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -31,6 +31,9 @@
> * <[email protected]> and Prasanna S Panchamukhi
> * <[email protected]> added function-return probes.
> */
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> #include <linux/kprobes.h>
> #include <linux/hash.h>
> #include <linux/init.h>
> @@ -985,7 +988,8 @@ static int arm_kprobe_ftrace(struct kprobe *p)
> ret = ftrace_set_filter_ip(&kprobe_ftrace_ops,
> (unsigned long)p->addr, 0, 0);
> if (ret) {
> - pr_debug("Failed to arm kprobe-ftrace at %p (%d)\n", p->addr, ret);
> + pr_debug("Failed to arm kprobe-ftrace at %p (%d)\n",
> + p->addr, ret);
> return ret;
> }
>
> @@ -2198,7 +2202,7 @@ static int __init populate_kprobe_blacklist(unsigned long *start,
> if (!kernel_text_address(entry) ||
> !kallsyms_lookup_size_offset(entry, &size, &offset)) {
> pr_err("Failed to find blacklist at %p\n",
> - (void *)entry);
> + (void *)entry);
> continue;
> }
>
> @@ -2281,8 +2285,8 @@ static int __init init_kprobes(void)
> err = populate_kprobe_blacklist(__start_kprobe_blacklist,
> __stop_kprobe_blacklist);
> if (err) {
> - pr_err("kprobes: failed to populate blacklist: %d\n", err);
> - pr_err("Please take care of using kprobes.\n");
> + pr_err("failed to populate blacklist: %d\n", err);
> + pr_err("Please take care of using kprobes\n");
> }
>
> if (kretprobe_blacklist_size) {
> @@ -2488,10 +2492,10 @@ static int arm_all_kprobes(void)
> }
>
> if (errors)
> - pr_warn("Kprobes globally enabled, but failed to arm %d out of %d probes\n",
> + pr_warn("globally enabled, but failed to arm %d out of %d probes\n",
> errors, total);
> else
> - pr_info("Kprobes globally enabled\n");
> + pr_info("globally enabled\n");
>
> already_enabled:
> mutex_unlock(&kprobe_mutex);
> @@ -2531,10 +2535,10 @@ static int disarm_all_kprobes(void)
> }
>
> if (errors)
> - pr_warn("Kprobes globally disabled, but failed to disarm %d out of %d probes\n",
> + pr_warn("globally disabled, but failed to disarm %d out of %d probes\n",
> errors, total);
> else
> - pr_info("Kprobes globally disabled\n");
> + pr_info("globally disabled\n");
>
> mutex_unlock(&kprobe_mutex);
>
> diff --git a/kernel/module.c b/kernel/module.c
> index 36543e382389..94624b46c9bd 100644
> --- a/kernel/module.c
> +++ b/kernel/module.c
> @@ -16,6 +16,9 @@
> along with this program; if not, write to the Free Software
> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> */
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> #include <linux/export.h>
> #include <linux/extable.h>
> #include <linux/moduleloader.h>
> @@ -523,21 +526,17 @@ static bool check_symbol(const struct symsearch *syms,
> if (syms->licence == GPL_ONLY)
> return false;
> if (syms->licence == WILL_BE_GPL_ONLY && fsa->warn) {
> - pr_warn("Symbol %s is being used by a non-GPL module, "
> - "which will not be allowed in the future\n",
> + pr_warn("Symbol %s is being used by a non-GPL module, which will not be allowed in the future.\n",
> fsa->name);
> }
> }
>
> #ifdef CONFIG_UNUSED_SYMBOLS
> if (syms->unused && fsa->warn) {
> - pr_warn("Symbol %s is marked as UNUSED, however this module is "
> - "using it.\n", fsa->name);
> + pr_warn("Symbol %s is marked as UNUSED, however this module is using it.\n",
> + fsa->name);
> pr_warn("This symbol will go away in the future.\n");
> - pr_warn("Please evaluate if this is the right api to use and "
> - "if it really is, submit a report to the linux kernel "
> - "mailing list together with submitting your code for "
> - "inclusion.\n");
> + pr_warn("Please evaluate if this is the right api to use and if it really is, submit a report to the linux kernel mailing list together with submitting your code for inclusion.\n");
> }
> #endif
>
> @@ -843,7 +842,7 @@ static int add_module_usage(struct module *a, struct module *b)
> {
> struct module_use *use;
>
> - pr_debug("Allocating new usage for %s.\n", a->name);
> + pr_debug("Allocating new usage for %s\n", a->name);
> use = kmalloc(sizeof(*use), GFP_ATOMIC);
> if (!use)
> return -ENOMEM;
> @@ -1265,7 +1264,7 @@ static int try_to_force_load(struct module *mod, const char *reason)
> {
> #ifdef CONFIG_MODULE_FORCE_LOAD
> if (!test_taint(TAINT_FORCED_MODULE))
> - pr_warn("%s: %s: kernel tainted.\n", mod->name, reason);
> + pr_warn("%s: %s: kernel tainted\n", mod->name, reason);
> add_taint_module(mod, TAINT_FORCED_MODULE, LOCKDEP_NOW_UNRELIABLE);
> return 0;
> #else
> @@ -1435,7 +1434,7 @@ resolve_symbol_wait(struct module *mod,
> !IS_ERR(ksym = resolve_symbol(mod, info, name, owner))
> || PTR_ERR(ksym) != -EBUSY,
> 30 * HZ) <= 0) {
> - pr_warn("%s: gave up waiting for init of module %s.\n",
> + pr_warn("%s: gave up waiting for init of module %s\n",
> mod->name, owner);
> }
> return ksym;
> @@ -2224,8 +2223,7 @@ static int verify_export_symbols(struct module *mod)
> for (i = 0; i < ARRAY_SIZE(arr); i++) {
> for (s = arr[i].sym; s < arr[i].sym + arr[i].num; s++) {
> if (find_symbol(s->name, &owner, NULL, true, false)) {
> - pr_err("%s: exports duplicate symbol %s"
> - " (owned by %s)\n",
> + pr_err("%s: exports duplicate symbol %s (owned by %s)\n",
> mod->name, s->name, module_name(owner));
> return -ENOEXEC;
> }
> @@ -2257,14 +2255,14 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
> supposed to happen. */
> pr_debug("Common symbol: %s\n", name);
> pr_warn("%s: please compile with -fno-common\n",
> - mod->name);
> + mod->name);
> ret = -ENOEXEC;
> break;
>
> case SHN_ABS:
> /* Don't need to do anything */
> pr_debug("Absolute symbol: 0x%08lx\n",
> - (long)sym[i].st_value);
> + (long)sym[i].st_value);
> break;
>
> case SHN_LIVEPATCH:
> @@ -2454,7 +2452,7 @@ static void set_license(struct module *mod, const char *license)
>
> if (!license_is_gpl_compatible(license)) {
> if (!test_taint(TAINT_PROPRIETARY_MODULE))
> - pr_warn("%s: module license '%s' taints kernel.\n",
> + pr_warn("%s: module license '%s' taints kernel\n",
> mod->name, license);
> add_taint_module(mod, TAINT_PROPRIETARY_MODULE,
> LOCKDEP_NOW_UNRELIABLE);
> @@ -2717,7 +2715,7 @@ static void dynamic_debug_setup(struct module *mod, struct _ddebug *debug, unsig
> #ifdef CONFIG_DYNAMIC_DEBUG
> if (ddebug_add_module(debug, num, mod->name))
> pr_err("dynamic debug error adding module: %s\n",
> - debug->modname);
> + debug->modname);
> #endif
> }
>
> @@ -2849,7 +2847,7 @@ static int check_modinfo_livepatch(struct module *mod, struct load_info *info)
> static int check_modinfo_livepatch(struct module *mod, struct load_info *info)
> {
> if (get_modinfo(info, "livepatch")) {
> - pr_err("%s: module is marked as livepatch module, but livepatch support is disabled",
> + pr_err("%s: module is marked as livepatch module, but livepatch support is disabled\n",
> mod->name);
> return -ENOEXEC;
> }
> @@ -2863,7 +2861,7 @@ static void check_modinfo_retpoline(struct module *mod, struct load_info *info)
> if (retpoline_module_ok(get_modinfo(info, "retpoline")))
> return;
>
> - pr_warn("%s: loading module not compiled with retpoline compiler.\n",
> + pr_warn("%s: loading module not compiled with retpoline compiler\n",
> mod->name);
> }
>
> @@ -3037,8 +3035,8 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
>
> if (get_modinfo(info, "staging")) {
> add_taint_module(mod, TAINT_CRAP, LOCKDEP_STILL_OK);
> - pr_warn("%s: module is from the staging directory, the quality "
> - "is unknown, you have been warned.\n", mod->name);
> + pr_warn("%s: module is from the staging directory, the quality is unknown, you have been warned\n",
> + mod->name);
> }
>
> err = check_modinfo_livepatch(mod, info);
> @@ -3089,8 +3087,8 @@ static int find_module_sections(struct module *mod, struct load_info *info)
> * This shouldn't happen with same compiler and binutils
> * building all parts of the module.
> */
> - pr_warn("%s: has both .ctors and .init_array.\n",
> - mod->name);
> + pr_warn("%s: has both .ctors and .init_array\n",
> + mod->name);
> return -EINVAL;
> }
> #endif
> @@ -3227,7 +3225,7 @@ static int check_module_license_and_versions(struct module *mod)
> LOCKDEP_NOW_UNRELIABLE);
>
> if (!prev_taint && test_taint(TAINT_PROPRIETARY_MODULE))
> - pr_warn("%s: module license taints kernel.\n", mod->name);
> + pr_warn("%s: module license taints kernel\n", mod->name);
>
> #ifdef CONFIG_MODVERSIONS
> if ((mod->num_syms && !mod->crcs)
> @@ -3459,8 +3457,7 @@ static noinline int do_init_module(struct module *mod)
> goto fail_free_freeinit;
> }
> if (ret > 0) {
> - pr_warn("%s: '%s'->init suspiciously returned %d, it should "
> - "follow 0/-E convention\n"
> + pr_warn("%s: '%s'->init suspiciously returned %d, it should follow 0/-E convention\n"
> "%s: loading module anyway...\n",
> __func__, mod->name, ret, __func__);
> dump_stack();
> @@ -3686,9 +3683,8 @@ static int load_module(struct load_info *info, const char __user *uargs,
> #ifdef CONFIG_MODULE_SIG
> mod->sig_ok = info->sig_ok;
> if (!mod->sig_ok) {
> - pr_notice_once("%s: module verification failed: signature "
> - "and/or required key missing - tainting "
> - "kernel\n", mod->name);
> + pr_notice_once("%s: module verification failed: signature and/or required key missing - tainting kernel\n",
> + mod->name);
> add_taint_module(mod, TAINT_UNSIGNED_MODULE, LOCKDEP_STILL_OK);
> }
> #endif
> @@ -3763,7 +3759,7 @@ static int load_module(struct load_info *info, const char __user *uargs,
> goto coming_cleanup;
> } else if (after_dashes) {
> pr_warn("%s: parameters '%s' after `--' ignored\n",
> - mod->name, after_dashes);
> + mod->name, after_dashes);
> }
>
> /* Link in to sysfs. */
> @@ -3843,8 +3839,7 @@ SYSCALL_DEFINE3(init_module, void __user *, umod,
> if (err)
> return err;
>
> - pr_debug("init_module: umod=%p, len=%lu, uargs=%p\n",
> - umod, len, uargs);
> + pr_debug("init_module: umod=%p, len=%lu, uargs=%p\n", umod, len, uargs);
>
> err = copy_module_from_user(umod, len, &info);
> if (err)
> diff --git a/kernel/panic.c b/kernel/panic.c
> index 42e487488554..e34631818bb7 100644
> --- a/kernel/panic.c
> +++ b/kernel/panic.c
> @@ -8,6 +8,9 @@
> * This function is used through-out the kernel (including mm and fs)
> * to indicate a major problem.
> */
> +
> +#define pr_fmt(fmt) fmt
> +
> #include <linux/debug_locks.h>
> #include <linux/sched/debug.h>
> #include <linux/interrupt.h>
> diff --git a/kernel/params.c b/kernel/params.c
> index ce89f757e6da..757049bfa346 100644
> --- a/kernel/params.c
> +++ b/kernel/params.c
> @@ -15,6 +15,9 @@
> along with this program; if not, write to the Free Software
> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> */
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> #include <linux/kernel.h>
> #include <linux/string.h>
> #include <linux/errno.h>
> @@ -141,8 +144,8 @@ static int parse_one(char *param,
> if (!val &&
> !(params[i].ops->flags & KERNEL_PARAM_OPS_FL_NOARG))
> return -EINVAL;
> - pr_debug("handling %s with %p\n", param,
> - params[i].ops->set);
> + pr_debug("handling %s with %p\n",
> + param, params[i].ops->set);
> kernel_param_lock(params[i].mod);
> param_check_unsafe(&params[i]);
> err = params[i].ops->set(val, &params[i]);
> @@ -496,8 +499,8 @@ int param_set_copystring(const char *val, const struct kernel_param *kp)
> const struct kparam_string *kps = kp->str;
>
> if (strlen(val)+1 > kps->maxlen) {
> - pr_err("%s: string doesn't fit in %u chars.\n",
> - kp->name, kps->maxlen-1);
> + pr_err("%s: string doesn't fit in %u chars\n",
> + kp->name, kps->maxlen - 1);
> return -ENOSPC;
> }
> strcpy(kps->string, val);
> @@ -763,7 +766,7 @@ static struct module_kobject * __init locate_module_kobject(const char *name)
> #endif
> if (err) {
> kobject_put(&mk->kobj);
> - pr_crit("Adding module '%s' to sysfs failed (%d), the system may be unstable.\n",
> + pr_crit("Adding module '%s' to sysfs failed (%d), the system may be unstable\n",
> name, err);
> return NULL;
> }
> diff --git a/kernel/pid.c b/kernel/pid.c
> index 157fe4b19971..2ddd7adfa77d 100644
> --- a/kernel/pid.c
> +++ b/kernel/pid.c
> @@ -26,6 +26,8 @@
> *
> */
>
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> #include <linux/mm.h>
> #include <linux/export.h>
> #include <linux/slab.h>
> diff --git a/kernel/profile.c b/kernel/profile.c
> index 9aa2a4445b0d..e5cc8f360236 100644
> --- a/kernel/profile.c
> +++ b/kernel/profile.c
> @@ -14,6 +14,8 @@
> * Oracle, 2004
> */
>
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> #include <linux/export.h>
> #include <linux/profile.h>
> #include <linux/bootmem.h>
> diff --git a/kernel/range.c b/kernel/range.c
> index d84de6766472..e828c950d401 100644
> --- a/kernel/range.c
> +++ b/kernel/range.c
> @@ -102,7 +102,7 @@ void subtract_range(struct range *range, int az, u64 start, u64 end)
> range[i].start = end;
> } else {
> pr_err("%s: run out of slot in ranges\n",
> - __func__);
> + __func__);
> }
> range[j].end = start;
> continue;
> diff --git a/kernel/relay.c b/kernel/relay.c
> index c955b10c973c..02f3790af754 100644
> --- a/kernel/relay.c
> +++ b/kernel/relay.c
> @@ -12,6 +12,9 @@
> *
> * This file is released under the GPL.
> */
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> #include <linux/errno.h>
> #include <linux/stddef.h>
> #include <linux/slab.h>
> @@ -527,7 +530,7 @@ int relay_prepare_cpu(unsigned int cpu)
> continue;
> buf = relay_open_buf(chan, cpu);
> if (!buf) {
> - pr_err("relay: cpu %d buffer creation failed\n", cpu);
> + pr_err("cpu %d buffer creation failed\n", cpu);
> mutex_unlock(&relay_channels_mutex);
> return -ENOMEM;
> }
> diff --git a/kernel/seccomp.c b/kernel/seccomp.c
> index 5386749cdd21..de696bc574b4 100644
> --- a/kernel/seccomp.c
> +++ b/kernel/seccomp.c
> @@ -14,6 +14,8 @@
> * of Berkeley Packet Filters/Linux Socket Filters.
> */
>
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> #include <linux/refcount.h>
> #include <linux/audit.h>
> #include <linux/compat.h>
> @@ -1323,7 +1325,7 @@ static int __init seccomp_sysctl_init(void)
>
> hdr = register_sysctl_paths(seccomp_sysctl_path, seccomp_sysctl_table);
> if (!hdr)
> - pr_warn("seccomp: sysctl registration failed\n");
> + pr_warn("sysctl registration failed\n");
> else
> kmemleak_not_leak(hdr);
>
> diff --git a/kernel/signal.c b/kernel/signal.c
> index 0f865d67415d..4b93feddcdcd 100644
> --- a/kernel/signal.c
> +++ b/kernel/signal.c
> @@ -10,6 +10,8 @@
> * to allow signals to be sent reliably.
> */
>
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> #include <linux/slab.h>
> #include <linux/export.h>
> #include <linux/init.h>
> @@ -235,7 +237,7 @@ static inline void print_dropped_signal(int sig)
> return;
>
> pr_info("%s/%d: reached RLIMIT_SIGPENDING, dropped signal %d\n",
> - current->comm, current->pid, sig);
> + current->comm, current->pid, sig);
> }
>
> /**
> @@ -1118,10 +1120,10 @@ static int send_signal(int sig, struct siginfo *info, struct task_struct *t,
> static void print_fatal_signal(int signr)
> {
> struct pt_regs *regs = signal_pt_regs();
> - pr_info("potentially unexpected fatal signal %d.\n", signr);
> + pr_info("potentially unexpected fatal signal %d\n", signr);
>
> #if defined(__i386__) && !defined(__arch_um__)
> - pr_info("code at %08lx: ", regs->ip);
> + pr_info("code at %08lx:", regs->ip);
> {
> int i;
> for (i = 0; i < 16; i++) {
> @@ -1129,7 +1131,7 @@ static void print_fatal_signal(int signr)
>
> if (get_user(insn, (unsigned char *)(regs->ip + i)))
> break;
> - pr_cont("%02x ", insn);
> + pr_cont(" %02x", insn);
> }
> }
> pr_cont("\n");
> diff --git a/kernel/smpboot.c b/kernel/smpboot.c
> index 5043e7433f4b..17e129faf498 100644
> --- a/kernel/smpboot.c
> +++ b/kernel/smpboot.c
> @@ -1,6 +1,9 @@
> /*
> * Common SMP CPU bringup/teardown functions
> */
> +
> +#define pr_fmt(fmt) "SMP: " fmt
> +
> #include <linux/cpu.h>
> #include <linux/err.h>
> #include <linux/smp.h>
> @@ -54,7 +57,7 @@ static inline void idle_init(unsigned int cpu)
> if (!tsk) {
> tsk = fork_idle(cpu);
> if (IS_ERR(tsk))
> - pr_err("SMP: fork_idle() failed for CPU %u\n", cpu);
> + pr_err("fork_idle() failed for CPU %u\n", cpu);
> else
> per_cpu(idle_threads, cpu) = tsk;
> }
> diff --git a/kernel/taskstats.c b/kernel/taskstats.c
> index 4e62a4a8fa91..8973cb0a1eab 100644
> --- a/kernel/taskstats.c
> +++ b/kernel/taskstats.c
> @@ -16,6 +16,8 @@
> *
> */
>
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> #include <linux/kernel.h>
> #include <linux/taskstats_kern.h>
> #include <linux/tsacct_kern.h>
> @@ -690,7 +692,7 @@ static int __init taskstats_init(void)
> return rc;
>
> family_registered = 1;
> - pr_info("registered taskstats version %d\n", TASKSTATS_GENL_VERSION);
> + pr_info("registered version %d\n", TASKSTATS_GENL_VERSION);
> return 0;
> }
>
> diff --git a/kernel/torture.c b/kernel/torture.c
> index 3de1efbecd6a..da4f95c11bf9 100644
> --- a/kernel/torture.c
> +++ b/kernel/torture.c
> @@ -20,6 +20,9 @@
> * Author: Paul E. McKenney <[email protected]>
> * Based on kernel/rcu/torture.c.
> */
> +
> +#define pr_fmt(fmt) fmt
> +
> #include <linux/types.h>
> #include <linux/kernel.h>
> #include <linux/init.h>
> @@ -99,8 +102,7 @@ bool torture_offline(int cpu, long *n_offl_attempts, long *n_offl_successes,
> return false;
>
> if (verbose)
> - pr_alert("%s" TORTURE_FLAG
> - "torture_onoff task: offlining %d\n",
> + pr_alert("%s" TORTURE_FLAG "torture_onoff task: offlining %d\n",
> torture_type, cpu);
> starttime = jiffies;
> (*n_offl_attempts)++;
> diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
> index 1e37da2e0c25..d4753ff47738 100644
> --- a/kernel/tracepoint.c
> +++ b/kernel/tracepoint.c
> @@ -15,6 +15,9 @@
> * along with this program; if not, write to the Free Software
> * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
> */
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> #include <linux/module.h>
> #include <linux/mutex.h>
> #include <linux/types.h>
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index ca7959be8aaa..7f1f75abcf7c 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -24,6 +24,8 @@
> * Please read Documentation/core-api/workqueue.rst for details.
> */
>
> +#define pr_fmt(fmt) fmt
> +
> #include <linux/export.h>
> #include <linux/kernel.h>
> #include <linux/sched.h>
> --
> 2.15.0
>



--
paul moore
http://www.paul-moore.com

2018-05-10 16:18:29

by Paul Moore

[permalink] [raw]
Subject: Re: [PATCH 15/18] security: Remove pr_fmt duplicate logging prefixes

On Thu, May 10, 2018 at 11:45 AM, Joe Perches <[email protected]> wrote:
> Converting pr_fmt from a simple define to use KBUILD_MODNAME added
> some duplicate logging prefixes to existing uses.
>
> Remove them.
>
> Signed-off-by: Joe Perches <[email protected]>
> ---
> security/selinux/selinuxfs.c | 29 ++++++++++++++---------------
> 1 file changed, 14 insertions(+), 15 deletions(-)

Acked-by: Paul Moore <[email protected]>

> diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
> index c0cadbc5f85c..be8f186a6256 100644
> --- a/security/selinux/selinuxfs.c
> +++ b/security/selinux/selinuxfs.c
> @@ -515,19 +515,19 @@ static int sel_make_policy_nodes(struct selinux_fs_info *fsi)
>
> ret = sel_make_bools(fsi);
> if (ret) {
> - pr_err("SELinux: failed to load policy booleans\n");
> + pr_err("failed to load policy booleans\n");
> return ret;
> }
>
> ret = sel_make_classes(fsi);
> if (ret) {
> - pr_err("SELinux: failed to load policy classes\n");
> + pr_err("failed to load policy classes\n");
> return ret;
> }
>
> ret = sel_make_policycap(fsi);
> if (ret) {
> - pr_err("SELinux: failed to load policy capabilities\n");
> + pr_err("failed to load policy capabilities\n");
> return ret;
> }
>
> @@ -570,7 +570,7 @@ static ssize_t sel_write_load(struct file *file, const char __user *buf,
>
> length = security_load_policy(fsi->state, data, count);
> if (length) {
> - pr_warn_ratelimited("SELinux: failed to load policy\n");
> + pr_warn_ratelimited("failed to load policy\n");
> goto out;
> }
>
> @@ -620,8 +620,8 @@ static ssize_t sel_write_context(struct file *file, char *buf, size_t size)
>
> length = -ERANGE;
> if (len > SIMPLE_TRANSACTION_LIMIT) {
> - printk(KERN_ERR "SELinux: %s: context size (%u) exceeds "
> - "payload max\n", __func__, len);
> + pr_err("%s: context size (%u) exceeds payload max\n",
> + __func__, len);
> goto out;
> }
>
> @@ -956,8 +956,8 @@ static ssize_t sel_write_create(struct file *file, char *buf, size_t size)
>
> length = -ERANGE;
> if (len > SIMPLE_TRANSACTION_LIMIT) {
> - printk(KERN_ERR "SELinux: %s: context size (%u) exceeds "
> - "payload max\n", __func__, len);
> + pr_err("%s: context size (%u) exceeds payload max\n",
> + __func__, len);
> goto out;
> }
>
> @@ -1147,8 +1147,8 @@ static ssize_t sel_write_member(struct file *file, char *buf, size_t size)
>
> length = -ERANGE;
> if (len > SIMPLE_TRANSACTION_LIMIT) {
> - printk(KERN_ERR "SELinux: %s: context size (%u) exceeds "
> - "payload max\n", __func__, len);
> + pr_err("%s: context size (%u) exceeds payload max\n",
> + __func__, len);
> goto out;
> }
>
> @@ -1389,8 +1389,8 @@ static int sel_make_bools(struct selinux_fs_info *fsi)
> ret = security_genfs_sid(fsi->state, "selinuxfs", page,
> SECCLASS_FILE, &sid);
> if (ret) {
> - pr_warn_ratelimited("SELinux: no sid found, defaulting to security isid for %s\n",
> - page);
> + pr_warn_ratelimited("no sid found, defaulting to security isid for %s\n",
> + page);
> sid = SECINITSID_SECURITY;
> }
>
> @@ -1996,8 +1996,7 @@ static int sel_fill_super(struct super_block *sb, void *data, int silent)
> goto err;
> return 0;
> err:
> - printk(KERN_ERR "SELinux: %s: failed while creating inodes\n",
> - __func__);
> + pr_err("%s: failed while creating inodes\n", __func__);
>
> selinux_fs_info_free(sb);
>
> @@ -2046,7 +2045,7 @@ static int __init init_sel_fs(void)
>
> selinux_null.mnt = selinuxfs_mount = kern_mount(&sel_fs_type);
> if (IS_ERR(selinuxfs_mount)) {
> - printk(KERN_ERR "selinuxfs: could not mount!\n");
> + pr_err("selinuxfs: could not mount!\n");
> err = PTR_ERR(selinuxfs_mount);
> selinuxfs_mount = NULL;
> }
> --
> 2.15.0
>



--
paul moore
http://www.paul-moore.com

2018-05-10 16:31:00

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH 03/18] printk: Convert pr_fmt from blank define to KBUILD_MODNAME

On Thu, 10 May 2018 08:45:29 -0700
Joe Perches <[email protected]> wrote:

> There are more than 1000 uses of #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> Make that the default define so these uses can be removed later via script.
>
> Signed-off-by: Joe Perches <[email protected]>
> ---
> include/linux/printk.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/printk.h b/include/linux/printk.h
> index 6d7e800affd8..172dce24e1b6 100644
> --- a/include/linux/printk.h
> +++ b/include/linux/printk.h
> @@ -285,7 +285,7 @@ static inline void printk_safe_flush_on_panic(void)
> extern int kptr_restrict;
>
> #ifndef pr_fmt
> -#define pr_fmt(fmt) fmt
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> #endif

Interesting change. The ring buffer test went from:

[ 12.778404] CPU 0:
[ 12.780488] events: 1596368
[ 12.784841] dropped bytes: 0
[ 12.788682] alloced bytes: 124382988
[ 12.793206] written bytes: 121852123
[ 12.797711] biggest event: 263
[ 12.801706] smallest event: 4
[ 12.809384] read events: 12106
[ 12.813464] lost events: 1584262
[ 12.817709] total events: 1596368
[ 12.821951] recorded len bytes: 975776
[ 12.826107] recorded size bytes: 955733
[ 12.830263] With dropped events, record len and size may not match
[ 12.830263] alloced and written from above

to

[ 12.779526] ring_buffer: CPU 0:
[ 12.782753] ring_buffer: events: 1812797
[ 12.788223] ring_buffer: dropped bytes: 0
[ 12.793179] ring_buffer: alloced bytes: 142291920
[ 12.798815] ring_buffer: written bytes: 139410962
[ 12.804446] ring_buffer: biggest event: 211
[ 12.809558] ring_buffer: smallest event: 4
[ 12.818571] ring_buffer: read events: 13099
[ 12.824929] ring_buffer: lost events: 1799698
[ 12.830293] ring_buffer: total events: 1812797
[ 12.835657] ring_buffer: recorded len bytes: 974336
[ 12.840935] ring_buffer: recorded size bytes: 953514
[ 12.846218] ring_buffer: With dropped events, record len and size may not match
[ 12.846218] alloced and written from above

I'm fine with it.

Acked-by: Steven Rostedt (VMware) <[email protected]>

-- Steve

2018-05-10 18:10:12

by James Morris

[permalink] [raw]
Subject: Re: [PATCH 17/18] security: encrypted-keys: Remove pr_fmt duplicate logging prefixes

On Thu, 10 May 2018, Joe Perches wrote:

> Converting pr_fmt from a simple define to use KBUILD_MODNAME added
> some duplicate logging prefixes to existing uses.
>
> Remove them.
>
> Signed-off-by: Joe Perches <[email protected]>
> ---
> security/keys/encrypted-keys/encrypted.c | 63 ++++++++++++++------------------
> 1 file changed, 28 insertions(+), 35 deletions(-)


Reviewed-by: James Morris <[email protected]>


--
James Morris
<[email protected]>


2018-05-10 19:06:19

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH 01/18] kernel: Use pr_fmt

On Thu, May 10, 2018 at 8:45 AM, Joe Perches <[email protected]> wrote:
> Sometime in the future, it would be useful to convert pr_fmt from a
> default simple define to use a default prefix with KBUILD_MODNAME.
>
> There are files in kernel/ that use pr_<level>, some with an embedded
> prefix, that also do not have a specific pr_fmt define.
>
> Add pr_fmt for those files.
>
> There are some differences in output as some messages are now prefixed
> with their KBUILD_MODNAME.
>
> Miscellanea:
>
> o Align multiline statements to open parenthesis
> o Wrap and realign arguments to 80 columns where sensible
> o Coalesce formats
>
> Signed-off-by: Joe Perches <[email protected]>

Reviewed-by: Kees Cook <[email protected]>

-Kees

--
Kees Cook
Pixel Security

2018-05-10 19:42:43

by Richard Cochran

[permalink] [raw]
Subject: Re: [PATCH 09/18] ptp: Remove pr_fmt duplicate logging prefixes

On Thu, May 10, 2018 at 08:45:35AM -0700, Joe Perches wrote:
> Converting pr_fmt from a simple define to use KBUILD_MODNAME added
> some duplicate logging prefixes to existing uses.
>
> Remove them.
>
> Signed-off-by: Joe Perches <[email protected]>

Acked-by: Richard Cochran <[email protected]>

2018-05-11 01:52:11

by Sergey Senozhatsky

[permalink] [raw]
Subject: Re: [PATCH 03/18] printk: Convert pr_fmt from blank define to KBUILD_MODNAME

On (05/10/18 08:45), Joe Perches wrote:
> There are more than 1000 uses of #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> Make that the default define so these uses can be removed later via script.
>
> Signed-off-by: Joe Perches <[email protected]>

In general, the idea looks OK to me, so FWIW
Acked-by: Sergey Senozhatsky <[email protected]>

A quick question:

- Would "can be removed later via script" be so trivial?
What about these guys?

drivers/of/address.c:#define pr_fmt(fmt) "OF: " fmt
drivers/of/base.c:#define pr_fmt(fmt) "OF: " fmt
drivers/of/dynamic.c:#define pr_fmt(fmt) "OF: " fmt
drivers/of/fdt.c:#define pr_fmt(fmt) "OF: fdt: " fmt
drivers/of/fdt_address.c:#define pr_fmt(fmt) "OF: fdt: " fmt
drivers/of/irq.c:#define pr_fmt(fmt) "OF: " fmt
drivers/of/of_numa.c:#define pr_fmt(fmt) "OF: NUMA: " fmt
drivers/of/of_reserved_mem.c:#define pr_fmt(fmt) "OF: reserved mem: " fmt
drivers/of/overlay.c:#define pr_fmt(fmt) "OF: overlay: " fmt
drivers/of/platform.c:#define pr_fmt(fmt) "OF: " fmt
drivers/of/property.c:#define pr_fmt(fmt) "OF: " fmt
drivers/of/resolver.c:#define pr_fmt(fmt) "OF: resolver: " fmt

-ss

2018-05-11 01:56:24

by Sergey Senozhatsky

[permalink] [raw]
Subject: Re: [PATCH 13/18] printk: Remove pr_fmt duplicate logging prefixes

On (05/10/18 08:45), Joe Perches wrote:
> Converting pr_fmt from a simple define to use KBUILD_MODNAME added
> some duplicate logging prefixes to existing uses.
>
> Remove them.
>
> Signed-off-by: Joe Perches <[email protected]>

Acked-by: Sergey Senozhatsky <[email protected]>

-ss

2018-05-11 01:57:55

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 03/18] printk: Convert pr_fmt from blank define to KBUILD_MODNAME

On Fri, 2018-05-11 at 10:51 +0900, Sergey Senozhatsky wrote:
> On (05/10/18 08:45), Joe Perches wrote:
> > There are more than 1000 uses of #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> > Make that the default define so these uses can be removed later via script.
> >
> > Signed-off-by: Joe Perches <[email protected]>
>
> In general, the idea looks OK to me, so FWIW
> Acked-by: Sergey Senozhatsky <[email protected]>
>
> A quick question:
>
> - Would "can be removed later via script" be so trivial?
> What about these guys?
>
> drivers/of/address.c:#define pr_fmt(fmt) "OF: " fmt
> drivers/of/base.c:#define pr_fmt(fmt) "OF: " fmt
> drivers/of/dynamic.c:#define pr_fmt(fmt) "OF: " fmt
> drivers/of/fdt.c:#define pr_fmt(fmt) "OF: fdt: " fmt
> drivers/of/fdt_address.c:#define pr_fmt(fmt) "OF: fdt: " fmt
> drivers/of/irq.c:#define pr_fmt(fmt) "OF: " fmt
> drivers/of/of_numa.c:#define pr_fmt(fmt) "OF: NUMA: " fmt
> drivers/of/of_reserved_mem.c:#define pr_fmt(fmt) "OF: reserved mem: " fmt
> drivers/of/overlay.c:#define pr_fmt(fmt) "OF: overlay: " fmt
> drivers/of/platform.c:#define pr_fmt(fmt) "OF: " fmt
> drivers/of/property.c:#define pr_fmt(fmt) "OF: " fmt
> drivers/of/resolver.c:#define pr_fmt(fmt) "OF: resolver: " fmt

What about them?

All those defines above are non-generic as they are
specified to start with "OF: " and then some optional
extra bit.

Why should these defines be updated or modified?


2018-05-11 02:13:36

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 03/18] printk: Convert pr_fmt from blank define to KBUILD_MODNAME

On Thu, 2018-05-10 at 18:57 -0700, Joe Perches wrote:
> On Fri, 2018-05-11 at 10:51 +0900, Sergey Senozhatsky wrote:
> > On (05/10/18 08:45), Joe Perches wrote:
> > > There are more than 1000 uses of #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> > > Make that the default define so these uses can be removed later via script.
> > >
> > > Signed-off-by: Joe Perches <[email protected]>
> >
> > In general, the idea looks OK to me, so FWIW
> > Acked-by: Sergey Senozhatsky <[email protected]>
> >
> > A quick question:
> >
> > - Would "can be removed later via script" be so trivial?
> > What about these guys?
> >
> > drivers/of/address.c:#define pr_fmt(fmt) "OF: " fmt
> > drivers/of/base.c:#define pr_fmt(fmt) "OF: " fmt
> > drivers/of/dynamic.c:#define pr_fmt(fmt) "OF: " fmt
> > drivers/of/fdt.c:#define pr_fmt(fmt) "OF: fdt: " fmt
> > drivers/of/fdt_address.c:#define pr_fmt(fmt) "OF: fdt: " fmt
> > drivers/of/irq.c:#define pr_fmt(fmt) "OF: " fmt
> > drivers/of/of_numa.c:#define pr_fmt(fmt) "OF: NUMA: " fmt
> > drivers/of/of_reserved_mem.c:#define pr_fmt(fmt) "OF: reserved mem: " fmt
> > drivers/of/overlay.c:#define pr_fmt(fmt) "OF: overlay: " fmt
> > drivers/of/platform.c:#define pr_fmt(fmt) "OF: " fmt
> > drivers/of/property.c:#define pr_fmt(fmt) "OF: " fmt
> > drivers/of/resolver.c:#define pr_fmt(fmt) "OF: resolver: " fmt
>
> What about them?
>
> All those defines above are non-generic as they are
> specified to start with "OF: " and then some optional
> extra bit.
>
> Why should these defines be updated or modified?

What would be good, and is something that I will
eventually work on, is to make the KBUILD_MODNAME ": "
use a singleton looked up and inserted by the printk
subsystem instead of stored with each format.



2018-05-11 02:23:45

by Sergey Senozhatsky

[permalink] [raw]
Subject: Re: [PATCH 03/18] printk: Convert pr_fmt from blank define to KBUILD_MODNAME

On (05/11/18 10:51), Sergey Senozhatsky wrote:
> In general, the idea looks OK to me, so FWIW
> Acked-by: Sergey Senozhatsky <[email protected]>

Looking at dmesg,

Base:
[ 0.000000] KERNEL supported cpus:
[ 0.000000] Intel GenuineIntel
[...]
[ 0.000000] 00000-9FFFF write-back
[ 0.000000] A0000-BFFFF uncachable
[ 0.000000] C0000-FFFFF write-protect
[ 0.000000] MTRR variable ranges enabled:
[ 0.000000] 0 base 00E0000000 mask 7FE0000000 uncachable
[ 0.000000] 1 disabled
[ 0.000000] 2 disabled
[ 0.000000] 3 disabled
[ 0.000000] 4 disabled
[..]

Patched:
[ 0.000000] common: KERNEL supported cpus:
[ 0.000000] common: Intel GenuineIntel
[...]
[ 0.000000] generic: MTRR default type: write-back
[ 0.000000] generic: MTRR fixed ranges enabled:
[ 0.000000] generic: 00000-9FFFF write-back
[ 0.000000] generic: A0000-BFFFF uncachable
[ 0.000000] generic: C0000-FFFFF write-protect
[ 0.000000] generic: MTRR variable ranges enabled:
[ 0.000000] generic: 0 base 00E0000000 mask 7FE0000000 uncachable
[ 0.000000] generic: 1 disabled
[ 0.000000] generic: 2 disabled
[ 0.000000] generic: 3 disabled
[ 0.000000] generic: 4 disabled
[..]

Is it correct that WARN_ON() from "generic: " will now also be prefixed?
In other words, we will have something like this

[ 28.420519] generic: RSP: 0018:ffffa01dc062bda8 EFLAGS: 00010282
[ 28.420522] generic: RAX: ffffffff8317612f RBX: ffffffffffffffea RCX: ffffa01dc062bdc8
[ 28.420523] generic: RDX: 000055a6a3f03110 RSI: 0000000000000001 RDI: ffffffff83e31540
[ 28.420525] generic: RBP: 0000000000000001 R08: ffffa01dc062bec0 R09: 0000000000000004
[ 28.420526] generic: R10: 0000000000000001 R11: 0000000000000000 R12: 0000000000000001
[ 28.420528] generic: R13: ffffffff83e31540 R14: ffffa01dc062bec0 R15: 0000000000000002
[ 28.420547] generic: ? rcu_read_lock_sched_held+0x5d/0x63
[ 28.420549] generic: ? rcu_sync_lockdep_assert+0x2e/0x54
[ 28.420551] generic: ? __sb_start_write+0xeb/0x1a3

Correct?

-ss

2018-05-11 02:25:34

by Sergey Senozhatsky

[permalink] [raw]
Subject: Re: [PATCH 03/18] printk: Convert pr_fmt from blank define to KBUILD_MODNAME

On (05/10/18 18:57), Joe Perches wrote:
>
> What about them?
>
> All those defines above are non-generic as they are
> specified to start with "OF: " and then some optional
> extra bit.
>
> Why should these defines be updated or modified?

Nevermind, my bad. I, for some reason, assumed that you were going
to drop all of those pr_fmt, but you obviously was speaking only
about those that have "KBUILD_MODNAME".

-ss

2018-05-11 02:34:26

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 03/18] printk: Convert pr_fmt from blank define to KBUILD_MODNAME

On Fri, 2018-05-11 at 11:23 +0900, Sergey Senozhatsky wrote:
> On (05/11/18 10:51), Sergey Senozhatsky wrote:
> > In general, the idea looks OK to me, so FWIW
> > Acked-by: Sergey Senozhatsky <[email protected]>
>
> Looking at dmesg,
>
> Base:
> [ 0.000000] KERNEL supported cpus:
> [ 0.000000] Intel GenuineIntel
> [...]
> [ 0.000000] 00000-9FFFF write-back
> [ 0.000000] A0000-BFFFF uncachable
> [ 0.000000] C0000-FFFFF write-protect
> [ 0.000000] MTRR variable ranges enabled:
> [ 0.000000] 0 base 00E0000000 mask 7FE0000000 uncachable
> [ 0.000000] 1 disabled
> [ 0.000000] 2 disabled
> [ 0.000000] 3 disabled
> [ 0.000000] 4 disabled
> [..]
>
> Patched:
> [ 0.000000] common: KERNEL supported cpus:
> [ 0.000000] common: Intel GenuineIntel
> [...]
> [ 0.000000] generic: MTRR default type: write-back
> [ 0.000000] generic: MTRR fixed ranges enabled:
> [ 0.000000] generic: 00000-9FFFF write-back
> [ 0.000000] generic: A0000-BFFFF uncachable
> [ 0.000000] generic: C0000-FFFFF write-protect
> [ 0.000000] generic: MTRR variable ranges enabled:
> [ 0.000000] generic: 0 base 00E0000000 mask 7FE0000000 uncachable
> [ 0.000000] generic: 1 disabled
> [ 0.000000] generic: 2 disabled
> [ 0.000000] generic: 3 disabled
> [ 0.000000] generic: 4 disabled
> [..]
>
> Is it correct that WARN_ON() from "generic: " will now also be prefixed?
> In other words, we will have something like this
>
> [ 28.420519] generic: RSP: 0018:ffffa01dc062bda8 EFLAGS: 00010282
> [ 28.420522] generic: RAX: ffffffff8317612f RBX: ffffffffffffffea RCX: ffffa01dc062bdc8
> [ 28.420523] generic: RDX: 000055a6a3f03110 RSI: 0000000000000001 RDI: ffffffff83e31540
> [ 28.420525] generic: RBP: 0000000000000001 R08: ffffa01dc062bec0 R09: 0000000000000004
> [ 28.420526] generic: R10: 0000000000000001 R11: 0000000000000000 R12: 0000000000000001
> [ 28.420528] generic: R13: ffffffff83e31540 R14: ffffa01dc062bec0 R15: 0000000000000002
> [ 28.420547] generic: ? rcu_read_lock_sched_held+0x5d/0x63
> [ 28.420549] generic: ? rcu_sync_lockdep_assert+0x2e/0x54
> [ 28.420551] generic: ? __sb_start_write+0xeb/0x1a3
>
> Correct?

No, that stack dump comes from arch/x86/kernel/dumpstack.c
and that uses printk(KERN_DEFAULT ... and generic printk(
which is not prefixed at all.

And it's likely that there should be more files, if
the desired output is not prefixed, that should add

#define pr_fmt(fmt) fmt

to remove prefixes like "generic: "


2018-05-11 02:42:15

by Sergey Senozhatsky

[permalink] [raw]
Subject: Re: [PATCH 03/18] printk: Convert pr_fmt from blank define to KBUILD_MODNAME

On (05/10/18 19:33), Joe Perches wrote:
> >
> > [ 28.420519] generic: RSP: 0018:ffffa01dc062bda8 EFLAGS: 00010282
> > [ 28.420522] generic: RAX: ffffffff8317612f RBX: ffffffffffffffea RCX: ffffa01dc062bdc8
> > [ 28.420523] generic: RDX: 000055a6a3f03110 RSI: 0000000000000001 RDI: ffffffff83e31540
> > [ 28.420525] generic: RBP: 0000000000000001 R08: ffffa01dc062bec0 R09: 0000000000000004
> > [ 28.420526] generic: R10: 0000000000000001 R11: 0000000000000000 R12: 0000000000000001
> > [ 28.420528] generic: R13: ffffffff83e31540 R14: ffffa01dc062bec0 R15: 0000000000000002
> > [ 28.420547] generic: ? rcu_read_lock_sched_held+0x5d/0x63
> > [ 28.420549] generic: ? rcu_sync_lockdep_assert+0x2e/0x54
> > [ 28.420551] generic: ? __sb_start_write+0xeb/0x1a3
> >
> > Correct?
>
> No, that stack dump comes from arch/x86/kernel/dumpstack.c
> and that uses printk(KERN_DEFAULT ... and generic printk(
> which is not prefixed at all.

That's platform specific. Right? Most of platforms [probably most of them]
use plain printk("... %pS"). But some use pr_emerg("[<%p>] %s%pS\n") or
pr_info("PC: [<%08lx>] %pS\n"), and so on.

In case of x86, I think we will have some changes as well. Looking
at generic __warn(): pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS\n")
and pr_warn("WARNING: CPU: %d PID: %d at %pS\n") and probably some
others will change now:

Instead of

[ 0.000000] ------------[ cut here ]------------
[ 0.000000] WARNING: CPU: 0 PID: 0 at blah-blah-blah

we will have
[ 0.000000] panic: ------------[ cut here ]------------
[ 0.000000] panic: WARNING: CPU: 0 PID: 0 at blah-blah-blah

-ss

2018-05-11 02:57:36

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 03/18] printk: Convert pr_fmt from blank define to KBUILD_MODNAME

On Fri, 2018-05-11 at 11:41 +0900, Sergey Senozhatsky wrote:
> On (05/10/18 19:33), Joe Perches wrote:
> > >
> > > [ 28.420519] generic: RSP: 0018:ffffa01dc062bda8 EFLAGS: 00010282
> > > [ 28.420522] generic: RAX: ffffffff8317612f RBX: ffffffffffffffea RCX: ffffa01dc062bdc8
> > > [ 28.420523] generic: RDX: 000055a6a3f03110 RSI: 0000000000000001 RDI: ffffffff83e31540
> > > [ 28.420525] generic: RBP: 0000000000000001 R08: ffffa01dc062bec0 R09: 0000000000000004
> > > [ 28.420526] generic: R10: 0000000000000001 R11: 0000000000000000 R12: 0000000000000001
> > > [ 28.420528] generic: R13: ffffffff83e31540 R14: ffffa01dc062bec0 R15: 0000000000000002
> > > [ 28.420547] generic: ? rcu_read_lock_sched_held+0x5d/0x63
> > > [ 28.420549] generic: ? rcu_sync_lockdep_assert+0x2e/0x54
> > > [ 28.420551] generic: ? __sb_start_write+0xeb/0x1a3
> > >
> > > Correct?
> >
> > No, that stack dump comes from arch/x86/kernel/dumpstack.c
> > and that uses printk(KERN_DEFAULT ... and generic printk(
> > which is not prefixed at all.
>
> That's platform specific. Right?

yes, it seems so.

> Most of platforms [probably most of them]
> use plain printk("... %pS"). But some use pr_emerg("[<%p>] %s%pS\n") or
> pr_info("PC: [<%08lx>] %pS\n"), and so on.
>
> In case of x86, I think we will have some changes as well. Looking
> at generic __warn(): pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS\n")
> and pr_warn("WARNING: CPU: %d PID: %d at %pS\n") and probably some
> others will change now:
>
> Instead of
>
> [ 0.000000] ------------[ cut here ]------------
> [ 0.000000] WARNING: CPU: 0 PID: 0 at blah-blah-blah
>
> we will have
> [ 0.000000] panic: ------------[ cut here ]------------
> [ 0.000000] panic: WARNING: CPU: 0 PID: 0 at blah-blah-blah

right.

So far, I've made no attempt to update arch/...

It's almost certain that some additions of
#define pr_fmt(fmt) fmt
will need to be made for some arch/... files.


2018-05-11 21:39:52

by Joe Perches

[permalink] [raw]
Subject: [PATCH] ring_buffer: Update logging to use single line output

With a possible change to pr_fmt coming, the logging output can
become unbalanced when an initial line has a prefix and subsequent
lines do not when a multiple line pr_<level> is emitted.

Fix it by emitting a single line.

Miscellanea:

o Convert consecutive tests of total_lost and !total_lost to if/else

Signed-off-by: Joe Perches <[email protected]>
---
kernel/trace/ring_buffer.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index c9cb9767d49b..ee74494a2da3 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -5132,10 +5132,9 @@ static __init int test_ringbuffer(void)
pr_info(" total events: %ld\n", total_lost + total_read);
pr_info(" recorded len bytes: %ld\n", total_len);
pr_info(" recorded size bytes: %ld\n", total_size);
- if (total_lost)
- pr_info(" With dropped events, record len and size may not match\n"
- " alloced and written from above\n");
- if (!total_lost) {
+ if (total_lost) {
+ pr_info(" With dropped events, record len and size may not match alloced and written from above\n");
+ } else {
if (RB_WARN_ON(buffer, total_len != total_alloc ||
total_size != total_written))
break;

2018-05-13 19:17:45

by Jessica Yu

[permalink] [raw]
Subject: Re: [PATCH 01/18] kernel: Use pr_fmt

+++ Joe Perches [10/05/18 08:45 -0700]:
>Sometime in the future, it would be useful to convert pr_fmt from a
>default simple define to use a default prefix with KBUILD_MODNAME.
>
>There are files in kernel/ that use pr_<level>, some with an embedded
>prefix, that also do not have a specific pr_fmt define.
>
>Add pr_fmt for those files.
>
>There are some differences in output as some messages are now prefixed
>with their KBUILD_MODNAME.
>
>Miscellanea:
>
>o Align multiline statements to open parenthesis
>o Wrap and realign arguments to 80 columns where sensible
>o Coalesce formats
>
>Signed-off-by: Joe Perches <[email protected]>

Acked-by: Jessica Yu <[email protected]> (for module.c)

>---
> kernel/acct.c | 2 ++
> kernel/async.c | 14 ++++++------
> kernel/audit_tree.c | 2 +-
> kernel/backtracetest.c | 8 +++----
> kernel/crash_core.c | 29 ++++++++++++++-----------
> kernel/exit.c | 2 ++
> kernel/hung_task.c | 13 +++++------
> kernel/kprobes.c | 20 ++++++++++-------
> kernel/module.c | 59 +++++++++++++++++++++++---------------------------
> kernel/panic.c | 3 +++
> kernel/params.c | 13 ++++++-----
> kernel/pid.c | 2 ++
> kernel/profile.c | 2 ++
> kernel/range.c | 2 +-
> kernel/relay.c | 5 ++++-
> kernel/seccomp.c | 4 +++-
> kernel/signal.c | 10 +++++----
> kernel/smpboot.c | 5 ++++-
> kernel/taskstats.c | 4 +++-
> kernel/torture.c | 6 +++--
> kernel/tracepoint.c | 3 +++
> kernel/workqueue.c | 2 ++
> 22 files changed, 122 insertions(+), 88 deletions(-)
>
>diff --git a/kernel/acct.c b/kernel/acct.c
>index addf7732fb56..c3d393655f11 100644
>--- a/kernel/acct.c
>+++ b/kernel/acct.c
>@@ -44,6 +44,8 @@
> * a struct file opened for write. Fixed. 2/6/2000, AV.
> */
>
>+#define pr_fmt(fmt) fmt
>+
> #include <linux/mm.h>
> #include <linux/slab.h>
> #include <linux/acct.h>
>diff --git a/kernel/async.c b/kernel/async.c
>index a893d6170944..9a6ab6016713 100644
>--- a/kernel/async.c
>+++ b/kernel/async.c
>@@ -120,8 +120,8 @@ static void async_run_entry_fn(struct work_struct *work)
> /* 1) run (and print duration) */
> if (initcall_debug && system_state < SYSTEM_RUNNING) {
> pr_debug("calling %lli_%pF @ %i\n",
>- (long long)entry->cookie,
>- entry->func, task_pid_nr(current));
>+ (long long)entry->cookie,
>+ entry->func, task_pid_nr(current));
> calltime = ktime_get();
> }
> entry->func(entry->data, entry->cookie);
>@@ -129,9 +129,9 @@ static void async_run_entry_fn(struct work_struct *work)
> rettime = ktime_get();
> delta = ktime_sub(rettime, calltime);
> pr_debug("initcall %lli_%pF returned 0 after %lld usecs\n",
>- (long long)entry->cookie,
>- entry->func,
>- (long long)ktime_to_ns(delta) >> 10);
>+ (long long)entry->cookie,
>+ entry->func,
>+ (long long)ktime_to_ns(delta) >> 10);
> }
>
> /* 2) remove self from the pending queues */
>@@ -300,8 +300,8 @@ void async_synchronize_cookie_domain(async_cookie_t cookie, struct async_domain
> delta = ktime_sub(endtime, starttime);
>
> pr_debug("async_continuing @ %i after %lli usec\n",
>- task_pid_nr(current),
>- (long long)ktime_to_ns(delta) >> 10);
>+ task_pid_nr(current),
>+ (long long)ktime_to_ns(delta) >> 10);
> }
> }
> EXPORT_SYMBOL_GPL(async_synchronize_cookie_domain);
>diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
>index 67e6956c0b61..f34f90b4a346 100644
>--- a/kernel/audit_tree.c
>+++ b/kernel/audit_tree.c
>@@ -739,7 +739,7 @@ static int audit_launch_prune(void)
> prune_thread = kthread_run(prune_tree_thread, NULL,
> "audit_prune_tree");
> if (IS_ERR(prune_thread)) {
>- pr_err("cannot start thread audit_prune_tree");
>+ pr_err("cannot start thread audit_prune_tree\n");
> prune_thread = NULL;
> return -ENOMEM;
> }
>diff --git a/kernel/backtracetest.c b/kernel/backtracetest.c
>index 1323360d90e3..d10cc39b0134 100644
>--- a/kernel/backtracetest.c
>+++ b/kernel/backtracetest.c
>@@ -19,7 +19,7 @@
>
> static void backtrace_test_normal(void)
> {
>- pr_info("Testing a backtrace from process context.\n");
>+ pr_info("Testing a backtrace from process context\n");
> pr_info("The following trace is a kernel self test and not a bug!\n");
>
> dump_stack();
>@@ -37,7 +37,7 @@ static DECLARE_TASKLET(backtrace_tasklet, &backtrace_test_irq_callback, 0);
>
> static void backtrace_test_irq(void)
> {
>- pr_info("Testing a backtrace from irq context.\n");
>+ pr_info("Testing a backtrace from irq context\n");
> pr_info("The following trace is a kernel self test and not a bug!\n");
>
> init_completion(&backtrace_work);
>@@ -51,7 +51,7 @@ static void backtrace_test_saved(void)
> struct stack_trace trace;
> unsigned long entries[8];
>
>- pr_info("Testing a saved backtrace.\n");
>+ pr_info("Testing a saved backtrace\n");
> pr_info("The following trace is a kernel self test and not a bug!\n");
>
> trace.nr_entries = 0;
>@@ -65,7 +65,7 @@ static void backtrace_test_saved(void)
> #else
> static void backtrace_test_saved(void)
> {
>- pr_info("Saved backtrace test skipped.\n");
>+ pr_info("Saved backtrace test skipped\n");
> }
> #endif
>
>diff --git a/kernel/crash_core.c b/kernel/crash_core.c
>index f7674d676889..4eda1ee9da8c 100644
>--- a/kernel/crash_core.c
>+++ b/kernel/crash_core.c
>@@ -6,6 +6,8 @@
> * Version 2. See the file COPYING for more details.
> */
>
>+#define pr_fmt(fmt) "crashkernel: " fmt
>+
> #include <linux/crash_core.h>
> #include <linux/utsname.h>
> #include <linux/vmalloc.h>
>@@ -49,12 +51,12 @@ static int __init parse_crashkernel_mem(char *cmdline,
> /* get the start of the range */
> start = memparse(cur, &tmp);
> if (cur == tmp) {
>- pr_warn("crashkernel: Memory value expected\n");
>+ pr_warn("Memory value expected\n");
> return -EINVAL;
> }
> cur = tmp;
> if (*cur != '-') {
>- pr_warn("crashkernel: '-' expected\n");
>+ pr_warn("'-' expected\n");
> return -EINVAL;
> }
> cur++;
>@@ -63,18 +65,18 @@ static int __init parse_crashkernel_mem(char *cmdline,
> if (*cur != ':') {
> end = memparse(cur, &tmp);
> if (cur == tmp) {
>- pr_warn("crashkernel: Memory value expected\n");
>+ pr_warn("Memory value expected\n");
> return -EINVAL;
> }
> cur = tmp;
> if (end <= start) {
>- pr_warn("crashkernel: end <= start\n");
>+ pr_warn("end <= start\n");
> return -EINVAL;
> }
> }
>
> if (*cur != ':') {
>- pr_warn("crashkernel: ':' expected\n");
>+ pr_warn("':' expected\n");
> return -EINVAL;
> }
> cur++;
>@@ -86,7 +88,7 @@ static int __init parse_crashkernel_mem(char *cmdline,
> }
> cur = tmp;
> if (size >= system_ram) {
>- pr_warn("crashkernel: invalid size\n");
>+ pr_warn("invalid size\n");
> return -EINVAL;
> }
>
>@@ -108,8 +110,9 @@ static int __init parse_crashkernel_mem(char *cmdline,
> return -EINVAL;
> }
> }
>- } else
>- pr_info("crashkernel size resulted in zero bytes\n");
>+ } else {
>+ pr_info("size resulted in zero bytes\n");
>+ }
>
> return 0;
> }
>@@ -129,14 +132,14 @@ static int __init parse_crashkernel_simple(char *cmdline,
>
> *crash_size = memparse(cmdline, &cur);
> if (cmdline == cur) {
>- pr_warn("crashkernel: memory value expected\n");
>+ pr_warn("memory value expected\n");
> return -EINVAL;
> }
>
> if (*cur == '@')
> *crash_base = memparse(cur+1, &cur);
> else if (*cur != ' ' && *cur != '\0') {
>- pr_warn("crashkernel: unrecognized char: %c\n", *cur);
>+ pr_warn("unrecognized char: %c\n", *cur);
> return -EINVAL;
> }
>
>@@ -167,18 +170,18 @@ static int __init parse_crashkernel_suffix(char *cmdline,
>
> *crash_size = memparse(cmdline, &cur);
> if (cmdline == cur) {
>- pr_warn("crashkernel: memory value expected\n");
>+ pr_warn("memory value expected\n");
> return -EINVAL;
> }
>
> /* check with suffix */
> if (strncmp(cur, suffix, strlen(suffix))) {
>- pr_warn("crashkernel: unrecognized char: %c\n", *cur);
>+ pr_warn("unrecognized char: %c\n", *cur);
> return -EINVAL;
> }
> cur += strlen(suffix);
> if (*cur != ' ' && *cur != '\0') {
>- pr_warn("crashkernel: unrecognized char: %c\n", *cur);
>+ pr_warn("unrecognized char: %c\n", *cur);
> return -EINVAL;
> }
>
>diff --git a/kernel/exit.c b/kernel/exit.c
>index 68e1598d7931..679d4de9a5fa 100644
>--- a/kernel/exit.c
>+++ b/kernel/exit.c
>@@ -4,6 +4,8 @@
> * Copyright (C) 1991, 1992 Linus Torvalds
> */
>
>+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>+
> #include <linux/mm.h>
> #include <linux/slab.h>
> #include <linux/sched/autogroup.h>
>diff --git a/kernel/hung_task.c b/kernel/hung_task.c
>index 32b479468e4d..c66278415811 100644
>--- a/kernel/hung_task.c
>+++ b/kernel/hung_task.c
>@@ -113,14 +113,13 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout)
> if (sysctl_hung_task_warnings) {
> if (sysctl_hung_task_warnings > 0)
> sysctl_hung_task_warnings--;
>- pr_err("INFO: task %s:%d blocked for more than %ld seconds.\n",
>- t->comm, t->pid, timeout);
>+ pr_err("INFO: task %s:%d blocked for more than %ld seconds\n",
>+ t->comm, t->pid, timeout);
> pr_err(" %s %s %.*s\n",
>- print_tainted(), init_utsname()->release,
>- (int)strcspn(init_utsname()->version, " "),
>- init_utsname()->version);
>- pr_err("\"echo 0 > /proc/sys/kernel/hung_task_timeout_secs\""
>- " disables this message.\n");
>+ print_tainted(), init_utsname()->release,
>+ (int)strcspn(init_utsname()->version, " "),
>+ init_utsname()->version);
>+ pr_err("\"echo 0 > /proc/sys/kernel/hung_task_timeout_secs\" disables this message\n");
> sched_show_task(t);
> hung_task_show_lock = true;
> }
>diff --git a/kernel/kprobes.c b/kernel/kprobes.c
>index ea619021d901..0b8facde8dd0 100644
>--- a/kernel/kprobes.c
>+++ b/kernel/kprobes.c
>@@ -31,6 +31,9 @@
> * <[email protected]> and Prasanna S Panchamukhi
> * <[email protected]> added function-return probes.
> */
>+
>+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>+
> #include <linux/kprobes.h>
> #include <linux/hash.h>
> #include <linux/init.h>
>@@ -985,7 +988,8 @@ static int arm_kprobe_ftrace(struct kprobe *p)
> ret = ftrace_set_filter_ip(&kprobe_ftrace_ops,
> (unsigned long)p->addr, 0, 0);
> if (ret) {
>- pr_debug("Failed to arm kprobe-ftrace at %p (%d)\n", p->addr, ret);
>+ pr_debug("Failed to arm kprobe-ftrace at %p (%d)\n",
>+ p->addr, ret);
> return ret;
> }
>
>@@ -2198,7 +2202,7 @@ static int __init populate_kprobe_blacklist(unsigned long *start,
> if (!kernel_text_address(entry) ||
> !kallsyms_lookup_size_offset(entry, &size, &offset)) {
> pr_err("Failed to find blacklist at %p\n",
>- (void *)entry);
>+ (void *)entry);
> continue;
> }
>
>@@ -2281,8 +2285,8 @@ static int __init init_kprobes(void)
> err = populate_kprobe_blacklist(__start_kprobe_blacklist,
> __stop_kprobe_blacklist);
> if (err) {
>- pr_err("kprobes: failed to populate blacklist: %d\n", err);
>- pr_err("Please take care of using kprobes.\n");
>+ pr_err("failed to populate blacklist: %d\n", err);
>+ pr_err("Please take care of using kprobes\n");
> }
>
> if (kretprobe_blacklist_size) {
>@@ -2488,10 +2492,10 @@ static int arm_all_kprobes(void)
> }
>
> if (errors)
>- pr_warn("Kprobes globally enabled, but failed to arm %d out of %d probes\n",
>+ pr_warn("globally enabled, but failed to arm %d out of %d probes\n",
> errors, total);
> else
>- pr_info("Kprobes globally enabled\n");
>+ pr_info("globally enabled\n");
>
> already_enabled:
> mutex_unlock(&kprobe_mutex);
>@@ -2531,10 +2535,10 @@ static int disarm_all_kprobes(void)
> }
>
> if (errors)
>- pr_warn("Kprobes globally disabled, but failed to disarm %d out of %d probes\n",
>+ pr_warn("globally disabled, but failed to disarm %d out of %d probes\n",
> errors, total);
> else
>- pr_info("Kprobes globally disabled\n");
>+ pr_info("globally disabled\n");
>
> mutex_unlock(&kprobe_mutex);
>
>diff --git a/kernel/module.c b/kernel/module.c
>index 36543e382389..94624b46c9bd 100644
>--- a/kernel/module.c
>+++ b/kernel/module.c
>@@ -16,6 +16,9 @@
> along with this program; if not, write to the Free Software
> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> */
>+
>+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>+
> #include <linux/export.h>
> #include <linux/extable.h>
> #include <linux/moduleloader.h>
>@@ -523,21 +526,17 @@ static bool check_symbol(const struct symsearch *syms,
> if (syms->licence == GPL_ONLY)
> return false;
> if (syms->licence == WILL_BE_GPL_ONLY && fsa->warn) {
>- pr_warn("Symbol %s is being used by a non-GPL module, "
>- "which will not be allowed in the future\n",
>+ pr_warn("Symbol %s is being used by a non-GPL module, which will not be allowed in the future.\n",
> fsa->name);
> }
> }
>
> #ifdef CONFIG_UNUSED_SYMBOLS
> if (syms->unused && fsa->warn) {
>- pr_warn("Symbol %s is marked as UNUSED, however this module is "
>- "using it.\n", fsa->name);
>+ pr_warn("Symbol %s is marked as UNUSED, however this module is using it.\n",
>+ fsa->name);
> pr_warn("This symbol will go away in the future.\n");
>- pr_warn("Please evaluate if this is the right api to use and "
>- "if it really is, submit a report to the linux kernel "
>- "mailing list together with submitting your code for "
>- "inclusion.\n");
>+ pr_warn("Please evaluate if this is the right api to use and if it really is, submit a report to the linux kernel mailing list together with submitting your code for inclusion.\n");
> }
> #endif
>
>@@ -843,7 +842,7 @@ static int add_module_usage(struct module *a, struct module *b)
> {
> struct module_use *use;
>
>- pr_debug("Allocating new usage for %s.\n", a->name);
>+ pr_debug("Allocating new usage for %s\n", a->name);
> use = kmalloc(sizeof(*use), GFP_ATOMIC);
> if (!use)
> return -ENOMEM;
>@@ -1265,7 +1264,7 @@ static int try_to_force_load(struct module *mod, const char *reason)
> {
> #ifdef CONFIG_MODULE_FORCE_LOAD
> if (!test_taint(TAINT_FORCED_MODULE))
>- pr_warn("%s: %s: kernel tainted.\n", mod->name, reason);
>+ pr_warn("%s: %s: kernel tainted\n", mod->name, reason);
> add_taint_module(mod, TAINT_FORCED_MODULE, LOCKDEP_NOW_UNRELIABLE);
> return 0;
> #else
>@@ -1435,7 +1434,7 @@ resolve_symbol_wait(struct module *mod,
> !IS_ERR(ksym = resolve_symbol(mod, info, name, owner))
> || PTR_ERR(ksym) != -EBUSY,
> 30 * HZ) <= 0) {
>- pr_warn("%s: gave up waiting for init of module %s.\n",
>+ pr_warn("%s: gave up waiting for init of module %s\n",
> mod->name, owner);
> }
> return ksym;
>@@ -2224,8 +2223,7 @@ static int verify_export_symbols(struct module *mod)
> for (i = 0; i < ARRAY_SIZE(arr); i++) {
> for (s = arr[i].sym; s < arr[i].sym + arr[i].num; s++) {
> if (find_symbol(s->name, &owner, NULL, true, false)) {
>- pr_err("%s: exports duplicate symbol %s"
>- " (owned by %s)\n",
>+ pr_err("%s: exports duplicate symbol %s (owned by %s)\n",
> mod->name, s->name, module_name(owner));
> return -ENOEXEC;
> }
>@@ -2257,14 +2255,14 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
> supposed to happen. */
> pr_debug("Common symbol: %s\n", name);
> pr_warn("%s: please compile with -fno-common\n",
>- mod->name);
>+ mod->name);
> ret = -ENOEXEC;
> break;
>
> case SHN_ABS:
> /* Don't need to do anything */
> pr_debug("Absolute symbol: 0x%08lx\n",
>- (long)sym[i].st_value);
>+ (long)sym[i].st_value);
> break;
>
> case SHN_LIVEPATCH:
>@@ -2454,7 +2452,7 @@ static void set_license(struct module *mod, const char *license)
>
> if (!license_is_gpl_compatible(license)) {
> if (!test_taint(TAINT_PROPRIETARY_MODULE))
>- pr_warn("%s: module license '%s' taints kernel.\n",
>+ pr_warn("%s: module license '%s' taints kernel\n",
> mod->name, license);
> add_taint_module(mod, TAINT_PROPRIETARY_MODULE,
> LOCKDEP_NOW_UNRELIABLE);
>@@ -2717,7 +2715,7 @@ static void dynamic_debug_setup(struct module *mod, struct _ddebug *debug, unsig
> #ifdef CONFIG_DYNAMIC_DEBUG
> if (ddebug_add_module(debug, num, mod->name))
> pr_err("dynamic debug error adding module: %s\n",
>- debug->modname);
>+ debug->modname);
> #endif
> }
>
>@@ -2849,7 +2847,7 @@ static int check_modinfo_livepatch(struct module *mod, struct load_info *info)
> static int check_modinfo_livepatch(struct module *mod, struct load_info *info)
> {
> if (get_modinfo(info, "livepatch")) {
>- pr_err("%s: module is marked as livepatch module, but livepatch support is disabled",
>+ pr_err("%s: module is marked as livepatch module, but livepatch support is disabled\n",
> mod->name);
> return -ENOEXEC;
> }
>@@ -2863,7 +2861,7 @@ static void check_modinfo_retpoline(struct module *mod, struct load_info *info)
> if (retpoline_module_ok(get_modinfo(info, "retpoline")))
> return;
>
>- pr_warn("%s: loading module not compiled with retpoline compiler.\n",
>+ pr_warn("%s: loading module not compiled with retpoline compiler\n",
> mod->name);
> }
>
>@@ -3037,8 +3035,8 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
>
> if (get_modinfo(info, "staging")) {
> add_taint_module(mod, TAINT_CRAP, LOCKDEP_STILL_OK);
>- pr_warn("%s: module is from the staging directory, the quality "
>- "is unknown, you have been warned.\n", mod->name);
>+ pr_warn("%s: module is from the staging directory, the quality is unknown, you have been warned\n",
>+ mod->name);
> }
>
> err = check_modinfo_livepatch(mod, info);
>@@ -3089,8 +3087,8 @@ static int find_module_sections(struct module *mod, struct load_info *info)
> * This shouldn't happen with same compiler and binutils
> * building all parts of the module.
> */
>- pr_warn("%s: has both .ctors and .init_array.\n",
>- mod->name);
>+ pr_warn("%s: has both .ctors and .init_array\n",
>+ mod->name);
> return -EINVAL;
> }
> #endif
>@@ -3227,7 +3225,7 @@ static int check_module_license_and_versions(struct module *mod)
> LOCKDEP_NOW_UNRELIABLE);
>
> if (!prev_taint && test_taint(TAINT_PROPRIETARY_MODULE))
>- pr_warn("%s: module license taints kernel.\n", mod->name);
>+ pr_warn("%s: module license taints kernel\n", mod->name);
>
> #ifdef CONFIG_MODVERSIONS
> if ((mod->num_syms && !mod->crcs)
>@@ -3459,8 +3457,7 @@ static noinline int do_init_module(struct module *mod)
> goto fail_free_freeinit;
> }
> if (ret > 0) {
>- pr_warn("%s: '%s'->init suspiciously returned %d, it should "
>- "follow 0/-E convention\n"
>+ pr_warn("%s: '%s'->init suspiciously returned %d, it should follow 0/-E convention\n"
> "%s: loading module anyway...\n",
> __func__, mod->name, ret, __func__);
> dump_stack();
>@@ -3686,9 +3683,8 @@ static int load_module(struct load_info *info, const char __user *uargs,
> #ifdef CONFIG_MODULE_SIG
> mod->sig_ok = info->sig_ok;
> if (!mod->sig_ok) {
>- pr_notice_once("%s: module verification failed: signature "
>- "and/or required key missing - tainting "
>- "kernel\n", mod->name);
>+ pr_notice_once("%s: module verification failed: signature and/or required key missing - tainting kernel\n",
>+ mod->name);
> add_taint_module(mod, TAINT_UNSIGNED_MODULE, LOCKDEP_STILL_OK);
> }
> #endif
>@@ -3763,7 +3759,7 @@ static int load_module(struct load_info *info, const char __user *uargs,
> goto coming_cleanup;
> } else if (after_dashes) {
> pr_warn("%s: parameters '%s' after `--' ignored\n",
>- mod->name, after_dashes);
>+ mod->name, after_dashes);
> }
>
> /* Link in to sysfs. */
>@@ -3843,8 +3839,7 @@ SYSCALL_DEFINE3(init_module, void __user *, umod,
> if (err)
> return err;
>
>- pr_debug("init_module: umod=%p, len=%lu, uargs=%p\n",
>- umod, len, uargs);
>+ pr_debug("init_module: umod=%p, len=%lu, uargs=%p\n", umod, len, uargs);
>
> err = copy_module_from_user(umod, len, &info);
> if (err)
>diff --git a/kernel/panic.c b/kernel/panic.c
>index 42e487488554..e34631818bb7 100644
>--- a/kernel/panic.c
>+++ b/kernel/panic.c
>@@ -8,6 +8,9 @@
> * This function is used through-out the kernel (including mm and fs)
> * to indicate a major problem.
> */
>+
>+#define pr_fmt(fmt) fmt
>+
> #include <linux/debug_locks.h>
> #include <linux/sched/debug.h>
> #include <linux/interrupt.h>
>diff --git a/kernel/params.c b/kernel/params.c
>index ce89f757e6da..757049bfa346 100644
>--- a/kernel/params.c
>+++ b/kernel/params.c
>@@ -15,6 +15,9 @@
> along with this program; if not, write to the Free Software
> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> */
>+
>+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>+
> #include <linux/kernel.h>
> #include <linux/string.h>
> #include <linux/errno.h>
>@@ -141,8 +144,8 @@ static int parse_one(char *param,
> if (!val &&
> !(params[i].ops->flags & KERNEL_PARAM_OPS_FL_NOARG))
> return -EINVAL;
>- pr_debug("handling %s with %p\n", param,
>- params[i].ops->set);
>+ pr_debug("handling %s with %p\n",
>+ param, params[i].ops->set);
> kernel_param_lock(params[i].mod);
> param_check_unsafe(&params[i]);
> err = params[i].ops->set(val, &params[i]);
>@@ -496,8 +499,8 @@ int param_set_copystring(const char *val, const struct kernel_param *kp)
> const struct kparam_string *kps = kp->str;
>
> if (strlen(val)+1 > kps->maxlen) {
>- pr_err("%s: string doesn't fit in %u chars.\n",
>- kp->name, kps->maxlen-1);
>+ pr_err("%s: string doesn't fit in %u chars\n",
>+ kp->name, kps->maxlen - 1);
> return -ENOSPC;
> }
> strcpy(kps->string, val);
>@@ -763,7 +766,7 @@ static struct module_kobject * __init locate_module_kobject(const char *name)
> #endif
> if (err) {
> kobject_put(&mk->kobj);
>- pr_crit("Adding module '%s' to sysfs failed (%d), the system may be unstable.\n",
>+ pr_crit("Adding module '%s' to sysfs failed (%d), the system may be unstable\n",
> name, err);
> return NULL;
> }
>diff --git a/kernel/pid.c b/kernel/pid.c
>index 157fe4b19971..2ddd7adfa77d 100644
>--- a/kernel/pid.c
>+++ b/kernel/pid.c
>@@ -26,6 +26,8 @@
> *
> */
>
>+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>+
> #include <linux/mm.h>
> #include <linux/export.h>
> #include <linux/slab.h>
>diff --git a/kernel/profile.c b/kernel/profile.c
>index 9aa2a4445b0d..e5cc8f360236 100644
>--- a/kernel/profile.c
>+++ b/kernel/profile.c
>@@ -14,6 +14,8 @@
> * Oracle, 2004
> */
>
>+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>+
> #include <linux/export.h>
> #include <linux/profile.h>
> #include <linux/bootmem.h>
>diff --git a/kernel/range.c b/kernel/range.c
>index d84de6766472..e828c950d401 100644
>--- a/kernel/range.c
>+++ b/kernel/range.c
>@@ -102,7 +102,7 @@ void subtract_range(struct range *range, int az, u64 start, u64 end)
> range[i].start = end;
> } else {
> pr_err("%s: run out of slot in ranges\n",
>- __func__);
>+ __func__);
> }
> range[j].end = start;
> continue;
>diff --git a/kernel/relay.c b/kernel/relay.c
>index c955b10c973c..02f3790af754 100644
>--- a/kernel/relay.c
>+++ b/kernel/relay.c
>@@ -12,6 +12,9 @@
> *
> * This file is released under the GPL.
> */
>+
>+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>+
> #include <linux/errno.h>
> #include <linux/stddef.h>
> #include <linux/slab.h>
>@@ -527,7 +530,7 @@ int relay_prepare_cpu(unsigned int cpu)
> continue;
> buf = relay_open_buf(chan, cpu);
> if (!buf) {
>- pr_err("relay: cpu %d buffer creation failed\n", cpu);
>+ pr_err("cpu %d buffer creation failed\n", cpu);
> mutex_unlock(&relay_channels_mutex);
> return -ENOMEM;
> }
>diff --git a/kernel/seccomp.c b/kernel/seccomp.c
>index 5386749cdd21..de696bc574b4 100644
>--- a/kernel/seccomp.c
>+++ b/kernel/seccomp.c
>@@ -14,6 +14,8 @@
> * of Berkeley Packet Filters/Linux Socket Filters.
> */
>
>+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>+
> #include <linux/refcount.h>
> #include <linux/audit.h>
> #include <linux/compat.h>
>@@ -1323,7 +1325,7 @@ static int __init seccomp_sysctl_init(void)
>
> hdr = register_sysctl_paths(seccomp_sysctl_path, seccomp_sysctl_table);
> if (!hdr)
>- pr_warn("seccomp: sysctl registration failed\n");
>+ pr_warn("sysctl registration failed\n");
> else
> kmemleak_not_leak(hdr);
>
>diff --git a/kernel/signal.c b/kernel/signal.c
>index 0f865d67415d..4b93feddcdcd 100644
>--- a/kernel/signal.c
>+++ b/kernel/signal.c
>@@ -10,6 +10,8 @@
> * to allow signals to be sent reliably.
> */
>
>+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>+
> #include <linux/slab.h>
> #include <linux/export.h>
> #include <linux/init.h>
>@@ -235,7 +237,7 @@ static inline void print_dropped_signal(int sig)
> return;
>
> pr_info("%s/%d: reached RLIMIT_SIGPENDING, dropped signal %d\n",
>- current->comm, current->pid, sig);
>+ current->comm, current->pid, sig);
> }
>
> /**
>@@ -1118,10 +1120,10 @@ static int send_signal(int sig, struct siginfo *info, struct task_struct *t,
> static void print_fatal_signal(int signr)
> {
> struct pt_regs *regs = signal_pt_regs();
>- pr_info("potentially unexpected fatal signal %d.\n", signr);
>+ pr_info("potentially unexpected fatal signal %d\n", signr);
>
> #if defined(__i386__) && !defined(__arch_um__)
>- pr_info("code at %08lx: ", regs->ip);
>+ pr_info("code at %08lx:", regs->ip);
> {
> int i;
> for (i = 0; i < 16; i++) {
>@@ -1129,7 +1131,7 @@ static void print_fatal_signal(int signr)
>
> if (get_user(insn, (unsigned char *)(regs->ip + i)))
> break;
>- pr_cont("%02x ", insn);
>+ pr_cont(" %02x", insn);
> }
> }
> pr_cont("\n");
>diff --git a/kernel/smpboot.c b/kernel/smpboot.c
>index 5043e7433f4b..17e129faf498 100644
>--- a/kernel/smpboot.c
>+++ b/kernel/smpboot.c
>@@ -1,6 +1,9 @@
> /*
> * Common SMP CPU bringup/teardown functions
> */
>+
>+#define pr_fmt(fmt) "SMP: " fmt
>+
> #include <linux/cpu.h>
> #include <linux/err.h>
> #include <linux/smp.h>
>@@ -54,7 +57,7 @@ static inline void idle_init(unsigned int cpu)
> if (!tsk) {
> tsk = fork_idle(cpu);
> if (IS_ERR(tsk))
>- pr_err("SMP: fork_idle() failed for CPU %u\n", cpu);
>+ pr_err("fork_idle() failed for CPU %u\n", cpu);
> else
> per_cpu(idle_threads, cpu) = tsk;
> }
>diff --git a/kernel/taskstats.c b/kernel/taskstats.c
>index 4e62a4a8fa91..8973cb0a1eab 100644
>--- a/kernel/taskstats.c
>+++ b/kernel/taskstats.c
>@@ -16,6 +16,8 @@
> *
> */
>
>+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>+
> #include <linux/kernel.h>
> #include <linux/taskstats_kern.h>
> #include <linux/tsacct_kern.h>
>@@ -690,7 +692,7 @@ static int __init taskstats_init(void)
> return rc;
>
> family_registered = 1;
>- pr_info("registered taskstats version %d\n", TASKSTATS_GENL_VERSION);
>+ pr_info("registered version %d\n", TASKSTATS_GENL_VERSION);
> return 0;
> }
>
>diff --git a/kernel/torture.c b/kernel/torture.c
>index 3de1efbecd6a..da4f95c11bf9 100644
>--- a/kernel/torture.c
>+++ b/kernel/torture.c
>@@ -20,6 +20,9 @@
> * Author: Paul E. McKenney <[email protected]>
> * Based on kernel/rcu/torture.c.
> */
>+
>+#define pr_fmt(fmt) fmt
>+
> #include <linux/types.h>
> #include <linux/kernel.h>
> #include <linux/init.h>
>@@ -99,8 +102,7 @@ bool torture_offline(int cpu, long *n_offl_attempts, long *n_offl_successes,
> return false;
>
> if (verbose)
>- pr_alert("%s" TORTURE_FLAG
>- "torture_onoff task: offlining %d\n",
>+ pr_alert("%s" TORTURE_FLAG "torture_onoff task: offlining %d\n",
> torture_type, cpu);
> starttime = jiffies;
> (*n_offl_attempts)++;
>diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
>index 1e37da2e0c25..d4753ff47738 100644
>--- a/kernel/tracepoint.c
>+++ b/kernel/tracepoint.c
>@@ -15,6 +15,9 @@
> * along with this program; if not, write to the Free Software
> * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
> */
>+
>+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>+
> #include <linux/module.h>
> #include <linux/mutex.h>
> #include <linux/types.h>
>diff --git a/kernel/workqueue.c b/kernel/workqueue.c
>index ca7959be8aaa..7f1f75abcf7c 100644
>--- a/kernel/workqueue.c
>+++ b/kernel/workqueue.c
>@@ -24,6 +24,8 @@
> * Please read Documentation/core-api/workqueue.rst for details.
> */
>
>+#define pr_fmt(fmt) fmt
>+
> #include <linux/export.h>
> #include <linux/kernel.h>
> #include <linux/sched.h>
>--
>2.15.0
>

Subject: [tip:x86/cleanups] x86: Remove pr_fmt duplicate logging prefixes

Commit-ID: 1de392f5d5e803663abbd8ed084233f154152bcd
Gitweb: https://git.kernel.org/tip/1de392f5d5e803663abbd8ed084233f154152bcd
Author: Joe Perches <[email protected]>
AuthorDate: Thu, 10 May 2018 08:45:30 -0700
Committer: Thomas Gleixner <[email protected]>
CommitDate: Sun, 13 May 2018 21:25:18 +0200

x86: Remove pr_fmt duplicate logging prefixes

Converting pr_fmt from a default simple #define to use KBUILD_MODNAME
added some duplicate prefixes.

Remove the duplicate prefixes.

Signed-off-by: Joe Perches <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Link: https://lkml.kernel.org/r/e7b709a2b040af7faa81b0aa2c3a125aed628a82.1525964383.git.joe@perches.com

---
arch/x86/events/amd/ibs.c | 2 +-
arch/x86/kernel/e820.c | 32 +++++++++++++++++---------------
arch/x86/kernel/hpet.c | 5 ++---
arch/x86/kernel/uprobes.c | 4 ++--
arch/x86/mm/numa.c | 22 +++++++++++-----------
5 files changed, 33 insertions(+), 32 deletions(-)

diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
index 786fd875de92..4b98101209a1 100644
--- a/arch/x86/events/amd/ibs.c
+++ b/arch/x86/events/amd/ibs.c
@@ -889,7 +889,7 @@ static void force_ibs_eilvt_setup(void)
if (!ibs_eilvt_valid())
goto out;

- pr_info("IBS: LVT offset %d assigned\n", offset);
+ pr_info("LVT offset %d assigned\n", offset);

return;
out:
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 6a2cb1442e05..d1f25c831447 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -155,7 +155,8 @@ static void __init __e820__range_add(struct e820_table *table, u64 start, u64 si
int x = table->nr_entries;

if (x >= ARRAY_SIZE(table->entries)) {
- pr_err("e820: too many entries; ignoring [mem %#010llx-%#010llx]\n", start, start + size - 1);
+ pr_err("too many entries; ignoring [mem %#010llx-%#010llx]\n",
+ start, start + size - 1);
return;
}

@@ -190,9 +191,10 @@ void __init e820__print_table(char *who)
int i;

for (i = 0; i < e820_table->nr_entries; i++) {
- pr_info("%s: [mem %#018Lx-%#018Lx] ", who,
- e820_table->entries[i].addr,
- e820_table->entries[i].addr + e820_table->entries[i].size - 1);
+ pr_info("%s: [mem %#018Lx-%#018Lx] ",
+ who,
+ e820_table->entries[i].addr,
+ e820_table->entries[i].addr + e820_table->entries[i].size - 1);

e820_print_type(e820_table->entries[i].type);
pr_cont("\n");
@@ -574,7 +576,7 @@ void __init e820__update_table_print(void)
if (e820__update_table(e820_table))
return;

- pr_info("e820: modified physical RAM map:\n");
+ pr_info("modified physical RAM map:\n");
e820__print_table("modified");
}

@@ -636,9 +638,8 @@ __init void e820__setup_pci_gap(void)
if (!found) {
#ifdef CONFIG_X86_64
gapstart = (max_pfn << PAGE_SHIFT) + 1024*1024;
- pr_err(
- "e820: Cannot find an available gap in the 32-bit address range\n"
- "e820: PCI devices with unassigned 32-bit BARs may not work!\n");
+ pr_err("Cannot find an available gap in the 32-bit address range\n");
+ pr_err("PCI devices with unassigned 32-bit BARs may not work!\n");
#else
gapstart = 0x10000000;
#endif
@@ -649,7 +650,8 @@ __init void e820__setup_pci_gap(void)
*/
pci_mem_start = gapstart;

- pr_info("e820: [mem %#010lx-%#010lx] available for PCI devices\n", gapstart, gapstart + gapsize - 1);
+ pr_info("[mem %#010lx-%#010lx] available for PCI devices\n",
+ gapstart, gapstart + gapsize - 1);
}

/*
@@ -711,7 +713,7 @@ void __init e820__memory_setup_extended(u64 phys_addr, u32 data_len)
memcpy(e820_table_firmware, e820_table, sizeof(*e820_table_firmware));

early_memunmap(sdata, data_len);
- pr_info("e820: extended physical RAM map:\n");
+ pr_info("extended physical RAM map:\n");
e820__print_table("extended");
}

@@ -780,7 +782,7 @@ u64 __init e820__memblock_alloc_reserved(u64 size, u64 align)
addr = __memblock_alloc_base(size, align, MEMBLOCK_ALLOC_ACCESSIBLE);
if (addr) {
e820__range_update_kexec(addr, size, E820_TYPE_RAM, E820_TYPE_RESERVED);
- pr_info("e820: update e820_table_kexec for e820__memblock_alloc_reserved()\n");
+ pr_info("update e820_table_kexec for e820__memblock_alloc_reserved()\n");
e820__update_table_kexec();
}

@@ -830,8 +832,8 @@ static unsigned long __init e820_end_pfn(unsigned long limit_pfn, enum e820_type
if (last_pfn > max_arch_pfn)
last_pfn = max_arch_pfn;

- pr_info("e820: last_pfn = %#lx max_arch_pfn = %#lx\n",
- last_pfn, max_arch_pfn);
+ pr_info("last_pfn = %#lx max_arch_pfn = %#lx\n",
+ last_pfn, max_arch_pfn);
return last_pfn;
}

@@ -1005,7 +1007,7 @@ void __init e820__finish_early_params(void)
if (e820__update_table(e820_table) < 0)
early_panic("Invalid user supplied memory map");

- pr_info("e820: user-defined physical RAM map:\n");
+ pr_info("user-defined physical RAM map:\n");
e820__print_table("user");
}
}
@@ -1238,7 +1240,7 @@ void __init e820__memory_setup(void)
memcpy(e820_table_kexec, e820_table, sizeof(*e820_table_kexec));
memcpy(e820_table_firmware, e820_table, sizeof(*e820_table_firmware));

- pr_info("e820: BIOS-provided physical RAM map:\n");
+ pr_info("BIOS-provided physical RAM map:\n");
e820__print_table(who);
}

diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index 8ce4212e2b8d..b6be34ee88e9 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -975,8 +975,7 @@ int __init hpet_enable(void)
cfg &= ~(HPET_CFG_ENABLE | HPET_CFG_LEGACY);
hpet_writel(cfg, HPET_CFG);
if (cfg)
- pr_warn("HPET: Unrecognized bits %#x set in global cfg\n",
- cfg);
+ pr_warn("Unrecognized bits %#x set in global cfg\n", cfg);

for (i = 0; i <= last; ++i) {
cfg = hpet_readl(HPET_Tn_CFG(i));
@@ -988,7 +987,7 @@ int __init hpet_enable(void)
| HPET_TN_64BIT_CAP | HPET_TN_32BIT | HPET_TN_ROUTE
| HPET_TN_FSB | HPET_TN_FSB_CAP);
if (cfg)
- pr_warn("HPET: Unrecognized bits %#x set in cfg#%u\n",
+ pr_warn("Unrecognized bits %#x set in cfg#%u\n",
cfg, i);
}
hpet_print_config();
diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
index 85c7ef23d99f..d1c468741915 100644
--- a/arch/x86/kernel/uprobes.c
+++ b/arch/x86/kernel/uprobes.c
@@ -1079,8 +1079,8 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
return orig_ret_vaddr;

if (nleft != rasize) {
- pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
- "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
+ pr_err("return address clobbered: pid=%d, %%sp=%#lx, %%ip=%#lx\n",
+ current->pid, regs->sp, regs->ip);

force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
}
diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index 25504d5aa816..fa150855647c 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -136,13 +136,13 @@ static int __init numa_add_memblk_to(int nid, u64 start, u64 end,

/* whine about and ignore invalid blks */
if (start > end || nid < 0 || nid >= MAX_NUMNODES) {
- pr_warning("NUMA: Warning: invalid memblk node %d [mem %#010Lx-%#010Lx]\n",
- nid, start, end - 1);
+ pr_warn("Warning: invalid memblk node %d [mem %#010Lx-%#010Lx]\n",
+ nid, start, end - 1);
return 0;
}

if (mi->nr_blks >= NR_NODE_MEMBLKS) {
- pr_err("NUMA: too many memblk ranges\n");
+ pr_err("too many memblk ranges\n");
return -EINVAL;
}

@@ -267,14 +267,14 @@ int __init numa_cleanup_meminfo(struct numa_meminfo *mi)
*/
if (bi->end > bj->start && bi->start < bj->end) {
if (bi->nid != bj->nid) {
- pr_err("NUMA: node %d [mem %#010Lx-%#010Lx] overlaps with node %d [mem %#010Lx-%#010Lx]\n",
+ pr_err("node %d [mem %#010Lx-%#010Lx] overlaps with node %d [mem %#010Lx-%#010Lx]\n",
bi->nid, bi->start, bi->end - 1,
bj->nid, bj->start, bj->end - 1);
return -EINVAL;
}
- pr_warning("NUMA: Warning: node %d [mem %#010Lx-%#010Lx] overlaps with itself [mem %#010Lx-%#010Lx]\n",
- bi->nid, bi->start, bi->end - 1,
- bj->start, bj->end - 1);
+ pr_warn("Warning: node %d [mem %#010Lx-%#010Lx] overlaps with itself [mem %#010Lx-%#010Lx]\n",
+ bi->nid, bi->start, bi->end - 1,
+ bj->start, bj->end - 1);
}

/*
@@ -364,7 +364,7 @@ static int __init numa_alloc_distance(void)
phys = memblock_find_in_range(0, PFN_PHYS(max_pfn_mapped),
size, PAGE_SIZE);
if (!phys) {
- pr_warning("NUMA: Warning: can't allocate distance table!\n");
+ pr_warn("Warning: can't allocate distance table!\n");
/* don't retry until explicitly reset */
numa_distance = (void *)1LU;
return -ENOMEM;
@@ -410,14 +410,14 @@ void __init numa_set_distance(int from, int to, int distance)

if (from >= numa_distance_cnt || to >= numa_distance_cnt ||
from < 0 || to < 0) {
- pr_warn_once("NUMA: Warning: node ids are out of bound, from=%d to=%d distance=%d\n",
- from, to, distance);
+ pr_warn_once("Warning: node ids are out of bound, from=%d to=%d distance=%d\n",
+ from, to, distance);
return;
}

if ((u8)distance != distance ||
(from == to && distance != LOCAL_DISTANCE)) {
- pr_warn_once("NUMA: Warning: invalid distance parameter, from=%d to=%d distance=%d\n",
+ pr_warn_once("Warning: invalid distance parameter, from=%d to=%d distance=%d\n",
from, to, distance);
return;
}

Subject: [tip:x86/cleanups] x86/mtrr: Rename main.c to mtrr.c and remove duplicate prefixes

Commit-ID: e6d8c84a58380030457759ad6085f3792a76b2ce
Gitweb: https://git.kernel.org/tip/e6d8c84a58380030457759ad6085f3792a76b2ce
Author: Joe Perches <[email protected]>
AuthorDate: Thu, 10 May 2018 08:45:31 -0700
Committer: Thomas Gleixner <[email protected]>
CommitDate: Sun, 13 May 2018 21:25:18 +0200

x86/mtrr: Rename main.c to mtrr.c and remove duplicate prefixes

Kbuild uses the first file as the name for KBUILD_MODNAME.
mtrr uses main.c as its first file, so rename that file to mtrr.c
and fixup the Makefile.

Remove the now duplicate "mtrr: " prefixes from the logging calls.

Signed-off-by: Joe Perches <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Link: https://lkml.kernel.org/r/ae1fa81a0d1fad87571967b91ea90f70f486e853.1525964384.git.joe@perches.com

---
arch/x86/kernel/cpu/mtrr/Makefile | 2 +-
arch/x86/kernel/cpu/mtrr/{main.c => mtrr.c} | 33 ++++++++++++++---------------
2 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/arch/x86/kernel/cpu/mtrr/Makefile b/arch/x86/kernel/cpu/mtrr/Makefile
index ad9e5ed81181..2ad9107ee980 100644
--- a/arch/x86/kernel/cpu/mtrr/Makefile
+++ b/arch/x86/kernel/cpu/mtrr/Makefile
@@ -1,3 +1,3 @@
-obj-y := main.o if.o generic.o cleanup.o
+obj-y := mtrr.o if.o generic.o cleanup.o
obj-$(CONFIG_X86_32) += amd.o cyrix.o centaur.o

diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/mtrr.c
similarity index 96%
rename from arch/x86/kernel/cpu/mtrr/main.c
rename to arch/x86/kernel/cpu/mtrr/mtrr.c
index 7468de429087..0c4f4fba9ec1 100644
--- a/arch/x86/kernel/cpu/mtrr/main.c
+++ b/arch/x86/kernel/cpu/mtrr/mtrr.c
@@ -100,7 +100,7 @@ static int have_wrcomb(void)
if (dev->vendor == PCI_VENDOR_ID_SERVERWORKS &&
dev->device == PCI_DEVICE_ID_SERVERWORKS_LE &&
dev->revision <= 5) {
- pr_info("mtrr: Serverworks LE rev < 6 detected. Write-combining disabled.\n");
+ pr_info("Serverworks LE rev < 6 detected. Write-combining disabled.\n");
pci_dev_put(dev);
return 0;
}
@@ -110,7 +110,7 @@ static int have_wrcomb(void)
*/
if (dev->vendor == PCI_VENDOR_ID_INTEL &&
dev->device == PCI_DEVICE_ID_INTEL_82451NX) {
- pr_info("mtrr: Intel 450NX MMC detected. Write-combining disabled.\n");
+ pr_info("Intel 450NX MMC detected. Write-combining disabled.\n");
pci_dev_put(dev);
return 0;
}
@@ -312,24 +312,24 @@ int mtrr_add_page(unsigned long base, unsigned long size,
return error;

if (type >= MTRR_NUM_TYPES) {
- pr_warn("mtrr: type: %u invalid\n", type);
+ pr_warn("type: %u invalid\n", type);
return -EINVAL;
}

/* If the type is WC, check that this processor supports it */
if ((type == MTRR_TYPE_WRCOMB) && !have_wrcomb()) {
- pr_warn("mtrr: your processor doesn't support write-combining\n");
+ pr_warn("your processor doesn't support write-combining\n");
return -ENOSYS;
}

if (!size) {
- pr_warn("mtrr: zero sized request\n");
+ pr_warn("zero sized request\n");
return -EINVAL;
}

if ((base | (base + size - 1)) >>
(boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) {
- pr_warn("mtrr: base or size exceeds the MTRR width\n");
+ pr_warn("base or size exceeds the MTRR width\n");
return -EINVAL;
}

@@ -360,8 +360,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
} else if (types_compatible(type, ltype))
continue;
}
- pr_warn("mtrr: 0x%lx000,0x%lx000 overlaps existing"
- " 0x%lx000,0x%lx000\n", base, size, lbase,
+ pr_warn("0x%lx000,0x%lx000 overlaps existing 0x%lx000,0x%lx000\n", base, size, lbase,
lsize);
goto out;
}
@@ -369,7 +368,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
if (ltype != type) {
if (types_compatible(type, ltype))
continue;
- pr_warn("mtrr: type mismatch for %lx000,%lx000 old: %s new: %s\n",
+ pr_warn("type mismatch for %lx000,%lx000 old: %s new: %s\n",
base, size, mtrr_attrib_to_str(ltype),
mtrr_attrib_to_str(type));
goto out;
@@ -395,7 +394,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
}
}
} else {
- pr_info("mtrr: no more MTRRs available\n");
+ pr_info("no more MTRRs available\n");
}
error = i;
out:
@@ -407,8 +406,8 @@ int mtrr_add_page(unsigned long base, unsigned long size,
static int mtrr_check(unsigned long base, unsigned long size)
{
if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) {
- pr_warn("mtrr: size and base must be multiples of 4 kiB\n");
- pr_debug("mtrr: size: 0x%lx base: 0x%lx\n", size, base);
+ pr_warn("size and base must be multiples of 4 kiB\n");
+ pr_debug("size: 0x%lx base: 0x%lx\n", size, base);
dump_stack();
return -1;
}
@@ -499,22 +498,22 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
}
}
if (reg < 0) {
- pr_debug("mtrr: no MTRR for %lx000,%lx000 found\n",
+ pr_debug("no MTRR for %lx000,%lx000 found\n",
base, size);
goto out;
}
}
if (reg >= max) {
- pr_warn("mtrr: register: %d too big\n", reg);
+ pr_warn("register: %d too big\n", reg);
goto out;
}
mtrr_if->get(reg, &lbase, &lsize, &ltype);
if (lsize < 1) {
- pr_warn("mtrr: MTRR %d not used\n", reg);
+ pr_warn("MTRR %d not used\n", reg);
goto out;
}
if (mtrr_usage_table[reg] < 1) {
- pr_warn("mtrr: reg: %d has count=0\n", reg);
+ pr_warn("reg: %d has count=0\n", reg);
goto out;
}
if (--mtrr_usage_table[reg] < 1)
@@ -775,7 +774,7 @@ void __init mtrr_bp_init(void)
}

if (!mtrr_enabled()) {
- pr_info("MTRR: Disabled\n");
+ pr_info("Disabled\n");

/*
* PAT initialization relies on MTRR's rendezvous handler.

2018-05-14 13:40:49

by Masami Hiramatsu

[permalink] [raw]
Subject: Re: [PATCH 01/18] kernel: Use pr_fmt

On Thu, 10 May 2018 08:45:27 -0700
Joe Perches <[email protected]> wrote:

> Sometime in the future, it would be useful to convert pr_fmt from a
> default simple define to use a default prefix with KBUILD_MODNAME.
>
> There are files in kernel/ that use pr_<level>, some with an embedded
> prefix, that also do not have a specific pr_fmt define.
>
> Add pr_fmt for those files.
>
> There are some differences in output as some messages are now prefixed
> with their KBUILD_MODNAME.
>
> Miscellanea:
>
> o Align multiline statements to open parenthesis
> o Wrap and realign arguments to 80 columns where sensible
> o Coalesce formats
>
> Signed-off-by: Joe Perches <[email protected]>

Kprobes part looks good to me.

Acked-by: Masami Hiramatsu <[email protected]>

Thanks!

--
Masami Hiramatsu <[email protected]>

2018-05-14 18:06:36

by Paul E. McKenney

[permalink] [raw]
Subject: Re: [PATCH 01/18] kernel: Use pr_fmt

On Thu, May 10, 2018 at 08:45:27AM -0700, Joe Perches wrote:
> Sometime in the future, it would be useful to convert pr_fmt from a
> default simple define to use a default prefix with KBUILD_MODNAME.
>
> There are files in kernel/ that use pr_<level>, some with an embedded
> prefix, that also do not have a specific pr_fmt define.
>
> Add pr_fmt for those files.
>
> There are some differences in output as some messages are now prefixed
> with their KBUILD_MODNAME.
>
> Miscellanea:
>
> o Align multiline statements to open parenthesis
> o Wrap and realign arguments to 80 columns where sensible
> o Coalesce formats
>
> Signed-off-by: Joe Perches <[email protected]>

For kernel/torture.c:

Acked-by: Paul E. McKenney <[email protected]>

> ---
> kernel/acct.c | 2 ++
> kernel/async.c | 14 ++++++------
> kernel/audit_tree.c | 2 +-
> kernel/backtracetest.c | 8 +++----
> kernel/crash_core.c | 29 ++++++++++++++-----------
> kernel/exit.c | 2 ++
> kernel/hung_task.c | 13 +++++------
> kernel/kprobes.c | 20 ++++++++++-------
> kernel/module.c | 59 +++++++++++++++++++++++---------------------------
> kernel/panic.c | 3 +++
> kernel/params.c | 13 ++++++-----
> kernel/pid.c | 2 ++
> kernel/profile.c | 2 ++
> kernel/range.c | 2 +-
> kernel/relay.c | 5 ++++-
> kernel/seccomp.c | 4 +++-
> kernel/signal.c | 10 +++++----
> kernel/smpboot.c | 5 ++++-
> kernel/taskstats.c | 4 +++-
> kernel/torture.c | 6 +++--
> kernel/tracepoint.c | 3 +++
> kernel/workqueue.c | 2 ++
> 22 files changed, 122 insertions(+), 88 deletions(-)
>
> diff --git a/kernel/acct.c b/kernel/acct.c
> index addf7732fb56..c3d393655f11 100644
> --- a/kernel/acct.c
> +++ b/kernel/acct.c
> @@ -44,6 +44,8 @@
> * a struct file opened for write. Fixed. 2/6/2000, AV.
> */
>
> +#define pr_fmt(fmt) fmt
> +
> #include <linux/mm.h>
> #include <linux/slab.h>
> #include <linux/acct.h>
> diff --git a/kernel/async.c b/kernel/async.c
> index a893d6170944..9a6ab6016713 100644
> --- a/kernel/async.c
> +++ b/kernel/async.c
> @@ -120,8 +120,8 @@ static void async_run_entry_fn(struct work_struct *work)
> /* 1) run (and print duration) */
> if (initcall_debug && system_state < SYSTEM_RUNNING) {
> pr_debug("calling %lli_%pF @ %i\n",
> - (long long)entry->cookie,
> - entry->func, task_pid_nr(current));
> + (long long)entry->cookie,
> + entry->func, task_pid_nr(current));
> calltime = ktime_get();
> }
> entry->func(entry->data, entry->cookie);
> @@ -129,9 +129,9 @@ static void async_run_entry_fn(struct work_struct *work)
> rettime = ktime_get();
> delta = ktime_sub(rettime, calltime);
> pr_debug("initcall %lli_%pF returned 0 after %lld usecs\n",
> - (long long)entry->cookie,
> - entry->func,
> - (long long)ktime_to_ns(delta) >> 10);
> + (long long)entry->cookie,
> + entry->func,
> + (long long)ktime_to_ns(delta) >> 10);
> }
>
> /* 2) remove self from the pending queues */
> @@ -300,8 +300,8 @@ void async_synchronize_cookie_domain(async_cookie_t cookie, struct async_domain
> delta = ktime_sub(endtime, starttime);
>
> pr_debug("async_continuing @ %i after %lli usec\n",
> - task_pid_nr(current),
> - (long long)ktime_to_ns(delta) >> 10);
> + task_pid_nr(current),
> + (long long)ktime_to_ns(delta) >> 10);
> }
> }
> EXPORT_SYMBOL_GPL(async_synchronize_cookie_domain);
> diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
> index 67e6956c0b61..f34f90b4a346 100644
> --- a/kernel/audit_tree.c
> +++ b/kernel/audit_tree.c
> @@ -739,7 +739,7 @@ static int audit_launch_prune(void)
> prune_thread = kthread_run(prune_tree_thread, NULL,
> "audit_prune_tree");
> if (IS_ERR(prune_thread)) {
> - pr_err("cannot start thread audit_prune_tree");
> + pr_err("cannot start thread audit_prune_tree\n");
> prune_thread = NULL;
> return -ENOMEM;
> }
> diff --git a/kernel/backtracetest.c b/kernel/backtracetest.c
> index 1323360d90e3..d10cc39b0134 100644
> --- a/kernel/backtracetest.c
> +++ b/kernel/backtracetest.c
> @@ -19,7 +19,7 @@
>
> static void backtrace_test_normal(void)
> {
> - pr_info("Testing a backtrace from process context.\n");
> + pr_info("Testing a backtrace from process context\n");
> pr_info("The following trace is a kernel self test and not a bug!\n");
>
> dump_stack();
> @@ -37,7 +37,7 @@ static DECLARE_TASKLET(backtrace_tasklet, &backtrace_test_irq_callback, 0);
>
> static void backtrace_test_irq(void)
> {
> - pr_info("Testing a backtrace from irq context.\n");
> + pr_info("Testing a backtrace from irq context\n");
> pr_info("The following trace is a kernel self test and not a bug!\n");
>
> init_completion(&backtrace_work);
> @@ -51,7 +51,7 @@ static void backtrace_test_saved(void)
> struct stack_trace trace;
> unsigned long entries[8];
>
> - pr_info("Testing a saved backtrace.\n");
> + pr_info("Testing a saved backtrace\n");
> pr_info("The following trace is a kernel self test and not a bug!\n");
>
> trace.nr_entries = 0;
> @@ -65,7 +65,7 @@ static void backtrace_test_saved(void)
> #else
> static void backtrace_test_saved(void)
> {
> - pr_info("Saved backtrace test skipped.\n");
> + pr_info("Saved backtrace test skipped\n");
> }
> #endif
>
> diff --git a/kernel/crash_core.c b/kernel/crash_core.c
> index f7674d676889..4eda1ee9da8c 100644
> --- a/kernel/crash_core.c
> +++ b/kernel/crash_core.c
> @@ -6,6 +6,8 @@
> * Version 2. See the file COPYING for more details.
> */
>
> +#define pr_fmt(fmt) "crashkernel: " fmt
> +
> #include <linux/crash_core.h>
> #include <linux/utsname.h>
> #include <linux/vmalloc.h>
> @@ -49,12 +51,12 @@ static int __init parse_crashkernel_mem(char *cmdline,
> /* get the start of the range */
> start = memparse(cur, &tmp);
> if (cur == tmp) {
> - pr_warn("crashkernel: Memory value expected\n");
> + pr_warn("Memory value expected\n");
> return -EINVAL;
> }
> cur = tmp;
> if (*cur != '-') {
> - pr_warn("crashkernel: '-' expected\n");
> + pr_warn("'-' expected\n");
> return -EINVAL;
> }
> cur++;
> @@ -63,18 +65,18 @@ static int __init parse_crashkernel_mem(char *cmdline,
> if (*cur != ':') {
> end = memparse(cur, &tmp);
> if (cur == tmp) {
> - pr_warn("crashkernel: Memory value expected\n");
> + pr_warn("Memory value expected\n");
> return -EINVAL;
> }
> cur = tmp;
> if (end <= start) {
> - pr_warn("crashkernel: end <= start\n");
> + pr_warn("end <= start\n");
> return -EINVAL;
> }
> }
>
> if (*cur != ':') {
> - pr_warn("crashkernel: ':' expected\n");
> + pr_warn("':' expected\n");
> return -EINVAL;
> }
> cur++;
> @@ -86,7 +88,7 @@ static int __init parse_crashkernel_mem(char *cmdline,
> }
> cur = tmp;
> if (size >= system_ram) {
> - pr_warn("crashkernel: invalid size\n");
> + pr_warn("invalid size\n");
> return -EINVAL;
> }
>
> @@ -108,8 +110,9 @@ static int __init parse_crashkernel_mem(char *cmdline,
> return -EINVAL;
> }
> }
> - } else
> - pr_info("crashkernel size resulted in zero bytes\n");
> + } else {
> + pr_info("size resulted in zero bytes\n");
> + }
>
> return 0;
> }
> @@ -129,14 +132,14 @@ static int __init parse_crashkernel_simple(char *cmdline,
>
> *crash_size = memparse(cmdline, &cur);
> if (cmdline == cur) {
> - pr_warn("crashkernel: memory value expected\n");
> + pr_warn("memory value expected\n");
> return -EINVAL;
> }
>
> if (*cur == '@')
> *crash_base = memparse(cur+1, &cur);
> else if (*cur != ' ' && *cur != '\0') {
> - pr_warn("crashkernel: unrecognized char: %c\n", *cur);
> + pr_warn("unrecognized char: %c\n", *cur);
> return -EINVAL;
> }
>
> @@ -167,18 +170,18 @@ static int __init parse_crashkernel_suffix(char *cmdline,
>
> *crash_size = memparse(cmdline, &cur);
> if (cmdline == cur) {
> - pr_warn("crashkernel: memory value expected\n");
> + pr_warn("memory value expected\n");
> return -EINVAL;
> }
>
> /* check with suffix */
> if (strncmp(cur, suffix, strlen(suffix))) {
> - pr_warn("crashkernel: unrecognized char: %c\n", *cur);
> + pr_warn("unrecognized char: %c\n", *cur);
> return -EINVAL;
> }
> cur += strlen(suffix);
> if (*cur != ' ' && *cur != '\0') {
> - pr_warn("crashkernel: unrecognized char: %c\n", *cur);
> + pr_warn("unrecognized char: %c\n", *cur);
> return -EINVAL;
> }
>
> diff --git a/kernel/exit.c b/kernel/exit.c
> index 68e1598d7931..679d4de9a5fa 100644
> --- a/kernel/exit.c
> +++ b/kernel/exit.c
> @@ -4,6 +4,8 @@
> * Copyright (C) 1991, 1992 Linus Torvalds
> */
>
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> #include <linux/mm.h>
> #include <linux/slab.h>
> #include <linux/sched/autogroup.h>
> diff --git a/kernel/hung_task.c b/kernel/hung_task.c
> index 32b479468e4d..c66278415811 100644
> --- a/kernel/hung_task.c
> +++ b/kernel/hung_task.c
> @@ -113,14 +113,13 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout)
> if (sysctl_hung_task_warnings) {
> if (sysctl_hung_task_warnings > 0)
> sysctl_hung_task_warnings--;
> - pr_err("INFO: task %s:%d blocked for more than %ld seconds.\n",
> - t->comm, t->pid, timeout);
> + pr_err("INFO: task %s:%d blocked for more than %ld seconds\n",
> + t->comm, t->pid, timeout);
> pr_err(" %s %s %.*s\n",
> - print_tainted(), init_utsname()->release,
> - (int)strcspn(init_utsname()->version, " "),
> - init_utsname()->version);
> - pr_err("\"echo 0 > /proc/sys/kernel/hung_task_timeout_secs\""
> - " disables this message.\n");
> + print_tainted(), init_utsname()->release,
> + (int)strcspn(init_utsname()->version, " "),
> + init_utsname()->version);
> + pr_err("\"echo 0 > /proc/sys/kernel/hung_task_timeout_secs\" disables this message\n");
> sched_show_task(t);
> hung_task_show_lock = true;
> }
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index ea619021d901..0b8facde8dd0 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -31,6 +31,9 @@
> * <[email protected]> and Prasanna S Panchamukhi
> * <[email protected]> added function-return probes.
> */
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> #include <linux/kprobes.h>
> #include <linux/hash.h>
> #include <linux/init.h>
> @@ -985,7 +988,8 @@ static int arm_kprobe_ftrace(struct kprobe *p)
> ret = ftrace_set_filter_ip(&kprobe_ftrace_ops,
> (unsigned long)p->addr, 0, 0);
> if (ret) {
> - pr_debug("Failed to arm kprobe-ftrace at %p (%d)\n", p->addr, ret);
> + pr_debug("Failed to arm kprobe-ftrace at %p (%d)\n",
> + p->addr, ret);
> return ret;
> }
>
> @@ -2198,7 +2202,7 @@ static int __init populate_kprobe_blacklist(unsigned long *start,
> if (!kernel_text_address(entry) ||
> !kallsyms_lookup_size_offset(entry, &size, &offset)) {
> pr_err("Failed to find blacklist at %p\n",
> - (void *)entry);
> + (void *)entry);
> continue;
> }
>
> @@ -2281,8 +2285,8 @@ static int __init init_kprobes(void)
> err = populate_kprobe_blacklist(__start_kprobe_blacklist,
> __stop_kprobe_blacklist);
> if (err) {
> - pr_err("kprobes: failed to populate blacklist: %d\n", err);
> - pr_err("Please take care of using kprobes.\n");
> + pr_err("failed to populate blacklist: %d\n", err);
> + pr_err("Please take care of using kprobes\n");
> }
>
> if (kretprobe_blacklist_size) {
> @@ -2488,10 +2492,10 @@ static int arm_all_kprobes(void)
> }
>
> if (errors)
> - pr_warn("Kprobes globally enabled, but failed to arm %d out of %d probes\n",
> + pr_warn("globally enabled, but failed to arm %d out of %d probes\n",
> errors, total);
> else
> - pr_info("Kprobes globally enabled\n");
> + pr_info("globally enabled\n");
>
> already_enabled:
> mutex_unlock(&kprobe_mutex);
> @@ -2531,10 +2535,10 @@ static int disarm_all_kprobes(void)
> }
>
> if (errors)
> - pr_warn("Kprobes globally disabled, but failed to disarm %d out of %d probes\n",
> + pr_warn("globally disabled, but failed to disarm %d out of %d probes\n",
> errors, total);
> else
> - pr_info("Kprobes globally disabled\n");
> + pr_info("globally disabled\n");
>
> mutex_unlock(&kprobe_mutex);
>
> diff --git a/kernel/module.c b/kernel/module.c
> index 36543e382389..94624b46c9bd 100644
> --- a/kernel/module.c
> +++ b/kernel/module.c
> @@ -16,6 +16,9 @@
> along with this program; if not, write to the Free Software
> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> */
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> #include <linux/export.h>
> #include <linux/extable.h>
> #include <linux/moduleloader.h>
> @@ -523,21 +526,17 @@ static bool check_symbol(const struct symsearch *syms,
> if (syms->licence == GPL_ONLY)
> return false;
> if (syms->licence == WILL_BE_GPL_ONLY && fsa->warn) {
> - pr_warn("Symbol %s is being used by a non-GPL module, "
> - "which will not be allowed in the future\n",
> + pr_warn("Symbol %s is being used by a non-GPL module, which will not be allowed in the future.\n",
> fsa->name);
> }
> }
>
> #ifdef CONFIG_UNUSED_SYMBOLS
> if (syms->unused && fsa->warn) {
> - pr_warn("Symbol %s is marked as UNUSED, however this module is "
> - "using it.\n", fsa->name);
> + pr_warn("Symbol %s is marked as UNUSED, however this module is using it.\n",
> + fsa->name);
> pr_warn("This symbol will go away in the future.\n");
> - pr_warn("Please evaluate if this is the right api to use and "
> - "if it really is, submit a report to the linux kernel "
> - "mailing list together with submitting your code for "
> - "inclusion.\n");
> + pr_warn("Please evaluate if this is the right api to use and if it really is, submit a report to the linux kernel mailing list together with submitting your code for inclusion.\n");
> }
> #endif
>
> @@ -843,7 +842,7 @@ static int add_module_usage(struct module *a, struct module *b)
> {
> struct module_use *use;
>
> - pr_debug("Allocating new usage for %s.\n", a->name);
> + pr_debug("Allocating new usage for %s\n", a->name);
> use = kmalloc(sizeof(*use), GFP_ATOMIC);
> if (!use)
> return -ENOMEM;
> @@ -1265,7 +1264,7 @@ static int try_to_force_load(struct module *mod, const char *reason)
> {
> #ifdef CONFIG_MODULE_FORCE_LOAD
> if (!test_taint(TAINT_FORCED_MODULE))
> - pr_warn("%s: %s: kernel tainted.\n", mod->name, reason);
> + pr_warn("%s: %s: kernel tainted\n", mod->name, reason);
> add_taint_module(mod, TAINT_FORCED_MODULE, LOCKDEP_NOW_UNRELIABLE);
> return 0;
> #else
> @@ -1435,7 +1434,7 @@ resolve_symbol_wait(struct module *mod,
> !IS_ERR(ksym = resolve_symbol(mod, info, name, owner))
> || PTR_ERR(ksym) != -EBUSY,
> 30 * HZ) <= 0) {
> - pr_warn("%s: gave up waiting for init of module %s.\n",
> + pr_warn("%s: gave up waiting for init of module %s\n",
> mod->name, owner);
> }
> return ksym;
> @@ -2224,8 +2223,7 @@ static int verify_export_symbols(struct module *mod)
> for (i = 0; i < ARRAY_SIZE(arr); i++) {
> for (s = arr[i].sym; s < arr[i].sym + arr[i].num; s++) {
> if (find_symbol(s->name, &owner, NULL, true, false)) {
> - pr_err("%s: exports duplicate symbol %s"
> - " (owned by %s)\n",
> + pr_err("%s: exports duplicate symbol %s (owned by %s)\n",
> mod->name, s->name, module_name(owner));
> return -ENOEXEC;
> }
> @@ -2257,14 +2255,14 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
> supposed to happen. */
> pr_debug("Common symbol: %s\n", name);
> pr_warn("%s: please compile with -fno-common\n",
> - mod->name);
> + mod->name);
> ret = -ENOEXEC;
> break;
>
> case SHN_ABS:
> /* Don't need to do anything */
> pr_debug("Absolute symbol: 0x%08lx\n",
> - (long)sym[i].st_value);
> + (long)sym[i].st_value);
> break;
>
> case SHN_LIVEPATCH:
> @@ -2454,7 +2452,7 @@ static void set_license(struct module *mod, const char *license)
>
> if (!license_is_gpl_compatible(license)) {
> if (!test_taint(TAINT_PROPRIETARY_MODULE))
> - pr_warn("%s: module license '%s' taints kernel.\n",
> + pr_warn("%s: module license '%s' taints kernel\n",
> mod->name, license);
> add_taint_module(mod, TAINT_PROPRIETARY_MODULE,
> LOCKDEP_NOW_UNRELIABLE);
> @@ -2717,7 +2715,7 @@ static void dynamic_debug_setup(struct module *mod, struct _ddebug *debug, unsig
> #ifdef CONFIG_DYNAMIC_DEBUG
> if (ddebug_add_module(debug, num, mod->name))
> pr_err("dynamic debug error adding module: %s\n",
> - debug->modname);
> + debug->modname);
> #endif
> }
>
> @@ -2849,7 +2847,7 @@ static int check_modinfo_livepatch(struct module *mod, struct load_info *info)
> static int check_modinfo_livepatch(struct module *mod, struct load_info *info)
> {
> if (get_modinfo(info, "livepatch")) {
> - pr_err("%s: module is marked as livepatch module, but livepatch support is disabled",
> + pr_err("%s: module is marked as livepatch module, but livepatch support is disabled\n",
> mod->name);
> return -ENOEXEC;
> }
> @@ -2863,7 +2861,7 @@ static void check_modinfo_retpoline(struct module *mod, struct load_info *info)
> if (retpoline_module_ok(get_modinfo(info, "retpoline")))
> return;
>
> - pr_warn("%s: loading module not compiled with retpoline compiler.\n",
> + pr_warn("%s: loading module not compiled with retpoline compiler\n",
> mod->name);
> }
>
> @@ -3037,8 +3035,8 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
>
> if (get_modinfo(info, "staging")) {
> add_taint_module(mod, TAINT_CRAP, LOCKDEP_STILL_OK);
> - pr_warn("%s: module is from the staging directory, the quality "
> - "is unknown, you have been warned.\n", mod->name);
> + pr_warn("%s: module is from the staging directory, the quality is unknown, you have been warned\n",
> + mod->name);
> }
>
> err = check_modinfo_livepatch(mod, info);
> @@ -3089,8 +3087,8 @@ static int find_module_sections(struct module *mod, struct load_info *info)
> * This shouldn't happen with same compiler and binutils
> * building all parts of the module.
> */
> - pr_warn("%s: has both .ctors and .init_array.\n",
> - mod->name);
> + pr_warn("%s: has both .ctors and .init_array\n",
> + mod->name);
> return -EINVAL;
> }
> #endif
> @@ -3227,7 +3225,7 @@ static int check_module_license_and_versions(struct module *mod)
> LOCKDEP_NOW_UNRELIABLE);
>
> if (!prev_taint && test_taint(TAINT_PROPRIETARY_MODULE))
> - pr_warn("%s: module license taints kernel.\n", mod->name);
> + pr_warn("%s: module license taints kernel\n", mod->name);
>
> #ifdef CONFIG_MODVERSIONS
> if ((mod->num_syms && !mod->crcs)
> @@ -3459,8 +3457,7 @@ static noinline int do_init_module(struct module *mod)
> goto fail_free_freeinit;
> }
> if (ret > 0) {
> - pr_warn("%s: '%s'->init suspiciously returned %d, it should "
> - "follow 0/-E convention\n"
> + pr_warn("%s: '%s'->init suspiciously returned %d, it should follow 0/-E convention\n"
> "%s: loading module anyway...\n",
> __func__, mod->name, ret, __func__);
> dump_stack();
> @@ -3686,9 +3683,8 @@ static int load_module(struct load_info *info, const char __user *uargs,
> #ifdef CONFIG_MODULE_SIG
> mod->sig_ok = info->sig_ok;
> if (!mod->sig_ok) {
> - pr_notice_once("%s: module verification failed: signature "
> - "and/or required key missing - tainting "
> - "kernel\n", mod->name);
> + pr_notice_once("%s: module verification failed: signature and/or required key missing - tainting kernel\n",
> + mod->name);
> add_taint_module(mod, TAINT_UNSIGNED_MODULE, LOCKDEP_STILL_OK);
> }
> #endif
> @@ -3763,7 +3759,7 @@ static int load_module(struct load_info *info, const char __user *uargs,
> goto coming_cleanup;
> } else if (after_dashes) {
> pr_warn("%s: parameters '%s' after `--' ignored\n",
> - mod->name, after_dashes);
> + mod->name, after_dashes);
> }
>
> /* Link in to sysfs. */
> @@ -3843,8 +3839,7 @@ SYSCALL_DEFINE3(init_module, void __user *, umod,
> if (err)
> return err;
>
> - pr_debug("init_module: umod=%p, len=%lu, uargs=%p\n",
> - umod, len, uargs);
> + pr_debug("init_module: umod=%p, len=%lu, uargs=%p\n", umod, len, uargs);
>
> err = copy_module_from_user(umod, len, &info);
> if (err)
> diff --git a/kernel/panic.c b/kernel/panic.c
> index 42e487488554..e34631818bb7 100644
> --- a/kernel/panic.c
> +++ b/kernel/panic.c
> @@ -8,6 +8,9 @@
> * This function is used through-out the kernel (including mm and fs)
> * to indicate a major problem.
> */
> +
> +#define pr_fmt(fmt) fmt
> +
> #include <linux/debug_locks.h>
> #include <linux/sched/debug.h>
> #include <linux/interrupt.h>
> diff --git a/kernel/params.c b/kernel/params.c
> index ce89f757e6da..757049bfa346 100644
> --- a/kernel/params.c
> +++ b/kernel/params.c
> @@ -15,6 +15,9 @@
> along with this program; if not, write to the Free Software
> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> */
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> #include <linux/kernel.h>
> #include <linux/string.h>
> #include <linux/errno.h>
> @@ -141,8 +144,8 @@ static int parse_one(char *param,
> if (!val &&
> !(params[i].ops->flags & KERNEL_PARAM_OPS_FL_NOARG))
> return -EINVAL;
> - pr_debug("handling %s with %p\n", param,
> - params[i].ops->set);
> + pr_debug("handling %s with %p\n",
> + param, params[i].ops->set);
> kernel_param_lock(params[i].mod);
> param_check_unsafe(&params[i]);
> err = params[i].ops->set(val, &params[i]);
> @@ -496,8 +499,8 @@ int param_set_copystring(const char *val, const struct kernel_param *kp)
> const struct kparam_string *kps = kp->str;
>
> if (strlen(val)+1 > kps->maxlen) {
> - pr_err("%s: string doesn't fit in %u chars.\n",
> - kp->name, kps->maxlen-1);
> + pr_err("%s: string doesn't fit in %u chars\n",
> + kp->name, kps->maxlen - 1);
> return -ENOSPC;
> }
> strcpy(kps->string, val);
> @@ -763,7 +766,7 @@ static struct module_kobject * __init locate_module_kobject(const char *name)
> #endif
> if (err) {
> kobject_put(&mk->kobj);
> - pr_crit("Adding module '%s' to sysfs failed (%d), the system may be unstable.\n",
> + pr_crit("Adding module '%s' to sysfs failed (%d), the system may be unstable\n",
> name, err);
> return NULL;
> }
> diff --git a/kernel/pid.c b/kernel/pid.c
> index 157fe4b19971..2ddd7adfa77d 100644
> --- a/kernel/pid.c
> +++ b/kernel/pid.c
> @@ -26,6 +26,8 @@
> *
> */
>
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> #include <linux/mm.h>
> #include <linux/export.h>
> #include <linux/slab.h>
> diff --git a/kernel/profile.c b/kernel/profile.c
> index 9aa2a4445b0d..e5cc8f360236 100644
> --- a/kernel/profile.c
> +++ b/kernel/profile.c
> @@ -14,6 +14,8 @@
> * Oracle, 2004
> */
>
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> #include <linux/export.h>
> #include <linux/profile.h>
> #include <linux/bootmem.h>
> diff --git a/kernel/range.c b/kernel/range.c
> index d84de6766472..e828c950d401 100644
> --- a/kernel/range.c
> +++ b/kernel/range.c
> @@ -102,7 +102,7 @@ void subtract_range(struct range *range, int az, u64 start, u64 end)
> range[i].start = end;
> } else {
> pr_err("%s: run out of slot in ranges\n",
> - __func__);
> + __func__);
> }
> range[j].end = start;
> continue;
> diff --git a/kernel/relay.c b/kernel/relay.c
> index c955b10c973c..02f3790af754 100644
> --- a/kernel/relay.c
> +++ b/kernel/relay.c
> @@ -12,6 +12,9 @@
> *
> * This file is released under the GPL.
> */
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> #include <linux/errno.h>
> #include <linux/stddef.h>
> #include <linux/slab.h>
> @@ -527,7 +530,7 @@ int relay_prepare_cpu(unsigned int cpu)
> continue;
> buf = relay_open_buf(chan, cpu);
> if (!buf) {
> - pr_err("relay: cpu %d buffer creation failed\n", cpu);
> + pr_err("cpu %d buffer creation failed\n", cpu);
> mutex_unlock(&relay_channels_mutex);
> return -ENOMEM;
> }
> diff --git a/kernel/seccomp.c b/kernel/seccomp.c
> index 5386749cdd21..de696bc574b4 100644
> --- a/kernel/seccomp.c
> +++ b/kernel/seccomp.c
> @@ -14,6 +14,8 @@
> * of Berkeley Packet Filters/Linux Socket Filters.
> */
>
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> #include <linux/refcount.h>
> #include <linux/audit.h>
> #include <linux/compat.h>
> @@ -1323,7 +1325,7 @@ static int __init seccomp_sysctl_init(void)
>
> hdr = register_sysctl_paths(seccomp_sysctl_path, seccomp_sysctl_table);
> if (!hdr)
> - pr_warn("seccomp: sysctl registration failed\n");
> + pr_warn("sysctl registration failed\n");
> else
> kmemleak_not_leak(hdr);
>
> diff --git a/kernel/signal.c b/kernel/signal.c
> index 0f865d67415d..4b93feddcdcd 100644
> --- a/kernel/signal.c
> +++ b/kernel/signal.c
> @@ -10,6 +10,8 @@
> * to allow signals to be sent reliably.
> */
>
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> #include <linux/slab.h>
> #include <linux/export.h>
> #include <linux/init.h>
> @@ -235,7 +237,7 @@ static inline void print_dropped_signal(int sig)
> return;
>
> pr_info("%s/%d: reached RLIMIT_SIGPENDING, dropped signal %d\n",
> - current->comm, current->pid, sig);
> + current->comm, current->pid, sig);
> }
>
> /**
> @@ -1118,10 +1120,10 @@ static int send_signal(int sig, struct siginfo *info, struct task_struct *t,
> static void print_fatal_signal(int signr)
> {
> struct pt_regs *regs = signal_pt_regs();
> - pr_info("potentially unexpected fatal signal %d.\n", signr);
> + pr_info("potentially unexpected fatal signal %d\n", signr);
>
> #if defined(__i386__) && !defined(__arch_um__)
> - pr_info("code at %08lx: ", regs->ip);
> + pr_info("code at %08lx:", regs->ip);
> {
> int i;
> for (i = 0; i < 16; i++) {
> @@ -1129,7 +1131,7 @@ static void print_fatal_signal(int signr)
>
> if (get_user(insn, (unsigned char *)(regs->ip + i)))
> break;
> - pr_cont("%02x ", insn);
> + pr_cont(" %02x", insn);
> }
> }
> pr_cont("\n");
> diff --git a/kernel/smpboot.c b/kernel/smpboot.c
> index 5043e7433f4b..17e129faf498 100644
> --- a/kernel/smpboot.c
> +++ b/kernel/smpboot.c
> @@ -1,6 +1,9 @@
> /*
> * Common SMP CPU bringup/teardown functions
> */
> +
> +#define pr_fmt(fmt) "SMP: " fmt
> +
> #include <linux/cpu.h>
> #include <linux/err.h>
> #include <linux/smp.h>
> @@ -54,7 +57,7 @@ static inline void idle_init(unsigned int cpu)
> if (!tsk) {
> tsk = fork_idle(cpu);
> if (IS_ERR(tsk))
> - pr_err("SMP: fork_idle() failed for CPU %u\n", cpu);
> + pr_err("fork_idle() failed for CPU %u\n", cpu);
> else
> per_cpu(idle_threads, cpu) = tsk;
> }
> diff --git a/kernel/taskstats.c b/kernel/taskstats.c
> index 4e62a4a8fa91..8973cb0a1eab 100644
> --- a/kernel/taskstats.c
> +++ b/kernel/taskstats.c
> @@ -16,6 +16,8 @@
> *
> */
>
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> #include <linux/kernel.h>
> #include <linux/taskstats_kern.h>
> #include <linux/tsacct_kern.h>
> @@ -690,7 +692,7 @@ static int __init taskstats_init(void)
> return rc;
>
> family_registered = 1;
> - pr_info("registered taskstats version %d\n", TASKSTATS_GENL_VERSION);
> + pr_info("registered version %d\n", TASKSTATS_GENL_VERSION);
> return 0;
> }
>
> diff --git a/kernel/torture.c b/kernel/torture.c
> index 3de1efbecd6a..da4f95c11bf9 100644
> --- a/kernel/torture.c
> +++ b/kernel/torture.c
> @@ -20,6 +20,9 @@
> * Author: Paul E. McKenney <[email protected]>
> * Based on kernel/rcu/torture.c.
> */
> +
> +#define pr_fmt(fmt) fmt
> +
> #include <linux/types.h>
> #include <linux/kernel.h>
> #include <linux/init.h>
> @@ -99,8 +102,7 @@ bool torture_offline(int cpu, long *n_offl_attempts, long *n_offl_successes,
> return false;
>
> if (verbose)
> - pr_alert("%s" TORTURE_FLAG
> - "torture_onoff task: offlining %d\n",
> + pr_alert("%s" TORTURE_FLAG "torture_onoff task: offlining %d\n",
> torture_type, cpu);
> starttime = jiffies;
> (*n_offl_attempts)++;
> diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
> index 1e37da2e0c25..d4753ff47738 100644
> --- a/kernel/tracepoint.c
> +++ b/kernel/tracepoint.c
> @@ -15,6 +15,9 @@
> * along with this program; if not, write to the Free Software
> * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
> */
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> #include <linux/module.h>
> #include <linux/mutex.h>
> #include <linux/types.h>
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index ca7959be8aaa..7f1f75abcf7c 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -24,6 +24,8 @@
> * Please read Documentation/core-api/workqueue.rst for details.
> */
>
> +#define pr_fmt(fmt) fmt
> +
> #include <linux/export.h>
> #include <linux/kernel.h>
> #include <linux/sched.h>
> --
> 2.15.0
>


2018-05-14 19:01:20

by Paul Moore

[permalink] [raw]
Subject: Re: [PATCH 01/18] kernel: Use pr_fmt

On Thu, May 10, 2018 at 11:45 AM, Joe Perches <[email protected]> wrote:
> Sometime in the future, it would be useful to convert pr_fmt from a
> default simple define to use a default prefix with KBUILD_MODNAME.
>
> There are files in kernel/ that use pr_<level>, some with an embedded
> prefix, that also do not have a specific pr_fmt define.
>
> Add pr_fmt for those files.
>
> There are some differences in output as some messages are now prefixed
> with their KBUILD_MODNAME.
>
> Miscellanea:
>
> o Align multiline statements to open parenthesis
> o Wrap and realign arguments to 80 columns where sensible
> o Coalesce formats
>
> Signed-off-by: Joe Perches <[email protected]>
> ---
> kernel/acct.c | 2 ++
> kernel/async.c | 14 ++++++------
> kernel/audit_tree.c | 2 +-
> kernel/backtracetest.c | 8 +++----
> kernel/crash_core.c | 29 ++++++++++++++-----------
> kernel/exit.c | 2 ++
> kernel/hung_task.c | 13 +++++------
> kernel/kprobes.c | 20 ++++++++++-------
> kernel/module.c | 59 +++++++++++++++++++++++---------------------------
> kernel/panic.c | 3 +++
> kernel/params.c | 13 ++++++-----
> kernel/pid.c | 2 ++
> kernel/profile.c | 2 ++
> kernel/range.c | 2 +-
> kernel/relay.c | 5 ++++-
> kernel/seccomp.c | 4 +++-
> kernel/signal.c | 10 +++++----
> kernel/smpboot.c | 5 ++++-
> kernel/taskstats.c | 4 +++-
> kernel/torture.c | 6 +++--
> kernel/tracepoint.c | 3 +++
> kernel/workqueue.c | 2 ++
> 22 files changed, 122 insertions(+), 88 deletions(-)

The audit change looks fine to me, thanks Joe.

Acked-by: Paul Moore <[email protected]>

> diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
> index 67e6956c0b61..f34f90b4a346 100644
> --- a/kernel/audit_tree.c
> +++ b/kernel/audit_tree.c
> @@ -739,7 +739,7 @@ static int audit_launch_prune(void)
> prune_thread = kthread_run(prune_tree_thread, NULL,
> "audit_prune_tree");
> if (IS_ERR(prune_thread)) {
> - pr_err("cannot start thread audit_prune_tree");
> + pr_err("cannot start thread audit_prune_tree\n");
> prune_thread = NULL;
> return -ENOMEM;
> }

--
paul moore
http://www.paul-moore.com

2018-05-14 20:28:44

by Paul E. McKenney

[permalink] [raw]
Subject: Re: [PATCH 18/18] rcu: Use pr_fmt to prefix "rcu: " to logging output

On Thu, May 10, 2018 at 08:45:44AM -0700, Joe Perches wrote:
> Use a consistent logging prefix for all rcu related output.
>
> Signed-off-by: Joe Perches <[email protected]>

I took parts of this (thank you!) but have concerns about other parts.

> ---
> kernel/rcu/rcu_segcblist.c | 2 ++
> kernel/rcu/rcuperf.c | 10 ++++---
> kernel/rcu/rcutorture.c | 46 +++++++++++++++----------------
> kernel/rcu/srcutiny.c | 2 ++
> kernel/rcu/srcutree.c | 5 +++-
> kernel/rcu/tiny.c | 3 +++
> kernel/rcu/tree.c | 8 +++---
> kernel/rcu/tree_plugin.h | 67 +++++++++++++++++++++++++++-------------------
> kernel/rcu/update.c | 19 ++++++++-----
> 9 files changed, 96 insertions(+), 66 deletions(-)
>
> diff --git a/kernel/rcu/rcu_segcblist.c b/kernel/rcu/rcu_segcblist.c
> index 5aff271adf1e..b5f0e7234c4b 100644
> --- a/kernel/rcu/rcu_segcblist.c
> +++ b/kernel/rcu/rcu_segcblist.c
> @@ -20,6 +20,8 @@
> * Authors: Paul E. McKenney <[email protected]>
> */
>
> +#define pr_fmt(fmt) "rcu: " fmt

Given that this file has no printk()s, how is this helping? Interactions with
WARN_ON() or some such?

> +
> #include <linux/types.h>
> #include <linux/kernel.h>
> #include <linux/interrupt.h>
> diff --git a/kernel/rcu/rcuperf.c b/kernel/rcu/rcuperf.c
> index 076a50fb22ad..ebdd77b45470 100644
> --- a/kernel/rcu/rcuperf.c
> +++ b/kernel/rcu/rcuperf.c
> @@ -19,6 +19,9 @@
> *
> * Authors: Paul E. McKenney <[email protected]>
> */
> +
> +#define pr_fmt(fmt) "rcu: " fmt

This is going to get us messages of the form "rcu: rcu-perf:", not?
(And other odd combinations, depending on the flavor of RCU under test.)
If so, this does not seem to be an improvement.

> +
> #include <linux/types.h>
> #include <linux/kernel.h>
> #include <linux/init.h>
> @@ -663,12 +666,11 @@ rcu_perf_init(void)
> break;
> }
> if (i == ARRAY_SIZE(perf_ops)) {
> - pr_alert("rcu-perf: invalid perf type: \"%s\"\n",
> - perf_type);
> + pr_alert("rcu-perf: invalid perf type: \"%s\"\n", perf_type);
> pr_alert("rcu-perf types:");
> for (i = 0; i < ARRAY_SIZE(perf_ops); i++)
> - pr_alert(" %s", perf_ops[i]->name);
> - pr_alert("\n");
> + pr_cont(" %s", perf_ops[i]->name);
> + pr_cont("\n");

However, I did take the above changes, good catch!

> firsterr = -EINVAL;
> goto unwind;
> }
> diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
> index 648e1c25707d..45d98ff0d5b8 100644
> --- a/kernel/rcu/rcutorture.c
> +++ b/kernel/rcu/rcutorture.c
> @@ -22,6 +22,7 @@
> *
> * See also: Documentation/RCU/torture.txt
> */
> +
> #include <linux/types.h>
> #include <linux/kernel.h>
> #include <linux/init.h>
> @@ -908,7 +909,7 @@ rcu_torture_writer(void *arg)
> VERBOSE_TOROUT_STRING("rcu_torture_writer task started");
> if (!can_expedite)
> pr_alert("%s" TORTURE_FLAG
> - " GP expediting controlled from boot/sysfs for %s.\n",
> + " GP expediting controlled from boot/sysfs for %s\n",
> torture_type, cur_ops->name);
>
> /* Initialize synctype[] array. If none set, take default. */
> @@ -916,27 +917,27 @@ rcu_torture_writer(void *arg)
> gp_cond1 = gp_exp1 = gp_normal1 = gp_sync1 = true;
> if (gp_cond1 && cur_ops->get_state && cur_ops->cond_sync) {
> synctype[nsynctypes++] = RTWS_COND_GET;
> - pr_info("%s: Testing conditional GPs.\n", __func__);
> + pr_info("%s: Testing conditional GPs\n", __func__);
> } else if (gp_cond && (!cur_ops->get_state || !cur_ops->cond_sync)) {
> - pr_alert("%s: gp_cond without primitives.\n", __func__);
> + pr_alert("%s: gp_cond without primitives\n", __func__);
> }
> if (gp_exp1 && cur_ops->exp_sync) {
> synctype[nsynctypes++] = RTWS_EXP_SYNC;
> - pr_info("%s: Testing expedited GPs.\n", __func__);
> + pr_info("%s: Testing expedited GPs\n", __func__);
> } else if (gp_exp && !cur_ops->exp_sync) {
> - pr_alert("%s: gp_exp without primitives.\n", __func__);
> + pr_alert("%s: gp_exp without primitives\n", __func__);
> }
> if (gp_normal1 && cur_ops->deferred_free) {
> synctype[nsynctypes++] = RTWS_DEF_FREE;
> - pr_info("%s: Testing asynchronous GPs.\n", __func__);
> + pr_info("%s: Testing asynchronous GPs\n", __func__);
> } else if (gp_normal && !cur_ops->deferred_free) {
> - pr_alert("%s: gp_normal without primitives.\n", __func__);
> + pr_alert("%s: gp_normal without primitives\n", __func__);
> }
> if (gp_sync1 && cur_ops->sync) {
> synctype[nsynctypes++] = RTWS_SYNC;
> - pr_info("%s: Testing normal GPs.\n", __func__);
> + pr_info("%s: Testing normal GPs\n", __func__);
> } else if (gp_sync && !cur_ops->sync) {
> - pr_alert("%s: gp_sync without primitives.\n", __func__);
> + pr_alert("%s: gp_sync without primitives\n", __func__);

I used a CDC Cyber 73 in the 1970s. It had tiny memory by today's
standards, but even it had periods in its error messages. We can easily
afford them today, especially given that rcutorture is not included in
small-memory Linux configurations.

> }
> if (WARN_ONCE(nsynctypes == 0,
> "rcu_torture_writer: No update-side primitives.\n")) {
> @@ -1027,7 +1028,7 @@ rcu_torture_writer(void *arg)
> WARN_ON_ONCE(can_expedite && rcu_gp_is_expedited());
> if (!can_expedite)
> pr_alert("%s" TORTURE_FLAG
> - " Dynamic grace-period expediting was disabled.\n",
> + " Dynamic grace-period expediting was disabled\n",
> torture_type);
> rcu_torture_writer_state = RTWS_STOPPING;
> torture_kthread_stopping("rcu_torture_writer");
> @@ -1436,7 +1437,7 @@ static int rcu_torture_stall(void *args)
> local_irq_disable();
> else
> preempt_disable();
> - pr_alert("rcu_torture_stall start on CPU %d.\n",
> + pr_alert("rcu_torture_stall start on CPU %d\n",
> smp_processor_id());
> while (ULONG_CMP_LT(get_seconds(), stop_at))
> continue; /* Induce RCU CPU stall warning. */
> @@ -1445,7 +1446,7 @@ static int rcu_torture_stall(void *args)
> else
> preempt_enable();
> rcu_read_unlock();
> - pr_alert("rcu_torture_stall end.\n");
> + pr_alert("rcu_torture_stall end\n");
> }
> torture_shutdown_absorb("rcu_torture_stall");
> while (!kthread_should_stop())
> @@ -1547,10 +1548,10 @@ static int rcu_torture_barrier_init(void)
> return 0;
> if (cur_ops->call == NULL || cur_ops->cb_barrier == NULL) {
> pr_alert("%s" TORTURE_FLAG
> - " Call or barrier ops missing for %s,\n",
> + " Call or barrier ops missing for %s\n",
> torture_type, cur_ops->name);
> pr_alert("%s" TORTURE_FLAG
> - " RCU barrier testing omitted from run.\n",
> + " RCU barrier testing omitted from run\n",
> torture_type);

And the same for these.

> return 0;
> }
> @@ -1679,7 +1680,7 @@ static void rcu_torture_err_cb(struct rcu_head *rhp)
> * next grace period. Unlikely, but can happen. If it
> * does happen, the debug-objects subsystem won't have splatted.
> */
> - pr_alert("%s: duplicated callback was invoked.\n", KBUILD_MODNAME);
> + pr_alert("duplicated callback was invoked\n");
> }
> #endif /* #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */
>
> @@ -1696,7 +1697,7 @@ static void rcu_test_debug_objects(void)
>
> init_rcu_head_on_stack(&rh1);
> init_rcu_head_on_stack(&rh2);
> - pr_alert("%s: WARN: Duplicate call_rcu() test starting.\n", KBUILD_MODNAME);
> + pr_alert("WARN: Duplicate call_rcu() test starting\n");
>
> /* Try to queue the rh2 pair of callbacks for the same grace period. */
> preempt_disable(); /* Prevent preemption from interrupting test. */
> @@ -1711,11 +1712,11 @@ static void rcu_test_debug_objects(void)
>
> /* Wait for them all to get done so we can safely return. */
> rcu_barrier();
> - pr_alert("%s: WARN: Duplicate call_rcu() test complete.\n", KBUILD_MODNAME);
> + pr_alert("WARN: Duplicate call_rcu() test complete\n");

I would like to keep these, as they mark the region of console output where
splats are expected.

> destroy_rcu_head_on_stack(&rh1);
> destroy_rcu_head_on_stack(&rh2);
> #else /* #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */
> - pr_alert("%s: !CONFIG_DEBUG_OBJECTS_RCU_HEAD, not testing duplicate call_rcu()\n", KBUILD_MODNAME);
> + pr_alert("!CONFIG_DEBUG_OBJECTS_RCU_HEAD, not testing duplicate call_rcu()\n");
> #endif /* #else #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */
> }
>
> @@ -1740,17 +1741,16 @@ rcu_torture_init(void)
> break;
> }
> if (i == ARRAY_SIZE(torture_ops)) {
> - pr_alert("rcu-torture: invalid torture type: \"%s\"\n",
> - torture_type);
> + pr_alert("invalid torture type: \"%s\"\n", torture_type);

I am leaving this one...

> pr_alert("rcu-torture types:");
> for (i = 0; i < ARRAY_SIZE(torture_ops); i++)
> - pr_alert(" %s", torture_ops[i]->name);
> - pr_alert("\n");
> + pr_cont(" %s", torture_ops[i]->name);
> + pr_cont("\n");

... but taking these. Good eyes! (Or scripts, as the case may be.)

> firsterr = -EINVAL;
> goto unwind;
> }
> if (cur_ops->fqs == NULL && fqs_duration != 0) {
> - pr_alert("rcu-torture: ->fqs NULL and non-zero fqs_duration, fqs disabled.\n");
> + pr_alert("->fqs NULL and non-zero fqs_duration, fqs disabled\n");

This I would like to keep. Easier to find.

> fqs_duration = 0;
> }
> if (cur_ops->init)
> diff --git a/kernel/rcu/srcutiny.c b/kernel/rcu/srcutiny.c
> index 622792abe41a..9392404cd0fb 100644
> --- a/kernel/rcu/srcutiny.c
> +++ b/kernel/rcu/srcutiny.c
> @@ -21,6 +21,8 @@
> * Author: Paul McKenney <[email protected]>
> */
>
> +#define pr_fmt(fmt) "rcu: " fmt
> +
> #include <linux/export.h>
> #include <linux/mutex.h>
> #include <linux/preempt.h>
> diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
> index ff894ae6d386..031d2713701f 100644
> --- a/kernel/rcu/srcutree.c
> +++ b/kernel/rcu/srcutree.c
> @@ -26,6 +26,8 @@
> *
> */
>
> +#define pr_fmt(fmt) "rcu: " fmt
> +
> #include <linux/export.h>
> #include <linux/mutex.h>
> #include <linux/percpu.h>
> @@ -390,7 +392,8 @@ void _cleanup_srcu_struct(struct srcu_struct *sp, bool quiesced)
> }
> if (WARN_ON(rcu_seq_state(READ_ONCE(sp->srcu_gp_seq)) != SRCU_STATE_IDLE) ||
> WARN_ON(srcu_readers_active(sp))) {
> - pr_info("%s: Active srcu_struct %p state: %d\n", __func__, sp, rcu_seq_state(READ_ONCE(sp->srcu_gp_seq)));
> + pr_info("%s: Active srcu_struct %p state: %d\n",
> + __func__, sp, rcu_seq_state(READ_ONCE(sp->srcu_gp_seq)));

I took these.

> return; /* Caller forgot to stop doing call_srcu()? */
> }
> free_percpu(sp->sda);
> diff --git a/kernel/rcu/tiny.c b/kernel/rcu/tiny.c
> index a64eee0db39e..52ab205db6e6 100644
> --- a/kernel/rcu/tiny.c
> +++ b/kernel/rcu/tiny.c
> @@ -22,6 +22,9 @@
> * For detailed explanation of Read-Copy Update mechanism see -
> * Documentation/RCU
> */
> +
> +#define pr_fmt(fmt) "rcu: " fmt
> +
> #include <linux/completion.h>
> #include <linux/interrupt.h>
> #include <linux/notifier.h>
> diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> index effcb898acca..fac633b3aa5e 100644
> --- a/kernel/rcu/tree.c
> +++ b/kernel/rcu/tree.c
> @@ -27,6 +27,9 @@
> * For detailed explanation of Read-Copy Update mechanism see -
> * Documentation/RCU
> */
> +
> +#define pr_fmt(fmt) "rcu: " fmt
> +
> #include <linux/types.h>
> #include <linux/kernel.h>
> #include <linux/init.h>
> @@ -1360,8 +1363,7 @@ static void print_other_cpu_stall(struct rcu_state *rsp, unsigned long gp_seq)
> * See Documentation/RCU/stallwarn.txt for info on how to debug
> * RCU CPU stall warnings.
> */
> - pr_err("INFO: %s detected stalls on CPUs/tasks:",
> - rsp->name);
> + pr_err("INFO: %s detected stalls on CPUs/tasks:", rsp->name);
> print_cpu_stall_info_begin();
> rcu_for_each_leaf_node(rsp, rnp) {
> raw_spin_lock_irqsave_rcu_node(rnp, flags);
> @@ -3984,7 +3986,7 @@ static void __init rcu_init_geometry(void)
> if (rcu_fanout_leaf == RCU_FANOUT_LEAF &&
> nr_cpu_ids == NR_CPUS)
> return;
> - pr_info("RCU: Adjusting geometry for rcu_fanout_leaf=%d, nr_cpu_ids=%u\n",
> + pr_info("Adjusting geometry for rcu_fanout_leaf=%d, nr_cpu_ids=%u\n",
> rcu_fanout_leaf, nr_cpu_ids);

And I took these.

>
> /*
> diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
> index f2dae728c446..7aafff8590d7 100644
> --- a/kernel/rcu/tree_plugin.h
> +++ b/kernel/rcu/tree_plugin.h
> @@ -71,51 +71,62 @@ static bool __read_mostly rcu_nocb_poll; /* Offload kthread are to poll. */
> static void __init rcu_bootup_announce_oddness(void)
> {
> if (IS_ENABLED(CONFIG_RCU_TRACE))
> - pr_info("\tRCU event tracing is enabled.\n");
> + pr_info("\tRCU event tracing is enabled\n");
> if ((IS_ENABLED(CONFIG_64BIT) && RCU_FANOUT != 64) ||
> (!IS_ENABLED(CONFIG_64BIT) && RCU_FANOUT != 32))
> pr_info("\tCONFIG_RCU_FANOUT set to non-default value of %d\n",
> - RCU_FANOUT);
> + RCU_FANOUT);

I took this whitespace fix and added the period.

> if (rcu_fanout_exact)
> - pr_info("\tHierarchical RCU autobalancing is disabled.\n");
> + pr_info("\tHierarchical RCU autobalancing is disabled\n");
> if (IS_ENABLED(CONFIG_RCU_FAST_NO_HZ))
> - pr_info("\tRCU dyntick-idle grace-period acceleration is enabled.\n");
> + pr_info("\tRCU dyntick-idle grace-period acceleration is enabled\n");
> if (IS_ENABLED(CONFIG_PROVE_RCU))
> - pr_info("\tRCU lockdep checking is enabled.\n");
> + pr_info("\tRCU lockdep checking is enabled\n");
> if (RCU_NUM_LVLS >= 4)
> - pr_info("\tFour(or more)-level hierarchy is enabled.\n");
> + pr_info("\tFour(or more)-level hierarchy is enabled\n");
> if (RCU_FANOUT_LEAF != 16)
> - pr_info("\tBuild-time adjustment of leaf fanout to %d.\n",
> + pr_info("\tBuild-time adjustment of leaf fanout to %d\n",
> RCU_FANOUT_LEAF);
> if (rcu_fanout_leaf != RCU_FANOUT_LEAF)
> - pr_info("\tBoot-time adjustment of leaf fanout to %d.\n", rcu_fanout_leaf);
> + pr_info("\tBoot-time adjustment of leaf fanout to %d\n",
> + rcu_fanout_leaf);

And this whitespace fix.

> if (nr_cpu_ids != NR_CPUS)
> - pr_info("\tRCU restricting CPUs from NR_CPUS=%d to nr_cpu_ids=%u.\n", NR_CPUS, nr_cpu_ids);
> + pr_info("\tRCU restricting CPUs from NR_CPUS=%d to nr_cpu_ids=%u\n",
> + NR_CPUS, nr_cpu_ids);

And I took this (but kept the period), plus used "%s" to make it fit in
80 characters:

pr_info("\tRCU restricting CPUs from %s=%d to %s=%u.\n",
"NR_CPUS", NR_CPUS, "nr_cpu_ids", nr_cpu_ids);

> #ifdef CONFIG_RCU_BOOST
> - pr_info("\tRCU priority boosting: priority %d delay %d ms.\n", kthread_prio, CONFIG_RCU_BOOST_DELAY);
> + pr_info("\tRCU priority boosting: priority %d delay %d ms\n",
> + kthread_prio, CONFIG_RCU_BOOST_DELAY);

I took this but kept the period.

> #endif
> if (blimit != DEFAULT_RCU_BLIMIT)
> - pr_info("\tBoot-time adjustment of callback invocation limit to %ld.\n", blimit);
> + pr_info("\tBoot-time adjustment of callback invocation limit to %ld\n",
> + blimit);
> if (qhimark != DEFAULT_RCU_QHIMARK)
> - pr_info("\tBoot-time adjustment of callback high-water mark to %ld.\n", qhimark);
> + pr_info("\tBoot-time adjustment of callback high-water mark to %ld\n",
> + qhimark);
> if (qlowmark != DEFAULT_RCU_QLOMARK)
> - pr_info("\tBoot-time adjustment of callback low-water mark to %ld.\n", qlowmark);
> + pr_info("\tBoot-time adjustment of callback low-water mark to %ld\n",
> + qlowmark);
> if (jiffies_till_first_fqs != ULONG_MAX)
> - pr_info("\tBoot-time adjustment of first FQS scan delay to %ld jiffies.\n", jiffies_till_first_fqs);
> + pr_info("\tBoot-time adjustment of first FQS scan delay to %ld jiffies\n",
> + jiffies_till_first_fqs);
> if (jiffies_till_next_fqs != ULONG_MAX)
> - pr_info("\tBoot-time adjustment of subsequent FQS scan delay to %ld jiffies.\n", jiffies_till_next_fqs);
> + pr_info("\tBoot-time adjustment of subsequent FQS scan delay to %ld jiffies\n",
> + jiffies_till_next_fqs);

And these don't fit even after breaking the line, and I couldn't immediately
come up with a natural way of making them fit, so I left them. In for a
penny, in for a pound!

> if (rcu_kick_kthreads)
> - pr_info("\tKick kthreads if too-long grace period.\n");
> + pr_info("\tKick kthreads if too-long grace period\n");
> if (IS_ENABLED(CONFIG_DEBUG_OBJECTS_RCU_HEAD))
> - pr_info("\tRCU callback double-/use-after-free debug enabled.\n");
> + pr_info("\tRCU callback double-/use-after-free debug enabled\n");
> if (gp_preinit_delay)
> - pr_info("\tRCU debug GP pre-init slowdown %d jiffies.\n", gp_preinit_delay);
> + pr_info("\tRCU debug GP pre-init slowdown %d jiffies\n",
> + gp_preinit_delay);
> if (gp_init_delay)
> - pr_info("\tRCU debug GP init slowdown %d jiffies.\n", gp_init_delay);
> + pr_info("\tRCU debug GP init slowdown %d jiffies\n",
> + gp_init_delay);
> if (gp_cleanup_delay)
> - pr_info("\tRCU debug GP init slowdown %d jiffies.\n", gp_cleanup_delay);
> + pr_info("\tRCU debug GP init slowdown %d jiffies\n",
> + gp_cleanup_delay);
> if (IS_ENABLED(CONFIG_RCU_EQS_DEBUG))
> - pr_info("\tRCU debug extended QS entry/exit.\n");
> + pr_info("\tRCU debug extended QS entry/exit\n");
> rcupdate_announce_bootup_oddness();
> }
>
> @@ -133,7 +144,7 @@ static void rcu_report_exp_rnp(struct rcu_state *rsp, struct rcu_node *rnp,
> */
> static void __init rcu_bootup_announce(void)
> {
> - pr_info("Preemptible hierarchical RCU implementation.\n");
> + pr_info("Preemptible hierarchical RCU implementation\n");
> rcu_bootup_announce_oddness();
> }
>
> @@ -885,7 +896,7 @@ static struct rcu_state *const rcu_state_p = &rcu_sched_state;
> */
> static void __init rcu_bootup_announce(void)
> {
> - pr_info("Hierarchical RCU implementation.\n");
> + pr_info("Hierarchical RCU implementation\n");
> rcu_bootup_announce_oddness();
> }
>
> @@ -2374,7 +2385,7 @@ void __init rcu_init_nohz(void)
>
> if (!cpumask_available(rcu_nocb_mask) && need_rcu_nocb_mask) {
> if (!zalloc_cpumask_var(&rcu_nocb_mask, GFP_KERNEL)) {
> - pr_info("rcu_nocb_mask allocation failed, callback offloading disabled.\n");
> + pr_info("rcu_nocb_mask allocation failed, callback offloading disabled\n");
> return;
> }
> }
> @@ -2387,17 +2398,17 @@ void __init rcu_init_nohz(void)
> #endif /* #if defined(CONFIG_NO_HZ_FULL) */
>
> if (!cpumask_subset(rcu_nocb_mask, cpu_possible_mask)) {
> - pr_info("\tNote: kernel parameter 'rcu_nocbs=', 'nohz_full', or 'isolcpus=' contains nonexistent CPUs.\n");
> + pr_info("\tNote: kernel parameter 'rcu_nocbs=', 'nohz_full', or 'isolcpus=' contains nonexistent CPUs\n");
> cpumask_and(rcu_nocb_mask, cpu_possible_mask,
> rcu_nocb_mask);
> }
> if (cpumask_empty(rcu_nocb_mask))
> - pr_info("\tOffload RCU callbacks from CPUs: (none).\n");
> + pr_info("\tOffload RCU callbacks from CPUs: (none)\n");
> else
> - pr_info("\tOffload RCU callbacks from CPUs: %*pbl.\n",
> + pr_info("\tOffload RCU callbacks from CPUs: %*pbl\n",
> cpumask_pr_args(rcu_nocb_mask));
> if (rcu_nocb_poll)
> - pr_info("\tPoll for callbacks from no-CBs CPUs.\n");
> + pr_info("\tPoll for callbacks from no-CBs CPUs\n");
>
> for_each_rcu_flavor(rsp) {
> for_each_cpu(cpu, rcu_nocb_mask)

Other than that, I kept the periods.

> diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c
> index 4c230a60ece4..e6ccf4864fe6 100644
> --- a/kernel/rcu/update.c
> +++ b/kernel/rcu/update.c
> @@ -30,6 +30,9 @@
> * http://lse.sourceforge.net/locking/rcupdate.html
> *
> */
> +
> +#define pr_fmt(fmt) "rcu: " fmt
> +
> #include <linux/types.h>
> #include <linux/kernel.h>
> #include <linux/init.h>
> @@ -844,9 +847,10 @@ static void __init rcu_tasks_bootup_oddness(void)
> {
> #ifdef CONFIG_TASKS_RCU
> if (rcu_task_stall_timeout != RCU_TASK_STALL_TIMEOUT)
> - pr_info("\tTasks-RCU CPU stall warnings timeout set to %d (rcu_task_stall_timeout).\n", rcu_task_stall_timeout);
> + pr_info("\tTasks-RCU CPU stall warnings timeout set to %d (rcu_task_stall_timeout)\n",
> + rcu_task_stall_timeout);
> else
> - pr_info("\tTasks RCU enabled.\n");
> + pr_info("\tTasks RCU enabled\n");
> #endif /* #ifdef CONFIG_TASKS_RCU */
> }
>
> @@ -945,15 +949,16 @@ void rcu_early_boot_tests(void) {}
> void __init rcupdate_announce_bootup_oddness(void)
> {
> if (rcu_normal)
> - pr_info("\tNo expedited grace period (rcu_normal).\n");
> + pr_info("\tNo expedited grace period (rcu_normal)\n");
> else if (rcu_normal_after_boot)
> - pr_info("\tNo expedited grace period (rcu_normal_after_boot).\n");
> + pr_info("\tNo expedited grace period (rcu_normal_after_boot)\n");
> else if (rcu_expedited)
> - pr_info("\tAll grace periods are expedited (rcu_expedited).\n");
> + pr_info("\tAll grace periods are expedited (rcu_expedited)\n");
> if (rcu_cpu_stall_suppress)
> - pr_info("\tRCU CPU stall warnings suppressed (rcu_cpu_stall_suppress).\n");
> + pr_info("\tRCU CPU stall warnings suppressed (rcu_cpu_stall_suppress)\n");
> if (rcu_cpu_stall_timeout != CONFIG_RCU_CPU_STALL_TIMEOUT)
> - pr_info("\tRCU CPU stall warnings timeout set to %d (rcu_cpu_stall_timeout).\n", rcu_cpu_stall_timeout);
> + pr_info("\tRCU CPU stall warnings timeout set to %d (rcu_cpu_stall_timeout)\n",
> + rcu_cpu_stall_timeout);
> rcu_tasks_bootup_oddness();
> }

And I kept these periods. Please see below for updated patch.

Thanx, Paul

------------------------------------------------------------------------

commit 7b88a0fd75ae1f4a018a315d1e9ffcdbfc6c8e6f
Author: Joe Perches <[email protected]>
Date: Mon May 14 13:27:33 2018 -0700

rcu: Use pr_fmt to prefix "rcu: " to logging output

This commit also adjusts some whitespace while in the area.

Signed-off-by: Joe Perches <[email protected]>
Signed-off-by: Paul E. McKenney <[email protected]>

diff --git a/kernel/rcu/rcuperf.c b/kernel/rcu/rcuperf.c
index 479820d231bf..9047e5439e46 100644
--- a/kernel/rcu/rcuperf.c
+++ b/kernel/rcu/rcuperf.c
@@ -663,12 +663,11 @@ rcu_perf_init(void)
break;
}
if (i == ARRAY_SIZE(perf_ops)) {
- pr_alert("rcu-perf: invalid perf type: \"%s\"\n",
- perf_type);
+ pr_alert("rcu-perf: invalid perf type: \"%s\"\n", perf_type);
pr_alert("rcu-perf types:");
for (i = 0; i < ARRAY_SIZE(perf_ops); i++)
- pr_alert(" %s", perf_ops[i]->name);
- pr_alert("\n");
+ pr_cont(" %s", perf_ops[i]->name);
+ pr_cont("\n");
firsterr = -EINVAL;
goto unwind;
}
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index ba82285a023a..9d80245b2a1c 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -1744,8 +1744,8 @@ rcu_torture_init(void)
torture_type);
pr_alert("rcu-torture types:");
for (i = 0; i < ARRAY_SIZE(torture_ops); i++)
- pr_alert(" %s", torture_ops[i]->name);
- pr_alert("\n");
+ pr_cont(" %s", torture_ops[i]->name);
+ pr_cont("\n");
firsterr = -EINVAL;
goto unwind;
}
diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index ff894ae6d386..031d2713701f 100644
--- a/kernel/rcu/srcutree.c
+++ b/kernel/rcu/srcutree.c
@@ -26,6 +26,8 @@
*
*/

+#define pr_fmt(fmt) "rcu: " fmt
+
#include <linux/export.h>
#include <linux/mutex.h>
#include <linux/percpu.h>
@@ -390,7 +392,8 @@ void _cleanup_srcu_struct(struct srcu_struct *sp, bool quiesced)
}
if (WARN_ON(rcu_seq_state(READ_ONCE(sp->srcu_gp_seq)) != SRCU_STATE_IDLE) ||
WARN_ON(srcu_readers_active(sp))) {
- pr_info("%s: Active srcu_struct %p state: %d\n", __func__, sp, rcu_seq_state(READ_ONCE(sp->srcu_gp_seq)));
+ pr_info("%s: Active srcu_struct %p state: %d\n",
+ __func__, sp, rcu_seq_state(READ_ONCE(sp->srcu_gp_seq)));
return; /* Caller forgot to stop doing call_srcu()? */
}
free_percpu(sp->sda);
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 23b855f5c5cb..3826ce90fd6e 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -27,6 +27,9 @@
* For detailed explanation of Read-Copy Update mechanism see -
* Documentation/RCU
*/
+
+#define pr_fmt(fmt) "rcu: " fmt
+
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/init.h>
@@ -1352,8 +1355,7 @@ static void print_other_cpu_stall(struct rcu_state *rsp, unsigned long gp_seq)
* See Documentation/RCU/stallwarn.txt for info on how to debug
* RCU CPU stall warnings.
*/
- pr_err("INFO: %s detected stalls on CPUs/tasks:",
- rsp->name);
+ pr_err("INFO: %s detected stalls on CPUs/tasks:", rsp->name);
print_cpu_stall_info_begin();
rcu_for_each_leaf_node(rsp, rnp) {
raw_spin_lock_irqsave_rcu_node(rnp, flags);
@@ -3996,7 +3998,7 @@ static void __init rcu_init_geometry(void)
if (rcu_fanout_leaf == RCU_FANOUT_LEAF &&
nr_cpu_ids == NR_CPUS)
return;
- pr_info("RCU: Adjusting geometry for rcu_fanout_leaf=%d, nr_cpu_ids=%u\n",
+ pr_info("Adjusting geometry for rcu_fanout_leaf=%d, nr_cpu_ids=%u\n",
rcu_fanout_leaf, nr_cpu_ids);

/*
diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index 54a251640f53..9a28ba2755b9 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -74,8 +74,8 @@ static void __init rcu_bootup_announce_oddness(void)
pr_info("\tRCU event tracing is enabled.\n");
if ((IS_ENABLED(CONFIG_64BIT) && RCU_FANOUT != 64) ||
(!IS_ENABLED(CONFIG_64BIT) && RCU_FANOUT != 32))
- pr_info("\tCONFIG_RCU_FANOUT set to non-default value of %d\n",
- RCU_FANOUT);
+ pr_info("\tCONFIG_RCU_FANOUT set to non-default value of %d.\n",
+ RCU_FANOUT);
if (rcu_fanout_exact)
pr_info("\tHierarchical RCU autobalancing is disabled.\n");
if (IS_ENABLED(CONFIG_RCU_FAST_NO_HZ))
@@ -88,11 +88,14 @@ static void __init rcu_bootup_announce_oddness(void)
pr_info("\tBuild-time adjustment of leaf fanout to %d.\n",
RCU_FANOUT_LEAF);
if (rcu_fanout_leaf != RCU_FANOUT_LEAF)
- pr_info("\tBoot-time adjustment of leaf fanout to %d.\n", rcu_fanout_leaf);
+ pr_info("\tBoot-time adjustment of leaf fanout to %d.\n",
+ rcu_fanout_leaf);
if (nr_cpu_ids != NR_CPUS)
- pr_info("\tRCU restricting CPUs from NR_CPUS=%d to nr_cpu_ids=%u.\n", NR_CPUS, nr_cpu_ids);
+ pr_info("\tRCU restricting CPUs from %s=%d to %s=%u.\n",
+ "NR_CPUS", NR_CPUS, "nr_cpu_ids", nr_cpu_ids);
#ifdef CONFIG_RCU_BOOST
- pr_info("\tRCU priority boosting: priority %d delay %d ms.\n", kthread_prio, CONFIG_RCU_BOOST_DELAY);
+ pr_info("\tRCU priority boosting: priority %d delay %d ms.\n",
+ kthread_prio, CONFIG_RCU_BOOST_DELAY);
#endif
if (blimit != DEFAULT_RCU_BLIMIT)
pr_info("\tBoot-time adjustment of callback invocation limit to %ld.\n", blimit);


2018-05-14 20:38:43

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH 18/18] rcu: Use pr_fmt to prefix "rcu: " to logging output

On Mon, May 14, 2018 at 11:29 PM, Paul E. McKenney
<[email protected]> wrote:
> On Thu, May 10, 2018 at 08:45:44AM -0700, Joe Perches wrote:

> And I took this (but kept the period), plus used "%s" to make it fit in
> 80 characters:
>
> pr_info("\tRCU restricting CPUs from %s=%d to %s=%u.\n",
> "NR_CPUS", NR_CPUS, "nr_cpu_ids", nr_cpu_ids);

Why do care about 80 characters for string literals? (Checkpatch
dropped this limit long time ago after some discussions)
I think it's better to find line if more context given (this my
objection agains %s for string literals).

--
With Best Regards,
Andy Shevchenko

2018-05-14 20:54:20

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH 18/18] rcu: Use pr_fmt to prefix "rcu: " to logging output

On 05/14/2018 01:29 PM, Paul E. McKenney wrote:
> On Thu, May 10, 2018 at 08:45:44AM -0700, Joe Perches wrote:
>> Use a consistent logging prefix for all rcu related output.
>>
>> Signed-off-by: Joe Perches <[email protected]>
>
> I took parts of this (thank you!) but have concerns about other parts.
>
>> ---
>> kernel/rcu/rcu_segcblist.c | 2 ++
>> kernel/rcu/rcuperf.c | 10 ++++---
>> kernel/rcu/rcutorture.c | 46 +++++++++++++++----------------
>> kernel/rcu/srcutiny.c | 2 ++
>> kernel/rcu/srcutree.c | 5 +++-
>> kernel/rcu/tiny.c | 3 +++
>> kernel/rcu/tree.c | 8 +++---
>> kernel/rcu/tree_plugin.h | 67 +++++++++++++++++++++++++++-------------------
>> kernel/rcu/update.c | 19 ++++++++-----
>> 9 files changed, 96 insertions(+), 66 deletions(-)
>>

>> diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
>> index 648e1c25707d..45d98ff0d5b8 100644
>> --- a/kernel/rcu/rcutorture.c
>> +++ b/kernel/rcu/rcutorture.c
>> @@ -22,6 +22,7 @@
>> *
>> * See also: Documentation/RCU/torture.txt
>> */
>> +
>> #include <linux/types.h>
>> #include <linux/kernel.h>
>> #include <linux/init.h>
>> @@ -908,7 +909,7 @@ rcu_torture_writer(void *arg)
>> VERBOSE_TOROUT_STRING("rcu_torture_writer task started");
>> if (!can_expedite)
>> pr_alert("%s" TORTURE_FLAG
>> - " GP expediting controlled from boot/sysfs for %s.\n",
>> + " GP expediting controlled from boot/sysfs for %s\n",
>> torture_type, cur_ops->name);
>>
>> /* Initialize synctype[] array. If none set, take default. */
>> @@ -916,27 +917,27 @@ rcu_torture_writer(void *arg)
>> gp_cond1 = gp_exp1 = gp_normal1 = gp_sync1 = true;
>> if (gp_cond1 && cur_ops->get_state && cur_ops->cond_sync) {
>> synctype[nsynctypes++] = RTWS_COND_GET;
>> - pr_info("%s: Testing conditional GPs.\n", __func__);
>> + pr_info("%s: Testing conditional GPs\n", __func__);
>> } else if (gp_cond && (!cur_ops->get_state || !cur_ops->cond_sync)) {
>> - pr_alert("%s: gp_cond without primitives.\n", __func__);
>> + pr_alert("%s: gp_cond without primitives\n", __func__);
>> }
>> if (gp_exp1 && cur_ops->exp_sync) {
>> synctype[nsynctypes++] = RTWS_EXP_SYNC;
>> - pr_info("%s: Testing expedited GPs.\n", __func__);
>> + pr_info("%s: Testing expedited GPs\n", __func__);
>> } else if (gp_exp && !cur_ops->exp_sync) {
>> - pr_alert("%s: gp_exp without primitives.\n", __func__);
>> + pr_alert("%s: gp_exp without primitives\n", __func__);

Unlike some of the others, the one above is not a sentence, so it doesn't
_need_ a period ... except for consistency.

But I don't care either way. :)

>> }
>> if (gp_normal1 && cur_ops->deferred_free) {
>> synctype[nsynctypes++] = RTWS_DEF_FREE;
>> - pr_info("%s: Testing asynchronous GPs.\n", __func__);
>> + pr_info("%s: Testing asynchronous GPs\n", __func__);
>> } else if (gp_normal && !cur_ops->deferred_free) {
>> - pr_alert("%s: gp_normal without primitives.\n", __func__);
>> + pr_alert("%s: gp_normal without primitives\n", __func__);
>> }
>> if (gp_sync1 && cur_ops->sync) {
>> synctype[nsynctypes++] = RTWS_SYNC;
>> - pr_info("%s: Testing normal GPs.\n", __func__);
>> + pr_info("%s: Testing normal GPs\n", __func__);
>> } else if (gp_sync && !cur_ops->sync) {
>> - pr_alert("%s: gp_sync without primitives.\n", __func__);
>> + pr_alert("%s: gp_sync without primitives\n", __func__);








--
~Randy

2018-05-14 21:06:41

by Paul E. McKenney

[permalink] [raw]
Subject: Re: [PATCH 18/18] rcu: Use pr_fmt to prefix "rcu: " to logging output

On Mon, May 14, 2018 at 01:52:48PM -0700, Randy Dunlap wrote:
> On 05/14/2018 01:29 PM, Paul E. McKenney wrote:
> > On Thu, May 10, 2018 at 08:45:44AM -0700, Joe Perches wrote:
> >> Use a consistent logging prefix for all rcu related output.
> >>
> >> Signed-off-by: Joe Perches <[email protected]>
> >
> > I took parts of this (thank you!) but have concerns about other parts.
> >
> >> ---
> >> kernel/rcu/rcu_segcblist.c | 2 ++
> >> kernel/rcu/rcuperf.c | 10 ++++---
> >> kernel/rcu/rcutorture.c | 46 +++++++++++++++----------------
> >> kernel/rcu/srcutiny.c | 2 ++
> >> kernel/rcu/srcutree.c | 5 +++-
> >> kernel/rcu/tiny.c | 3 +++
> >> kernel/rcu/tree.c | 8 +++---
> >> kernel/rcu/tree_plugin.h | 67 +++++++++++++++++++++++++++-------------------
> >> kernel/rcu/update.c | 19 ++++++++-----
> >> 9 files changed, 96 insertions(+), 66 deletions(-)
> >>
>
> >> diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
> >> index 648e1c25707d..45d98ff0d5b8 100644
> >> --- a/kernel/rcu/rcutorture.c
> >> +++ b/kernel/rcu/rcutorture.c
> >> @@ -22,6 +22,7 @@
> >> *
> >> * See also: Documentation/RCU/torture.txt
> >> */
> >> +
> >> #include <linux/types.h>
> >> #include <linux/kernel.h>
> >> #include <linux/init.h>
> >> @@ -908,7 +909,7 @@ rcu_torture_writer(void *arg)
> >> VERBOSE_TOROUT_STRING("rcu_torture_writer task started");
> >> if (!can_expedite)
> >> pr_alert("%s" TORTURE_FLAG
> >> - " GP expediting controlled from boot/sysfs for %s.\n",
> >> + " GP expediting controlled from boot/sysfs for %s\n",
> >> torture_type, cur_ops->name);
> >>
> >> /* Initialize synctype[] array. If none set, take default. */
> >> @@ -916,27 +917,27 @@ rcu_torture_writer(void *arg)
> >> gp_cond1 = gp_exp1 = gp_normal1 = gp_sync1 = true;
> >> if (gp_cond1 && cur_ops->get_state && cur_ops->cond_sync) {
> >> synctype[nsynctypes++] = RTWS_COND_GET;
> >> - pr_info("%s: Testing conditional GPs.\n", __func__);
> >> + pr_info("%s: Testing conditional GPs\n", __func__);
> >> } else if (gp_cond && (!cur_ops->get_state || !cur_ops->cond_sync)) {
> >> - pr_alert("%s: gp_cond without primitives.\n", __func__);
> >> + pr_alert("%s: gp_cond without primitives\n", __func__);
> >> }
> >> if (gp_exp1 && cur_ops->exp_sync) {
> >> synctype[nsynctypes++] = RTWS_EXP_SYNC;
> >> - pr_info("%s: Testing expedited GPs.\n", __func__);
> >> + pr_info("%s: Testing expedited GPs\n", __func__);
> >> } else if (gp_exp && !cur_ops->exp_sync) {
> >> - pr_alert("%s: gp_exp without primitives.\n", __func__);
> >> + pr_alert("%s: gp_exp without primitives\n", __func__);
>
> Unlike some of the others, the one above is not a sentence, so it doesn't
> _need_ a period ... except for consistency.
>
> But I don't care either way. :)

;-) ;-) ;-)

Thanx, Paul

> >> }
> >> if (gp_normal1 && cur_ops->deferred_free) {
> >> synctype[nsynctypes++] = RTWS_DEF_FREE;
> >> - pr_info("%s: Testing asynchronous GPs.\n", __func__);
> >> + pr_info("%s: Testing asynchronous GPs\n", __func__);
> >> } else if (gp_normal && !cur_ops->deferred_free) {
> >> - pr_alert("%s: gp_normal without primitives.\n", __func__);
> >> + pr_alert("%s: gp_normal without primitives\n", __func__);
> >> }
> >> if (gp_sync1 && cur_ops->sync) {
> >> synctype[nsynctypes++] = RTWS_SYNC;
> >> - pr_info("%s: Testing normal GPs.\n", __func__);
> >> + pr_info("%s: Testing normal GPs\n", __func__);
> >> } else if (gp_sync && !cur_ops->sync) {
> >> - pr_alert("%s: gp_sync without primitives.\n", __func__);
> >> + pr_alert("%s: gp_sync without primitives\n", __func__);
>
>
>
>
>
>
>
>
> --
> ~Randy
>


2018-05-14 21:09:19

by Paul E. McKenney

[permalink] [raw]
Subject: Re: [PATCH 18/18] rcu: Use pr_fmt to prefix "rcu: " to logging output

On Mon, May 14, 2018 at 11:37:56PM +0300, Andy Shevchenko wrote:
> On Mon, May 14, 2018 at 11:29 PM, Paul E. McKenney
> <[email protected]> wrote:
> > On Thu, May 10, 2018 at 08:45:44AM -0700, Joe Perches wrote:
>
> > And I took this (but kept the period), plus used "%s" to make it fit in
> > 80 characters:
> >
> > pr_info("\tRCU restricting CPUs from %s=%d to %s=%u.\n",
> > "NR_CPUS", NR_CPUS, "nr_cpu_ids", nr_cpu_ids);
>
> Why do care about 80 characters for string literals? (Checkpatch
> dropped this limit long time ago after some discussions)
> I think it's better to find line if more context given (this my
> objection agains %s for string literals).

Good point! I am reverting that portion of the commit with attribution,
thank you!

Thanx, Paul


2018-05-14 21:42:36

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 18/18] rcu: Use pr_fmt to prefix "rcu: " to logging output

On Mon, 2018-05-14 at 13:29 -0700, Paul E. McKenney wrote:
> On Thu, May 10, 2018 at 08:45:44AM -0700, Joe Perches wrote:
> > Use a consistent logging prefix for all rcu related output.
> >
> > Signed-off-by: Joe Perches <[email protected]>
>
> I took parts of this (thank you!) but have concerns about other parts.
[]
> > diff --git a/kernel/rcu/rcuperf.c b/kernel/rcu/rcuperf.c
> > index 076a50fb22ad..ebdd77b45470 100644
> > --- a/kernel/rcu/rcuperf.c
> > +++ b/kernel/rcu/rcuperf.c
> > @@ -19,6 +19,9 @@
> > *
> > * Authors: Paul E. McKenney <[email protected]>
> > */
> > +
> > +#define pr_fmt(fmt) "rcu: " fmt
>
> This is going to get us messages of the form "rcu: rcu-perf:", not?
> (And other odd combinations, depending on the flavor of RCU under test.)
> If so, this does not seem to be an improvement.

That depends on the existing embedded content of the format.
This will prefix just "rcu: " to pr_<level> output.

> > diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
[]
> > @@ -908,7 +909,7 @@ rcu_torture_writer(void *arg)
> > VERBOSE_TOROUT_STRING("rcu_torture_writer task started");
> > if (!can_expedite)
> > pr_alert("%s" TORTURE_FLAG
> > - " GP expediting controlled from boot/sysfs for %s.\n",
> > + " GP expediting controlled from boot/sysfs for %s\n",
> > torture_type, cur_ops->name);

As there is _no_ pr_fmt #defined in this file,
output will/could be prefixed with KBUILD_MODNAME ": "
(in this case "rcutorture: ") if/when the generic
pr_fmt conversion patch is applied.

> > } else if (gp_sync && !cur_ops->sync) {
> > - pr_alert("%s: gp_sync without primitives.\n", __func__);
> > + pr_alert("%s: gp_sync without primitives\n", __func__);
>
> I used a CDC Cyber 73 in the 1970s.

Fancy. I used a CDC 6400 and an IBM 1620, but
those were pretty old when I started.

> It had tiny memory by today's
> standards, but even it had periods in its error messages. We can easily
> afford them today, especially given that rcutorture is not included in
> small-memory Linux configurations.

OK, but I like consistency too.

~90 percent of linux logging does not use terminating periods.
For instance, on my laptop:

$ uptime -p
up 1 week, 1 day, 13 hours, 37 minute
$ dmesg | wc -l
4240
$ dmesg | grep -P "\w\.$"| wc -l
381

> > @@ -1711,11 +1712,11 @@ static void rcu_test_debug_objects(void)
> >
> > /* Wait for them all to get done so we can safely return. */
> > rcu_barrier();
> > - pr_alert("%s: WARN: Duplicate call_rcu() test complete.\n", KBUILD_MODNAME);
> > + pr_alert("WARN: Duplicate call_rcu() test complete\n");
>
> I would like to keep these, as they mark the region of console output where
> splats are expected.

The prefixes are still there...

> > if (cur_ops->fqs == NULL && fqs_duration != 0) {
> > - pr_alert("rcu-torture: ->fqs NULL and non-zero fqs_duration, fqs disabled.\n");
> > + pr_alert("->fqs NULL and non-zero fqs_duration, fqs disabled\n");
>
> This I would like to keep. Easier to find.

One thing that you could use to validate the
output string format is after compilation:

$ strings kernel/rcu/rcutorture.o | grep -P "^[0-6]\w+:"

With your change, you will see duplicated prefixes.

cheers, Joe
>

2018-05-14 22:25:06

by Paul E. McKenney

[permalink] [raw]
Subject: Re: [PATCH 18/18] rcu: Use pr_fmt to prefix "rcu: " to logging output

On Mon, May 14, 2018 at 02:41:59PM -0700, Joe Perches wrote:
> On Mon, 2018-05-14 at 13:29 -0700, Paul E. McKenney wrote:
> > On Thu, May 10, 2018 at 08:45:44AM -0700, Joe Perches wrote:
> > > Use a consistent logging prefix for all rcu related output.
> > >
> > > Signed-off-by: Joe Perches <[email protected]>
> >
> > I took parts of this (thank you!) but have concerns about other parts.
> []
> > > diff --git a/kernel/rcu/rcuperf.c b/kernel/rcu/rcuperf.c
> > > index 076a50fb22ad..ebdd77b45470 100644
> > > --- a/kernel/rcu/rcuperf.c
> > > +++ b/kernel/rcu/rcuperf.c
> > > @@ -19,6 +19,9 @@
> > > *
> > > * Authors: Paul E. McKenney <[email protected]>
> > > */
> > > +
> > > +#define pr_fmt(fmt) "rcu: " fmt
> >
> > This is going to get us messages of the form "rcu: rcu-perf:", not?
> > (And other odd combinations, depending on the flavor of RCU under test.)
> > If so, this does not seem to be an improvement.
>
> That depends on the existing embedded content of the format.
> This will prefix just "rcu: " to pr_<level> output.

OK, so to make this work, I need to create special-purpose pr_fmt()
definitions for torture, rcutorture, locktorture, and rcuperf. Most
of the rest don't care.

Or am I missing something basic here?

> > > diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
> []
> > > @@ -908,7 +909,7 @@ rcu_torture_writer(void *arg)
> > > VERBOSE_TOROUT_STRING("rcu_torture_writer task started");
> > > if (!can_expedite)
> > > pr_alert("%s" TORTURE_FLAG
> > > - " GP expediting controlled from boot/sysfs for %s.\n",
> > > + " GP expediting controlled from boot/sysfs for %s\n",
> > > torture_type, cur_ops->name);
>
> As there is _no_ pr_fmt #defined in this file,
> output will/could be prefixed with KBUILD_MODNAME ": "
> (in this case "rcutorture: ") if/when the generic
> pr_fmt conversion patch is applied.

Not a fan, NACK.

> > > } else if (gp_sync && !cur_ops->sync) {
> > > - pr_alert("%s: gp_sync without primitives.\n", __func__);
> > > + pr_alert("%s: gp_sync without primitives\n", __func__);
> >
> > I used a CDC Cyber 73 in the 1970s.
>
> Fancy. I used a CDC 6400 and an IBM 1620, but
> those were pretty old when I started.

;-)

> > It had tiny memory by today's
> > standards, but even it had periods in its error messages. We can easily
> > afford them today, especially given that rcutorture is not included in
> > small-memory Linux configurations.
>
> OK, but I like consistency too.
>
> ~90 percent of linux logging does not use terminating periods.
> For instance, on my laptop:
>
> $ uptime -p
> up 1 week, 1 day, 13 hours, 37 minute
> $ dmesg | wc -l
> 4240
> $ dmesg | grep -P "\w\.$"| wc -l
> 381

Why is this a problem worth fixing? From where I sit, it is not.

Even assuming that this is somehow worth solving, why is it buried
in an unrelated patch?

> > > @@ -1711,11 +1712,11 @@ static void rcu_test_debug_objects(void)
> > >
> > > /* Wait for them all to get done so we can safely return. */
> > > rcu_barrier();
> > > - pr_alert("%s: WARN: Duplicate call_rcu() test complete.\n", KBUILD_MODNAME);
> > > + pr_alert("WARN: Duplicate call_rcu() test complete\n");
> >
> > I would like to keep these, as they mark the region of console output where
> > splats are expected.
>
> The prefixes are still there...
>
> > > if (cur_ops->fqs == NULL && fqs_duration != 0) {
> > > - pr_alert("rcu-torture: ->fqs NULL and non-zero fqs_duration, fqs disabled.\n");
> > > + pr_alert("->fqs NULL and non-zero fqs_duration, fqs disabled\n");
> >
> > This I would like to keep. Easier to find.
>
> One thing that you could use to validate the
> output string format is after compilation:
>
> $ strings kernel/rcu/rcutorture.o | grep -P "^[0-6]\w+:"
>
> With your change, you will see duplicated prefixes.

Except that right now there are not duplicated prefixes. Those
apparently only show up after some earlier patch in/before your set is
applied, correct? Plus with your change, I apparently get quite a few
semi-duplicated prefixes, which I would rather avoid, as it would add
pointless thrash to my rcutorture scripting.

Is there some C-preprocessor macro indicating whether or not your changes
have been applied?

Thanx, Paul


2018-05-14 22:54:55

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 18/18] rcu: Use pr_fmt to prefix "rcu: " to logging output

On Mon, 2018-05-14 at 15:24 -0700, Paul E. McKenney wrote:
> On Mon, May 14, 2018 at 02:41:59PM -0700, Joe Perches wrote:
> > On Mon, 2018-05-14 at 13:29 -0700, Paul E. McKenney wrote:
> > > On Thu, May 10, 2018 at 08:45:44AM -0700, Joe Perches wrote:
> > > > Use a consistent logging prefix for all rcu related output.
> > > >
> > > > Signed-off-by: Joe Perches <[email protected]>
> > >
> > > I took parts of this (thank you!) but have concerns about other parts.
> >
> > []
> > > > diff --git a/kernel/rcu/rcuperf.c b/kernel/rcu/rcuperf.c
> > > > index 076a50fb22ad..ebdd77b45470 100644
> > > > --- a/kernel/rcu/rcuperf.c
> > > > +++ b/kernel/rcu/rcuperf.c
> > > > @@ -19,6 +19,9 @@
> > > > *
> > > > * Authors: Paul E. McKenney <[email protected]>
> > > > */
> > > > +
> > > > +#define pr_fmt(fmt) "rcu: " fmt
> > >
> > > This is going to get us messages of the form "rcu: rcu-perf:", not?
> > > (And other odd combinations, depending on the flavor of RCU under test.)
> > > If so, this does not seem to be an improvement.
> >
> > That depends on the existing embedded content of the format.
> > This will prefix just "rcu: " to pr_<level> output.
>
> OK, so to make this work, I need to create special-purpose pr_fmt()
> definitions for torture, rcutorture, locktorture, and rcuperf. Most
> of the rest don't care.

Yes, or allow the new generic #define for pr_fmt
to set those prefixes for you

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

will do the appropriate thing for rcutorture,

> Or am I missing something basic here?
>
> > > > diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
> >
> > []
> > > > @@ -908,7 +909,7 @@ rcu_torture_writer(void *arg)
> > > > VERBOSE_TOROUT_STRING("rcu_torture_writer task started");
> > > > if (!can_expedite)
> > > > pr_alert("%s" TORTURE_FLAG
> > > > - " GP expediting controlled from boot/sysfs for %s.\n",
> > > > + " GP expediting controlled from boot/sysfs for %s\n",
> > > > torture_type, cur_ops->name);
> >
> > As there is _no_ pr_fmt #defined in this file,
> > output will/could be prefixed with KBUILD_MODNAME ": "
> > (in this case "rcutorture: ") if/when the generic
> > pr_fmt conversion patch is applied.
>
> Not a fan, NACK.
>
> > > > } else if (gp_sync && !cur_ops->sync) {
> > > > - pr_alert("%s: gp_sync without primitives.\n", __func__);
> > > > + pr_alert("%s: gp_sync without primitives\n", __func__);
> > >
> > > I used a CDC Cyber 73 in the 1970s.
> >
> > Fancy. I used a CDC 6400 and an IBM 1620, but
> > those were pretty old when I started.
>
> ;-)
>
> > > It had tiny memory by today's
> > > standards, but even it had periods in its error messages. We can easily
> > > afford them today, especially given that rcutorture is not included in
> > > small-memory Linux configurations.
> >
> > OK, but I like consistency too.
> >
> > ~90 percent of linux logging does not use terminating periods.
> > For instance, on my laptop:
> >
> > $ uptime -p
> > up 1 week, 1 day, 13 hours, 37 minute
> > $ dmesg | wc -l
> > 4240
> > $ dmesg | grep -P "\w\.$"| wc -l
> > 381
>
> Why is this a problem worth fixing? From where I sit, it is not.

It's not a _problem_. It's just an inconsistency.
I modify them passively when I see them.
If you don't like it, don't take it.

> Even assuming that this is somehow worth solving, why is it buried
> in an unrelated patch?

Touches each line fewer times.

> > > > @@ -1711,11 +1712,11 @@ static void rcu_test_debug_objects(void)
> > > >
> > > > /* Wait for them all to get done so we can safely return. */
> > > > rcu_barrier();
> > > > - pr_alert("%s: WARN: Duplicate call_rcu() test complete.\n", KBUILD_MODNAME);
> > > > + pr_alert("WARN: Duplicate call_rcu() test complete\n");
> > >
> > > I would like to keep these, as they mark the region of console output where
> > > splats are expected.
> >
> > The prefixes are still there...
> >
> > > > if (cur_ops->fqs == NULL && fqs_duration != 0) {
> > > > - pr_alert("rcu-torture: ->fqs NULL and non-zero fqs_duration, fqs disabled.\n");
> > > > + pr_alert("->fqs NULL and non-zero fqs_duration, fqs disabled\n");
> > >
> > > This I would like to keep. Easier to find.
> >
> > One thing that you could use to validate the
> > output string format is after compilation:
> >
> > $ strings kernel/rcu/rcutorture.o | grep -P "^[0-6]\w+:"
> >
> > With your change, you will see duplicated prefixes.
>
> Except that right now there are not duplicated prefixes. Those
> apparently only show up after some earlier patch in/before your set is
> applied, correct?

yes.
[PATCH 03/18] printk: Convert pr_fmt from blank define to KBUILD_MODNAME

> Is there some C-preprocessor macro indicating whether or not your changes
> have been applied?

? pr_fmt would either be blank or something else.


2018-05-14 23:57:43

by Paul E. McKenney

[permalink] [raw]
Subject: Re: [PATCH 18/18] rcu: Use pr_fmt to prefix "rcu: " to logging output

On Mon, May 14, 2018 at 03:54:13PM -0700, Joe Perches wrote:
> On Mon, 2018-05-14 at 15:24 -0700, Paul E. McKenney wrote:
> > On Mon, May 14, 2018 at 02:41:59PM -0700, Joe Perches wrote:
> > > On Mon, 2018-05-14 at 13:29 -0700, Paul E. McKenney wrote:
> > > > On Thu, May 10, 2018 at 08:45:44AM -0700, Joe Perches wrote:
> > > > > Use a consistent logging prefix for all rcu related output.
> > > > >
> > > > > Signed-off-by: Joe Perches <[email protected]>
> > > >
> > > > I took parts of this (thank you!) but have concerns about other parts.
> > >
> > > []
> > > > > diff --git a/kernel/rcu/rcuperf.c b/kernel/rcu/rcuperf.c
> > > > > index 076a50fb22ad..ebdd77b45470 100644
> > > > > --- a/kernel/rcu/rcuperf.c
> > > > > +++ b/kernel/rcu/rcuperf.c
> > > > > @@ -19,6 +19,9 @@
> > > > > *
> > > > > * Authors: Paul E. McKenney <[email protected]>
> > > > > */
> > > > > +
> > > > > +#define pr_fmt(fmt) "rcu: " fmt
> > > >
> > > > This is going to get us messages of the form "rcu: rcu-perf:", not?
> > > > (And other odd combinations, depending on the flavor of RCU under test.)
> > > > If so, this does not seem to be an improvement.
> > >
> > > That depends on the existing embedded content of the format.
> > > This will prefix just "rcu: " to pr_<level> output.
> >
> > OK, so to make this work, I need to create special-purpose pr_fmt()
> > definitions for torture, rcutorture, locktorture, and rcuperf. Most
> > of the rest don't care.
>
> Yes, or allow the new generic #define for pr_fmt
> to set those prefixes for you
>
> #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>
> will do the appropriate thing for rcutorture,

OK. For rcutorture, there are special prefixes. More on this at the end.

> > Or am I missing something basic here?
> >
> > > > > diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
> > >
> > > []
> > > > > @@ -908,7 +909,7 @@ rcu_torture_writer(void *arg)
> > > > > VERBOSE_TOROUT_STRING("rcu_torture_writer task started");
> > > > > if (!can_expedite)
> > > > > pr_alert("%s" TORTURE_FLAG
> > > > > - " GP expediting controlled from boot/sysfs for %s.\n",
> > > > > + " GP expediting controlled from boot/sysfs for %s\n",
> > > > > torture_type, cur_ops->name);
> > >
> > > As there is _no_ pr_fmt #defined in this file,
> > > output will/could be prefixed with KBUILD_MODNAME ": "
> > > (in this case "rcutorture: ") if/when the generic
> > > pr_fmt conversion patch is applied.
> >
> > Not a fan, NACK.
> >
> > > > > } else if (gp_sync && !cur_ops->sync) {
> > > > > - pr_alert("%s: gp_sync without primitives.\n", __func__);
> > > > > + pr_alert("%s: gp_sync without primitives\n", __func__);
> > > >
> > > > I used a CDC Cyber 73 in the 1970s.
> > >
> > > Fancy. I used a CDC 6400 and an IBM 1620, but
> > > those were pretty old when I started.
> >
> > ;-)
> >
> > > > It had tiny memory by today's
> > > > standards, but even it had periods in its error messages. We can easily
> > > > afford them today, especially given that rcutorture is not included in
> > > > small-memory Linux configurations.
> > >
> > > OK, but I like consistency too.
> > >
> > > ~90 percent of linux logging does not use terminating periods.
> > > For instance, on my laptop:
> > >
> > > $ uptime -p
> > > up 1 week, 1 day, 13 hours, 37 minute
> > > $ dmesg | wc -l
> > > 4240
> > > $ dmesg | grep -P "\w\.$"| wc -l
> > > 381
> >
> > Why is this a problem worth fixing? From where I sit, it is not.
>
> It's not a _problem_. It's just an inconsistency.
> I modify them passively when I see them.
> If you don't like it, don't take it.

OK, fair enough. I will pass.

> > Even assuming that this is somehow worth solving, why is it buried
> > in an unrelated patch?
>
> Touches each line fewer times.
>
> > > > > @@ -1711,11 +1712,11 @@ static void rcu_test_debug_objects(void)
> > > > >
> > > > > /* Wait for them all to get done so we can safely return. */
> > > > > rcu_barrier();
> > > > > - pr_alert("%s: WARN: Duplicate call_rcu() test complete.\n", KBUILD_MODNAME);
> > > > > + pr_alert("WARN: Duplicate call_rcu() test complete\n");
> > > >
> > > > I would like to keep these, as they mark the region of console output where
> > > > splats are expected.
> > >
> > > The prefixes are still there...
> > >
> > > > > if (cur_ops->fqs == NULL && fqs_duration != 0) {
> > > > > - pr_alert("rcu-torture: ->fqs NULL and non-zero fqs_duration, fqs disabled.\n");
> > > > > + pr_alert("->fqs NULL and non-zero fqs_duration, fqs disabled\n");
> > > >
> > > > This I would like to keep. Easier to find.
> > >
> > > One thing that you could use to validate the
> > > output string format is after compilation:
> > >
> > > $ strings kernel/rcu/rcutorture.o | grep -P "^[0-6]\w+:"
> > >
> > > With your change, you will see duplicated prefixes.
> >
> > Except that right now there are not duplicated prefixes. Those
> > apparently only show up after some earlier patch in/before your set is
> > applied, correct?
>
> yes.
> [PATCH 03/18] printk: Convert pr_fmt from blank define to KBUILD_MODNAME
>
> > Is there some C-preprocessor macro indicating whether or not your changes
> > have been applied?
>
> ? pr_fmt would either be blank or something else.

OK, so if I define pr_fmt as follows, I get the old behavior?

#define pr_fmt(fmt) fmt

If so, I can add this to the torture files, and then define pr_fmt more
sensibly for the torture files once your changes hit mainline.

Or if we can agree on the defintion, perhaps we get the sensible
definition into your patch series. But I would much prefer the former
given the high rate of change in RCU at the moment.

Note that my concerns apply only to kernel/torture.c, kernel/rcu/rcuperf.c,
kernel/rcu/rcutorture.c, and kernel/locking/locktorture.c (despite my
earlier ack). The other RCU files, including kernel/rcu/rcu_segcblist.c,
should be just fine with "#define pr_fmt()" added. And I just queued
a commit to be squashed into my version of your patch 18/18 that adds
this to kernel/rcu/rcu_segcblist.c. This joins the ones that your
patch added to kernel/rcu/srcutree.c and kernel/rcu/tree.c.

Should I also add "#define pr_fmt(fmt) "rcu: " fmt" to these files?

kernel/rcu/srcutiny.c
kernel/rcu/sync.c
kernel/rcu/tiny.c

Thanx, Paul


2018-05-15 00:24:27

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 18/18] rcu: Use pr_fmt to prefix "rcu: " to logging output

On Mon, 2018-05-14 at 16:58 -0700, Paul E. McKenney wrote:
> OK, so if I define pr_fmt as follows, I get the old behavior?
>
> #define pr_fmt(fmt) fmt

yes.

> I just queued
> a commit to be squashed into my version of your patch 18/18 that adds
> this to kernel/rcu/rcu_segcblist.c. This joins the ones that your
> patch added to kernel/rcu/srcutree.c and kernel/rcu/tree.c.
>
> Should I also add "#define pr_fmt(fmt) "rcu: " fmt" to these files?
>
> kernel/rcu/srcutiny.c
> kernel/rcu/sync.c
> kernel/rcu/tiny.c

Well, I don't actually remember why the define
was added to rcu_segcblist.c.

Most of this was done via a script which looked
for pr_<level> uses without a pr_fmt in the same
file.

Dunno why rcu_segcblist was modified.
Maybe it was a braino.

2018-05-15 00:31:04

by Paul E. McKenney

[permalink] [raw]
Subject: Re: [PATCH 18/18] rcu: Use pr_fmt to prefix "rcu: " to logging output

On Mon, May 14, 2018 at 05:23:59PM -0700, Joe Perches wrote:
> On Mon, 2018-05-14 at 16:58 -0700, Paul E. McKenney wrote:
> > OK, so if I define pr_fmt as follows, I get the old behavior?
> >
> > #define pr_fmt(fmt) fmt
>
> yes.

OK, then I will queue patches with this for the near term for
the various torture files.

> > I just queued
> > a commit to be squashed into my version of your patch 18/18 that adds
> > this to kernel/rcu/rcu_segcblist.c. This joins the ones that your
> > patch added to kernel/rcu/srcutree.c and kernel/rcu/tree.c.
> >
> > Should I also add "#define pr_fmt(fmt) "rcu: " fmt" to these files?
> >
> > kernel/rcu/srcutiny.c
> > kernel/rcu/sync.c
> > kernel/rcu/tiny.c
>
> Well, I don't actually remember why the define
> was added to rcu_segcblist.c.
>
> Most of this was done via a script which looked
> for pr_<level> uses without a pr_fmt in the same
> file.
>
> Dunno why rcu_segcblist was modified.
> Maybe it was a braino.

So this change does not affect WARN_ON_ONCE() and friends? (That was
my guess.) If not, I will revert my squash patch.

And it could also be that the files changed between your running the
script and sending the patch.

Thanx, Paul


2018-05-15 01:22:34

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 18/18] rcu: Use pr_fmt to prefix "rcu: " to logging output

On Mon, 2018-05-14 at 17:32 -0700, Paul E. McKenney wrote:
> So this change does not affect WARN_ON_ONCE() and friends?

Changing define pr_fmt does not modify WARN_ON output.


2018-05-15 03:40:51

by Paul E. McKenney

[permalink] [raw]
Subject: Re: [PATCH 18/18] rcu: Use pr_fmt to prefix "rcu: " to logging output

On Mon, May 14, 2018 at 06:22:02PM -0700, Joe Perches wrote:
> On Mon, 2018-05-14 at 17:32 -0700, Paul E. McKenney wrote:
> > So this change does not affect WARN_ON_ONCE() and friends?
>
> Changing define pr_fmt does not modify WARN_ON output.

Very good, I removed my --squash patch adding pr_fmt() to the file
kernel/rcu/rcu_segcblist.c.

Thanx, Paul


2018-05-15 19:28:11

by Paul E. McKenney

[permalink] [raw]
Subject: Re: [PATCH 18/18] rcu: Use pr_fmt to prefix "rcu: " to logging output

On Mon, May 14, 2018 at 05:32:05PM -0700, Paul E. McKenney wrote:
> On Mon, May 14, 2018 at 05:23:59PM -0700, Joe Perches wrote:
> > On Mon, 2018-05-14 at 16:58 -0700, Paul E. McKenney wrote:
> > > OK, so if I define pr_fmt as follows, I get the old behavior?
> > >
> > > #define pr_fmt(fmt) fmt
> >
> > yes.
>
> OK, then I will queue patches with this for the near term for
> the various torture files.

And here is the patch. Thoughts?

Thanx, Paul

------------------------------------------------------------------------

commit de94f0b65dd4dcb7e651e2d85df9d9bc86b5bf23
Author: Paul E. McKenney <[email protected]>
Date: Tue May 15 12:25:05 2018 -0700

torture: Keep old-school dmesg format

This commit adds "#define pr_fmt(fmt) fmt" to the torture-test files
in order to keep the current dmesg format. Once Joe's commits have
hit mainline, these definitions will be changed in order to automatically
generate the dmesg line prefix that the scripts expect. This will have
the beneficial side-effect of allowing printk() formats to be used more
widely and of shortening some pr_*() lines.

Signed-off-by: Paul E. McKenney <[email protected]>
Cc: Joe Perches <[email protected]>

diff --git a/kernel/locking/locktorture.c b/kernel/locking/locktorture.c
index 6d42670a1c70..5f00e5a2ef3b 100644
--- a/kernel/locking/locktorture.c
+++ b/kernel/locking/locktorture.c
@@ -21,6 +21,9 @@
* Davidlohr Bueso <[email protected]>
* Based on kernel/rcu/torture.c.
*/
+
+#define pr_fmt(fmt) fmt
+
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/kthread.h>
diff --git a/kernel/rcu/rcuperf.c b/kernel/rcu/rcuperf.c
index 9047e5439e46..791f8ae7ce20 100644
--- a/kernel/rcu/rcuperf.c
+++ b/kernel/rcu/rcuperf.c
@@ -19,6 +19,9 @@
*
* Authors: Paul E. McKenney <[email protected]>
*/
+
+#define pr_fmt(fmt) fmt
+
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/init.h>
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index 9d80245b2a1c..ca08e6733fa2 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -22,6 +22,9 @@
*
* See also: Documentation/RCU/torture.txt
*/
+
+#define pr_fmt(fmt) fmt
+
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/init.h>
diff --git a/kernel/torture.c b/kernel/torture.c
index 840fd33c1cda..1ac24a826589 100644
--- a/kernel/torture.c
+++ b/kernel/torture.c
@@ -20,6 +20,9 @@
* Author: Paul E. McKenney <[email protected]>
* Based on kernel/rcu/torture.c.
*/
+
+#define pr_fmt(fmt) fmt
+
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/init.h>


2018-05-15 21:12:46

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 18/18] rcu: Use pr_fmt to prefix "rcu: " to logging output

On Tue, 2018-05-15 at 12:28 -0700, Paul E. McKenney wrote:
> On Mon, May 14, 2018 at 05:32:05PM -0700, Paul E. McKenney wrote:
> > On Mon, May 14, 2018 at 05:23:59PM -0700, Joe Perches wrote:
> > > On Mon, 2018-05-14 at 16:58 -0700, Paul E. McKenney wrote:
> > > > OK, so if I define pr_fmt as follows, I get the old behavior?
> > > >
> > > > #define pr_fmt(fmt) fmt
> > >
> > > yes.
> >
> > OK, then I will queue patches with this for the near term for
> > the various torture files.
>
> And here is the patch. Thoughts?

Seems sensible.
Perhaps still do the pr_alert->pr_cont conversions.

cheers, Joe

2018-05-15 21:24:24

by Paul E. McKenney

[permalink] [raw]
Subject: Re: [PATCH 18/18] rcu: Use pr_fmt to prefix "rcu: " to logging output

On Tue, May 15, 2018 at 02:11:48PM -0700, Joe Perches wrote:
> On Tue, 2018-05-15 at 12:28 -0700, Paul E. McKenney wrote:
> > On Mon, May 14, 2018 at 05:32:05PM -0700, Paul E. McKenney wrote:
> > > On Mon, May 14, 2018 at 05:23:59PM -0700, Joe Perches wrote:
> > > > On Mon, 2018-05-14 at 16:58 -0700, Paul E. McKenney wrote:
> > > > > OK, so if I define pr_fmt as follows, I get the old behavior?
> > > > >
> > > > > #define pr_fmt(fmt) fmt
> > > >
> > > > yes.
> > >
> > > OK, then I will queue patches with this for the near term for
> > > the various torture files.
> >
> > And here is the patch. Thoughts?
>
> Seems sensible.
> Perhaps still do the pr_alert->pr_cont conversions.

Agreed, and I have those queued as shown below. Please let me know
if I missed something.

Thanx, Paul

------------------------------------------------------------------------

commit adf02580b79ba77156bf60ccd338d9f49eaf8eb3
Author: Joe Perches <[email protected]>
Date: Mon May 14 13:27:33 2018 -0700

rcu: Use pr_fmt to prefix "rcu: " to logging output

This commit also adjusts some whitespace while in the area.

Signed-off-by: Joe Perches <[email protected]>
Signed-off-by: Paul E. McKenney <[email protected]>
[ paulmck: Revert string-breaking %s as requested by Andy Shevchenko. ]

diff --git a/kernel/rcu/rcuperf.c b/kernel/rcu/rcuperf.c
index 479820d231bf..9047e5439e46 100644
--- a/kernel/rcu/rcuperf.c
+++ b/kernel/rcu/rcuperf.c
@@ -663,12 +663,11 @@ rcu_perf_init(void)
break;
}
if (i == ARRAY_SIZE(perf_ops)) {
- pr_alert("rcu-perf: invalid perf type: \"%s\"\n",
- perf_type);
+ pr_alert("rcu-perf: invalid perf type: \"%s\"\n", perf_type);
pr_alert("rcu-perf types:");
for (i = 0; i < ARRAY_SIZE(perf_ops); i++)
- pr_alert(" %s", perf_ops[i]->name);
- pr_alert("\n");
+ pr_cont(" %s", perf_ops[i]->name);
+ pr_cont("\n");
firsterr = -EINVAL;
goto unwind;
}
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index ba82285a023a..9d80245b2a1c 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -1744,8 +1744,8 @@ rcu_torture_init(void)
torture_type);
pr_alert("rcu-torture types:");
for (i = 0; i < ARRAY_SIZE(torture_ops); i++)
- pr_alert(" %s", torture_ops[i]->name);
- pr_alert("\n");
+ pr_cont(" %s", torture_ops[i]->name);
+ pr_cont("\n");
firsterr = -EINVAL;
goto unwind;
}
diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index ff894ae6d386..031d2713701f 100644
--- a/kernel/rcu/srcutree.c
+++ b/kernel/rcu/srcutree.c
@@ -26,6 +26,8 @@
*
*/

+#define pr_fmt(fmt) "rcu: " fmt
+
#include <linux/export.h>
#include <linux/mutex.h>
#include <linux/percpu.h>
@@ -390,7 +392,8 @@ void _cleanup_srcu_struct(struct srcu_struct *sp, bool quiesced)
}
if (WARN_ON(rcu_seq_state(READ_ONCE(sp->srcu_gp_seq)) != SRCU_STATE_IDLE) ||
WARN_ON(srcu_readers_active(sp))) {
- pr_info("%s: Active srcu_struct %p state: %d\n", __func__, sp, rcu_seq_state(READ_ONCE(sp->srcu_gp_seq)));
+ pr_info("%s: Active srcu_struct %p state: %d\n",
+ __func__, sp, rcu_seq_state(READ_ONCE(sp->srcu_gp_seq)));
return; /* Caller forgot to stop doing call_srcu()? */
}
free_percpu(sp->sda);
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 23b855f5c5cb..3826ce90fd6e 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -27,6 +27,9 @@
* For detailed explanation of Read-Copy Update mechanism see -
* Documentation/RCU
*/
+
+#define pr_fmt(fmt) "rcu: " fmt
+
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/init.h>
@@ -1352,8 +1355,7 @@ static void print_other_cpu_stall(struct rcu_state *rsp, unsigned long gp_seq)
* See Documentation/RCU/stallwarn.txt for info on how to debug
* RCU CPU stall warnings.
*/
- pr_err("INFO: %s detected stalls on CPUs/tasks:",
- rsp->name);
+ pr_err("INFO: %s detected stalls on CPUs/tasks:", rsp->name);
print_cpu_stall_info_begin();
rcu_for_each_leaf_node(rsp, rnp) {
raw_spin_lock_irqsave_rcu_node(rnp, flags);
@@ -3996,7 +3998,7 @@ static void __init rcu_init_geometry(void)
if (rcu_fanout_leaf == RCU_FANOUT_LEAF &&
nr_cpu_ids == NR_CPUS)
return;
- pr_info("RCU: Adjusting geometry for rcu_fanout_leaf=%d, nr_cpu_ids=%u\n",
+ pr_info("Adjusting geometry for rcu_fanout_leaf=%d, nr_cpu_ids=%u\n",
rcu_fanout_leaf, nr_cpu_ids);

/*
diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index 54a251640f53..dbfe90191e19 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -74,8 +74,8 @@ static void __init rcu_bootup_announce_oddness(void)
pr_info("\tRCU event tracing is enabled.\n");
if ((IS_ENABLED(CONFIG_64BIT) && RCU_FANOUT != 64) ||
(!IS_ENABLED(CONFIG_64BIT) && RCU_FANOUT != 32))
- pr_info("\tCONFIG_RCU_FANOUT set to non-default value of %d\n",
- RCU_FANOUT);
+ pr_info("\tCONFIG_RCU_FANOUT set to non-default value of %d.\n",
+ RCU_FANOUT);
if (rcu_fanout_exact)
pr_info("\tHierarchical RCU autobalancing is disabled.\n");
if (IS_ENABLED(CONFIG_RCU_FAST_NO_HZ))
@@ -88,11 +88,13 @@ static void __init rcu_bootup_announce_oddness(void)
pr_info("\tBuild-time adjustment of leaf fanout to %d.\n",
RCU_FANOUT_LEAF);
if (rcu_fanout_leaf != RCU_FANOUT_LEAF)
- pr_info("\tBoot-time adjustment of leaf fanout to %d.\n", rcu_fanout_leaf);
+ pr_info("\tBoot-time adjustment of leaf fanout to %d.\n",
+ rcu_fanout_leaf);
if (nr_cpu_ids != NR_CPUS)
pr_info("\tRCU restricting CPUs from NR_CPUS=%d to nr_cpu_ids=%u.\n", NR_CPUS, nr_cpu_ids);
#ifdef CONFIG_RCU_BOOST
- pr_info("\tRCU priority boosting: priority %d delay %d ms.\n", kthread_prio, CONFIG_RCU_BOOST_DELAY);
+ pr_info("\tRCU priority boosting: priority %d delay %d ms.\n",
+ kthread_prio, CONFIG_RCU_BOOST_DELAY);
#endif
if (blimit != DEFAULT_RCU_BLIMIT)
pr_info("\tBoot-time adjustment of callback invocation limit to %ld.\n", blimit);


2018-05-17 18:28:10

by Borislav Petkov

[permalink] [raw]
Subject: Re: [tip:x86/cleanups] x86: Remove pr_fmt duplicate logging prefixes

On Sun, May 13, 2018 at 12:27:45PM -0700, tip-bot for Joe Perches wrote:
> Commit-ID: 1de392f5d5e803663abbd8ed084233f154152bcd
> Gitweb: https://git.kernel.org/tip/1de392f5d5e803663abbd8ed084233f154152bcd
> Author: Joe Perches <[email protected]>
> AuthorDate: Thu, 10 May 2018 08:45:30 -0700
> Committer: Thomas Gleixner <[email protected]>
> CommitDate: Sun, 13 May 2018 21:25:18 +0200
>
> x86: Remove pr_fmt duplicate logging prefixes
>
> Converting pr_fmt from a default simple #define to use KBUILD_MODNAME
> added some duplicate prefixes.
>
> Remove the duplicate prefixes.
>
> Signed-off-by: Joe Perches <[email protected]>
> Signed-off-by: Thomas Gleixner <[email protected]>
> Cc: "H. Peter Anvin" <[email protected]>
> Link: https://lkml.kernel.org/r/e7b709a2b040af7faa81b0aa2c3a125aed628a82.1525964383.git.joe@perches.com
>
> ---
> arch/x86/events/amd/ibs.c | 2 +-
> arch/x86/kernel/e820.c | 32 +++++++++++++++++---------------
> arch/x86/kernel/hpet.c | 5 ++---
> arch/x86/kernel/uprobes.c | 4 ++--
> arch/x86/mm/numa.c | 22 +++++++++++-----------
> 5 files changed, 33 insertions(+), 32 deletions(-)

...

> @@ -830,8 +832,8 @@ static unsigned long __init e820_end_pfn(unsigned long limit_pfn, enum e820_type
> if (last_pfn > max_arch_pfn)
> last_pfn = max_arch_pfn;
>
> - pr_info("e820: last_pfn = %#lx max_arch_pfn = %#lx\n",
> - last_pfn, max_arch_pfn);
> + pr_info("last_pfn = %#lx max_arch_pfn = %#lx\n",
> + last_pfn, max_arch_pfn);
> return last_pfn;
> }
>
> @@ -1005,7 +1007,7 @@ void __init e820__finish_early_params(void)
> if (e820__update_table(e820_table) < 0)
> early_panic("Invalid user supplied memory map");
>
> - pr_info("e820: user-defined physical RAM map:\n");
> + pr_info("user-defined physical RAM map:\n");
> e820__print_table("user");
> }
> }
> @@ -1238,7 +1240,7 @@ void __init e820__memory_setup(void)
> memcpy(e820_table_kexec, e820_table, sizeof(*e820_table_kexec));
> memcpy(e820_table_firmware, e820_table, sizeof(*e820_table_firmware));
>
> - pr_info("e820: BIOS-provided physical RAM map:\n");
> + pr_info("BIOS-provided physical RAM map:\n");
> e820__print_table(who);
> }

Maybe I'm missing something but this dropped the prefixes now
completely:

-e820: BIOS-provided physical RAM map:
+BIOS-provided physical RAM map:

-e820: last_pfn = 0x43f000 max_arch_pfn = 0x400000000
+last_pfn = 0x43f000 max_arch_pfn = 0x400000000

-e820: last_pfn = 0x9d000 max_arch_pfn = 0x400000000
+last_pfn = 0x9d000 max_arch_pfn = 0x400000000

...

I don't think that was the intention.

--
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

2018-05-17 18:44:50

by Joe Perches

[permalink] [raw]
Subject: Re: [tip:x86/cleanups] x86: Remove pr_fmt duplicate logging prefixes

On Thu, 2018-05-17 at 20:27 +0200, Borislav Petkov wrote:
> On Sun, May 13, 2018 at 12:27:45PM -0700, tip-bot for Joe Perches wrote:
> > Commit-ID: 1de392f5d5e803663abbd8ed084233f154152bcd
> > Gitweb: https://git.kernel.org/tip/1de392f5d5e803663abbd8ed084233f154152bcd
> > Author: Joe Perches <[email protected]>
> > AuthorDate: Thu, 10 May 2018 08:45:30 -0700
> > Committer: Thomas Gleixner <[email protected]>
> > CommitDate: Sun, 13 May 2018 21:25:18 +0200
> >
> > x86: Remove pr_fmt duplicate logging prefixes
> >
> > Converting pr_fmt from a default simple #define to use KBUILD_MODNAME
> > added some duplicate prefixes.
> >
> > Remove the duplicate prefixes.
[]
> Maybe I'm missing something but this dropped the prefixes now
> completely:
>
> -e820: BIOS-provided physical RAM map:
> +BIOS-provided physical RAM map:
>
> -e820: last_pfn = 0x43f000 max_arch_pfn = 0x400000000
> +last_pfn = 0x43f000 max_arch_pfn = 0x400000000
>
> -e820: last_pfn = 0x9d000 max_arch_pfn = 0x400000000
> +last_pfn = 0x9d000 max_arch_pfn = 0x400000000
>
> ...
>
> I don't think that was the intention.

Hi Borislav

It wasn't and isn't the intention.

This is a patch _series_, and all of the patches
from 4-18 depend on patch 3 which converts the
generic define in include/linux/printk.h

from
#define pr_fmt(fmt) fmt
to
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

Perhaps a better option, which could be done in
a v2 of the series, is to add a temporary
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
to each file modified in patches 4-18 and then
allow the follow-on script described in the 0/18
cover letter to remove those #defines

cheers, Joe


2018-05-17 19:16:13

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [tip:x86/cleanups] x86: Remove pr_fmt duplicate logging prefixes

On Thu, 17 May 2018, Joe Perches wrote:
> On Thu, 2018-05-17 at 20:27 +0200, Borislav Petkov wrote:
> > On Sun, May 13, 2018 at 12:27:45PM -0700, tip-bot for Joe Perches wrote:
> > > Commit-ID: 1de392f5d5e803663abbd8ed084233f154152bcd
> > > Gitweb: https://git.kernel.org/tip/1de392f5d5e803663abbd8ed084233f154152bcd
> > > Author: Joe Perches <[email protected]>
> > > AuthorDate: Thu, 10 May 2018 08:45:30 -0700
> > > Committer: Thomas Gleixner <[email protected]>
> > > CommitDate: Sun, 13 May 2018 21:25:18 +0200
> > >
> > > x86: Remove pr_fmt duplicate logging prefixes
> > >
> > > Converting pr_fmt from a default simple #define to use KBUILD_MODNAME
> > > added some duplicate prefixes.
> > >
> > > Remove the duplicate prefixes.
> []
> > Maybe I'm missing something but this dropped the prefixes now
> > completely:
> >
> > -e820: BIOS-provided physical RAM map:
> > +BIOS-provided physical RAM map:
> >
> > -e820: last_pfn = 0x43f000 max_arch_pfn = 0x400000000
> > +last_pfn = 0x43f000 max_arch_pfn = 0x400000000
> >
> > -e820: last_pfn = 0x9d000 max_arch_pfn = 0x400000000
> > +last_pfn = 0x9d000 max_arch_pfn = 0x400000000
> >
> > ...
> >
> > I don't think that was the intention.
>
> Hi Borislav
>
> It wasn't and isn't the intention.
>
> This is a patch _series_, and all of the patches
> from 4-18 depend on patch 3 which converts the
> generic define in include/linux/printk.h
>
> from
> #define pr_fmt(fmt) fmt
> to
> #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>
> Perhaps a better option, which could be done in
> a v2 of the series, is to add a temporary
> #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> to each file modified in patches 4-18 and then
> allow the follow-on script described in the 0/18
> cover letter to remove those #defines

Yes, I think thats the right thing todo.

Thanks,

tglx

2018-05-18 08:42:39

by Petr Mladek

[permalink] [raw]
Subject: Re: [PATCH 03/18] printk: Convert pr_fmt from blank define to KBUILD_MODNAME

On Thu 2018-05-10 08:45:29, Joe Perches wrote:
> There are more than 1000 uses of #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> Make that the default define so these uses can be removed later via script.
>
> Signed-off-by: Joe Perches <[email protected]>

It removes a lot of duplicates. I just hope that we will not need to
add the same amount of defines to remove/change the prefix where the
new default would look ugly.

I am not completely convinced that it is worth it. But it makes some
sense. Feel free to use:

Acked-by: Petr Mladek <[email protected]>


BTW: I tried the entire patchset and there are still many locations
even in the boot log that might need an update:

[ 0.000000] main: Linux version 4.17.0-rc4-default+ (pmladek@pathway) (gcc version 7.3.1 20180226 [gcc-7-branch revision 257983] (SUSE Linux)) #4505 SMP Fri May 11 13:24:37 CEST 2018
[ 0.000000] e820: BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
[ 0.000000] e820: BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved
[ 0.000000] e820: BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved
[ 0.000000] e820: BIOS-e820: [mem 0x0000000000100000-0x00000000bffdefff] usable
[ 0.000000] e820: BIOS-e820: [mem 0x00000000bffdf000-0x00000000bfffffff] reserved
[ 0.000000] e820: BIOS-e820: [mem 0x00000000feffc000-0x00000000feffffff] reserved
[ 0.000000] e820: BIOS-e820: [mem 0x00000000fffc0000-0x00000000ffffffff] reserved
[ 0.000000] e820: BIOS-e820: [mem 0x0000000100000000-0x000000013fffffff] usable
[ 0.000000] dmi_scan: DMI: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.0.0-prebuilt.qemu-project.org 04/01/2014
[ 0.000000] hypervisor: Hypervisor detected: KVM
[ 0.000000] generic: MTRR default type: write-back
[ 0.000000] generic: MTRR fixed ranges enabled:
[ 0.000000] generic: 00000-9FFFF write-back
[ 0.000000] generic: A0000-BFFFF uncachable
[ 0.000000] generic: C0000-FFFFF write-protect
[ 0.000000] generic: MTRR variable ranges enabled:
[ 0.000000] generic: 0 base 000C0000000 mask 3FFC0000000 uncachable
[ 0.000000] generic: 1 disabled
[ 0.000000] generic: 2 disabled
[ 0.000000] generic: 3 disabled
[ 0.000000] generic: 4 disabled
[ 0.000000] generic: 5 disabled
[ 0.000000] generic: 6 disabled
[ 0.000000] generic: 7 disabled
[ 0.000000] libftrace: ftrace: allocating 40753 entries in 160 pages
[ 0.004008] apic: APIC: Switch to symmetric I/O mode setup
[ 0.056663] dca: dca service started, version 1.12.1
[ 0.057807] hugetlb: HugeTLB registered 2.00 MiB page size, pre-allocated 0 pages
[ 0.060035] cryptd: cryptd: max_cpu_qlen set to 1000
[ 0.066252] acpi: ACPI: (supports S0 S3 S4 S5)
[ 0.071004] acpi: ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-ff])
[ 0.136057] usbcore: usbcore: registered new interface driver usbfs
[ 0.136671] usbcore: usbcore: registered new interface driver hub
[ 0.137389] usbcore: usbcore: registered new device driver usb
[ 0.795954] key: Key type blacklist registered
[ 0.796479] workingset: workingset: timestamp_bits=36 max_order=20 bucket_order=0
[ 0.798899] key: Key type id_resolver registered
[ 0.799347] key: Key type id_legacy registered
[ 0.799790] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[ 1.044458] ipmi_si: ipmi_si: Unable to find any System Interface(s)
[ 1.046489] ioatdma: ioatdma: Intel(R) QuickData Technology Driver 4.00
[ 1.076080] ppdev: ppdev: user-space parallel port driver
[ 1.484645] ehci_pci: ehci-pci: EHCI PCI platform driver
[ 1.544643] parport: parport0: cannot grant exclusive access for device pps_parport
[ 1.545968] pps_parport: couldn't register with parport0
[ 1.556821] usbcore: usbcore: registered new interface driver usbhid
[ 1.558001] usbhid: usbhid: USB HID core driver
[ 1.559213] parport: parport0: cannot grant exclusive access for device MTS64
[ 1.562908] parport: parport0: cannot grant exclusive access for device portman

Best regards,
Petr

2018-05-18 08:47:35

by Petr Mladek

[permalink] [raw]
Subject: Re: [PATCH 13/18] printk: Remove pr_fmt duplicate logging prefixes

On Thu 2018-05-10 08:45:39, Joe Perches wrote:
> Converting pr_fmt from a simple define to use KBUILD_MODNAME added
> some duplicate logging prefixes to existing uses.
>
> Remove them.
>
> Signed-off-by: Joe Perches <[email protected]>

Acked-by: Petr Mladek <[email protected]>

Best Regards,
Petr

2018-05-18 09:12:09

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 03/18] printk: Convert pr_fmt from blank define to KBUILD_MODNAME

On Fri, 2018-05-18 at 10:42 +0200, Petr Mladek wrote:
> On Thu 2018-05-10 08:45:29, Joe Perches wrote:
> > There are more than 1000 uses of #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> > Make that the default define so these uses can be removed later via script.
> >
> > Signed-off-by: Joe Perches <[email protected]>
>
> It removes a lot of duplicates. I just hope that we will not need to
> add the same amount of defines to remove/change the prefix where the
> new default would look ugly.

I expect there will be far far fewer additions,
perhaps a few dozen, than the about 1200 removals.

> I am not completely convinced that it is worth it. But it makes some
> sense. Feel free to use:
>
> Acked-by: Petr Mladek <[email protected]>
>
>
> BTW: I tried the entire patchset and there are still many locations
> even in the boot log that might need an update:

Thanks.

> [ 0.000000] generic: MTRR default type: write-back

generic might be removed.

> [ 0.000000] libftrace: ftrace: allocating 40753 entries in 160 pages
> [ 0.004008] apic: APIC: Switch to symmetric I/O mode setup

I believe the uppercase APIC: bit should be removed.

> [ 0.796479] workingset: workingset: timestamp_bits=36 max_order=20 bucket_order=0

and I will submit patches for these other duplicates.

> [ 1.044458] ipmi_si: ipmi_si: Unable to find any System Interface(s)
> [ 1.046489] ioatdma: ioatdma: Intel(R) QuickData Technology Driver 4.00
> [ 1.076080] ppdev: ppdev: user-space parallel port driver
> [ 1.484645] ehci_pci: ehci-pci: EHCI PCI platform driver
> [ 1.544643] parport: parport0: cannot grant exclusive access for device pps_parport
> [ 1.556821] usbcore: usbcore: registered new interface driver usbhid
> [ 1.558001] usbhid: usbhid: USB HID core driver

cheers, Joe

2018-05-18 20:30:11

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH 03/18] printk: Convert pr_fmt from blank define to KBUILD_MODNAME

On Fri, May 18, 2018 at 12:10 PM, Joe Perches <[email protected]> wrote:
> On Fri, 2018-05-18 at 10:42 +0200, Petr Mladek wrote:
>> On Thu 2018-05-10 08:45:29, Joe Perches wrote:

>> [ 0.000000] libftrace: ftrace: allocating 40753 entries in 160 pages
>> [ 0.004008] apic: APIC: Switch to symmetric I/O mode setup
>
> I believe the uppercase APIC: bit should be removed.

I disagree on lowering the case of some prefixes.

In the case when kernel crashes at boot time and only what you have is
what on your screen it's much better to catch with different cases
than if everything would be either upper or lower.

--
With Best Regards,
Andy Shevchenko

2018-05-19 02:06:43

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 03/18] printk: Convert pr_fmt from blank define to KBUILD_MODNAME

On Fri, 2018-05-18 at 23:29 +0300, Andy Shevchenko wrote:
> On Fri, May 18, 2018 at 12:10 PM, Joe Perches <[email protected]> wrote:
> > On Fri, 2018-05-18 at 10:42 +0200, Petr Mladek wrote:
> > > On Thu 2018-05-10 08:45:29, Joe Perches wrote:
> > > [ 0.000000] libftrace: ftrace: allocating 40753 entries in 160 pages
> > > [ 0.004008] apic: APIC: Switch to symmetric I/O mode setup
> >
> > I believe the uppercase APIC: bit should be removed.
>
> I disagree on lowering the case of some prefixes.
>
> In the case when kernel crashes at boot time and only what you have is
> what on your screen it's much better to catch with different cases
> than if everything would be either upper or lower.

I don't parse.
My suggestion is to make "apic: " the only prefix.

ie:
---
arch/x86/kernel/apic/apic.c | 100 +++++++++++++++++++++-----------------------
1 file changed, 47 insertions(+), 53 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 2aabd4cb0e3f..67dd4e9191da 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -14,6 +14,8 @@
* Mikael Pettersson : PM converted to driver model.
*/

+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/perf_event.h>
#include <linux/kernel_stat.h>
#include <linux/mc146818rtc.h>
@@ -232,7 +234,7 @@ static int modern_apic(void)
*/
static void __init apic_disable(void)
{
- pr_info("APIC: switched to apic NOOP\n");
+ pr_info("switched to apic NOOP\n");
apic = &apic_noop;
}

@@ -430,17 +432,13 @@ int setup_APIC_eilvt(u8 offset, u8 vector, u8 msg_type, u8 mask)
reserved = reserve_eilvt_offset(offset, new);

if (reserved != new) {
- pr_err(FW_BUG "cpu %d, try to use APIC%lX (LVT offset %d) for "
- "vector 0x%x, but the register is already in use for "
- "vector 0x%x on another cpu\n",
+ pr_err(FW_BUG "cpu %d, try to use APIC%lX (LVT offset %d) for vector 0x%x, but the register is already in use for vector 0x%x on another cpu\n",
smp_processor_id(), reg, offset, new, reserved);
return -EINVAL;
}

if (!eilvt_entry_is_changeable(old, new)) {
- pr_err(FW_BUG "cpu %d, try to use APIC%lX (LVT offset %d) for "
- "vector 0x%x, but the register is already in use for "
- "vector 0x%x on this cpu\n",
+ pr_err(FW_BUG "cpu %d, try to use APIC%lX (LVT offset %d) for vector 0x%x, but the register is already in use for vector 0x%x on this cpu\n",
smp_processor_id(), reg, offset, new, old);
return -EBUSY;
}
@@ -624,8 +622,8 @@ static void apic_check_deadline_errata(void)
return;

setup_clear_cpu_cap(X86_FEATURE_TSC_DEADLINE_TIMER);
- pr_err(FW_BUG "TSC_DEADLINE disabled due to Errata; "
- "please update microcode to version: 0x%x (or later)\n", rev);
+ pr_err(FW_BUG "TSC_DEADLINE disabled due to Errata; please update microcode to version: 0x%x (or later)\n",
+ rev);
}

/*
@@ -769,14 +767,14 @@ calibrate_by_pmtimer(long deltapm, long *delta, long *deltatsc)

res = (((u64)deltapm) * mult) >> 22;
do_div(res, 1000000);
- pr_warning("APIC calibration not consistent "
- "with PM-Timer: %ldms instead of 100ms\n",(long)res);
+ pr_warn("calibration not consistent with PM-Timer: %ldms instead of 100ms\n",
+ (long)res);

/* Correct the lapic counter value */
res = (((u64)(*delta)) * pm_100ms);
do_div(res, deltapm);
- pr_info("APIC delta adjusted to PM-Timer: "
- "%lu (%ld)\n", (unsigned long)res, *delta);
+ pr_info("APIC delta adjusted to PM-Timer: %lu (%ld)\n",
+ (unsigned long)res, *delta);
*delta = (long)res;

/* Correct the tsc counter value */
@@ -893,7 +891,7 @@ static int __init calibrate_APIC_clock(void)
*/
if (lapic_timer_frequency < (1000000 / HZ)) {
local_irq_enable();
- pr_warning("APIC frequency too slow, disabling apic timer\n");
+ pr_warn("frequency too slow, disabling apic timer\n");
return -1;
}

@@ -936,8 +934,8 @@ static int __init calibrate_APIC_clock(void)
local_irq_enable();

if (levt->features & CLOCK_EVT_FEAT_DUMMY) {
- pr_warning("APIC timer disabled due to verification failure\n");
- return -1;
+ pr_warn("timer disabled due to verification failure\n");
+ return -1;
}

return 0;
@@ -1010,8 +1008,8 @@ static void local_apic_timer_interrupt(void)
* spurious.
*/
if (!evt->event_handler) {
- pr_warning("Spurious LAPIC timer interrupt on cpu %d\n",
- smp_processor_id());
+ pr_warn("Spurious LAPIC timer interrupt on cpu %d\n",
+ smp_processor_id());
/* Switch it off */
lapic_timer_shutdown(evt);
return;
@@ -1254,7 +1252,7 @@ static int __init apic_intr_mode_select(void)
APIC_INTEGRATED(boot_cpu_apic_version)) {
disable_apic = 1;
pr_err(FW_BUG "Local APIC %d not detected, force emulation\n",
- boot_cpu_physical_apicid);
+ boot_cpu_physical_apicid);
return APIC_PIC;
}
#endif
@@ -1263,7 +1261,7 @@ static int __init apic_intr_mode_select(void)
if (!smp_found_config) {
disable_ioapic_support();
if (!acpi_lapic) {
- pr_info("APIC: ACPI MADT or MP tables are not detected\n");
+ pr_info("ACPI MADT or MP tables are not detected\n");
return APIC_VIRTUAL_WIRE_NO_CONFIG;
}
return APIC_VIRTUAL_WIRE;
@@ -1272,7 +1270,7 @@ static int __init apic_intr_mode_select(void)
#ifdef CONFIG_SMP
/* If SMP should be disabled, then really disable it! */
if (!setup_max_cpus) {
- pr_info("APIC: SMP mode deactivated\n");
+ pr_info("SMP mode deactivated\n");
return APIC_SYMMETRIC_IO_NO_ROUTING;
}

@@ -1344,23 +1342,23 @@ void __init apic_intr_mode_init(void)

switch (apic_intr_mode) {
case APIC_PIC:
- pr_info("APIC: Keep in PIC mode(8259)\n");
+ pr_info("Keep in PIC mode(8259)\n");
return;
case APIC_VIRTUAL_WIRE:
- pr_info("APIC: Switch to virtual wire mode setup\n");
+ pr_info("Switch to virtual wire mode setup\n");
default_setup_apic_routing();
break;
case APIC_VIRTUAL_WIRE_NO_CONFIG:
- pr_info("APIC: Switch to virtual wire mode setup with no configuration\n");
+ pr_info("Switch to virtual wire mode setup with no configuration\n");
upmode = true;
default_setup_apic_routing();
break;
case APIC_SYMMETRIC_IO:
- pr_info("APIC: Switch to symmetric I/O mode setup\n");
+ pr_info("Switch to symmetric I/O mode setup\n");
default_setup_apic_routing();
break;
case APIC_SYMMETRIC_IO_NO_ROUTING:
- pr_info("APIC: Switch to symmetric I/O mode setup in no SMP routine\n");
+ pr_info("Switch to symmetric I/O mode setup in no SMP routine\n");
break;
}

@@ -1372,7 +1370,7 @@ static void lapic_setup_esr(void)
unsigned int oldvalue, value, maxlvt;

if (!lapic_is_integrated()) {
- pr_info("No ESR for 82489DX.\n");
+ pr_info("No ESR for 82489DX\n");
return;
}

@@ -1383,7 +1381,7 @@ static void lapic_setup_esr(void)
* ESR disabled - we can't do anything useful with the
* errors anyway - mbligh
*/
- pr_info("Leaving ESR disabled.\n");
+ pr_info("Leaving ESR disabled\n");
return;
}

@@ -1442,7 +1440,8 @@ static void apic_pending_intr_clear(void)
}
}
if (acked > 256) {
- pr_err("LAPIC pending interrupts after %d EOI\n", acked);
+ pr_err("LAPIC pending interrupts after %d EOI\n",
+ acked);
break;
}
if (queued) {
@@ -1679,11 +1678,11 @@ static int __init setup_nox2apic(char *str)
int apicid = native_apic_msr_read(APIC_ID);

if (apicid >= 255) {
- pr_warning("Apicid: %08x, cannot enforce nox2apic\n",
- apicid);
+ pr_warn("Apicid: %08x, cannot enforce nox2apic\n",
+ apicid);
return 0;
}
- pr_warning("x2apic already enabled.\n");
+ pr_warn("x2apic already enabled\n");
__x2apic_disable();
}
setup_clear_cpu_cap(X86_FEATURE_X2APIC);
@@ -1851,7 +1850,7 @@ static int __init apic_verify(void)
*/
features = cpuid_edx(1);
if (!(features & (1 << X86_FEATURE_APIC))) {
- pr_warning("Could not enable APIC!\n");
+ pr_warn("Could not enable APIC!\n");
return -1;
}
set_cpu_cap(&boot_cpu_data, X86_FEATURE_APIC);
@@ -1923,8 +1922,7 @@ static int __init detect_init_APIC(void)
* "lapic" specified.
*/
if (!force_enable_local_apic) {
- pr_info("Local APIC disabled by BIOS -- "
- "you can enable it with \"lapic\"\n");
+ pr_info("Local APIC disabled by BIOS -- you can enable it with \"lapic\"\n");
return -1;
}
if (apic_force_enable(APIC_DEFAULT_PHYS_BASE))
@@ -1961,7 +1959,7 @@ void __init init_apic_mappings(void)
/* If no local APIC can be found return early */
if (!smp_found_config && detect_init_APIC()) {
/* lets NOP'ify apic operations */
- pr_info("APIC: disable apic facility\n");
+ pr_info("disable apic facility\n");
apic_disable();
} else {
apic_phys = mp_lapic_addr;
@@ -2248,9 +2246,8 @@ int generic_processor_info(int apicid, int version)
disabled_cpu_apicid == apicid) {
int thiscpu = num_processors + disabled_cpus;

- pr_warning("APIC: Disabling requested cpu."
- " Processor %d/0x%x ignored.\n",
- thiscpu, apicid);
+ pr_warn("Disabling requested cpu. Processor %d/0x%x ignored.\n",
+ thiscpu, apicid);

disabled_cpus++;
return -ENODEV;
@@ -2264,10 +2261,7 @@ int generic_processor_info(int apicid, int version)
apicid != boot_cpu_physical_apicid) {
int thiscpu = max + disabled_cpus - 1;

- pr_warning(
- "APIC: NR_CPUS/possible_cpus limit of %i almost"
- " reached. Keeping one slot for boot cpu."
- " Processor %d/0x%x ignored.\n", max, thiscpu, apicid);
+ pr_warn("NR_CPUS/possible_cpus limit of %i almost reached. Keeping one slot for boot cpu. Processor %d/0x%x ignored.\n", max, thiscpu, apicid);

disabled_cpus++;
return -ENODEV;
@@ -2276,9 +2270,8 @@ int generic_processor_info(int apicid, int version)
if (num_processors >= nr_cpu_ids) {
int thiscpu = max + disabled_cpus;

- pr_warning("APIC: NR_CPUS/possible_cpus limit of %i "
- "reached. Processor %d/0x%x ignored.\n",
- max, thiscpu, apicid);
+ pr_warn("NR_CPUS/possible_cpus limit of %i reached. Processor %d/0x%x ignored.\n",
+ max, thiscpu, apicid);

disabled_cpus++;
return -EINVAL;
@@ -2308,13 +2301,13 @@ int generic_processor_info(int apicid, int version)
* Validate version
*/
if (version == 0x0) {
- pr_warning("BIOS bug: APIC version is 0 for CPU %d/0x%x, fixing up to 0x10\n",
- cpu, apicid);
+ pr_warn("BIOS bug: APIC version is 0 for CPU %d/0x%x, fixing up to 0x10\n",
+ cpu, apicid);
version = 0x10;
}

if (version != boot_cpu_apic_version) {
- pr_warning("BIOS bug: APIC version mismatch, boot CPU: %x, CPU %d: version %x\n",
+ pr_warn("BIOS bug: APIC version mismatch, boot CPU: %x, CPU %d: version %x\n",
boot_cpu_apic_version, cpu, version);
}

@@ -2590,7 +2583,7 @@ static int set_multi(const struct dmi_system_id *d)
{
if (multi)
return 0;
- pr_info("APIC: %s detected, Multi Chassis\n", d->ident);
+ pr_info("%s detected, Multi Chassis\n", d->ident);
multi = 1;
return 0;
}
@@ -2686,8 +2679,8 @@ static int __init apic_set_verbosity(char *arg)
apic_verbosity = APIC_VERBOSE;
#ifdef CONFIG_X86_64
else {
- pr_warning("APIC Verbosity level %s not recognised"
- " use apic=verbose or apic=debug\n", arg);
+ pr_warn("Verbosity level %s not recognised use apic=verbose or apic=debug\n",
+ arg);
return -EINVAL;
}
#endif
@@ -2736,7 +2729,8 @@ static int __init apic_set_extnmi(char *arg)
else if (!strncmp("bsp", arg, 3))
apic_extnmi = APIC_EXTNMI_BSP;
else {
- pr_warn("Unknown external NMI delivery mode `%s' ignored\n", arg);
+ pr_warn("Unknown external NMI delivery mode `%s' ignored\n",
+ arg);
return -EINVAL;
}


2018-05-19 18:27:52

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH 03/18] printk: Convert pr_fmt from blank define to KBUILD_MODNAME

On Sat, May 19, 2018 at 5:05 AM, Joe Perches <[email protected]> wrote:
> On Fri, 2018-05-18 at 23:29 +0300, Andy Shevchenko wrote:
>> On Fri, May 18, 2018 at 12:10 PM, Joe Perches <[email protected]> wrote:
>> > On Fri, 2018-05-18 at 10:42 +0200, Petr Mladek wrote:
>> > > On Thu 2018-05-10 08:45:29, Joe Perches wrote:
>> > > [ 0.000000] libftrace: ftrace: allocating 40753 entries in 160 pages
>> > > [ 0.004008] apic: APIC: Switch to symmetric I/O mode setup
>> >
>> > I believe the uppercase APIC: bit should be removed.
>>
>> I disagree on lowering the case of some prefixes.
>>
>> In the case when kernel crashes at boot time and only what you have is
>> what on your screen it's much better to catch with different cases
>> than if everything would be either upper or lower.
>
> I don't parse.
> My suggestion is to make "apic: " the only prefix.

What I mean is after your patch it would be like:

subsys1: ...
...
framework1: ...
...
subsys2: ...
...

What I meant is what you can see in any current log, something like:

subsys1: ...
...
FRAMEWORK1: ...
...
subsys2: ...
...

When you see such on a long screen, you can momentarely put your eyes
on string in question.


--
With Best Regards,
Andy Shevchenko

2018-07-12 03:15:34

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH] ring_buffer: Update logging to use single line output

On Fri, 11 May 2018 14:39:18 -0700
Joe Perches <[email protected]> wrote:

> With a possible change to pr_fmt coming, the logging output can
> become unbalanced when an initial line has a prefix and subsequent
> lines do not when a multiple line pr_<level> is emitted.
>
> Fix it by emitting a single line.
>
> Miscellanea:
>
> o Convert consecutive tests of total_lost and !total_lost to if/else

I just noticed this patch. Please don't send patches Cc'd to other
threads. They need to start a new thread, otherwise, like this one, it
will most likely be lost.

If you want this applied still, please resend it properly.

-- Steve

>
> Signed-off-by: Joe Perches <[email protected]>
> ---
> kernel/trace/ring_buffer.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
> index c9cb9767d49b..ee74494a2da3 100644
> --- a/kernel/trace/ring_buffer.c
> +++ b/kernel/trace/ring_buffer.c
> @@ -5132,10 +5132,9 @@ static __init int test_ringbuffer(void)
> pr_info(" total events: %ld\n", total_lost + total_read);
> pr_info(" recorded len bytes: %ld\n", total_len);
> pr_info(" recorded size bytes: %ld\n", total_size);
> - if (total_lost)
> - pr_info(" With dropped events, record len and size may not match\n"
> - " alloced and written from above\n");
> - if (!total_lost) {
> + if (total_lost) {
> + pr_info(" With dropped events, record len and size may not match alloced and written from above\n");
> + } else {
> if (RB_WARN_ON(buffer, total_len != total_alloc ||
> total_size != total_written))
> break;


2018-07-12 04:44:24

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH] ring_buffer: Update logging to use single line output

On Wed, 2018-07-11 at 22:57 -0400, Steven Rostedt wrote:
> On Fri, 11 May 2018 14:39:18 -0700
> Joe Perches <[email protected]> wrote:
>
> > With a possible change to pr_fmt coming, the logging output can
> > become unbalanced when an initial line has a prefix and subsequent
> > lines do not when a multiple line pr_<level> is emitted.
> >
> > Fix it by emitting a single line.
> >
> > Miscellanea:
> >
> > o Convert consecutive tests of total_lost and !total_lost to if/else
>
> I just noticed this patch. Please don't send patches Cc'd to other
> threads. They need to start a new thread, otherwise, like this one, it
> will most likely be lost.
>
> If you want this applied still, please resend it properly.

An email sent directly to you should not be lost by you.


> -- Steve
>
> >
> > Signed-off-by: Joe Perches <[email protected]>
> > ---
> > kernel/trace/ring_buffer.c | 7 +++----
> > 1 file changed, 3 insertions(+), 4 deletions(-)
> >
> > diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
> > index c9cb9767d49b..ee74494a2da3 100644
> > --- a/kernel/trace/ring_buffer.c
> > +++ b/kernel/trace/ring_buffer.c
> > @@ -5132,10 +5132,9 @@ static __init int test_ringbuffer(void)
> > pr_info(" total events: %ld\n", total_lost + total_read);
> > pr_info(" recorded len bytes: %ld\n", total_len);
> > pr_info(" recorded size bytes: %ld\n", total_size);
> > - if (total_lost)
> > - pr_info(" With dropped events, record len and size may not match\n"
> > - " alloced and written from above\n");
> > - if (!total_lost) {
> > + if (total_lost) {
> > + pr_info(" With dropped events, record len and size may not match alloced and written from above\n");
> > + } else {
> > if (RB_WARN_ON(buffer, total_len != total_alloc ||
> > total_size != total_written))
> > break;
>
>

2018-07-12 13:02:46

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH] ring_buffer: Update logging to use single line output

On Wed, 11 Jul 2018 21:42:53 -0700
Joe Perches <[email protected]> wrote:

> > I just noticed this patch. Please don't send patches Cc'd to other
> > threads. They need to start a new thread, otherwise, like this one, it
> > will most likely be lost.
> >
> > If you want this applied still, please resend it properly.
>
> An email sent directly to you should not be lost by you.

OK, it was ignored.

-- Steve

2019-02-21 06:26:31

by Bjorn Helgaas

[permalink] [raw]
Subject: Re: [tip:x86/cleanups] x86: Remove pr_fmt duplicate logging prefixes

On Thu, May 17, 2018 at 11:45 AM Joe Perches <[email protected]> wrote:
>
> On Thu, 2018-05-17 at 20:27 +0200, Borislav Petkov wrote:
> > On Sun, May 13, 2018 at 12:27:45PM -0700, tip-bot for Joe Perches wrote:
> > > Commit-ID: 1de392f5d5e803663abbd8ed084233f154152bcd
> > > Gitweb: https://git.kernel.org/tip/1de392f5d5e803663abbd8ed084233f154152bcd
> > > Author: Joe Perches <[email protected]>
> > > AuthorDate: Thu, 10 May 2018 08:45:30 -0700
> > > Committer: Thomas Gleixner <[email protected]>
> > > CommitDate: Sun, 13 May 2018 21:25:18 +0200
> > >
> > > x86: Remove pr_fmt duplicate logging prefixes
> > >
> > > Converting pr_fmt from a default simple #define to use KBUILD_MODNAME
> > > added some duplicate prefixes.
> > >
> > > Remove the duplicate prefixes.
> []
> > Maybe I'm missing something but this dropped the prefixes now
> > completely:
> >
> > -e820: BIOS-provided physical RAM map:
> > +BIOS-provided physical RAM map:
> >
> > -e820: last_pfn = 0x43f000 max_arch_pfn = 0x400000000
> > +last_pfn = 0x43f000 max_arch_pfn = 0x400000000
> >
> > -e820: last_pfn = 0x9d000 max_arch_pfn = 0x400000000
> > +last_pfn = 0x9d000 max_arch_pfn = 0x400000000
> >
> > ...
> >
> > I don't think that was the intention.
>
> Hi Borislav
>
> It wasn't and isn't the intention.
>
> This is a patch _series_, and all of the patches
> from 4-18 depend on patch 3 which converts the
> generic define in include/linux/printk.h
>
> from
> #define pr_fmt(fmt) fmt
> to
> #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>
> Perhaps a better option, which could be done in
> a v2 of the series, is to add a temporary
> #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> to each file modified in patches 4-18 and then
> allow the follow-on script described in the 0/18
> cover letter to remove those #defines

Was there ever a v2? What I see from 1de392f5d5e8 ("x86: Remove
pr_fmt duplicate logging prefixes") is exactly what Borislav noted.

For example, https://bugzilla.kernel.org/attachment.cgi?id=281007 is a
v4.20 dmesg log from
https://bugzilla.kernel.org/show_bug.cgi?id=202511 . That bug also
has a v4.17 dmesg log
(https://bugzilla.kernel.org/attachment.cgi?id=281011). Comparing
them shows:

-Linux version 4.17.19-gentoo (root@survivor) (gcc version 7.3.0
(Gentoo 7.3.0-r3 p1.4)) #2 SMP Sat Sep 22 09:53:01 EDT 2018
+Linux version 4.20.6-gentoo (root@survivor) (gcc version 7.3.0
(Gentoo 7.3.0-r3 p1.4)) #1 SMP Tue Feb 5 09:46:51 EST 2019
...
-e820: BIOS-provided physical RAM map:
+BIOS-provided physical RAM map:

Not a big deal as far as I'm concerned, but it is a minor annoyance.

Bjorn