Skip to content

Commit b1de0d1

Browse files
Mitchel Humpherystorvalds
authored andcommitted
mm: convert some level-less printks to pr_*
printk is meant to be used with an associated log level. There are some instances of printk scattered around the mm code where the log level is missing. Add a log level and adhere to suggestions by scripts/checkpatch.pl by moving to the pr_* macros. Also add the typical pr_fmt definition so that print statements can be easily traced back to the modules where they occur, correlated one with another, etc. This will require the removal of some (now redundant) prefixes on a few print statements. Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent b3fe92b commit b1de0d1

5 files changed

Lines changed: 29 additions & 14 deletions

File tree

‎block/bounce.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* - Split from highmem.c
44
*/
55

6+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
7+
68
#include <linux/mm.h>
79
#include <linux/export.h>
810
#include <linux/swap.h>
@@ -15,6 +17,7 @@
1517
#include <linux/hash.h>
1618
#include <linux/highmem.h>
1719
#include <linux/bootmem.h>
20+
#include <linux/printk.h>
1821
#include <asm/tlbflush.h>
1922

2023
#include <trace/events/block.h>
@@ -34,7 +37,7 @@ static __init int init_emergency_pool(void)
3437

3538
page_pool = mempool_create_page_pool(POOL_SIZE, 0);
3639
BUG_ON(!page_pool);
37-
printk("bounce pool size: %d pages\n", POOL_SIZE);
40+
pr_info("pool size: %d pages\n", POOL_SIZE);
3841

3942
return 0;
4043
}
@@ -86,7 +89,7 @@ int init_emergency_isa_pool(void)
8689
mempool_free_pages, (void *) 0);
8790
BUG_ON(!isa_page_pool);
8891

89-
printk("isa bounce pool size: %d pages\n", ISA_POOL_SIZE);
92+
pr_info("isa pool size: %d pages\n", ISA_POOL_SIZE);
9093
return 0;
9194
}
9295

‎mm/mempolicy.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
kernel is not always grateful with that.
6666
*/
6767

68+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
69+
6870
#include <linux/mempolicy.h>
6971
#include <linux/mm.h>
7072
#include <linux/highmem.h>
@@ -91,6 +93,7 @@
9193
#include <linux/ctype.h>
9294
#include <linux/mm_inline.h>
9395
#include <linux/mmu_notifier.h>
96+
#include <linux/printk.h>
9497

9598
#include <asm/tlbflush.h>
9699
#include <asm/uaccess.h>
@@ -2645,7 +2648,7 @@ void __init numa_policy_init(void)
26452648
node_set(prefer, interleave_nodes);
26462649

26472650
if (do_set_mempolicy(MPOL_INTERLEAVE, 0, &interleave_nodes))
2648-
printk("numa_policy_init: interleaving failed\n");
2651+
pr_err("%s: interleaving failed\n", __func__);
26492652

26502653
check_numabalancing_enable();
26512654
}

‎mm/mmap.c‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* Address space accounting code <alan@lxorguk.ukuu.org.uk>
77
*/
88

9+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
10+
911
#include <linux/kernel.h>
1012
#include <linux/slab.h>
1113
#include <linux/backing-dev.h>
@@ -37,6 +39,7 @@
3739
#include <linux/sched/sysctl.h>
3840
#include <linux/notifier.h>
3941
#include <linux/memory.h>
42+
#include <linux/printk.h>
4043

