1. 24 4月, 2012 1 次提交
    • S
      tracing: Add percpu buffers for trace_printk() · 07d777fe
      Steven Rostedt 提交于
      Currently, trace_printk() uses a single buffer to write into
      to calculate the size and format needed to save the trace. To
      do this safely in an SMP environment, a spin_lock() is taken
      to only allow one writer at a time to the buffer. But this could
      also affect what is being traced, and add synchronization that
      would not be there otherwise.
      
      Ideally, using percpu buffers would be useful, but since trace_printk()
      is only used in development, having per cpu buffers for something
      never used is a waste of space. Thus, the use of the trace_bprintk()
      format section is changed to be used for static fmts as well as dynamic ones.
      Then at boot up, we can check if the section that holds the trace_printk
      formats is non-empty, and if it does contain something, then we
      know a trace_printk() has been added to the kernel. At this time
      the trace_printk per cpu buffers are allocated. A check is also
      done at module load time in case a module is added that contains a
      trace_printk().
      
      Once the buffers are allocated, they are never freed. If you use
      a trace_printk() then you should know what you are doing.
      
      A buffer is made for each type of context:
      
        normal
        softirq
        irq
        nmi
      
      The context is checked and the appropriate buffer is used.
      This allows for totally lockless usage of trace_printk(),
      and they no longer even disable interrupts.
      Requested-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      07d777fe
  2. 24 3月, 2012 2 次提交
  3. 21 3月, 2012 1 次提交
  4. 13 3月, 2012 1 次提交
  5. 05 3月, 2012 2 次提交
    • P
      kernel.h: doesn't explicitly use bug.h, so don't include it. · 6c03438e
      Paul Gortmaker 提交于
      This header isn't using bug.h infrastructure, but due to historical
      reasons, it was including it.  Removing it revealed several implicit
      dependencies (since kernel.h is everywhere) so we've fixed those 1st
      before deploying this change.
      Signed-off-by: NPaul Gortmaker <paul.gortmaker@windriver.com>
      6c03438e
    • P
      bug: consolidate BUILD_BUG_ON with other bug code · 35edd910
      Paul Gortmaker 提交于
      The support for BUILD_BUG in linux/kernel.h predates the
      addition of linux/bug.h -- with this chunk off separate,
      you can run into situations where a person gets a compile
      fail even when they've included linux/bug.h, like this:
      
          CC      lib/string.o
        lib/string.c: In function 'strlcat':
        lib/string.c:225:2: error: implicit declaration of function 'BUILD_BUG_ON'
        make[2]: *** [lib/string.o] Error 1
        $
        $ grep linux/bug.h lib/string.c
        #include <linux/bug.h>
        $
      
      Since the above violates the principle of least surprise, move
      the BUG chunks from kernel.h to bug.h so it is all together.
      Signed-off-by: NPaul Gortmaker <paul.gortmaker@windriver.com>
      35edd910
  6. 21 2月, 2012 1 次提交
  7. 13 1月, 2012 3 次提交
  8. 11 1月, 2012 1 次提交
    • D
      kernel.h: add BUILD_BUG() macro · 1399ff86
      David Daney 提交于
      We can place this in definitions that we expect the compiler to remove by
      dead code elimination.  If this assertion fails, we get a nice error
      message at build time.
      
      The GCC function attribute error("message") was added in version 4.3, so
      we define a new macro __linktime_error(message) to expand to this for
      GCC-4.3 and later.  This will give us an error diagnostic from the
      compiler on the line that fails.  For other compilers
      __linktime_error(message) expands to nothing, and we have to be content
      with a link time error, but at least we will still get a build error.
      
      BUILD_BUG() expands to the undefined function __build_bug_failed() and
      will fail at link time if the compiler ever emits code for it.  On GCC-4.3
      and later, attribute((error())) is used so that the failure will be noted
      at compile time instead.
      Signed-off-by: NDavid Daney <david.daney@cavium.com>
      Acked-by: NDavid Rientjes <rientjes@google.com>
      Cc: DM <dm.n9107@gmail.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Acked-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      1399ff86
  9. 05 12月, 2011 1 次提交
  10. 07 11月, 2011 1 次提交
  11. 01 11月, 2011 3 次提交
  12. 21 9月, 2011 1 次提交
    • M
      lib: add error checking to hex2bin · b7804983
      Mimi Zohar 提交于
      hex2bin converts a hexadecimal string to its binary representation.
      The original version of hex2bin did not do any error checking.  This
      patch adds error checking and returns the result.
      
      Changelog v1:
      - removed unpack_hex_byte()
      - changed return code from boolean to int
      
      Changelog:
      - use the new unpack_hex_byte()
      - add __must_check compiler option (Andy Shevchenko's suggestion)
      - change function API to return error checking result
        (based on Tetsuo Handa's initial patch)
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      Acked-by: NAndy Shevchenko <andy.shevchenko@gmail.com>
      b7804983
  13. 26 7月, 2011 3 次提交
  14. 23 6月, 2011 1 次提交
  15. 16 6月, 2011 1 次提交
  16. 25 5月, 2011 2 次提交
  17. 19 5月, 2011 1 次提交
    • S
      ftrace: Allow dynamically allocated function tracers · cdbe61bf
      Steven Rostedt 提交于
      Now that functions may be selected individually, it only makes sense
      that we should allow dynamically allocated trace structures to
      be traced. This will allow perf to allocate a ftrace_ops structure
      at runtime and use it to pick and choose which functions that
      structure will trace.
      
      Note, a dynamically allocated ftrace_ops will always be called
      indirectly instead of being called directly from the mcount in
      entry.S. This is because there's no safe way to prevent mcount
      from being preempted before calling the function, unless we
      modify every entry.S to do so (not likely). Thus, dynamically allocated
      functions will now be called by the ftrace_ops_list_func() that
      loops through the ops that are allocated if there are more than
      one op allocated at a time. This loop is protected with a
      preempt_disable.
      
      To determine if an ftrace_ops structure is allocated or not, a new
      util function was added to the kernel/extable.c called
      core_kernel_data(), which returns 1 if the address is between
      _sdata and _edata.
      
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      cdbe61bf
  18. 23 3月, 2011 1 次提交
    • A
      kstrto*: converting strings to integers done (hopefully) right · 33ee3b2e
      Alexey Dobriyan 提交于
      1. simple_strto*() do not contain overflow checks and crufty,
         libc way to indicate failure.
      2. strict_strto*() also do not have overflow checks but the name and
         comments pretend they do.
      3. Both families have only "long long" and "long" variants,
         but users want strtou8()
      4. Both "simple" and "strict" prefixes are wrong:
         Simple doesn't exactly say what's so simple, strict should not exist
         because conversion should be strict by default.
      
      The solution is to use "k" prefix and add convertors for more types.
      Enter
      	kstrtoull()
      	kstrtoll()
      	kstrtoul()
      	kstrtol()
      	kstrtouint()
      	kstrtoint()
      
      	kstrtou64()
      	kstrtos64()
      	kstrtou32()
      	kstrtos32()
      	kstrtou16()
      	kstrtos16()
      	kstrtou8()
      	kstrtos8()
      
      Include runtime testsuite (somewhat incomplete) as well.
      
      strict_strto*() become deprecated, stubbed to kstrto*() and
      eventually will be removed altogether.
      
      Use kstrto*() in code today!
      
      Note: on some archs _kstrtoul() and _kstrtol() are left in tree, even if
            they'll be unused at runtime. This is temporarily solution,
            because I don't want to hardcode list of archs where these
            functions aren't needed. Current solution with sizeof() and
            __alignof__ at least always works.
      Signed-off-by: NAlexey Dobriyan <adobriyan@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      33ee3b2e
  19. 01 2月, 2011 1 次提交
  20. 24 1月, 2011 2 次提交
    • R
      Remove MAYBE_BUILD_BUG_ON · 1765e3a4
      Rusty Russell 提交于
      Now BUILD_BUG_ON() can handle optimizable constants, we don't need
      MAYBE_BUILD_BUG_ON any more.
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      1765e3a4
    • R
      BUILD_BUG_ON: make it handle more cases · 7ef88ad5
      Rusty Russell 提交于
      BUILD_BUG_ON used to use the optimizer to do code elimination or fail
      at link time; it was changed to first the size of a negative array (a
      nicer compile time error), then (in
      8c87df45) to a bitfield.
      
      This forced us to change some non-constant cases to MAYBE_BUILD_BUG_ON();
      as Jan points out in that commit, it didn't work as intended anyway.
      
      bitfields: needs a literal constant at parse time, and can't be put under
      	"if (__builtin_constant_p(x))" for example.
      negative array: can handle anything, but if the compiler can't tell it's
      	a constant, silently has no effect.
      link time: breaks link if the compiler can't determine the value, but the
      	linker output is not usually as informative as a compiler error.
      
      If we use the negative-array-size method *and* the link time trick,
      we get the ability to use BUILD_BUG_ON() under __builtin_constant_p()
      branches, and maximal ability for the compiler to detect errors at
      build time.
      
      We also document it thoroughly.
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      Cc: Jan Beulich <JBeulich@novell.com>
      Acked-by: NHollis Blanchard <hollisb@us.ibm.com>
      7ef88ad5
  21. 20 1月, 2011 1 次提交
    • T
      lockdep: Move early boot local IRQ enable/disable status to init/main.c · 2ce802f6
      Tejun Heo 提交于
      During early boot, local IRQ is disabled until IRQ subsystem is
      properly initialized.  During this time, no one should enable
      local IRQ and some operations which usually are not allowed with
      IRQ disabled, e.g. operations which might sleep or require
      communications with other processors, are allowed.
      
      lockdep tracked this with early_boot_irqs_off/on() callbacks.
      As other subsystems need this information too, move it to
      init/main.c and make it generally available.  While at it,
      toggle the boolean to early_boot_irqs_disabled instead of
      enabled so that it can be initialized with %false and %true
      indicates the exceptional condition.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Acked-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
      Acked-by: NPekka Enberg <penberg@kernel.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      LKML-Reference: <20110120110635.GB6036@htj.dyndns.org>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      2ce802f6
  22. 14 1月, 2011 2 次提交
    • M
      mm: vmscan: reclaim order-0 and use compaction instead of lumpy reclaim · 3e7d3449
      Mel Gorman 提交于
      Lumpy reclaim is disruptive.  It reclaims a large number of pages and
      ignores the age of the pages it reclaims.  This can incur significant
      stalls and potentially increase the number of major faults.
      
      Compaction has reached the point where it is considered reasonably stable
      (meaning it has passed a lot of testing) and is a potential candidate for
      displacing lumpy reclaim.  This patch introduces an alternative to lumpy
      reclaim whe compaction is available called reclaim/compaction.  The basic
      operation is very simple - instead of selecting a contiguous range of
      pages to reclaim, a number of order-0 pages are reclaimed and then
      compaction is later by either kswapd (compact_zone_order()) or direct
      compaction (__alloc_pages_direct_compact()).
      
      [akpm@linux-foundation.org: fix build]
      [akpm@linux-foundation.org: use conventional task_struct naming]
      Signed-off-by: NMel Gorman <mel@csn.ul.ie>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
      Cc: Rik van Riel <riel@redhat.com>
      Acked-by: NJohannes Weiner <hannes@cmpxchg.org>
      Cc: Andy Whitcroft <apw@shadowen.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      3e7d3449
    • A
      include/linux/kernel.h: abs(): fix handling of 32-bit unsigneds on 64-bit · 71a90484
      Andrew Morton 提交于
      Michal reports:
      
      In the framebuffer subsystem the abs() macro is often used as a part of
      the calculation of a Manhattan metric, which in turn is used as a measure
      of similarity between video modes.  The arguments of abs() are sometimes
      unsigned numbers.  This worked fine until commit a49c59c0 ("Make sure the
      value in abs() does not get truncated if it is greater than 2^32:) , which
      changed the definition of abs() to prevent truncation.  As a result of
      this change, in the following piece of code:
      
      u32 a = 0, b = 1;
      u32 c = abs(a - b);
      
      'c' will end up with a value of 0xffffffff instead of the expected 0x1.
      
      A problem caused by this change and visible by the end user is that
      framebuffer drivers relying on functions from modedb.c will fail to find
      high resolution video modes similar to that explicitly requested by the
      user if an exact match cannot be found (see e.g.
      
      Fix this by special-casing `long' types within abs().
      
      This patch reduces x86_64 code size a bit - drivers/video/uvesafb.o shrunk
      by 15 bytes, presumably because it is doing abs() on 4-byte quantities,
      and expanding those to 8-byte longs adds code.
      
      testcase:
      
      #define oldabs(x) ({				\
      		long __x = (x);			\
      		(__x < 0) ? -__x : __x;		\
      	})
      
      #define newabs(x) ({						\
      		long ret;					\
      		if (sizeof(x) == sizeof(long)) {		\
      			long __x = (x);				\
      			ret = (__x < 0) ? -__x : __x;		\
      		} else {					\
      			int __x = (x);				\
      			ret = (__x < 0) ? -__x : __x;		\
      		}						\
      		ret;						\
      	})
      
      typedef unsigned int u32;
      
      main()
      {
      	u32 a = 0;
      	u32 b = 1;
      	u32 oldc = oldabs(a - b);
      	u32 newc = newabs(a - b);
      
      	printf("%u %u\n", oldc, newc);
      }
      
      akpm:/home/akpm> gcc t.c
      akpm:/home/akpm> ./a.out
      4294967295 1
      Reported-by: NMichal Januszewski <michalj@gmail.com>
      Cc: Rolf Eike Beer <eike-kernel@sf-tec.de
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      71a90484
  23. 29 11月, 2010 1 次提交
  24. 16 11月, 2010 1 次提交
  25. 12 11月, 2010 1 次提交
  26. 10 11月, 2010 1 次提交
  27. 09 11月, 2010 1 次提交
  28. 27 10月, 2010 2 次提交