07 Jan, 2009

1 commit


04 Jan, 2009

1 commit

  • Before, when we only ever printed out the pointer value itself, a NULL
    pointer would never cause issues and might as well be printed out as
    just its numeric value.

    However, with the extended %p formats, especially %pR, we might validly
    want to print out resources for debugging. And sometimes they don't
    even exist, and the resource pointer is just NULL. Print it out as
    such, rather than oopsing.

    This is a more generic version of a patch done by Trent Piepho (catching
    all %p cases rather than just %pR, and using "(null)" instead of
    "[NULL]" to match glibc).

    Requested-by: Trent Piepho
    Acked-by: Harvey Harrison
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

25 Nov, 2008

1 commit


04 Nov, 2008

1 commit


30 Oct, 2008

2 commits


29 Oct, 2008

1 commit

  • Takes a pointer to a IPv6 address and formats it in the usual
    colon-separated hex format:
    xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx

    Each 16 bit word is printed in network-endian byteorder.

    %#p6 is also supported and will omit the colons.

    %p6 is a replacement for NIP6_FMT and NIP6()
    %#p6 is a replacement for NIP6_SEQFMT and NIP6()

    Note that NIP6() took a struct in6_addr whereas this takes a pointer
    to a struct in6_addr.

    Signed-off-by: Harvey Harrison
    Signed-off-by: David S. Miller

    Harvey Harrison
     

28 Oct, 2008

1 commit


21 Oct, 2008

1 commit


17 Oct, 2008

4 commits

  • Open-code them rather than using defining macros. The function bodies are now
    next to their kerneldoc comments as a bonus.

    Add casts to the signed cases as they call into the unsigned versions.

    Avoids the sparse warnings:
    lib/vsprintf.c:249:1: warning: incorrect type in argument 3 (different signedness)
    lib/vsprintf.c:249:1: expected unsigned long *res
    lib/vsprintf.c:249:1: got long *res
    lib/vsprintf.c:249:1: warning: incorrect type in argument 3 (different signedness)
    lib/vsprintf.c:249:1: expected unsigned long *res
    lib/vsprintf.c:249:1: got long *res
    lib/vsprintf.c:251:1: warning: incorrect type in argument 3 (different signedness)
    lib/vsprintf.c:251:1: expected unsigned long long *res
    lib/vsprintf.c:251:1: got long long *res
    lib/vsprintf.c:251:1: warning: incorrect type in argument 3 (different signedness)
    lib/vsprintf.c:251:1: expected unsigned long long *res
    lib/vsprintf.c:251:1: got long long *res

    Signed-off-by: Harvey Harrison
    Signed-off-by: Linus Torvalds

    Harvey Harrison
     
  • Remove extra lines before the EXPORT_SYMBOL()s

    Signed-off-by: Harvey Harrison
    Signed-off-by: Linus Torvalds

    Harvey Harrison
     
  • The default base is 10 unless there is a leading zero, in which
    case the base will be guessed as 8.

    The base will only be guesed as 16 when the string starts with '0x'
    the third character is a valid hex digit.

    Signed-off-by: Harvey Harrison
    Signed-off-by: Linus Torvalds

    Harvey Harrison
     
  • Add documentation in kerneldoc for new printk format extensions

    This patch documents the new %pS/%pF options in printk in kernel doc.

    Hope I didn't miss any other extension.

    Signed-off-by: Andi Kleen
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andi Kleen
     

10 Sep, 2008

1 commit

  • It was introduced by "vsprintf: add support for '%pS' and '%pF' pointer
    formats" in commit 0fe1ef24f7bd0020f29ffe287dfdb9ead33ca0b2. However,
    the current way its coded doesn't work on parisc64. For two reasons: 1)
    parisc isn't in the #ifdef and 2) parisc has a different format for
    function descriptors

    Make dereference_function_descriptor() more accommodating by allowing
    architecture overrides. I put the three overrides (for parisc64, ppc64
    and ia64) in arch/kernel/module.c because that's where the kernel
    internal linker which knows how to deal with function descriptors sits.

    Signed-off-by: James Bottomley
    Acked-by: Benjamin Herrenschmidt
    Acked-by: Tony Luck
    Acked-by: Kyle McMartin
    Signed-off-by: Linus Torvalds

    James Bottomley
     

13 Aug, 2008

1 commit


07 Jul, 2008