4144
#include <asm/uaccess.h>
4245
#include <asm/cacheflush.h>
@@ -361,20 +364,20 @@ static int browse_rb(struct rb_root *root)
361364
struct vm_area_struct *vma;
362365
vma = rb_entry(nd, struct vm_area_struct, vm_rb);
363366
if (vma->vm_start < prev) {
364-
printk("vm_start %lx prev %lx\n", vma->vm_start, prev);
367+
pr_info("vm_start %lx prev %lx\n", vma->vm_start, prev);
365368
bug = 1;
366369
}
367370
if (vma->vm_start < pend) {
368-
printk("vm_start %lx pend %lx\n", vma->vm_start, pend);
371+
pr_info("vm_start %lx pend %lx\n", vma->vm_start, pend);
369372
bug = 1;
370373
}
371374
if (vma->vm_start > vma->vm_end) {
372-
printk("vm_end %lx < vm_start %lx\n",
375+
pr_info("vm_end %lx < vm_start %lx\n",
373376
vma->vm_end, vma->vm_start);
374377
bug = 1;
375378
}
376379
if (vma->rb_subtree_gap != vma_compute_subtree_gap(vma)) {
377-
printk("free gap %lx, correct %lx\n",
380+
pr_info("free gap %lx, correct %lx\n",
378381
vma->rb_subtree_gap,
379382
vma_compute_subtree_gap(vma));
380383
bug = 1;
@@ -388,7 +391,7 @@ static int browse_rb(struct rb_root *root)
388391
for (nd = pn; nd; nd = rb_prev(nd))
389392
j++;
390393
if (i != j) {
391-
printk("backwards %d, forwards %d\n", j, i);
394+
pr_info("backwards %d, forwards %d\n", j, i);
392395
bug = 1;
393396
}
394397
return bug ? -1 : i;
@@ -423,17 +426,17 @@ static void validate_mm(struct mm_struct *mm)
423426
i++;
424427
}
425428
if (i != mm->map_count) {
426-
printk("map_count %d vm_next %d\n", mm->map_count, i);
429+
pr_info("map_count %d vm_next %d\n", mm->map_count, i);
427430
bug = 1;
428431
}
429432
if (highest_address != mm->highest_vm_end) {
430-
printk("mm->highest_vm_end %lx, found %lx\n",
433+
pr_info("mm->highest_vm_end %lx, found %lx\n",
431434
mm->highest_vm_end, highest_address);
432435
bug = 1;
433436
}
434437
i = browse_rb(&mm->mm_rb);
435438
if (i != mm->map_count) {
436-
printk("map_count %d rb %d\n", mm->map_count, i);
439+
pr_info("map_count %d rb %d\n", mm->map_count, i);
437440
bug = 1;
438441
}
439442
BUG_ON(bug);
@@ -3280,7 +3283,7 @@ static struct notifier_block reserve_mem_nb = {
32803283
static int __meminit init_reserve_notifier(void)
32813284
{
32823285
if (register_hotmemory_notifier(&reserve_mem_nb))
3283-
printk("Failed registering memory add/remove notifier for admin reserve");
3286+
pr_err("Failed registering memory add/remove notifier for admin reserve\n");
32843287

32853288
return 0;
32863289
}

‎mm/nommu.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* Copyright (c) 2007-2010 Paul Mundt <lethal@linux-sh.org>
1414
*/
1515

16+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
17+
1618
#include <linux/export.h>
1719
#include <linux/mm.h>
1820
#include <linux/vmacache.h>
@@ -32,6 +34,7 @@
3234
#include <linux/syscalls.h>
3335
#include <linux/audit.h>
3436
#include <linux/sched/sysctl.h>
37+
#include <linux/printk.h>
3538

3639
#include <asm/uaccess.h>
3740
#include <asm/tlb.h>
@@ -1246,7 +1249,7 @@ static int do_mmap_private(struct vm_area_struct *vma,
12461249
return ret;
12471250

12481251
enomem:
1249-
printk("Allocation of length %lu from process %d (%s) failed\n",
1252+
pr_err("Allocation of length %lu from process %d (%s) failed\n",
12501253
len, current->pid, current->comm);
12511254
show_free_areas(0);
12521255
return -ENOMEM;

‎mm/vmscan.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
* Multiqueue VM started 5.8.00, Rik van Riel.
1212
*/
1313

14+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
15+
1416
#include <linux/mm.h>
1517
#include <linux/module.h>
1618
#include <linux/gfp.h>
@@ -43,6 +45,7 @@
4345
#include <linux/sysctl.h>
4446
#include <linux/oom.h>
4547
#include <linux/prefetch.h>
48+
#include <linux/printk.h>
4649

4750
#include <asm/tlbflush.h>
4851
#include <asm/div64.h>
@@ -480,7 +483,7 @@ static pageout_t pageout(struct page *page, struct address_space *mapping,
480483
if (page_has_private(page)) {
481484
if (try_to_free_buffers(page)) {
482485
ClearPageDirty(page);
483-
printk("%s: orphaned page\n", __func__);
486+
pr_info("%s: orphaned page\n", __func__);
484487
return PAGE_CLEAN;
485488
}
486489
}

0 commit comments

Comments
 (0)