1. 26 Jun, 2015 40 commits
    • Joe Perches's avatar
      checkpatch: categorize some long line length checks · 47e0c88b
      Joe Perches authored
      Many lines of code extend beyond the maximum line length.  Some of these
      are possibly justified by use type.
      
      For instance:
      
      structure definitions where comments are added per member like:
      struct foo {
      	type member;		/* some long description */
      
      And lines that don't fit the typical logging message style
      where a string constant is used like:
      
              SOME_MACRO(args, "Some long string");
      
      Categorize these long line types so that checkpatch can use a command-line
      --ignore=<type> option to avoid emitting some long line warnings.
      
      One of the existing checkpatch exclusions allowed kernel-doc argument
      documentation to exceed 80 columns because old versions of kernel-doc
      required single line documentation.  The requirement was removed in 2009
      so remove that exclusion.
      
      Add documentation to make the test a bit clearer.
      Signed-off-by: default avatarJoe Perches <joe@perches.com>
      Cc: Julia Lawall <julia.lawall@lip6.fr>
      Cc: Michael Shuey <shuey@purdue.edu>
      Cc: Dan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      47e0c88b
    • Joe Perches's avatar
      checkpatch: use $String consistently · 33acb54a
      Joe Perches authored
      String detection where a source line with a string constant is converted
      can either have an X or a space.
      
      Some of the string detection regexes do not allow the space character, but
      there is a handy $String variable that does.
      
      Convert the remaining uses of string detection regexes to use the $String
      variable to reduce possible false negatives.
      Signed-off-by: default avatarJoe Perches <joe@perches.com>
      Cc: Andy Whitcroft <apw@canonical.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      33acb54a
    • Alex Dowad's avatar
      checkpatch: make types found in a source file/patch local · 485ff23e
      Alex Dowad authored
      checkpatch uses various cues in its input patches and files to discover
      the names of user-defined types and modifiers.  It then uses that
      information when processing expressions to discover potential style
      issues.
      
      Unfortunately, in rare cases, this means that checkpatch may give
      different results if you run it on several input files in one execution,
      or one by one!
      
      The reason is that it may identify a type (or something that looks like a
      type) in one file, and then carry this information over when processing a
      different file.
      
      For example, drivers/staging/media/bcm2048/radio-bcm2048.c contains this
      line (in a macro):
      
      	size value;
      
      and drivers/staging/media/davinci_vpfe/vpfe_video.c has this line:
      
      	while (size * *nbuffers > vpfe_dev->video_limit)
      
      If checkpatch processes these 2 files in a single command like:
      	./scripts/checkpatch.pl -f $file1 $file2
      the (spurious) "size" type detected in the first file will cause it to flag
      the second file for improper use of the pointer dereference operator.
      
      To fix this, store types and modifiers found in a file in separate arrays
      from built-in ones, and reset the arrays of types and modifiers found in
      files at the beginning of each new source file.
      Signed-off-by: default avatarAlex Dowad <alexinbeijing@gmail.com>
      Signed-off-by: default avatarJoe Perches <joe@perches.com>
      Acked-by: default avatarAndy Whitcroft <apw@canonical.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      485ff23e
    • Joe Perches's avatar
      checkpatch: add --strict warning for c99 fixed size typedefs : int<size>_t · e6176fa4
      Joe Perches authored
      Using declarations like u_int16_t in kernel code is not preferred.
      
      Suggest the kernel sized types instead of the c99 types when not in the
      uapi directory.
      
      Add a $typeC99Typedefs variable for the types to check and neaten the
      other typedef variables.
      Signed-off-by: default avatarJoe Perches <joe@perches.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      e6176fa4
    • Joe Perches's avatar
      checkpatch: check for uncommented waitqueue_active() · cb426e99
      Joe Perches authored
      Linus sayeth:
      
      : Pretty much every single time people use this "if
      : (waitqueue_active())" model, it tends to be a bug, because it means
      : that there is zero serialization with people who are just about to go
      : to sleep. It's fundamentally racy against all the "wait_event()" loops
      : that carefully do memory barriers between testing conditions and going
      : to sleep, because the memory barriers now don't exist on the waking
      : side.
      :
      : So I'm making a new rule: if you use waitqueue_active(), I want an
      : explanation for why it's not racy with the waiter. A big comment about
      : the memory ordering, or about higher-level locks that are held by the
      : caller, or something.
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      cb426e99
    • Michal Simek's avatar
      drivers/firmware/memmap.c: fix kernel-doc format · cbdc2810
      Michal Simek authored
      Fix kernel-doc format validation to be able to use kernel-doc script for
      checking it.
      Signed-off-by: default avatarMichal Simek <michal.simek@xilinx.com>
      Reviewed-by: default avatarYasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      cbdc2810
    • Rasmus Villemoes's avatar
      fs/ext4/super.c: use strreplace() in ext4_fill_super() · ec3904dc
      Rasmus Villemoes authored
      This makes a very large function a little smaller.
      Signed-off-by: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ec3904dc
    • Rasmus Villemoes's avatar
      fs/jbd2/journal.c: use strreplace() · 81ae394b
      Rasmus Villemoes authored
      In one case, we eliminate a local variable; in the other a strlen()
      call and some .text.
      Signed-off-by: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      81ae394b
    • Rasmus Villemoes's avatar
      drivers/md/md.c: use strreplace() · 90a9befb
      Rasmus Villemoes authored
      There's no point in starting over when we meet a '/'.  This also
      eliminates a stack variable and a little .text.
      Signed-off-by: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
      Acked-by: default avatarNeilBrown <neilb@suse.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      90a9befb
    • Rasmus Villemoes's avatar
      drivers/base/core.c: use strreplace() · a29fd614
      Rasmus Villemoes authored
      This eliminates a little .text and avoids repeating the strchr call when
      we meet a '!' (which will happen at least once).
      Signed-off-by: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      a29fd614
    • Rasmus Villemoes's avatar
      lib/kobject.c: use strreplace() · 2abf114f
      Rasmus Villemoes authored
      There's probably not many slashes in the name, but starting over when
      we see one feels wrong.
      Signed-off-by: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      2abf114f
    • Rasmus Villemoes's avatar
      kernel/trace/blktrace.c: use strreplace() in do_blk_trace_setup() · ff14417c
      Rasmus Villemoes authored
      Part of the disassembly of do_blk_trace_setup:
      
          231b:       e8 00 00 00 00          callq  2320 <do_blk_trace_setup+0x50>
                              231c: R_X86_64_PC32     strlen+0xfffffffffffffffc
          2320:       eb 0a                   jmp    232c <do_blk_trace_setup+0x5c>
          2322:       66 0f 1f 44 00 00       nopw   0x0(%rax,%rax,1)
          2328:       48 83 c3 01             add    $0x1,%rbx
          232c:       48 39 d8                cmp    %rbx,%rax
          232f:       76 47                   jbe    2378 <do_blk_trace_setup+0xa8>
          2331:       41 80 3c 1c 2f          cmpb   $0x2f,(%r12,%rbx,1)
          2336:       75 f0                   jne    2328 <do_blk_trace_setup+0x58>
          2338:       41 c6 04 1c 5f          movb   $0x5f,(%r12,%rbx,1)
          233d:       4c 89 e7                mov    %r12,%rdi
          2340:       e8 00 00 00 00          callq  2345 <do_blk_trace_setup+0x75>
                              2341: R_X86_64_PC32     strlen+0xfffffffffffffffc
          2345:       eb e1                   jmp    2328 <do_blk_trace_setup+0x58>
      
      Yep, that's right: gcc isn't smart enough to realize that replacing '/' by
      '_' cannot change the strlen(), so we call it again and again (at least
      when a '/' is found).  Even if gcc were that smart, this construction
      would still loop over the string twice, once for the initial strlen() call
      and then the open-coded loop.
      
      Let's simply use strreplace() instead.
      Signed-off-by: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
      Acked-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Liked-by: default avatarJens Axboe <axboe@fb.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ff14417c
    • Rasmus Villemoes's avatar
      kernel/trace/trace_events_filter.c: use strreplace() · 1bb56471
      Rasmus Villemoes authored
      There's no point in starting over every time we see a ','...
      Signed-off-by: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
      Acked-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      1bb56471
    • Rasmus Villemoes's avatar
      lib/string.c: introduce strreplace() · 94df2904
      Rasmus Villemoes authored
      Strings are sometimes sanitized by replacing a certain character (often
      '/') by another (often '!').  In a few places, this is done the same way
      Schlemiel the Painter would do it.  Others are slightly smarter but still
      do multiple strchr() calls.  Introduce strreplace() to do this using a
      single function call and a single pass over the string.
      
      One would expect the return value to be one of three things: void, s, or
      the number of replacements made.  I chose the fourth, returning a pointer
      to the end of the string.  This is more likely to be useful (for example
      allowing the caller to avoid a strlen call).
      Signed-off-by: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Neil Brown <neilb@suse.de>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Joe Perches <joe@perches.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      94df2904
    • Kirill A. Shutemov's avatar
      radix-tree: replace preallocated node array with linked list · 9d2a8da0
      Kirill A. Shutemov authored
      Currently we use per-cpu array to hold pointers to preallocated nodes.
      Let's replace it with linked list.  On x86_64 it saves 256 bytes in
      per-cpu ELF section which may translate into freeing up 2MB of memory for
      NR_CPUS==8192.
      
      [akpm@linux-foundation.org: fix comment, coding style]
      Signed-off-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9d2a8da0
    • Sudeep Holla's avatar
      bitmap: remove explicit newline handling using scnprintf format string · 9cf79d11
      Sudeep Holla authored
      bitmap_print_to_pagebuf uses scnprintf to copy the cpumask/list to page
      buffer.  It handles the newline and trailing null character explicitly.
      
      It's unnecessary and also partially duplicated as scnprintf already adds
      trailing null character.  The newline can be passed through format
      string to scnprintf.  This patch does that simplification.
      
      However theoretically there's one behavior difference: when the buffer
      is too small, the original code would still output '\n' at the end while
      the new code(with this patch) would just continue to print the formatted
      string.  Since this function is dealing with only page buffers, it's
      highly unlikely to hit that corner case.
      
      This patch will help in auditing the users of bitmap_print_to_pagebuf to
      verify that the buffer passed is large enough and get rid of it
      completely by replacing them with direct scnprintf()
      
      [akpm@linux-foundation.org: tweak comment]
      Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
      Suggested-by: default avatarPawel Moll <Pawel.Moll@arm.com>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9cf79d11
    • Daniel Wagner's avatar
      lib/sort: Add 64 bit swap function · ca96ab85
      Daniel Wagner authored
      In case the call side is not providing a swap function, we either use a
      32 bit or a generic swap function.  When swapping around pointers on 64
      bit architectures falling back to use the generic swap function seems
      like an unnecessary waste.
      
      There at least 9 users ('sort' is of difficult to grep for) of sort()
      and all of them use the sort function without a customized swap
      function.  Furthermore, they are all using pointers to swap around:
      
      arch/x86/kernel/e820.c:sanitize_e820_map()
      arch/x86/mm/extable.c:sort_extable()
      drivers/acpi/fan.c:acpi_fan_get_fps()
      fs/btrfs/super.c:btrfs_descending_sort_devices()
      fs/xfs/libxfs/xfs_dir2_block.c:xfs_dir2_sf_to_block()
      kernel/range.c:clean_sort_range()
      mm/memcontrol.c:__mem_cgroup_usage_register_event()
      sound/pci/hda/hda_auto_parser.c:snd_hda_parse_pin_defcfg()
      sound/pci/hda/hda_auto_parser.c:sort_pins_by_sequence()
      
      Obviously, we could improve the swap for other sizes as well
      but this is overkill at this point.
      
      A simple test shows sorting a 400 element array (try to stay in one
      page) with either with u32_swap() or u64_swap() show that the theory
      actually works. This test was done on a x86_64 (Intel Xeon E5-4610)
      machine.
      
      - swap_32:
      
      NumSamples = 100; Min = 48.00; Max = 49.00
      Mean = 48.320000; Variance = 0.217600; SD = 0.466476; Median 48.000000
      each * represents a count of 1
         48.0000 -    48.1000 [    68]: ********************************************************************
         48.1000 -    48.2000 [     0]:
         48.2000 -    48.3000 [     0]:
         48.3000 -    48.4000 [     0]:
         48.4000 -    48.5000 [     0]:
         48.5000 -    48.6000 [     0]:
         48.6000 -    48.7000 [     0]:
         48.7000 -    48.8000 [     0]:
         48.8000 -    48.9000 [     0]:
         48.9000 -    49.0000 [    32]: ********************************
      
      - swap_64:
      
      NumSamples = 100; Min = 44.00; Max = 63.00
      Mean = 48.250000; Variance = 18.687500; SD = 4.322904; Median 47.000000
      each * represents a count of 1
         44.0000 -    45.9000 [    15]: ***************
         45.9000 -    47.8000 [    37]: *************************************
         47.8000 -    49.7000 [    39]: ***************************************
         49.7000 -    51.6000 [     0]:
         51.6000 -    53.5000 [     0]:
         53.5000 -    55.4000 [     0]:
         55.4000 -    57.3000 [     0]:
         57.3000 -    59.2000 [     1]: *
         59.2000 -    61.1000 [     3]: ***
         61.1000 -    63.0000 [     5]: *****
      
      - swap_72:
      
      NumSamples = 100; Min = 53.00; Max = 71.00
      Mean = 55.070000; Variance = 21.565100; SD = 4.643824; Median 53.000000
      each * represents a count of 1
         53.0000 -    54.8000 [    73]: *************************************************************************
         54.8000 -    56.6000 [     9]: *********
         56.6000 -    58.4000 [     9]: *********
         58.4000 -    60.2000 [     0]:
         60.2000 -    62.0000 [     0]:
         62.0000 -    63.8000 [     0]:
         63.8000 -    65.6000 [     0]:
         65.6000 -    67.4000 [     1]: *
         67.4000 -    69.2000 [     4]: ****
         69.2000 -    71.0000 [     4]: ****
      
      - test program:
      
      static int cmp_32(const void *a, const void *b)
      {
      	u32 l = *(u32 *)a;
      	u32 r = *(u32 *)b;
      
      	if (l < r)
      		return -1;
      	if (l > r)
      		return 1;
      	return 0;
      }
      
      static int cmp_64(const void *a, const void *b)
      {
      	u64 l = *(u64 *)a;
      	u64 r = *(u64 *)b;
      
      	if (l < r)
      		return -1;
      	if (l > r)
      		return 1;
      	return 0;
      }
      
      static int cmp_72(const void *a, const void *b)
      {
      	u32 l = get_unaligned((u32 *) a);
      	u32 r = get_unaligned((u32 *) b);
      
      	if (l < r)
      		return -1;
      	if (l > r)
      		return 1;
      	return 0;
      }
      
      static void init_array32(void *array)
      {
      	u32 *a = array;
      	int i;
      
      	a[0] = 3821;
      	for (i = 1; i < ARRAY_ELEMENTS; i++)
      		a[i] = next_pseudo_random32(a[i-1]);
      }
      
      static void init_array64(void *array)
      {
      	u64 *a = array;
      	int i;
      
      	a[0] = 3821;
      	for (i = 1; i < ARRAY_ELEMENTS; i++)
      		a[i] = next_pseudo_random32(a[i-1]);
      }
      
      static void init_array72(void *array)
      {
      	char *p;
      	u32 v;
      	int i;
      
      	v = 3821;
      	for (i = 0; i < ARRAY_ELEMENTS; i++) {
      		p = (char *)array + (i * 9);
      		put_unaligned(v, (u32*) p);
      		v = next_pseudo_random32(v);
      	}
      }
      
      static void sort_test(void (*init)(void *array),
      		      int (*cmp) (const void *, const void *),
      		      void *array, size_t size)
      {
      	ktime_t start, stop;
      	int i;
      
      	for (i = 0; i < 10000; i++) {
      		init(array);
      
      		local_irq_disable();
      		start = ktime_get();
      
      		sort(array, ARRAY_ELEMENTS, size, cmp, NULL);
      
      		stop = ktime_get();
      		local_irq_enable();
      
      		if (i > 10000 - 101)
      		  pr_info("%lld\n",  ktime_to_us(ktime_sub(stop, start)));
      	}
      }
      
      static void *create_array(size_t size)
      {
      	void *array;
      
      	array = kmalloc(ARRAY_ELEMENTS * size, GFP_KERNEL);
      	if (!array)
      		return NULL;
      
      	return array;
      }
      
      static int perform_test(size_t size)
      {
      	void *array;
      
      	array = create_array(size);
      	if (!array)
      		return -ENOMEM;
      
      	pr_info("test element size %d bytes\n", (int)size);
      	switch (size) {
      	case 4:
      		sort_test(init_array32, cmp_32, array, size);
      		break;
      	case 8:
      		sort_test(init_array64, cmp_64, array, size);
      		break;
      	case 9:
      		sort_test(init_array72, cmp_72, array, size);
      		break;
      	}
      	kfree(array);
      
      	return 0;
      }
      
      static int __init sort_tests_init(void)
      {
      	int err;
      
      	err = perform_test(sizeof(u32));
      	if (err)
      		return err;
      
      	err = perform_test(sizeof(u64));
      	if (err)
      		return err;
      
      	err = perform_test(sizeof(u64)+1);
      	if (err)
      		return err;
      
      	return 0;
      }
      
      static void __exit sort_tests_exit(void)
      {
      }
      
      module_init(sort_tests_init);
      module_exit(sort_tests_exit);
      
      MODULE_LICENSE("GPL v2");
      MODULE_AUTHOR("Daniel Wagner");
      MODULE_DESCRIPTION("sort perfomance tests");
      Signed-off-by: default avatarDaniel Wagner <daniel.wagner@bmw-carit.de>
      Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ca96ab85
    • Geert Uytterhoeven's avatar
      hexdump: Make test data really const · 79e23d57
      Geert Uytterhoeven authored
      The test data arrays, containing pointers to test strings, are never
      modified, so they can be const, too.  Hence mark them "const" and
      "__initconst".
      
      This moves 28 pointers from ".init.data" to ".init.rodata".
      Signed-off-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      79e23d57
    • Chris Metcalf's avatar
      __bitmap_parselist: fix bug in empty string handling · 2528a8b8
      Chris Metcalf authored
      bitmap_parselist("", &mask, nmaskbits) will erroneously set bit zero in
      the mask.  The same bug is visible in cpumask_parselist() since it is
      layered on top of the bitmask code, e.g.  if you boot with "isolcpus=",
      you will actually end up with cpu zero isolated.
      
      The bug was introduced in commit 4b060420 ("bitmap, irq: add
      smp_affinity_list interface to /proc/irq") when bitmap_parselist() was
      generalized to support userspace as well as kernelspace.
      
      Fixes: 4b060420 ("bitmap, irq: add smp_affinity_list interface to /proc/irq")
      Signed-off-by: default avatarChris Metcalf <cmetcalf@ezchip.com>
      Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      2528a8b8
    • Andrew Morton's avatar
      MAINTAINERS: Davidlohr has moved · 4f973c63
      Andrew Morton authored
      Reported-by: default avatarRob Landley <rob@landley.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Davidlohr Bueso <dave@stgolabs.net>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      4f973c63
    • Joe Perches's avatar
      MAINTAINERS: Add quotation marks around names with commas · e43cdb56
      Joe Perches authored
      This makes it easier to copy/paste names with periods to email clients.
      
      All the other names with commas already have quotation marks.
      Signed-off-by: default avatarJoe Perches <joe@perches.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      e43cdb56
    • Joe Perches's avatar
      MAINTAINERS: add quotation marks around names with periods · 9c3646d1
      Joe Perches authored
      This makes it easier to copy/paste names with periods to email clients.
      
      All the other names with periods already have quotation marks.
      Signed-off-by: default avatarJoe Perches <joe@perches.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9c3646d1
    • Jim Davis's avatar
      MAINTAINERS: alsa-devel@alsa-project.org is moderated for non-subscribers · e5747e40
      Jim Davis authored
      Fix a few inconsistent annotations to show that the alsa-devel mailing
      list is moderated for non-subscribers.
      Signed-off-by: default avatarJim Davis <jim.epost@gmail.com>
      Cc: Joe Perches <joe@perches.com>
      Cc: Takashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      e5747e40
    • Joe Perches's avatar
      get_maintainer: fix perl 5.22/5.24 deprecated/incompatible "\C" use · ce8155f7
      Joe Perches authored
      Perl 5.22 emits a deprecated message when "\C" is used in a regex.  Perl
      5.24 will disallow it altogether.
      
      Fix it by using [A-Z] instead of \C.
      Signed-off-by: default avatarJoe Perches <joe@perches.com>
      Reported-by: default avatarValdis Kletnieks <Valdis.Kletnieks@vt.edu>
      Tested-by: default avatarValdis Kletnieks <Valdis.Kletnieks@vt.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ce8155f7
    • Joe Perches's avatar
      get_maintainer: emit longer section headers · 364f68dc
      Joe Perches authored
      Section headers can be quite long and some are very long and duplicated
      for many initial characters.
      
      The current maximum length emitted for a section header is 20 bytes (or
      17 bytes then ...  when the section header length is > 20).
      
      Change that length to 50 so more of the section is shown.
      
      Example new output:
      $ ./scripts/get_maintainer.pl -f drivers/net/ethernet/broadcom/bnx2x/
      Ariel Elior <ariel.elior@qlogic.com> (supporter:BROADCOM BNX2X 10 GIGABIT ETHERNET DRIVER)
      netdev@vger.kernel.org (open list:BROADCOM BNX2X 10 GIGABIT ETHERNET DRIVER)
      linux-kernel@vger.kernel.org (open list)
      
      Old:
      $ ./scripts/get_maintainer.pl -f drivers/net/ethernet/broadcom/bnx2x/
      Ariel Elior <ariel.elior@qlogic.com> (supporter:BROADCOM BNX2X 10...)
      netdev@vger.kernel.org (open list:BROADCOM BNX2X 10...)
      linux-kernel@vger.kernel.org (open list)
      Signed-off-by: default avatarJoe Perches <joe@perches.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      364f68dc
    • Joe Perches's avatar
      get_maintainer.pl: add .get_maintainer.ignore file capability · 435de078
      Joe Perches authored
      Some people prefer not to be cc'd on patches.  Add an ability to have a
      file (.get_maintainer.ignore) with names and email addresses that are
      excluded from being listed except when specifically listed as a maintainer
      in a section.
      Signed-off-by: default avatarJoe Perches <joe@perches.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      435de078
    • Vasily Averin's avatar
      check_syslog_permissions() cleanup · 3ea4331c
      Vasily Averin authored
      Patch fixes drawbacks in heck_syslog_permissions() noticed by AKPM:
      "from_file handling makes me cry.
      
      That's not a boolean - it's an enumerated value with two values
      currently defined.
      
      But the code in check_syslog_permissions() treats it as a boolean and
      also hardwires the knowledge that SYSLOG_FROM_PROC == 1 (or == `true`).
      
      And the name is wrong: it should be called from_proc to match
      SYSLOG_FROM_PROC."
      Signed-off-by: default avatarVasily Averin <vvs@virtuozzo.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Josh Boyer <jwboyer@redhat.com>
      Cc: Eric Paris <eparis@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      3ea4331c
    • Vasily Averin's avatar
      security_syslog() should be called once only · d194e5d6
      Vasily Averin authored
      The final version of commit 637241a9 ("kmsg: honor dmesg_restrict
      sysctl on /dev/kmsg") lost few hooks, as result security_syslog() are
      processed incorrectly:
      
      - open of /dev/kmsg checks syslog access permissions by using
        check_syslog_permissions() where security_syslog() is not called if
        dmesg_restrict is set.
      
      - syslog syscall and /proc/kmsg calls do_syslog() where security_syslog
        can be executed twice (inside check_syslog_permissions() and then
        directly in do_syslog())
      
      With this patch security_syslog() is called once only in all
      syslog-related operations regardless of dmesg_restrict value.
      
      Fixes: 637241a9 ("kmsg: honor dmesg_restrict sysctl on /dev/kmsg")
      Signed-off-by: default avatarVasily Averin <vvs@virtuozzo.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Josh Boyer <jwboyer@redhat.com>
      Cc: Eric Paris <eparis@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d194e5d6
    • Tejun Heo's avatar
      netconsole: implement extended console support · e2f15f9a
      Tejun Heo authored
      printk logbuf keeps various metadata and optional key=value dictionary for
      structured messages, both of which are stripped when messages are handed
      to regular console drivers.
      
      It can be useful to have this metadata and dictionary available to
      netconsole consumers.  This obviously makes logging via netconsole more
      complete and the sequence number in particular is useful in environments
      where messages may be lost or reordered in transit - e.g.  when netconsole
      is used to collect messages in a large cluster where packets may have to
      travel congested hops to reach the aggregator.  The lost and reordered
      messages can easily be identified and handled accordingly using the
      sequence numbers.
      
      printk recently added extended console support which can be selected by
      setting CON_EXTENDED flag.  From console driver side, not much changes.
      The only difference is that the text passed to the write callback is
      formatted the same way as /dev/kmsg.
      
      This patch implements extended console support for netconsole which can be
      enabled by either prepending "+" to a netconsole boot param entry or
      echoing 1 to "extended" file in configfs.  When enabled, netconsole
      transmits extended log messages with headers identical to /dev/kmsg
      output.
      
      There's one complication due to message fragments.  netconsole limits the
      maximum message size to 1k and messages longer than that are split into
      multiple fragments.  As all extended console messages should carry
      matching headers and be uniquely identifiable, each extended message
      fragment carries full copy of the metadata and an extra header field to
      identify the specific fragment.  The optional header is of the form
      "ncfrag=OFF/LEN" where OFF is the byte offset into the message body and
      LEN is the total length.
      
      To avoid unnecessarily making printk format extended messages, Extended
      netconsole is registered with printk when the first extended netconsole is
      configured.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: David Miller <davem@davemloft.net>
      Cc: Kay Sievers <kay@vrfy.org>
      Cc: Petr Mladek <pmladek@suse.cz>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      e2f15f9a
    • Tejun Heo's avatar
      netconsole: make all dynamic netconsoles share a mutex · 369e5a88
      Tejun Heo authored
      Currently, each dynamic netconsole_target uses its own separate mutex to
      synchronize the configuration operations.
      
      This patch replaces the per-netconsole_target mutexes with a single
      mutex - dynamic_netconsole_mutex.  The reduced granularity doesn't hurt
      anything, the code is minutely simpler and this'd allow adding
      operations which should be synchronized across all dynamic netconsoles.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: David Miller <davem@davemloft.net>
      Cc: Kay Sievers <kay@vrfy.org>
      Cc: Petr Mladek <pmladek@suse.cz>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      369e5a88
    • Tejun Heo's avatar
      netconsole: make netconsole_target->enabled a bool · 698cf1c6
      Tejun Heo authored
      netconsole uses both bool and int for boolean values.  Let's convert
      nt->enabled to bool for consistency.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: David Miller <davem@davemloft.net>
      Cc: Kay Sievers <kay@vrfy.org>
      Cc: Petr Mladek <pmladek@suse.cz>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      698cf1c6
    • Tejun Heo's avatar
      netconsole: remove unnecessary netconsole_target_get/out() from write_msg() · a6d403ac
      Tejun Heo authored
      write_msg() grabs target_list_lock and walks target_list invoking
      netpool_send_udp() on each target.  Curiously, it protects each iteration
      with netconsole_target_get/put() even though it never releases
      target_list_lock which protects all the members.
      
      While this doesn't harm anything, it doesn't serve any purpose either.
      The items on the list can't go away while target_list_lock is held.
      Remove the unnecessary get/put pair.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: David Miller <davem@davemloft.net>
      Cc: Kay Sievers <kay@vrfy.org>
      Cc: Petr Mladek <pmladek@suse.cz>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      a6d403ac
    • Tejun Heo's avatar
      printk: implement support for extended console drivers · 6fe29354
      Tejun Heo authored
      printk log_buf keeps various metadata for each message including its
      sequence number and timestamp.  The metadata is currently available only
      through /dev/kmsg and stripped out before passed onto console drivers.  We
      want this metadata to be available to console drivers too so that console
      consumers can get full information including the metadata and dictionary,
      which among other things can be used to detect whether messages got lost
      in transit.
      
      This patch implements support for extended console drivers.  Consoles can
      indicate that they want extended messages by setting the new CON_EXTENDED
      flag and they'll be fed messages formatted the same way as /dev/kmsg.
      
       "<level>,<sequnum>,<timestamp>,<contflag>;<message text>\n"
      
      If extended consoles exist, in-kernel fragment assembly is disabled.  This
      ensures that all messages emitted to consoles have full metadata including
      sequence number.  The contflag carries enough information to reassemble
      the fragments from the reader side trivially.  Note that this only affects
      /dev/kmsg.  Regular console and /proc/kmsg outputs are not affected by
      this change.
      
      * Extended message formatting for console drivers is enabled iff there
        are registered extended consoles.
      
      * Comment describing /dev/kmsg message format updated to add missing
        contflag field and help distinguishing variable from verbatim terms.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: David Miller <davem@davemloft.net>
      Cc: Kay Sievers <kay@vrfy.org>
      Reviewed-by: default avatarPetr Mladek <pmladek@suse.cz>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      6fe29354
    • Tejun Heo's avatar
      printk: factor out message formatting from devkmsg_read() · 0a295e67
      Tejun Heo authored
      The extended message formatting used for /dev/kmsg will be used implement
      extended consoles.  Factor out msg_print_ext_header() and
      msg_print_ext_body() from devkmsg_read().
      
      This is pure restructuring.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: David Miller <davem@davemloft.net>
      Cc: Kay Sievers <kay@vrfy.org>
      Reviewed-by: default avatarPetr Mladek <pmladek@suse.cz>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      0a295e67
    • Tejun Heo's avatar
      printk: guard the amount written per line by devkmsg_read() · d43ff430
      Tejun Heo authored
      This patchset updates netconsole so that it can emit messages with the
      same header as used in /dev/kmsg which gives neconsole receiver full log
      information which enables things like structured logging and detection
      of lost messages.
      
      This patch (of 7):
      
      devkmsg_read() uses 8k buffer and assumes that the formatted output
      message won't overrun which seems safe given LOG_LINE_MAX, the current use
      of dict and the escaping method being used; however, we're planning to use
      devkmsg formatting wider and accounting for the buffer size properly isn't
      that complicated.
      
      This patch defines CONSOLE_EXT_LOG_MAX as 8192 and updates devkmsg_read()
      so that it limits output accordingly.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: David Miller <davem@davemloft.net>
      Cc: Kay Sievers <kay@vrfy.org>
      Reviewed-by: default avatarPetr Mladek <pmladek@suse.cz>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d43ff430
    • Colin Ian King's avatar
      drivers/misc/altera-stapl/altera.c: remove extraneous KERN_INFO prefix · 4ae555a5
      Colin Ian King authored
      The KERN_INFO prefix is being prepended to KERN_DEBUG when using the
      dprink macro, Remove it as it is extraneous since we are printing the
      message out as debug via dprintk().
      
      Fixes smatch warning:
      
      drivers/misc/altera-stapl/altera.c:2454 altera_init()
         warn: KERN_* level not at start of string
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
      Cc: Igor M. Liplianin <liplianin@netup.ru>
      Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      4ae555a5
    • Josh Triplett's avatar
      clone: support passing tls argument via C rather than pt_regs magic · 3033f14a
      Josh Triplett authored
      clone has some of the quirkiest syscall handling in the kernel, with a
      pile of special cases, historical curiosities, and architecture-specific
      calling conventions.  In particular, clone with CLONE_SETTLS accepts a
      parameter "tls" that the C entry point completely ignores and some
      assembly entry points overwrite; instead, the low-level arch-specific
      code pulls the tls parameter out of the arch-specific register captured
      as part of pt_regs on entry to the kernel.  That's a massive hack, and
      it makes the arch-specific code only work when called via the specific
      existing syscall entry points; because of this hack, any new clone-like
      system call would have to accept an identical tls argument in exactly
      the same arch-specific position, rather than providing a unified system
      call entry point across architectures.
      
      The first patch allows architectures to handle the tls argument via
      normal C parameter passing, if they opt in by selecting
      HAVE_COPY_THREAD_TLS.  The second patch makes 32-bit and 64-bit x86 opt
      into this.
      
      These two patches came out of the clone4 series, which isn't ready for
      this merge window, but these first two cleanup patches were entirely
      uncontroversial and have acks.  I'd like to go ahead and submit these
      two so that other architectures can begin building on top of this and
      opting into HAVE_COPY_THREAD_TLS.  However, I'm also happy to wait and
      send these through the next merge window (along with v3 of clone4) if
      anyone would prefer that.
      
      This patch (of 2):
      
      clone with CLONE_SETTLS accepts an argument to set the thread-local
      storage area for the new thread.  sys_clone declares an int argument
      tls_val in the appropriate point in the argument list (based on the
      various CLONE_BACKWARDS variants), but doesn't actually use or pass along
      that argument.  Instead, sys_clone calls do_fork, which calls
      copy_process, which calls the arch-specific copy_thread, and copy_thread
      pulls the corresponding syscall argument out of the pt_regs captured at
      kernel entry (knowing what argument of clone that architecture passes tls
      in).
      
      Apart from being awful and inscrutable, that also only works because only
      one code path into copy_thread can pass the CLONE_SETTLS flag, and that
      code path comes from sys_clone with its architecture-specific
      argument-passing order.  This prevents introducing a new version of the
      clone system call without propagating the same architecture-specific
      position of the tls argument.
      
      However, there's no reason to pull the argument out of pt_regs when
      sys_clone could just pass it down via C function call arguments.
      
      Introduce a new CONFIG_HAVE_COPY_THREAD_TLS for architectures to opt into,
      and a new copy_thread_tls that accepts the tls parameter as an additional
      unsigned long (syscall-argument-sized) argument.  Change sys_clone's tls
      argument to an unsigned long (which does not change the ABI), and pass
      that down to copy_thread_tls.
      
      Architectures that don't opt into copy_thread_tls will continue to ignore
      the C argument to sys_clone in favor of the pt_regs captured at kernel
      entry, and thus will be unable to introduce new versions of the clone
      syscall.
      
      Patch co-authored by Josh Triplett and Thiago Macieira.
      Signed-off-by: default avatarJosh Triplett <josh@joshtriplett.org>
      Acked-by: default avatarAndy Lutomirski <luto@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Thiago Macieira <thiago.macieira@intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      3033f14a
    • Joe Perches's avatar
      stddef.h: move offsetofend inside #ifndef/#endif guard, neaten · 8c7fbe57
      Joe Perches authored
      Commit 38764884 ("include/stddef.h: Move offsetofend() from vfio.h
      to a generic kernel header") added offsetofend outside the normal
      include #ifndef/#endif guard.  Move it inside.
      
      Miscellanea:
      
      o remove unnecessary blank line
      o standardize offsetof macros whitespace style
      Signed-off-by: default avatarJoe Perches <joe@perches.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      8c7fbe57
    • Kees Cook's avatar
      mailmap: add rdunlap email auto-correction · 4d5b367c
      Kees Cook authored
      To avoid having xenotime bounce when things like get_maintainers gives
      me addresses, add Randy's current address.
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Acked-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: Joe Perches <joe@perches.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      4d5b367c
    • Pratyush Anand's avatar
      Mohit Kumar has moved · 9c5dcdd0
      Pratyush Anand authored
      Mohit's email-id doesn't exist anymore as he has left the company.
      Replace ST's id with mohit.kumar.dhaka@gmail.com.
      Signed-off-by: default avatarPratyush Anand <pratyush.anand@gmail.com>
      Cc: Mohit Kumar <mohit.kumar.dhaka@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9c5dcdd0