4 commits

  • They print out a pointer in symbolic format, if possible (ie using
    symbolic KALLSYMS information). The '%pS' format is for regular direct
    pointers (which can point to data or code and that you find on the stack
    during backtraces etc), while '%pF' is for C function pointer types.

    On most architectures, the two mean exactly the same thing, but some
    architectures use an indirect pointer for C function pointers, where the
    function pointer points to a function descriptor (which in turn contains
    the actual pointer to the code). The '%pF' code automatically does the
    appropriate function descriptor dereference on such architectures.

    Signed-off-by: Linus Torvalds

    Linus Torvalds
     
  • This expands the kernel '%p' handling with an arbitrary alphanumberic
    specifier extension string immediately following the '%p'. Right now
    it's just being ignored, but the next commit will start adding some
    specific pointer type extensions.

    NOTE! The reason the extension is appended to the '%p' is to allow
    minimal gcc type checking: gcc will still see the '%p' and will check
    that the argument passed in is indeed a pointer, and yet will not
    complain about the extended information that gcc doesn't understand
    about (on the other hand, it also won't actually check that the pointer
    type and the extension are compatible).

    Alphanumeric characters were chosen because there is no sane existing
    use for a string format with a hex pointer representation immediately
    followed by alphanumerics (which is what such a format string would have
    traditionally resulted in).

    Signed-off-by: Linus Torvalds

    Linus Torvalds
     
  • The actual code is the same, just split out into a helper function.
    This makes it easier to read, and allows for simple future extension
    of %p handling.

    Signed-off-by: Linus Torvalds

    Linus Torvalds
     
  • The actual code is the same, just split out into a helper function.
    This makes it easier to read, and allows for future sharing of the
    string code.

    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

24 Feb, 2008

1 commit


10 Feb, 2008

1 commit

  • In arch/x86/boot/printf.c gets rid of unused tail of digits: const char
    *digits = "0123456789abcdefghijklmnopqrstuvwxyz"; (we are using 0-9a-f
    only)

    Uses smaller/faster lowercasing (by ORing with 0x20)
    if we know that we work on numbers/digits. Makes
    strtoul smaller, and also we are getting rid of

    static const char small_digits[] = "0123456789abcdefx";
    static const char large_digits[] = "0123456789ABCDEFX";

    since this works equally well:

    static const char digits[16] = "0123456789ABCDEF";

    Size savings:

    $ size vmlinux.org vmlinux
    text data bss dec hex filename
    877320 112252 90112 1079684 107984 vmlinux.org
    877048 112252 90112 1079412 107874 vmlinux

    It may be also a tiny bit faster because code has less
    branches now, but I doubt it is measurable.

    [ hugh@veritas.com: uppercase pointers fix ]

    Signed-off-by: Denys Vlasenko
    Cc: Andi Kleen
    Signed-off-by: Andrew Morton
    Signed-off-by: Ingo Molnar
    Signed-off-by: Thomas Gleixner

    Denys Vlasenko
     

09 Feb, 2008

