1. 20 10月, 2007 40 次提交
    • B
      ide: add IDE_HFLAG_FORCE_LEGACY_IRQS host flag · 8acf28c0
      Bartlomiej Zolnierkiewicz 提交于
      Add IDE_HFLAG_FORCE_LEGACY_IRQS host flag to tell ide_pci_setup_ports()
      to always set hwif->irq to legacy IRQ 14/15 and convert generic IDE PCI
      and via82cxxx host drivers to use it.
      
      While at it:
      
      * Add IDE_HFLAGS_UMC define (generic IDE PCI host driver).
      
      * Remove no longer needed init_hwif_generic() (generic IDE PCI host driver).
      
      * Set d->udma_mask instead of hwif->ultra_mask (via82cxxx host driver).
      Signed-off-by: NBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
      8acf28c0
    • B
      ide: add ->chipset field to ide_pci_device_t · 528a572d
      Bartlomiej Zolnierkiewicz 提交于
      Add ->chipset field to ide_pci_device_t and use it in ide_hwif_configure()
      to set hwif->chipset.  Convert cmd64x, cy82c693, rz1000 and trm290 host
      drivers to use this new ability.
      
      While at it define hwif_chipset_t as u8 to save some space in hw_regs_t,
      ide_hwif_t and ide_pci_device_t instances.
      Signed-off-by: NBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
      528a572d
    • B
    • M
      Linux Kernel Markers - Samples · 31155bc0
      Mathieu Desnoyers 提交于
      Module example showing how to use the Linux Kernel Markers.
      
      [akpm@linux-foundation.org: coding-style fixes]
      Signed-off-by: NMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      31155bc0
    • M
      Linux Kernel Markers · 8256e47c
      Mathieu Desnoyers 提交于
      The marker activation functions sits in kernel/marker.c.  A hash table is used
      to keep track of the registered probes and armed markers, so the markers
      within a newly loaded module that should be active can be activated at module
      load time.
      
      marker_query has been removed. marker_get_first, marker_get_next and
      marker_release should be used as iterators on the markers.
      
      [akpm@linux-foundation.org: coding-style fixes]
      Signed-off-by: NMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
      Acked-by: N"Frank Ch. Eigler" <fche@redhat.com>
      Cc: Christoph Hellwig <hch@infradead.org>
      Cc: Rusty Russell <rusty@rustcorp.com.au>
      Cc: Mike Mason <mmlnx@us.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8256e47c
    • S
      Hook up group scheduler with control groups · 68318b8e
      Srivatsa Vaddagiri 提交于
      Enable "cgroup" (formerly containers) based fair group scheduling.  This
      will let administrator create arbitrary groups of tasks (using "cgroup"
      pseudo filesystem) and control their cpu bandwidth usage.
      
      [akpm@linux-foundation.org: fix cpp condition]
      Signed-off-by: NSrivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>
      Signed-off-by: NDhaval Giani <dhaval@linux.vnet.ibm.com>
      Cc: Randy Dunlap <randy.dunlap@oracle.com>
      Cc: Balbir Singh <balbir@in.ibm.com>
      Cc: Paul Menage <menage@google.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      68318b8e
    • B
      Extended crashkernel command line · cba63c30
      Bernhard Walle 提交于
      This patch adds a extended crashkernel syntax that makes the value of reserved
      system RAM dependent on the system RAM itself:
      
          crashkernel=<range1>:<size1>[,<range2>:<size2>,...][@offset]
          range=start-[end]
      
      For example:
      
          crashkernel=512M-2G:64M,2G-:128M
      
      The motivation comes from distributors that configure their crashkernel
      command line automatically with some configuration tool (YaST, you know ;)).
      Of course that tool knows the value of System RAM, but if the user removes
      RAM, then the system becomes unbootable or at least unusable and error
      handling is very difficult.
      
      This series implements this change for i386, x86_64, ia64, ppc64 and sh.  That
      should be all platforms that support kdump in current mainline.  I tested all
      platforms except sh due to the lack of a sh processor.
      
      This patch:
      
      This is the generic part of the patch.  It adds a parse_crashkernel() function
      in kernel/kexec.c that is called by the architecture specific code that
      actually reserves the memory.  That function takes the whole command line and
      looks itself for "crashkernel=" in it.
      
      If there are multiple occurrences, then the last one is taken.  The advantage
      is that if you have a bootloader like lilo or elilo which allows you to append
      a command line parameter but not to remove one (like in GRUB), then you can
      add another crashkernel value for testing at the boot command line and this
      one overwrites the command line in the configuration then.
      Signed-off-by: NBernhard Walle <bwalle@suse.de>
      Cc: Andi Kleen <ak@suse.de>
      Cc: "Luck, Tony" <tony.luck@intel.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mundt <lethal@linux-sh.org>
      Cc: Vivek Goyal <vgoyal@in.ibm.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      cba63c30
    • K
      virtualization of sysv msg queues is incomplete · 3ac88a41
      Kirill Korotaev 提交于
      Virtualization of sysv msg queues is incomplete: msg_hdrs and msg_bytes
      variables visible from userspace are global.  Let's make them
      per-namespace.
      Signed-off-by: NAlexey Kuznetsov <alexey@openvz.org>
      Signed-off-by: NKirill Korotaev <dev@openvz.org>
      Cc: Pierre Peiffer <pierre.peiffer@bull.net>
      Cc: Nadia Derbey <Nadia.Derbey@bull.net>
      Cc: Serge Hallyn <serue@us.ibm.com>
      Acked-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      3ac88a41
    • N
      ipc: store ipcs into IDRs · 7ca7e564
      Nadia Derbey 提交于
      This patch introduces ipcs storage into IDRs. The main changes are:
        . This ipc_ids structure is changed: the entries array is changed into a
          root idr structure.
        . The grow_ary() routine is removed: it is not needed anymore when adding
          an ipc structure, since we are now using the IDR facility.
        . The ipc_rmid() routine interface is changed:
             . there is no need for this routine to return the pointer passed in as
               argument: it is now declared as a void
             . since the id is now part of the kern_ipc_perm structure, no need to
               have it as an argument to the routine
      Signed-off-by: NNadia Derbey <Nadia.Derbey@bull.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      7ca7e564
    • C
      hotplug cpu: migrate a task within its cpuset · 470fd646
      Cliff Wickman 提交于
      When a cpu is disabled, move_task_off_dead_cpu() is called for tasks that have
      been running on that cpu.
      
      Currently, such a task is migrated:
       1) to any cpu on the same node as the disabled cpu, which is both online
          and among that task's cpus_allowed
       2) to any cpu which is both online and among that task's cpus_allowed
      
      It is typical of a multithreaded application running on a large NUMA system to
      have its tasks confined to a cpuset so as to cluster them near the memory that
      they share.  Furthermore, it is typical to explicitly place such a task on a
      specific cpu in that cpuset.  And in that case the task's cpus_allowed
      includes only a single cpu.
      
      This patch would insert a preference to migrate such a task to some cpu within
      its cpuset (and set its cpus_allowed to its entire cpuset).
      
      With this patch, migrate the task to:
       1) to any cpu on the same node as the disabled cpu, which is both online
          and among that task's cpus_allowed
       2) to any online cpu within the task's cpuset
       3) to any cpu which is both online and among that task's cpus_allowed
      
      In order to do this, move_task_off_dead_cpu() must make a call to
      cpuset_cpus_allowed_locked(), a new subset of cpuset_cpus_allowed(), that will
      not block.  (name change - per Oleg's suggestion)
      
      Calls are made to cpuset_lock() and cpuset_unlock() in migration_call() to set
      the cpuset mutex during the whole migrate_live_tasks() and
      migrate_dead_tasks() procedure.
      
      [akpm@linux-foundation.org: build fix]
      [pj@sgi.com: Fix indentation and spacing]
      Signed-off-by: NCliff Wickman <cpw@sgi.com>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Cc: Christoph Lameter <clameter@sgi.com>
      Cc: Paul Jackson <pj@sgi.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Signed-off-by: NPaul Jackson <pj@sgi.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      470fd646
    • P
      Use helpers to obtain task pid in printks · ba25f9dc
      Pavel Emelyanov 提交于
      The task_struct->pid member is going to be deprecated, so start
      using the helpers (task_pid_nr/task_pid_vnr/task_pid_nr_ns) in
      the kernel.
      
      The first thing to start with is the pid, printed to dmesg - in
      this case we may safely use task_pid_nr(). Besides, printks produce
      more (much more) than a half of all the explicit pid usage.
      
      [akpm@linux-foundation.org: git-drm went and changed lots of stuff]
      Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
      Cc: Dave Airlie <airlied@linux.ie>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ba25f9dc
    • P
      Isolate the explicit usage of signal->pgrp · 9a2e7057
      Pavel Emelyanov 提交于
      The pgrp field is not used widely around the kernel so it is now marked as
      deprecated with appropriate comment.
      
      The initialization of INIT_SIGNALS is trimmed because
      a) they are set to 0 automatically;
      b) gcc cannot properly initialize two anonymous (the second one
         is the one with the session) unions. In this particular case
         to make it compile we'd have to add some field initialized
         right before the .pgrp.
      
      This is the same patch as the 1ec320af one
      (from Cedric), but for the pgrp field.
      
      Some progress report:
      
      We have to deprecate the pid, tgid, session and pgrp fields on struct
      task_struct and struct signal_struct.  The session and pgrp are already
      deprecated.  The tgid value is close to being such - the worst known usage
      in in fs/locks.c and audit code.  The pid field deprecation is mainly
      blocked by numerous printk-s around the kernel that print the tsk->pid to
      log.
      Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com>
      Cc: Cedric Le Goater <clg@fr.ibm.com>
      Cc: Serge Hallyn <serue@us.ibm.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Herbert Poetzl <herbert@13thfloor.at>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      9a2e7057
    • J
      remove BITS_TO_TYPE macro · 14ed9d23
      Jiri Slaby 提交于
      remove BITS_TO_TYPE macro
      
      I realized, that it is actually the same as DIV_ROUND_UP, use it instead.
      
      [akpm@linux-foundation.org: build fix]
      Signed-off-by: NJiri Slaby <jirislaby@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      14ed9d23
    • J
      define global BIT macro · 93043ece
      Jiri Slaby 提交于
      define global BIT macro
      
      move all local BIT defines to the new globally define macro.
      Signed-off-by: NJiri Slaby <jirislaby@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Kumar Gala <galak@gate.crashing.org>
      Cc: Dmitry Torokhov <dtor@mail.ru>
      Cc: Jeff Garzik <jeff@garzik.org>
      Cc: James Bottomley <James.Bottomley@steeleye.com>
      Cc: "Antonino A. Daplas" <adaplas@pol.net>
      Cc: Russell King <rmk@arm.linux.org.uk>
      Acked-by: NRalf Baechle <ralf@linux-mips.org>
      Cc: "John W. Linville" <linville@tuxdriver.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      93043ece
    • J
      get rid of input BIT* duplicate defines · 7b19ada2
      Jiri Slaby 提交于
      get rid of input BIT* duplicate defines
      
      use newly global defined macros for input layer. Also remove includes of
      input.h from non-input sources only for BIT macro definiton. Define the
      macro temporarily in local manner, all those local definitons will be
      removed further in this patchset (to not break bisecting).
      BIT macro will be globally defined (1<<x)
      Signed-off-by: NJiri Slaby <jirislaby@gmail.com>
      Cc: <dtor@mail.ru>
      Acked-by: NJiri Kosina <jkosina@suse.cz>
      Cc: <lenb@kernel.org>
      Acked-by: NMarcel Holtmann <marcel@holtmann.org>
      Cc: <perex@suse.cz>
      Acked-by: NMauro Carvalho Chehab <mchehab@infradead.org>
      Cc: <vernux@us.ibm.com>
      Cc: <malattia@linux.it>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      7b19ada2
    • J
      define first set of BIT* macros · d05be13b
      Jiri Slaby 提交于
      define first set of BIT* macros
      
      - move BITOP_MASK and BITOP_WORD from asm-generic/bitops/atomic.h to
        include/linux/bitops.h and rename it to BIT_MASK and BIT_WORD
      - move BITS_TO_LONGS and BITS_PER_BYTE to bitops.h too and allow easily
        define another BITS_TO_something (e.g. in event.c) by BITS_TO_TYPE macro
      Remaining (and common) BIT macro will be defined after all occurences and
      conflicts will be sorted out in the patches.
      Signed-off-by: NJiri Slaby <jirislaby@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      d05be13b
    • J
      remove asm/bitops.h includes · 1977f032
      Jiri Slaby 提交于
      remove asm/bitops.h includes
      
      including asm/bitops directly may cause compile errors. don't include it
      and include linux/bitops instead. next patch will deny including asm header
      directly.
      
      Cc: Adrian Bunk <bunk@kernel.org>
      Signed-off-by: NJiri Slaby <jirislaby@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      1977f032
    • J
      Misc: phantom, improved data passing · bc552f77
      Jiri Slaby 提交于
      This new version guarantees amb_bit switch in small enough intervals, so that
      the device won't stop working in the middle of a movement anymore.  However it
      preserves old (openhaptics) functionality.
      Signed-off-by: NJiri Slaby <jirislaby@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      bc552f77
    • P
      Fix cpusets update_cpumask · 8707d8b8
      Paul Menage 提交于
      Cause writes to cpuset "cpus" file to update cpus_allowed for member tasks:
      
      - collect batches of tasks under tasklist_lock and then call
        set_cpus_allowed() on them outside the lock (since this can sleep).
      
      - add a simple generic priority heap type to allow efficient collection
        of batches of tasks to be processed without duplicating or missing any
        tasks in subsequent batches.
      
      - make "cpus" file update a no-op if the mask hasn't changed
      
      - fix race between update_cpumask() and sched_setaffinity() by making
        sched_setaffinity() post-check that it's not running on any cpus outside
        cpuset_cpus_allowed().
      
      [akpm@linux-foundation.org: coding-style fixes]
      Signed-off-by: NPaul Menage <menage@google.com>
      Cc: Paul Jackson <pj@sgi.com>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Nick Piggin <nickpiggin@yahoo.com.au>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Balbir Singh <balbir@in.ibm.com>
      Cc: Cedric Le Goater <clg@fr.ibm.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Serge Hallyn <serue@us.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8707d8b8
    • P
      cpuset sched_load_balance flag · 029190c5
      Paul Jackson 提交于
      Add a new per-cpuset flag called 'sched_load_balance'.
      
      When enabled in a cpuset (the default value) it tells the kernel scheduler
      that the scheduler should provide the normal load balancing on the CPUs in
      that cpuset, sometimes moving tasks from one CPU to a second CPU if the
      second CPU is less loaded and if that task is allowed to run there.
      
      When disabled (write "0" to the file) then it tells the kernel scheduler
      that load balancing is not required for the CPUs in that cpuset.
      
      Now even if this flag is disabled for some cpuset, the kernel may still
      have to load balance some or all the CPUs in that cpuset, if some
      overlapping cpuset has its sched_load_balance flag enabled.
      
      If there are some CPUs that are not in any cpuset whose sched_load_balance
      flag is enabled, the kernel scheduler will not load balance tasks to those
      CPUs.
      
      Moreover the kernel will partition the 'sched domains' (non-overlapping
      sets of CPUs over which load balancing is attempted) into the finest
      granularity partition that it can find, while still keeping any two CPUs
      that are in the same shed_load_balance enabled cpuset in the same element
      of the partition.
      
      This serves two purposes:
       1) It provides a mechanism for real time isolation of some CPUs, and
       2) it can be used to improve performance on systems with many CPUs
          by supporting configurations in which load balancing is not done
          across all CPUs at once, but rather only done in several smaller
          disjoint sets of CPUs.
      
      This mechanism replaces the earlier overloading of the per-cpuset
      flag 'cpu_exclusive', which overloading was removed in an earlier
      patch: cpuset-remove-sched-domain-hooks-from-cpusets
      
      See further the Documentation and comments in the code itself.
      
      [akpm@linux-foundation.org: don't be weird]
      Signed-off-by: NPaul Jackson <pj@sgi.com>
      Acked-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      029190c5
    • P
      Uninline the task_xid_nr_ns() calls · 2f2a3a46
      Pavel Emelyanov 提交于
      Since these are expanded into call to pid_nr_ns() anyway, it's OK to move
      the whole routine out-of-line.  This is a cheap way to save ~100 bytes from
      vmlinux.  Together with the previous two patches, it saves half-a-kilo from
      the vmlinux.
      
      Un-inline other (currently inlined) functions must be done with additional
      performance testing.
      Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
      Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Cc: Paul Menage <menage@google.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      2f2a3a46
    • P
      Uninline find_pid etc set of functions · 8990571e
      Pavel Emelyanov 提交于
      The find_pid/_vpid/_pid_ns functions are used to find the struct pid by its
      id, depending on whic id - global or virtual - is used.
      
      The find_vpid() is a macro that pushes the current->nsproxy->pid_ns on the
      stack to call another function - find_pid_ns().  It turned out, that this
      dereference together with the push itself cause the kernel text size to
      grow too much.
      
      Move all these out-of-line.  Together with the previous patch this saves a
      bit less that 400 bytes from .text section.
      Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
      Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Cc: Paul Menage <menage@google.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8990571e
    • P
      Isolate some explicit usage of task->tgid · bac0abd6
      Pavel Emelyanov 提交于
      With pid namespaces this field is now dangerous to use explicitly, so hide
      it behind the helpers.
      
      Also the pid and pgrp fields o task_struct and signal_struct are to be
      deprecated.  Unfortunately this patch cannot be sent right now as this
      leads to tons of warnings, so start isolating them, and deprecate later.
      
      Actually the p->tgid == pid has to be changed to has_group_leader_pid(),
      but Oleg pointed out that in case of posix cpu timers this is the same, and
      thread_group_leader() is more preferable.
      Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
      Acked-by: NOleg Nesterov <oleg@tv-sign.ru>
      Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      bac0abd6
    • P
      pid namespaces: remove the struct pid unneeded fields · 19b9b9b5
      Pavel Emelyanov 提交于
      Since we've switched from using pid->nr to pid->upids->nr some
      fields on struct pid are no longer needed
      Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com>
      Cc: Paul Menage <menage@google.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      19b9b9b5
    • P
      Uninline find_task_by_xxx set of functions · 228ebcbe
      Pavel Emelyanov 提交于
      The find_task_by_something is a set of macros are used to find task by pid
      depending on what kind of pid is proposed - global or virtual one.  All of
      them are wrappers above the most generic one - find_task_by_pid_type_ns() -
      and just substitute some args for it.
      
      It turned out, that dereferencing the current->nsproxy->pid_ns construction
      and pushing one more argument on the stack inline cause kernel text size to
      grow.
      
      This patch moves all this stuff out-of-line into kernel/pid.c.  Together
      with the next patch it saves a bit less than 400 bytes from the .text
      section.
      Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
      Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Cc: Paul Menage <menage@google.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Acked-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      228ebcbe
    • S
      pid namespaces: destroy pid namespace on init's death · 3eb07c8c
      Sukadev Bhattiprolu 提交于
      Terminate all processes in a namespace when the reaper of the namespace is
      exiting.  We do this by walking the pidmap of the namespace and sending
      SIGKILL to all processes.
      Signed-off-by: NSukadev Bhattiprolu <sukadev@us.ibm.com>
      Acked-by: NPavel Emelyanov <xemul@openvz.org>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com>
      Cc: Paul Menage <menage@google.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      3eb07c8c
    • P
      pid namespaces: initialize the namespace's proc_mnt · 6f4e6433
      Pavel Emelyanov 提交于
      The namespace's proc_mnt must be kern_mount-ed to make this pointer always
      valid, independently of whether the user space mounted the proc or not.  This
      solves raced in proc_flush_task, etc.  with the proc_mnt switching from NULL
      to not-NULL.
      
      The initialization is done after the init's pid is created and hashed to make
      proc_get_sb() finr it and get for root inode.
      
      Sice the namespace holds the vfsmnt, vfsmnt holds the superblock and the
      superblock holds the namespace we must explicitly break this circle to destroy
      all the stuff.  This is done after the init of the namespace dies.  Running a
      few steps forward - when init exits it will kill all its children, so no
      proc_mnt will be needed after its death.
      Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com>
      Cc: Paul Menage <menage@google.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      6f4e6433
    • P
      pid namespaces: allow cloning of new namespace · 30e49c26
      Pavel Emelyanov 提交于
      When clone() is invoked with CLONE_NEWPID, create a new pid namespace and then
      create a new struct pid for the new process.  Allocate pid_t's for the new
      process in the new pid namespace and all ancestor pid namespaces.  Make the
      newly cloned process the session and process group leader.
      
      Since the active pid namespace is special and expected to be the first entry
      in pid->upid_list, preserve the order of pid namespaces.
      
      The size of 'struct pid' is dependent on the the number of pid namespaces the
      process exists in, so we use multiple pid-caches'.  Only one pid cache is
      created during system startup and this used by processes that exist only in
      init_pid_ns.
      
      When a process clones its pid namespace, we create additional pid caches as
      necessary and use the pid cache to allocate 'struct pids' for that depth.
      
      Note, that with this patch the newly created namespace won't work, since the
      rest of the kernel still uses global pids, but this is to be fixed soon.  Init
      pid namespace still works.
      
      [oleg@tv-sign.ru: merge fix]
      Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
      Signed-off-by: NSukadev Bhattiprolu <sukadev@us.ibm.com>
      Cc: Paul Menage <menage@google.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      30e49c26
    • P
      pid namespaces: miscellaneous preparations for pid namespaces · b461cc03
      Pavel Emelyanov 提交于
      * remove pid.h from pid_namespaces.h;
      * rework is_(cgroup|global)_init;
      * optimize (get|put)_pid_ns for init_pid_ns;
      * declare task_child_reaper to return actual reaper.
      Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com>
      Cc: Paul Menage <menage@google.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      b461cc03
    • P
      pid namespaces: make proc have multiple superblocks - one for each namespace · 07543f5c
      Pavel Emelyanov 提交于
      Each pid namespace have to be visible through its own proc mount.  Thus we
      need to have per-namespace proc trees with their own superblocks.
      
      We cannot easily show different pid namespace via one global proc tree, since
      each pid refers to different tasks in different namespaces.  E.g.  pid 1
      refers to the init task in the initial namespace and to some other task when
      seeing from another namespace.  Moreover - pid, exisintg in one namespace may
      not exist in the other.
      
      This approach has one move advantage is that the tasks from the init namespace
      can see what tasks live in another namespace by reading entries from another
      proc tree.
      Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com>
      Cc: Paul Menage <menage@google.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      07543f5c
    • P
      pid namespaces: helpers to find the task by its numerical ids · 198fe21b
      Pavel Emelyanov 提交于
      When searching the task by numerical id on may need to find it using global
      pid (as it is done now in kernel) or by its virtual id, e.g.  when sending a
      signal to a task from one namespace the sender will specify the task's virtual
      id and we should find the task by this value.
      
      [akpm@linux-foundation.org: fix gfs2 linkage]
      Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com>
      Cc: Paul Menage <menage@google.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      198fe21b
    • P
      pid namespaces: helpers to obtain pid numbers · 7af57294
      Pavel Emelyanov 提交于
      When showing pid to user or getting the pid numerical id for in-kernel use the
      value of this id may differ depending on the namespace.
      
      This set of helpers is used to get the global pid nr, the virtual (i.e.  seen
      by task in its namespace) nr and the nr as it is seen from the specified
      namespace.
      Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com>
      Cc: Paul Menage <menage@google.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      7af57294
    • P
      pid namespaces: make alloc_pid(), free_pid() and put_pid() work with struct upid · 8ef047aa
      Pavel Emelyanov 提交于
      Each struct upid element of struct pid has to be initialized properly, i.e.
      its nr mst be allocated from appropriate pidmap and ns set to appropriate
      namespace.
      
      When allocating a new pid, we need to know the namespace this pid will live
      in, so the additional argument is added to alloc_pid().
      
      On the other hand, the rest of the kernel still uses the pid->nr and
      pid->pid_chain fields, so these ones are still initialized, but this will be
      removed soon.
      Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com>
      Cc: Paul Menage <menage@google.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8ef047aa
    • P
      pid namespaces: add support for pid namespaces hierarchy · faacbfd3
      Pavel Emelyanov 提交于
      Each namespace has a parent and is characterized by its "level".  Level is the
      number of the namespace generation.  E.g.  init namespace has level 0, after
      cloning new one it will have level 1, the next one - 2 and so on and so forth.
       This level is not explicitly limited.
      
      True hierarchy must have some way to find each namespace's children, but it is
      not used in the patches, so this ability is not added (yet).
      Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com>
      Cc: Paul Menage <menage@google.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      faacbfd3
    • S
      pid namespaces: introduce struct upid · 4c3f2ead
      Sukadev Bhattiprolu 提交于
      Since task will be visible from different pid namespaces each of them have to
      be addressed by multiple pids.  struct upid is to store the information about
      which id refers to which namespace.
      
      The constuciton looks like this.  Each struct pid carried the reference
      counter and the list of tasks attached to this pid.  At its end it has a
      variable length array of struct upid-s.  Each struct upid has a numerical id
      (pid itself), pointer to the namespace, this ID is valid in and is hashed into
      a pid_hash for searching the pids.
      
      The nr and pid_chain fields are kept in struct pid for a while to make kernel
      still work (no patch initialize the upids yet), but it will be removed at the
      end of this series when we switch to upids completely.
      Signed-off-by: NSukadev Bhattiprolu <sukadev@us.ibm.com>
      Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Cc: Paul Menage <menage@google.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      4c3f2ead
    • P
      pid namespaces: prepare proc_flust_task() to flush entries from multiple proc trees · 60347f67
      Pavel Emelyanov 提交于
      The first part is trivial - we just make the proc_flush_task() to operate on
      arbitrary vfsmount with arbitrary ids and pass the pid and global proc_mnt to
      it.
      
      The other change is more tricky: I moved the proc_flush_task() call in
      release_task() higher to address the following problem.
      
      When flushing task from many proc trees we need to know the set of ids (not
      just one pid) to find the dentries' names to flush.  Thus we need to pass the
      task's pid to proc_flush_task() as struct pid is the only object that can
      provide all the pid numbers.  But after __exit_signal() task has detached all
      his pids and this information is lost.
      
      This creates a tiny gap for proc_pid_lookup() to bring some dentries back to
      tree and keep them in hash (since pids are still alive before __exit_signal())
      till the next shrink, but since proc_flush_task() does not provide a 100%
      guarantee that the dentries will be flushed, this is OK to do so.
      Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com>
      Cc: Paul Menage <menage@google.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      60347f67
    • P
      pid namespaces: introduce MS_KERNMOUNT flag · 8bf9725c
      Pavel Emelyanov 提交于
      This flag tells the .get_sb callback that this is a kern_mount() call so that
      it can trust *data pointer to be valid in-kernel one.  If this flag is passed
      from the user process, it is cleared since the *data pointer is not a valid
      kernel object.
      
      Running a few steps forward - this will be needed for proc to create the
      superblock and store a valid pid namespace on it during the namespace
      creation.  The reason, why the namespace cannot live without proc mount is
      described in the appropriate patch.
      Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com>
      Cc: Paul Menage <menage@google.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8bf9725c
    • J
      workqueue: debug flushing deadlocks with lockdep · 4e6045f1
      Johannes Berg 提交于
      In the following scenario:
      
      code path 1:
        my_function() -> lock(L1); ...; flush_workqueue(); ...
      
      code path 2:
        run_workqueue() -> my_work() -> ...; lock(L1); ...
      
      you can get a deadlock when my_work() is queued or running
      but my_function() has acquired L1 already.
      
      This patch adds a pseudo-lock to each workqueue to make lockdep
      warn about this scenario.
      
      [akpm@linux-foundation.org: coding-style fixes]
      Signed-off-by: NJohannes Berg <johannes@sipsolutions.net>
      Acked-by: NOleg Nesterov <oleg@tv-sign.ru>
      Acked-by: NIngo Molnar <mingo@elte.hu>
      Acked-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      4e6045f1
    • P
      Make access to task's nsproxy lighter · cf7b708c
      Pavel Emelyanov 提交于
      When someone wants to deal with some other taks's namespaces it has to lock
      the task and then to get the desired namespace if the one exists.  This is
      slow on read-only paths and may be impossible in some cases.
      
      E.g.  Oleg recently noticed a race between unshare() and the (sent for
      review in cgroups) pid namespaces - when the task notifies the parent it
      has to know the parent's namespace, but taking the task_lock() is
      impossible there - the code is under write locked tasklist lock.
      
      On the other hand switching the namespace on task (daemonize) and releasing
      the namespace (after the last task exit) is rather rare operation and we
      can sacrifice its speed to solve the issues above.
      
      The access to other task namespaces is proposed to be performed
      like this:
      
           rcu_read_lock();
           nsproxy = task_nsproxy(tsk);
           if (nsproxy != NULL) {
                   / *
                     * work with the namespaces here
                     * e.g. get the reference on one of them
                     * /
           } / *
               * NULL task_nsproxy() means that this task is
               * almost dead (zombie)
               * /
           rcu_read_unlock();
      
      This patch has passed the review by Eric and Oleg :) and,
      of course, tested.
      
      [clg@fr.ibm.com: fix unshare()]
      [ebiederm@xmission.com: Update get_net_ns_by_pid]
      Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Serge Hallyn <serue@us.ibm.com>
      Signed-off-by: NCedric Le Goater <clg@fr.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      cf7b708c
    • S
      pid namespaces: define is_global_init() and is_container_init() · b460cbc5
      Serge E. Hallyn 提交于
      is_init() is an ambiguous name for the pid==1 check.  Split it into
      is_global_init() and is_container_init().
      
      A cgroup init has it's tsk->pid == 1.
      
      A global init also has it's tsk->pid == 1 and it's active pid namespace
      is the init_pid_ns.  But rather than check the active pid namespace,
      compare the task structure with 'init_pid_ns.child_reaper', which is
      initialized during boot to the /sbin/init process and never changes.
      
      Changelog:
      
      	2.6.22-rc4-mm2-pidns1:
      	- Use 'init_pid_ns.child_reaper' to determine if a given task is the
      	  global init (/sbin/init) process. This would improve performance
      	  and remove dependence on the task_pid().
      
      	2.6.21-mm2-pidns2:
      
      	- [Sukadev Bhattiprolu] Changed is_container_init() calls in {powerpc,
      	  ppc,avr32}/traps.c for the _exception() call to is_global_init().
      	  This way, we kill only the cgroup if the cgroup's init has a
      	  bug rather than force a kernel panic.
      
      [akpm@linux-foundation.org: fix comment]
      [sukadev@us.ibm.com: Use is_global_init() in arch/m32r/mm/fault.c]
      [bunk@stusta.de: kernel/pid.c: remove unused exports]
      [sukadev@us.ibm.com: Fix capability.c to work with threaded init]
      Signed-off-by: NSerge E. Hallyn <serue@us.ibm.com>
      Signed-off-by: NSukadev Bhattiprolu <sukadev@us.ibm.com>
      Acked-by: NPavel Emelianov <xemul@openvz.org>
      Cc: Eric W. Biederman <ebiederm@xmission.com>
      Cc: Cedric Le Goater <clg@fr.ibm.com>
      Cc: Dave Hansen <haveblue@us.ibm.com>
      Cc: Herbert Poetzel <herbert@13thfloor.at>
      Cc: Kirill Korotaev <dev@sw.ru>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      b460cbc5