04 Jul, 2013

40 commits

  • Signed-off-by: Jan Luebbe
    Acked-by: Rodolfo Giometti
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jan Luebbe
     
  • Replaced calls to kmalloc and memset with kzalloc.
    Patch found using coccinelle.

    Signed-off-by: Alexandru Gheorghiu
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexandru Gheorghiu
     
  • Avoid strncpy anti-pattern.

    [akpm@linux-foundation.org: remove the str[cpy|dup] altogether]
    Signed-off-by: Kees Cook
    Cc: Andreas Schwab
    Cc: Rob Landley
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Kees Cook
     
  • Signed-off-by: Ed Cashin
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ed Cashin
     
  • Signed-off-by: Ed Cashin
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ed Cashin
     
  • Some users have a large AoE target while others like to use many AoE
    targets at the same time. In the latter case, there is an opportunity to
    greatly improve aggregate throughput by allowing different threads to
    complete the I/O associated with each target. For 36 targets, 4 KiB read
    throughput roughly doubles, for example, with these changes in place.

    Signed-off-by: Ed Cashin
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ed Cashin
     
  • Currently, when a disconnect is requested by the user (via NBD_DISCONNECT
    ioctl) the return from NBD_DO_IT is undefined (it is usually one of
    several error codes). This means that nbd-client does not know if a
    manual disconnect was performed or whether a network error occurred.
    Because of this, nbd-client's persist mode (which tries to reconnect after
    error, but not after manual disconnect) does not always work correctly.

    This change fixes this by causing NBD_DO_IT to always return 0 if a user
    requests a disconnect. This means that nbd-client can correctly either
    persist the connection (if an error occurred) or disconnect (if the user
    requested it).

    Signed-off-by: Paul Clements
    Acked-by: Rob Landley
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Paul Clements
     
  • The NBD_CLEAR_QUE ioctl has been deprecated for quite some time (its job
    is now done by two other ioctls). We should stop trying to make bogus
    assertions in it. Also, user-level code should remove calls to
    NBD_CLEAR_QUE, ASAP.

    Signed-off-by: Michal Belczyk
    Signed-off-by: Paul Clements
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michal Belczyk
     
  • Move statement to static initilization of init_pid_ns.

    Signed-off-by: Raphael S. Carvalho
    Cc: "Eric W. Biederman"
    Acked-by: Serge Hallyn
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Raphael S. Carvalho
     
  • Change endpoint device name format to use a component tag value instead of
    device destination ID.

    RapidIO specification defines a component tag to be a unique identifier
    for devices in a network. RapidIO switches already use component tag as
    part of their device name and also use it for device identification when
    processing error management event notifications.

    Forming an endpoint's device name using its component tag instead of
    destination ID allows to keep sysfs device directories unchanged in case
    if a routing process dynamically changes endpoint's destination ID as a
    result of route optimization.

    This change should not affect any existing users because a valid device
    destination ID always should be obtained by reading "destid" attribute and
    not by parsing device name.

    This patch also removes switchid member from struct rio_switch because it
    simply duplicates the component tag and does not have other use than in
    device name generation.

    Signed-off-by: Alexandre Bounine
    Cc: Matt Porter
    Cc: Li Yang
    Cc: Kumar Gala
    Cc: Andre van Herk
    Cc: Micha Nelissen
    Cc: Stef van Os
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexandre Bounine
     
  • Update RapidIO documentation files to reflect modularization changes.

    Signed-off-by: Alexandre Bounine
    Cc: Matt Porter
    Cc: Li Yang
    Cc: Kumar Gala
    Cc: Andre van Herk
    Cc: Micha Nelissen
    Cc: Stef van Os
    Cc: Jean Delvare
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexandre Bounine
     
  • Add RapidIO-specific modalias generation to enable udev notifications
    about RapidIO-specific events.

    The RapidIO modalias string format is shown below:

    "rapidio:vNNNNdNNNNavNNNNadNNNN"

    Where:
    v - Device Vendor ID (16 bit),
    d - Device ID (16 bit),
    av - Assembly Vendor ID (16 bit),
    ad - Assembly ID (16 bit),

    as they are reported in corresponding Capability Registers (CARs)
    of each RapidIO device.

    Signed-off-by: Alexandre Bounine
    Cc: Matt Porter
    Cc: Li Yang
    Cc: Kumar Gala
    Cc: Andre van Herk
    Cc: Micha Nelissen
    Cc: Stef van Os
    Cc: Jean Delvare
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexandre Bounine
     
  • Add a configuration option to build RapidIO subsystem core code as a
    loadable kernel module. Currently this option is available only for
    x86-based platforms, with the additional patch for PowerPC planned to be
    provided later.

    This patch replaces kernel command line parameter "riohdid=" with its
    module-specific analog "rapidio.hdid=".

    Signed-off-by: Alexandre Bounine
    Cc: Matt Porter
    Cc: Li Yang
    Cc: Kumar Gala
    Cc: Andre van Herk
    Cc: Micha Nelissen
    Cc: Stef van Os
    Cc: Jean Delvare
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexandre Bounine
     
  • This patch adds an option to build device driver for Tsi721 PCIe-to-SRIO
    bridge device as a kernel module.

    Currently this module cannot be unloaded because the existing RapidIO
    subsystem code does not support dynamic removal of local RapidIO
    controllers (TODO).

    Signed-off-by: Alexandre Bounine
    Cc: Matt Porter
    Cc: Li Yang
    Cc: Kumar Gala
    Cc: Andre van Herk
    Cc: Micha Nelissen
    Cc: Stef van Os
    Cc: Jean Delvare
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexandre Bounine
     
  • Update enumeration/discovery method registration mechanism to allow
    loading enumeration/discovery methods before all mports are registered.

    Existing statically linked RapidIO subsystem expects that all available
    RapidIO mport devices are initialized and registered before the
    enumeration/discovery method is registered. Switching to loadable mport
    device drivers creates situation when mport device driver can be loaded
    after enumeration/discovery method is attached (e.g., loadable mport
    driver in a system with statically linked RapidIO core and enumerator).
    This also will happen in a system with hot-pluggable RapidIO controllers.

    To remove the dependency on the initialization/registration order this
    patch introduces enumeration/discovery registration mechanism that
    supports arbitrary registration order of mports and enumerator/discovery
    methods.

    The following registration rules are implemented:
    - only one enumeration/discovery method can be registered for given mport ID
    (including RIO_MPORT_ANY);
    - when new enumeration/discovery methods tries to attach to the registered mport
    device, method with matching mport ID will replace a default method previously
    registered for given mport (if any);
    - enumeration/discovery method with target ID=RIO_MPORT_ANY will be attached
    only to mports that do not have another enumerator attached to them;
    - when new mport device is registered with RapidIO subsystem, registration
    routine searches for the enumeration/discovery method with the best matching
    mport ID;

    Signed-off-by: Alexandre Bounine
    Cc: Matt Porter
    Cc: Li Yang
    Cc: Kumar Gala
    Cc: Andre van Herk
    Cc: Micha Nelissen
    Cc: Stef van Os
    Cc: Jean Delvare
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexandre Bounine
     
  • Rework probe/remove routines to prevent rionet driver from monopolizing
    target RapidIO devices. Fix conflict with modular RapidIO switch drivers.

    Using one of RapidIO messaging channels rionet driver provides a service
    layer common to all endpoint devices in a system's RapidIO network. These
    devices may also require their own specific device driver which will be
    blocked from attaching to the target device by rionet (or block rionet if
    loaded earlier). To avoid conflict with device-specific drivers, the
    rionet driver is reworked to be registered as a subsystem interface on the
    RapidIO bus.

    The reworked rio_remove_dev() and rionet_exit() routines also include
    handling of individual rionet peer device removal which was not supported
    before.

    Signed-off-by: Alexandre Bounine
    Cc: Matt Porter
    Cc: Li Yang
    Cc: Kumar Gala
    Cc: "David S. Miller"
    Cc: Andre van Herk
    Cc: Micha Nelissen
    Cc: Stef van Os
    Cc: Jean Delvare
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexandre Bounine
     
  • Rework RapidIO switch drivers to add an option to build them as loadable
    kernel modules.

    This patch removes RapidIO-specific vmlinux section and converts switch
    drivers to be compatible with LDM driver registration method. To simplify
    registration of device-specific callback routines this patch introduces
    rio_switch_ops data structure. The sw_sysfs() callback is removed from
    the list of device-specific operations because under the new structure its
    functions can be handled by switch driver's probe() and remove() routines.

    If a specific switch device driver is not loaded the RapidIO subsystem
    core will use default standard-based operations to configure a switch.
    Because the current implementation of RapidIO enumeration/discovery method
    relies on availability of device-specific operations for error management,
    switch device drivers must be loaded before the RapidIO
    enumeration/discovery starts.

    This patch also moves several common routines from enumeration/discovery
    module into the RapidIO core code to make switch-specific operations
    accessible to all components of RapidIO subsystem.

    Signed-off-by: Alexandre Bounine
    Cc: Matt Porter
    Cc: Li Yang
    Cc: Kumar Gala
    Cc: Andre van Herk
    Cc: Micha Nelissen
    Cc: Stef van Os
    Cc: Jean Delvare
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexandre Bounine
     
  • sparse warnings:

    drivers/rapidio/rio-scan.c:1143:5: sparse: symbol 'rio_enum_mport' was not declared. Should it be static?
    drivers/rapidio/rio-scan.c:1246:5: sparse: symbol 'rio_disc_mport' was not declared. Should it be static?

    Signed-off-by: Fengguang Wu
    Cc: "Bounine, Alexandre"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Wu Fengguang
     
  • Remove the driver for Tsi500 Parallel RapidIO switch because this device
    has not been available for several years. Since the first introduction of
    Tsi500, the parallel RapidIO interface was replaced by the serial RapidIO
    (sRIO) and therefore there is no value in keeping this driver.

    Signed-off-by: Alexandre Bounine
    Cc: Matt Porter
    Cc: Li Yang
    Cc: Kumar Gala
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexandre Bounine
     
  • We print a dump stack after idr_remove warning. This is useful to find
    the faulty piece of code. Let's do the same for ida_remove, as it would
    be equally useful there.

    [akpm@linux-foundation.org: convert the open-coded printk+dump_stack into WARN()]
    Signed-off-by: Jean Delvare
    Cc: Tejun Heo
    Cc: Takashi Iwai
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jean Delvare
     
  • The only user of saved_max_pfn in s390 is read_oldmem interface but we
    have removed that interface, so saved_max_pfn is now unneeded in s390, and
    we needn't set it anymore.

    Signed-off-by: Zhang Yanfei
    Cc: Martin Schwidefsky
    Cc: Heiko Carstens
    Cc: Michael Holzheu
    Cc: "Eric W. Biederman"
    Cc: "H. Peter Anvin"
    Cc: Benjamin Herrenschmidt
    Cc: Dave Hansen
    Cc: Fenghua Yu
    Cc: Matt Fleming
    Cc: Paul Mackerras
    Cc: Ralf Baechle
    Cc: Tony Luck
    Cc: Vivek Goyal
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Zhang Yanfei
     
  • The only user of saved_max_pfn in ia64 is read_oldmem interface but we
    have removed that interface, so saved_max_pfn is now unneeded in ia64, and
    we needn't set it anymore.

    Signed-off-by: Zhang Yanfei
    Cc: Matt Fleming
    Cc: Tony Luck
    Cc: Fenghua Yu
    Cc: "Eric W. Biederman"
    Cc: "H. Peter Anvin"
    Cc: Benjamin Herrenschmidt
    Cc: Dave Hansen
    Cc: Heiko Carstens
    Cc: Martin Schwidefsky
    Cc: Michael Holzheu
    Cc: Paul Mackerras
    Cc: Ralf Baechle
    Cc: Vivek Goyal
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Zhang Yanfei
     
  • saved_max_pfn is used to know the amount of memory that the previous
    kernel used. And for powerpc, we set saved_max_pfn by passing the kernel
    commandline parameter "savemaxmem=".

    The only user of saved_max_pfn in powerpc is read_oldmem interface. Since
    we have removed read_oldmem, we don't need this parameter anymore.

    Signed-off-by: Zhang Yanfei
    Cc: Benjamin Herrenschmidt
    Cc: Paul Mackerras
    Cc: "Eric W. Biederman"
    Cc: "H. Peter Anvin"
    Cc: Dave Hansen
    Cc: Fenghua Yu
    Cc: Heiko Carstens
    Cc: Martin Schwidefsky
    Cc: Matt Fleming
    Cc: Michael Holzheu
    Cc: Ralf Baechle
    Cc: Tony Luck
    Cc: Vivek Goyal
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Zhang Yanfei
     
  • saved_max_pfn is used to know the amount of memory that the previous
    kernel used. And for powerpc, we set saved_max_pfn by passing the kernel
    commandline parameter "savemaxmem=".

    The only user of saved_max_pfn in mips is read_oldmem interface. Since we
    have removed read_oldmem, so we don't need this parameter anymore.

    Signed-off-by: Zhang Yanfei
    Cc: Ralf Baechle
    Cc: "Eric W. Biederman"
    Cc: "H. Peter Anvin"
    Cc: Benjamin Herrenschmidt
    Cc: Dave Hansen
    Cc: Fenghua Yu
    Cc: Heiko Carstens
    Cc: Martin Schwidefsky
    Cc: Matt Fleming
    Cc: Michael Holzheu
    Cc: Paul Mackerras
    Cc: Tony Luck
    Cc: Vivek Goyal

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

    Zhang Yanfei
     
  • Signed-off-by: Zhang Yanfei
    Cc: Vivek Goyal
    Cc: "Eric W. Biederman"
    Cc: "H. Peter Anvin"
    Cc: Benjamin Herrenschmidt
    Cc: Dave Hansen
    Cc: Fenghua Yu
    Cc: Heiko Carstens
    Cc: Martin Schwidefsky
    Cc: Matt Fleming
    Cc: Michael Holzheu
    Cc: Paul Mackerras
    Cc: Ralf Baechle
    Cc: Tony Luck
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Zhang Yanfei
     
  • /dev/oldmem provides the interface for us to access the "old memory" in
    the dump-capture kernel. Unfortunately, no one actually uses this
    interface.

    And this interface could actually cause some real problems if used on ia64
    where the cached/uncached accesses are mixed. See the discussion from the
    link: https://lkml.org/lkml/2013/4/12/386.

    So Eric suggested that we should remove /dev/oldmem as an unused piece of
    code.

    [akpm@linux-foundation.org: mention /dev/oldmem obsolescence in devices.txt]
    Suggested-by: "Eric W. Biederman"
    Signed-off-by: Zhang Yanfei
    Cc: Vivek Goyal
    Cc: Dave Hansen
    Cc: "H. Peter Anvin"
    Cc: "H. Peter Anvin"
    Cc: Benjamin Herrenschmidt
    Cc: Fenghua Yu
    Cc: Heiko Carstens
    Cc: Martin Schwidefsky
    Cc: Matt Fleming
    Cc: Michael Holzheu
    Cc: Paul Mackerras
    Cc: Ralf Baechle
    Cc: Tony Luck
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Zhang Yanfei
     
  • 924b42d5 ("Use boot based time for process start time and boot time in
    /proc") updated copy_process/do_task_stat but forgot about de_thread().
    This breaks "ps axOT" if a sub-thread execs.

    Note: I think that task->start_time should die.

    Signed-off-by: Oleg Nesterov
    Cc: "Eric W. Biederman"
    Acked-by: John Stultz
    Cc: Tomas Janousek
    Cc: Tomas Smetana
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Oleg Nesterov
     
  • Trivial cleanup. do_execve_common() can use current_user() and avoid the
    unnecessary "struct cred *cred" var.

    Signed-off-by: Oleg Nesterov
    Cc: Vasiliy Kulikov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Oleg Nesterov
     
  • copy_process() does a lot of "chaotic" initializations and checks
    CLONE_THREAD twice before it takes tasklist. In particular it sets
    "p->group_leader = p" and then changes it again under tasklist if
    !thread_group_leader(p).

    This looks a bit confusing, lets create a single "if (CLONE_THREAD)" block
    which initializes ->exit_signal, ->group_leader, and ->tgid.

    Signed-off-by: Oleg Nesterov
    Cc: "Eric W. Biederman"
    Cc: Michal Hocko
    Cc: Pavel Emelyanov
    Cc: Sergey Dyasly
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Oleg Nesterov
     
  • copy_process() adds the new child to thread_group/init_task.tasks list and
    then does attach_pid(child, PIDTYPE_PID). This means that the lockless
    next_thread() or next_task() can see this thread with the wrong pid. Say,
    "ls /proc/pid/task" can list the same inode twice.

    We could move attach_pid(child, PIDTYPE_PID) up, but in this case
    find_task_by_vpid() can find the new thread before it was fully
    initialized.

    And this is already true for PIDTYPE_PGID/PIDTYPE_SID, With this patch
    copy_process() initializes child->pids[*].pid first, then calls
    attach_pid() to insert the task into the pid->tasks list.

    attach_pid() no longer need the "struct pid*" argument, it is always
    called after pid_link->pid was already set.

    Signed-off-by: Oleg Nesterov
    Cc: "Eric W. Biederman"
    Cc: Michal Hocko
    Cc: Pavel Emelyanov
    Cc: Sergey Dyasly
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Oleg Nesterov
     
  • Cleanup and preparation for the next changes.

    Move the "if (clone_flags & CLONE_THREAD)" code down under "if
    (likely(p->pid))" and turn it into into the "else" branch. This makes the
    process/thread initialization more symmetrical and removes one check.

    Signed-off-by: Oleg Nesterov
    Cc: "Eric W. Biederman"
    Cc: Michal Hocko
    Cc: Pavel Emelyanov
    Cc: Sergey Dyasly
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Oleg Nesterov
     
  • When a task is attempting to violate the RLIMIT_NPROC limit we have a
    check to see if the task is sufficiently priviledged. The check first
    looks at CAP_SYS_ADMIN, then CAP_SYS_RESOURCE, then if the task is uid=0.

    A result is that tasks which are allowed by the uid=0 check are first
    checked against the security subsystem. This results in the security
    subsystem auditting a denial for sys_admin and sys_resource and then the
    task passing the uid=0 check.

    This patch rearranges the code to first check uid=0, since if we pass that
    we shouldn't hit the security system at all. We then check sys_resource,
    since it is the smallest capability which will solve the problem. Lastly
    we check the fallback everything cap_sysadmin. We don't want to give this
    capability many places since it is so powerful.

    This will eliminate many of the false positive/needless denial messages we
    get when a root task tries to violate the nproc limit. (note that
    kthreads count against root, so on a sufficiently large machine we can
    actually get past the default limits before any userspace tasks are
    launched.)

    Signed-off-by: Eric Paris
    Cc: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Eric Paris
     
  • For NUL terminated string, set '\0' at the end.

    Signed-off-by: Zhao Hongjiang
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Zhao Hongjiang
     
  • Change uptime_proc_show() to use get_monotonic_boottime() instead of
    do_posix_clock_monotonic_gettime() + monotonic_to_bootbased().

    Signed-off-by: Oleg Nesterov
    Cc: "Eric W. Biederman"
    Acked-by: John Stultz
    Cc: Tomas Janousek
    Cc: Tomas Smetana
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Oleg Nesterov
     
  • Move __set_special_pids() from exit.c to sys.c close to its single caller
    and make it static.

    And rename it to set_special_pids(), another helper with this name has
    gone away.

    Signed-off-by: Oleg Nesterov
    Cc: "Eric W. Biederman"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Oleg Nesterov
     
  • de_thread() can use change_pid() instead of detach + attach. This looks
    better and this ensures that, say, next_thread() can never see a task with
    ->pid == NULL.

    Signed-off-by: Oleg Nesterov
    Acked-by: "Eric W. Biederman"
    Cc: Michal Hocko
    Cc: Pavel Emelyanov
    Cc: Sergey Dyasly
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Oleg Nesterov
     
  • "goto end" should not bypass the "Backward compatibility with
    core_uses_pid" code, move this label up.

    While at it,

    - It is ugly to copy '|' into cn->corename and then inc
    the pointer for argv_split().

    Change format_corename() to increment pat_ptr instead.

    - Remove the dead "if (*pat_ptr == 0)" in format_corename(),
    we already checked it is not zero.

    Signed-off-by: Oleg Nesterov
    Cc: Andi Kleen
    Cc: Colin Walters
    Cc: Denys Vlasenko
    Cc: Jiri Slaby
    Cc: Lennart Poettering
    Cc: Lucas De Marchi
    Acked-by: Neil Horman
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Oleg Nesterov
     
  • Imho, "atomic_t call_count" is ugly and should die. It buys nothing and
    in fact it can grow more than necessary, expand doesn't check if it was
    already incremented by another task.

    Kill it, and introduce "static int core_name_size" updated by
    expand_corename(). This is obviously racy too but harmless, and
    core_name_size never grows for no reason.

    We do not bother to to calculate the "right" new size, we simply do
    kmalloc(size_we_need) and use ksize() to rely on kmalloc_index's decision.

    Finally change format_corename() to use expand_corename(), krealloc(NULL)
    is fine.

    Signed-off-by: Oleg Nesterov
    Cc: Andi Kleen
    Cc: Colin Walters
    Cc: Denys Vlasenko
    Cc: Jiri Slaby
    Cc: Lennart Poettering
    Cc: Lucas De Marchi
    Acked-by: Neil Horman
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Oleg Nesterov
     
  • The usage of cn_escape() looks really annoying, imho this sequence needs a
    wrapper. And it is buggy. If cn_printf() does expand_corename()
    cn_escape() writes to the freed memory.

    Introduce cn_esc_printf() which hopefully does this all right. It records
    the index before cn_vprintf(), not "char *" which is no longer valid (in
    general) after krealloc().

    Signed-off-by: Oleg Nesterov
    Cc: Andi Kleen
    Cc: Colin Walters
    Cc: Denys Vlasenko
    Cc: Jiri Slaby
    Cc: Lennart Poettering
    Cc: Lucas De Marchi
    Acked-by: Neil Horman
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Oleg Nesterov
     
  • cn_vprintf() looks really overcomplicated and sub-optimal. We do not need
    vsnprintf(NULL) to calculate the size we need, we can simply try to print
    into the current buffer and expand/retry only if necessary.

    Signed-off-by: Oleg Nesterov
    Cc: Andi Kleen
    Cc: Colin Walters
    Cc: Denys Vlasenko
    Cc: Jiri Slaby
    Cc: Lennart Poettering
    Cc: Lucas De Marchi
    Acked-by: Neil Horman
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Oleg Nesterov