1 commit

  • Currently, for every sysfs node, the callers will be responsible for
    implementing store operation, so many many callers are doing duplicate
    things to validate input, they have the same mistakes because they are
    calling simple_strtol/ul/ll/uul, especially for module params, they are
    just numeric, but you can echo such values as 0x1234xxx, 07777888 and
    1234aaa, for these cases, module params store operation just ignores
    succesive invalid char and converts prefix part to a numeric although input
    is acctually invalid.

    This patch tries to fix the aforementioned issues and implements
    strict_strtox serial functions, kernel/params.c uses them to strictly
    validate input, so module params will reject such values as 0x1234xxxx and
    returns an error:

    write error: Invalid argument

    Any modules which export numeric sysfs node can use strict_strtox instead of
    simple_strtox to reject any invalid input.

    Here are some test results:

    Before applying this patch:

    [root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
    4096
    [root@yangyi-dev /]# echo 0x1000 > /sys/module/e1000/parameters/copybreak
    [root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
    4096
    [root@yangyi-dev /]# echo 0x1000g > /sys/module/e1000/parameters/copybreak
    [root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
    4096
    [root@yangyi-dev /]# echo 0x1000gggggggg > /sys/module/e1000/parameters/copybreak
    [root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
    4096
    [root@yangyi-dev /]# echo 010000 > /sys/module/e1000/parameters/copybreak
    [root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
    4096
    [root@yangyi-dev /]# echo 0100008 > /sys/module/e1000/parameters/copybreak
    [root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
    4096
    [root@yangyi-dev /]# echo 010000aaaaa > /sys/module/e1000/parameters/copybreak
    [root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
    4096
    [root@yangyi-dev /]#

    After applying this patch:

    [root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
    4096
    [root@yangyi-dev /]# echo 0x1000 > /sys/module/e1000/parameters/copybreak
    [root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
    4096
    [root@yangyi-dev /]# echo 0x1000g > /sys/module/e1000/parameters/copybreak
    -bash: echo: write error: Invalid argument
    [root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
    4096
    [root@yangyi-dev /]# echo 0x1000gggggggg > /sys/module/e1000/parameters/copybreak
    -bash: echo: write error: Invalid argument
    [root@yangyi-dev /]# echo 010000 > /sys/module/e1000/parameters/copybreak
    [root@yangyi-dev /]# echo 0100008 > /sys/module/e1000/parameters/copybreak
    -bash: echo: write error: Invalid argument
    [root@yangyi-dev /]# echo 010000aaaaa > /sys/module/e1000/parameters/copybreak
    -bash: echo: write error: Invalid argument
    [root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
    4096
    [root@yangyi-dev /]# echo -n 4096 > /sys/module/e1000/parameters/copybreak
    [root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
    4096
    [root@yangyi-dev /]#

    [akpm@linux-foundation.org: fix compiler warnings]
    [akpm@linux-foundation.org: fix off-by-one found by tiwai@suse.de]
    Signed-off-by: Yi Yang
    Cc: Greg KH
    Cc: "Randy.Dunlap"
    Cc: Takashi Iwai
    Cc: Hugh Dickins
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yi Yang
     

01 Aug, 2007

1 commit

  • kasprintf pulls in kmalloc which proved to be fatal for at least
    bootimage target on alpha.
    Move it to a separate file so only users of kasprintf are exposed
    to the dependency on kmalloc.

    Signed-off-by: Sam Ravnborg
    Cc: Jeremy Fitzhardinge
    Cc: Meelis Roos
    Cc: Richard Henderson
    Cc: Ivan Kokshaysky
    Cc: Jay Estabrook
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Sam Ravnborg
     

17 Jul, 2007

2 commits

  • Optimize integer-to-string conversion in vsprintf.c for base 10. This is
    by far the most used conversion, and in some use cases it impacts
    performance. For example, top reads /proc/$PID/stat for every process, and
    with 4000 processes decimal conversion alone takes noticeable time.

    Using code from

    http://www.cs.uiowa.edu/~jones/bcd/decimal.html
    (with permission from the author, Douglas W. Jones)

    binary-to-decimal-string conversion is done in groups of five digits at
    once, using only additions/subtractions/shifts (with -O2; -Os throws in
    some multiply instructions).

    On i386 arch gcc 4.1.2 -O2 generates ~500 bytes of code.

    This patch is run tested. Userspace benchmark/test is also attached.
    I tested it on PIII and AMD64 and new code is generally ~2.5 times
    faster. On AMD64:

    # ./vsprintf_verify-O2
    Original decimal conv: .......... 151 ns per iteration
    Patched decimal conv: .......... 62 ns per iteration
    Testing correctness
    12895992590592 ok... [Ctrl-C]
    # ./vsprintf_verify-O2
    Original decimal conv: .......... 151 ns per iteration
    Patched decimal conv: .......... 62 ns per iteration
    Testing correctness
    26025406464 ok... [Ctrl-C]

    More realistic test: top from busybox project was modified to
    report how many us it took to scan /proc (this does not account
    any processing done after that, like sorting process list),
    and then I test it with 4000 processes:

    #!/bin/sh
    i=4000
    while test $i != 0; do
    sleep 30 &
    let i--
    done
    busybox top -b -n3 >/dev/null

    on unpatched kernel:

    top: 4120 processes took 102864 microseconds to scan
    top: 4120 processes took 91757 microseconds to scan
    top: 4120 processes took 92517 microseconds to scan
    top: 4120 processes took 92581 microseconds to scan

    on patched kernel:

    top: 4120 processes took 75460 microseconds to scan
    top: 4120 processes took 66451 microseconds to scan
    top: 4120 processes took 67267 microseconds to scan
    top: 4120 processes took 67618 microseconds to scan

    The speedup comes from much faster generation of /proc/PID/stat
    by sprintf() calls inside the kernel.

    Signed-off-by: Douglas W Jones
    Signed-off-by: Denys Vlasenko
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Denis Vlasenko
     
  • * There is no point in having full "0...9a...z" constant vector,
    if we use only "0...9a...f" (and "x" for "0x").

    * Post-decrement usually needs a few more instructions, so use
    pre decrement instead where makes sense:
    -       while (i < precision--) {
    +       while (i base 8 or 16), we can avoid using division
    in a loop and use mask/shift, obtaining much faster conversion.
    (More complex optimization for base 10 case is in the second patch).

    Overall, size vsprintf.o shows ~80 bytes smaller text section
    with this patch applied.

    Signed-off-by: Douglas W Jones
    Signed-off-by: Denys Vlasenko
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Denis Vlasenko
     

09 May, 2007

1 commit

  • I was playing with some code that sometimes got a string where a %n
    match should have been done where the input string ended, for example
    like this:

    sscanf("abc123", "abc%d%n", &a, &n); /* doesn't work */
    sscanf("abc123a", "abc%d%n", &a, &n); /* works */

    However, the scanf function in the kernel doesn't convert the %n in that
    case because it has already matched the complete input after %d and just
    completely stops matching then. This patch fixes that.

    [akpm@linux-foundation.org: cleanups]
    Signed-off-by: Johannes Berg
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Johannes Berg
     

01 May, 2007

1 commit

  • Add a kvasprintf() function to complement kasprintf().

    No in-tree users yet, but I have some coming up.

    [akpm@linux-foundation.org: EXPORT it]
    Signed-off-by: Jeremy Fitzhardinge
    Cc: Andrew Morton
    Cc: Keir Fraser
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jeremy Fitzhardinge
     

13 Feb, 2007

1 commit


12 Feb, 2007

1 commit

  • A variety of (mostly) innocuous fixes to the embedded kernel-doc content in
    source files, including:

    * make multi-line initial descriptions single line
    * denote some function names, constants and structs as such
    * change erroneous opening '/*' to '/**' in a few places
    * reword some text for clarity

    Signed-off-by: Robert P. J. Day
    Cc: "Randy.Dunlap"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Robert P. J. Day
     

29 Jun, 2006

1 commit

  • The recent vsnprintf() fix introduced an off-by-one, and it's now
    possible to overrun the target buffer by one byte.

    The "end" pointer points to past the end of the buffer, so if we
    have to truncate the result, it needs to be done though "end[-1]".

    [ This is just an alternate and simpler patch to one proposed by Andrew
    and Jeremy, who actually noticed the problem ]

    Acked-by: Andrew Morton
    Acked-by: Jeremy Fitzhardinge
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

26 Jun, 2006

2 commits

  • Implement kasprintf, a kernel version of asprintf. This allocates the
    memory required for the formatted string, including the trailing '\0'.
    Returns NULL on allocation failure.

    Signed-off-by: Jeremy Fitzhardinge
    Signed-off-by: Chris Wright
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jeremy Fitzhardinge
     
  • This change allows callers to use a 0-byte buffer and a NULL buffer pointer
    with vsnprintf, so it can be used to determine how large the resulting
    formatted string will be.

    Previously the code effectively treated a size of 0 as a size of 4G (on
    32-bit systems), with other checks preventing it from actually trying to
    emit the string - but the terminal \0 would still be written, which would
    crash if the buffer is NULL.

    This change changes the boundary check so that 'end' points to the putative
    location of the terminal '\0', which is only written if size > 0.

    vsnprintf still allows the buffer size to be set very large, to allow
    unbounded buffer sizes (to implement sprintf, etc).

    [akpm@osdl.org: fix long-vs-longlong confusion]
    Signed-off-by: Jeremy Fitzhardinge
    Signed-off-by: Chris Wright
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jeremy Fitzhardinge
     

31 Oct, 2005

1 commit

  • I recently picked up my older work to remove unnecessary #includes of
    sched.h, starting from a patch by Dave Jones to not include sched.h
    from module.h. This reduces the number of indirect includes of sched.h
    by ~300. Another ~400 pointless direct includes can be removed after
    this disentangling (patch to follow later).
    However, quite a few indirect includes need to be fixed up for this.

    In order to feed the patches through -mm with as little disturbance as
    possible, I've split out the fixes I accumulated up to now (complete for
    i386 and x86_64, more archs to follow later) and post them before the real
    patch. This way this large part of the patch is kept simple with only
    adding #includes, and all hunks are independent of each other. So if any
    hunk rejects or gets in the way of other patches, just drop it. My scripts
    will pick it up again in the next round.

    Signed-off-by: Tim Schmielau
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tim Schmielau
     

24 Aug, 2005

1 commit


17 Apr, 2005

1 commit

  • Initial git repository build. I'm not bothering with the full history,
    even though we have it. We can create a separate "historical" git
    archive of that later if we want to, and in the meantime it's about
    3.2GB when imported into git - space that would just make the early
    git days unnecessarily complicated, when we don't have a lot of good
    infrastructure for it.

    Let it rip!

    Linus Torvalds