1. 13 3月, 2013 27 次提交
    • T
      workqueue: make it clear that WQ_DRAINING is an internal flag · 618b01eb
      Tejun Heo 提交于
      We're gonna add another internal WQ flag.  Let's make the distinction
      clear.  Prefix WQ_DRAINING with __ and move it to bit 16.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reviewed-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      618b01eb
    • T
      workqueue: implement apply_workqueue_attrs() · 9e8cd2f5
      Tejun Heo 提交于
      Implement apply_workqueue_attrs() which applies workqueue_attrs to the
      specified unbound workqueue by creating a new pwq (pool_workqueue)
      linked to worker_pool with the specified attributes.
      
      A new pwq is linked at the head of wq->pwqs instead of tail and
      __queue_work() verifies that the first unbound pwq has positive refcnt
      before choosing it for the actual queueing.  This is to cover the case
      where creation of a new pwq races with queueing.  As base ref on a pwq
      won't be dropped without making another pwq the first one,
      __queue_work() is guaranteed to make progress and not add work item to
      a dead pwq.
      
      init_and_link_pwq() is updated to return the last first pwq the new
      pwq replaced, which is put by apply_workqueue_attrs().
      
      Note that apply_workqueue_attrs() is almost identical to unbound pwq
      part of alloc_and_link_pwqs().  The only difference is that there is
      no previous first pwq.  apply_workqueue_attrs() is implemented to
      handle such cases and replaces unbound pwq handling in
      alloc_and_link_pwqs().
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reviewed-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      9e8cd2f5
    • T
      workqueue: perform non-reentrancy test when queueing to unbound workqueues too · c9178087
      Tejun Heo 提交于
      Because per-cpu workqueues have multiple pwqs (pool_workqueues) to
      serve the CPUs, to guarantee that a single work item isn't queued on
      one pwq while still executing another, __queue_work() takes a look at
      the previous pool the target work item was on and if it's still
      executing there, queue the work item on that pool.
      
      To support changing workqueue_attrs on the fly, unbound workqueues too
      will have multiple pwqs and thus need non-reentrancy test when
      queueing.  This patch modifies __queue_work() such that the reentrancy
      test is performed regardless of the workqueue type.
      
      per_cpu_ptr(wq->cpu_pwqs, cpu) used to be used to determine the
      matching pwq for the last pool.  This can't be used for unbound
      workqueues and is replaced with worker->current_pwq which also happens
      to be simpler.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reviewed-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      c9178087
    • T
      workqueue: prepare flush_workqueue() for dynamic creation and destrucion of unbound pool_workqueues · 75ccf595
      Tejun Heo 提交于
      Unbound pwqs (pool_workqueues) will be dynamically created and
      destroyed with the scheduled unbound workqueue w/ custom attributes
      support.  This patch synchronizes pwq linking and unlinking against
      flush_workqueue() so that its operation isn't disturbed by pwqs coming
      and going.
      
      Linking and unlinking a pwq into wq->pwqs is now protected also by
      wq->flush_mutex and a new pwq's work_color is initialized to
      wq->work_color during linking.  This ensures that pwqs changes don't
      disturb flush_workqueue() in progress and the new pwq's work coloring
      stays in sync with the rest of the workqueue.
      
      flush_mutex during unlinking isn't strictly necessary but it's simpler
      to do it anyway.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reviewed-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      75ccf595
    • T
      workqueue: implement get/put_pwq() · 8864b4e5
      Tejun Heo 提交于
      Add pool_workqueue->refcnt along with get/put_pwq().  Both per-cpu and
      unbound pwqs have refcnts and any work item inserted on a pwq
      increments the refcnt which is dropped when the work item finishes.
      
      For per-cpu pwqs the base ref is never dropped and destroy_workqueue()
      frees the pwqs as before.  For unbound ones, destroy_workqueue()
      simply drops the base ref on the first pwq.  When the refcnt reaches
      zero, pwq_unbound_release_workfn() is scheduled on system_wq, which
      unlinks the pwq, puts the associated pool and frees the pwq and wq as
      necessary.  This needs to be done from a work item as put_pwq() needs
      to be protected by pool->lock but release can't happen with the lock
      held - e.g. put_unbound_pool() involves blocking operations.
      
      Unbound pool->locks are marked with lockdep subclas 1 as put_pwq()
      will schedule the release work item on system_wq while holding the
      unbound pool's lock and triggers recursive locking warning spuriously.
      
      This will be used to implement dynamic creation and destruction of
      unbound pwqs.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reviewed-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      8864b4e5
    • T
      workqueue: restructure __alloc_workqueue_key() · d2c1d404
      Tejun Heo 提交于
      * Move initialization and linking of pool_workqueues into
        init_and_link_pwq().
      
      * Make the failure path use destroy_workqueue() once pool_workqueue
        initialization succeeds.
      
      These changes are to prepare for dynamic management of pool_workqueues
      and don't introduce any functional changes.
      
      While at it, convert list_del(&wq->list) to list_del_init() as a
      precaution as scheduled changes will make destruction more complex.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reviewed-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      d2c1d404
    • T
      workqueue: drop WQ_RESCUER and test workqueue->rescuer for NULL instead · 493008a8
      Tejun Heo 提交于
      WQ_RESCUER is superflous.  WQ_MEM_RECLAIM indicates that the user
      wants a rescuer and testing wq->rescuer for NULL can answer whether a
      given workqueue has a rescuer or not.  Drop WQ_RESCUER and test
      wq->rescuer directly.
      
      This will help simplifying __alloc_workqueue_key() failure path by
      allowing it to use destroy_workqueue() on a partially constructed
      workqueue, which in turn will help implementing dynamic management of
      pool_workqueues.
      
      While at it, clear wq->rescuer after freeing it in
      destroy_workqueue().  This is a precaution as scheduled changes will
      make destruction more complex.
      
      This patch doesn't introduce any functional changes.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reviewed-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      493008a8
    • T
      workqueue: add pool ID to the names of unbound kworkers · ac6104cd
      Tejun Heo 提交于
      There are gonna be multiple unbound pools.  Include pool ID in the
      name of unbound kworkers.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reviewed-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      ac6104cd
    • T
      workqueue: drop "std" from cpu_std_worker_pools and for_each_std_worker_pool() · f02ae73a
      Tejun Heo 提交于
      All per-cpu pools are standard, so there's no need to use both "cpu"
      and "std" and for_each_std_worker_pool() is confusing in that it can
      be used only for per-cpu pools.
      
      * s/cpu_std_worker_pools/cpu_worker_pools/
      
      * s/for_each_std_worker_pool()/for_each_cpu_worker_pool()/
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reviewed-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      f02ae73a
    • T
      workqueue: remove unbound_std_worker_pools[] and related helpers · 7a62c2c8
      Tejun Heo 提交于
      Workqueue no longer makes use of unbound_std_worker_pools[].  All
      unbound worker_pools are created dynamically and there's nothing
      special about the standard ones.  With unbound_std_worker_pools[]
      unused, workqueue no longer has places where it needs to treat the
      per-cpu pools-cpu and unbound pools together.
      
      Remove unbound_std_worker_pools[] and the helpers wrapping it to
      present unified per-cpu and unbound standard worker_pools.
      
      * for_each_std_worker_pool() now only walks through per-cpu pools.
      
      * for_each[_online]_wq_cpu() which don't have any users left are
        removed.
      
      * std_worker_pools() and std_worker_pool_pri() are unused and removed.
      
      * get_std_worker_pool() is removed.  Its only user -
        alloc_and_link_pwqs() - only used it for per-cpu pools anyway.  Open
        code per_cpu access in alloc_and_link_pwqs() instead.
      
      This patch doesn't introduce any functional changes.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reviewed-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      7a62c2c8
    • T
      workqueue: implement attribute-based unbound worker_pool management · 29c91e99
      Tejun Heo 提交于
      This patch makes unbound worker_pools reference counted and
      dynamically created and destroyed as workqueues needing them come and
      go.  All unbound worker_pools are hashed on unbound_pool_hash which is
      keyed by the content of worker_pool->attrs.
      
      When an unbound workqueue is allocated, get_unbound_pool() is called
      with the attributes of the workqueue.  If there already is a matching
      worker_pool, the reference count is bumped and the pool is returned.
      If not, a new worker_pool with matching attributes is created and
      returned.
      
      When an unbound workqueue is destroyed, put_unbound_pool() is called
      which decrements the reference count of the associated worker_pool.
      If the refcnt reaches zero, the worker_pool is destroyed in sched-RCU
      safe way.
      
      Note that the standard unbound worker_pools - normal and highpri ones
      with no specific cpumask affinity - are no longer created explicitly
      during init_workqueues().  init_workqueues() only initializes
      workqueue_attrs to be used for standard unbound pools -
      unbound_std_wq_attrs[].  The pools are spawned on demand as workqueues
      are created.
      
      v2: - Comment added to init_worker_pool() explaining that @pool should
            be in a condition which can be passed to put_unbound_pool() even
            on failure.
      
          - pool->refcnt reaching zero and the pool being removed from
            unbound_pool_hash should be dynamic.  pool->refcnt is converted
            to int from atomic_t and now manipulated inside workqueue_lock.
      
          - Removed an incorrect sanity check on nr_idle in
            put_unbound_pool() which may trigger spuriously.
      
          All changes were suggested by Lai Jiangshan.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reviewed-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      29c91e99
    • T
      workqueue: introduce workqueue_attrs · 7a4e344c
      Tejun Heo 提交于
      Introduce struct workqueue_attrs which carries worker attributes -
      currently the nice level and allowed cpumask along with helper
      routines alloc_workqueue_attrs() and free_workqueue_attrs().
      
      Each worker_pool now carries ->attrs describing the attributes of its
      workers.  All functions dealing with cpumask and nice level of workers
      are updated to follow worker_pool->attrs instead of determining them
      from other characteristics of the worker_pool, and init_workqueues()
      is updated to set worker_pool->attrs appropriately for all standard
      pools.
      
      Note that create_worker() is updated to always perform set_user_nice()
      and use set_cpus_allowed_ptr() combined with manual assertion of
      PF_THREAD_BOUND instead of kthread_bind().  This simplifies handling
      random attributes without affecting the outcome.
      
      This patch doesn't introduce any behavior changes.
      
      v2: Missing cpumask_var_t definition caused build failure on some
          archs.  linux/cpumask.h included.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reported-by: Nkbuild test robot <fengguang.wu@intel.com>
      Reviewed-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      7a4e344c
    • T
      workqueue: separate out init_worker_pool() from init_workqueues() · 4e1a1f9a
      Tejun Heo 提交于
      This will be used to implement unbound pools with custom attributes.
      
      This patch doesn't introduce any functional changes.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reviewed-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      4e1a1f9a
    • T
      workqueue: replace POOL_MANAGING_WORKERS flag with worker_pool->manager_arb · 34a06bd6
      Tejun Heo 提交于
      POOL_MANAGING_WORKERS is used to synchronize the manager role.
      Synchronizing among workers doesn't need blocking and that's why it's
      implemented as a flag.
      
      It got converted to a mutex a while back to add blocking wait from CPU
      hotplug path - 60373152 ("workqueue: use mutex for global_cwq
      manager exclusion").  Later it turned out that synchronization among
      workers and cpu hotplug need to be done separately.  Eventually,
      POOL_MANAGING_WORKERS is restored and workqueue->manager_mutex got
      morphed into workqueue->assoc_mutex - 552a37e9 ("workqueue: restore
      POOL_MANAGING_WORKERS") and b2eb83d1 ("workqueue: rename
      manager_mutex to assoc_mutex").
      
      Now, we're gonna need to be able to lock out managers from
      destroy_workqueue() to support multiple unbound pools with custom
      attributes making it again necessary to be able to block on the
      manager role.  This patch replaces POOL_MANAGING_WORKERS with
      worker_pool->manager_arb.
      
      This patch doesn't introduce any behavior changes.
      
      v2: s/manager_mutex/manager_arb/
      Signed-off-by: NTejun Heo <tj@kernel.org>
      34a06bd6
    • T
      workqueue: update synchronization rules on worker_pool_idr · fa1b54e6
      Tejun Heo 提交于
      Make worker_pool_idr protected by workqueue_lock for writes and
      sched-RCU protected for reads.  Lockdep assertions are added to
      for_each_pool() and get_work_pool() and all their users are converted
      to either hold workqueue_lock or disable preemption/irq.
      
      worker_pool_assign_id() is updated to hold workqueue_lock when
      allocating a pool ID.  As idr_get_new() always performs RCU-safe
      assignment, this is enough on the writer side.
      
      As standard pools are never destroyed, there's nothing to do on that
      side.
      
      The locking is superflous at this point.  This is to help
      implementation of unbound pools/pwqs with custom attributes.
      
      This patch doesn't introduce any behavior changes.
      
      v2: Updated for_each_pwq() use if/else for the hidden assertion
          statement instead of just if as suggested by Lai.  This avoids
          confusing the following else clause.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reviewed-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      fa1b54e6
    • T
      workqueue: update synchronization rules on workqueue->pwqs · 76af4d93
      Tejun Heo 提交于
      Make workqueue->pwqs protected by workqueue_lock for writes and
      sched-RCU protected for reads.  Lockdep assertions are added to
      for_each_pwq() and first_pwq() and all their users are converted to
      either hold workqueue_lock or disable preemption/irq.
      
      alloc_and_link_pwqs() is updated to use list_add_tail_rcu() for
      consistency which isn't strictly necessary as the workqueue isn't
      visible.  destroy_workqueue() isn't updated to sched-RCU release pwqs.
      This is okay as the workqueue should have on users left by that point.
      
      The locking is superflous at this point.  This is to help
      implementation of unbound pools/pwqs with custom attributes.
      
      This patch doesn't introduce any behavior changes.
      
      v2: Updated for_each_pwq() use if/else for the hidden assertion
          statement instead of just if as suggested by Lai.  This avoids
          confusing the following else clause.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reviewed-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      76af4d93
    • T
      workqueue: replace get_pwq() with explicit per_cpu_ptr() accesses and first_pwq() · 7fb98ea7
      Tejun Heo 提交于
      get_pwq() takes @cpu, which can also be WORK_CPU_UNBOUND, and @wq and
      returns the matching pwq (pool_workqueue).  We want to move away from
      using @cpu for identifying pools and pwqs for unbound pools with
      custom attributes and there is only one user - workqueue_congested() -
      which makes use of the WQ_UNBOUND conditional in get_pwq().  All other
      users already know whether they're dealing with a per-cpu or unbound
      workqueue.
      
      Replace get_pwq() with explicit per_cpu_ptr(wq->cpu_pwqs, cpu) for
      per-cpu workqueues and first_pwq() for unbound ones, and open-code
      WQ_UNBOUND conditional in workqueue_congested().
      
      Note that this makes workqueue_congested() behave sligntly differently
      when @cpu other than WORK_CPU_UNBOUND is specified.  It ignores @cpu
      for unbound workqueues and always uses the first pwq instead of
      oopsing.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reviewed-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      7fb98ea7
    • T
      workqueue: remove workqueue_struct->pool_wq.single · 420c0ddb
      Tejun Heo 提交于
      workqueue->pool_wq union is used to point either to percpu pwqs
      (pool_workqueues) or single unbound pwq.  As the first pwq can be
      accessed via workqueue->pwqs list, there's no reason for the single
      pointer anymore.
      
      Use list_first_entry(workqueue->pwqs) to access the unbound pwq and
      drop workqueue->pool_wq.single pointer and the pool_wq union.  It
      simplifies the code and eases implementing multiple unbound pools w/
      custom attributes.
      
      This patch doesn't introduce any visible behavior changes.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reviewed-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      420c0ddb
    • T
      workqueue: consistently use int for @cpu variables · d84ff051
      Tejun Heo 提交于
      Workqueue is mixing unsigned int and int for @cpu variables.  There's
      no point in using unsigned int for cpus - many of cpu related APIs
      take int anyway.  Consistently use int for @cpu variables so that we
      can use negative values to mark special ones.
      
      This patch doesn't introduce any visible behavior changes.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reviewed-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      d84ff051
    • T
      workqueue: add wokrqueue_struct->maydays list to replace mayday cpu iterators · 493a1724
      Tejun Heo 提交于
      Similar to how pool_workqueue iteration used to be, raising and
      servicing mayday requests is based on CPU numbers.  It's hairy because
      cpumask_t may not be able to handle WORK_CPU_UNBOUND and cpumasks are
      assumed to be always set on UP.  This is ugly and can't handle
      multiple unbound pools to be added for unbound workqueues w/ custom
      attributes.
      
      Add workqueue_struct->maydays.  When a pool_workqueue needs rescuing,
      it gets chained on the list through pool_workqueue->mayday_node and
      rescuer_thread() consumes the list until it's empty.
      
      This patch doesn't introduce any visible behavior changes.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reviewed-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      493a1724
    • T
      workqueue: restructure pool / pool_workqueue iterations in freeze/thaw functions · 24b8a847
      Tejun Heo 提交于
      The three freeze/thaw related functions - freeze_workqueues_begin(),
      freeze_workqueues_busy() and thaw_workqueues() - need to iterate
      through all pool_workqueues of all freezable workqueues.  They did it
      by first iterating pools and then visiting all pwqs (pool_workqueues)
      of all workqueues and process it if its pwq->pool matches the current
      pool.  This is rather backwards and done this way partly because
      workqueue didn't have fitting iteration helpers and partly to avoid
      the number of lock operations on pool->lock.
      
      Workqueue now has fitting iterators and the locking operation overhead
      isn't anything to worry about - those locks are unlikely to be
      contended and the same CPU visiting the same set of locks multiple
      times isn't expensive.
      
      Restructure the three functions such that the flow better matches the
      logical steps and pwq iteration is done using for_each_pwq() inside
      workqueue iteration.
      
      * freeze_workqueues_begin(): Setting of FREEZING is moved into a
        separate for_each_pool() iteration.  pwq iteration for clearing
        max_active is updated as described above.
      
      * freeze_workqueues_busy(): pwq iteration updated as described above.
      
      * thaw_workqueues(): The single for_each_wq_cpu() iteration is broken
        into three discrete steps - clearing FREEZING, restoring max_active,
        and kicking workers.  The first and last steps use for_each_pool()
        and the second step uses pwq iteration described above.
      
      This makes the code easier to understand and removes the use of
      for_each_wq_cpu() for walking pwqs, which can't support multiple
      unbound pwqs which will be needed to implement unbound workqueues with
      custom attributes.
      
      This patch doesn't introduce any visible behavior changes.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reviewed-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      24b8a847
    • T
      workqueue: introduce for_each_pool() · 17116969
      Tejun Heo 提交于
      With the scheduled unbound pools with custom attributes, there will be
      multiple unbound pools, so it wouldn't be able to use
      for_each_wq_cpu() + for_each_std_worker_pool() to iterate through all
      pools.
      
      Introduce for_each_pool() which iterates through all pools using
      worker_pool_idr and use it instead of for_each_wq_cpu() +
      for_each_std_worker_pool() combination in freeze_workqueues_begin().
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reviewed-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      17116969
    • T
      workqueue: replace for_each_pwq_cpu() with for_each_pwq() · 49e3cf44
      Tejun Heo 提交于
      Introduce for_each_pwq() which iterates all pool_workqueues of a
      workqueue using the recently added workqueue->pwqs list and replace
      for_each_pwq_cpu() usages with it.
      
      This is primarily to remove the single unbound CPU assumption from pwq
      iteration for the scheduled unbound pools with custom attributes
      support which would introduce multiple unbound pwqs per workqueue;
      however, it also simplifies iterator users.
      
      Note that pwq->pool initialization is moved to alloc_and_link_pwqs()
      as that now is the only place which is explicitly handling the two pwq
      types.
      
      This patch doesn't introduce any visible behavior changes.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reviewed-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      49e3cf44
    • T
      workqueue: add workqueue_struct->pwqs list · 30cdf249
      Tejun Heo 提交于
      Add workqueue_struct->pwqs list and chain all pool_workqueues
      belonging to a workqueue there.  This will be used to implement
      generic pool_workqueue iteration and handle multiple pool_workqueues
      for the scheduled unbound pools with custom attributes.
      
      This patch doesn't introduce any visible behavior changes.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reviewed-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      30cdf249
    • T
      workqueue: introduce kmem_cache for pool_workqueues · e904e6c2
      Tejun Heo 提交于
      pool_workqueues need to be aligned to 1 << WORK_STRUCT_FLAG_BITS as
      the lower bits of work->data are used for flags when they're pointing
      to pool_workqueues.
      
      Due to historical reasons, unbound pool_workqueues are allocated using
      kzalloc() with sufficient buffer area for alignment and aligned
      manually.  The original pointer is stored at the end which free_pwqs()
      retrieves when freeing it.
      
      There's no reason for this hackery anymore.  Set alignment of struct
      pool_workqueue to 1 << WORK_STRUCT_FLAG_BITS, add kmem_cache for
      pool_workqueues with proper alignment and replace the hacky alloc and
      free implementation with plain kmem_cache_zalloc/free().
      
      In case WORK_STRUCT_FLAG_BITS gets shrunk too much and makes fields of
      pool_workqueues misaligned, trigger WARN if the alignment of struct
      pool_workqueue becomes smaller than that of long long.
      
      Note that assertion on IS_ALIGNED() is removed from alloc_pwqs().  We
      already have another one in pwq init loop in __alloc_workqueue_key().
      
      This patch doesn't introduce any visible behavior changes.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reviewed-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      e904e6c2
    • T
      workqueue: make workqueue_lock irq-safe · e98d5b16
      Tejun Heo 提交于
      workqueue_lock will be used to synchronize areas which require
      irq-safety and there isn't much benefit in keeping it not irq-safe.
      Make it irq-safe.
      
      This patch doesn't introduce any visible behavior changes.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reviewed-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      e98d5b16
    • T
      workqueue: make sanity checks less punshing using WARN_ON[_ONCE]()s · 6183c009
      Tejun Heo 提交于
      Workqueue has been using mostly BUG_ON()s for sanity checks, which
      fail unnecessarily harshly when the assertion doesn't hold.  Most
      assertions can converted to be less drastic such that things can limp
      along instead of dying completely.  Convert BUG_ON()s to
      WARN_ON[_ONCE]()s with softer failure behaviors - e.g. if assertion
      check fails in destroy_worker(), trigger WARN and silently ignore
      destruction request.
      
      Most conversions are trivial.  Note that sanity checks in
      destroy_workqueue() are moved above removal from workqueues list so
      that it can bail out without side-effects if assertion checks fail.
      
      This patch doesn't introduce any visible behavior changes during
      normal operation.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reviewed-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      6183c009
  2. 05 3月, 2013 4 次提交
    • L
      workqueue: better define synchronization rule around rescuer->pool updates · b3104104
      Lai Jiangshan 提交于
      Rescuers visit different worker_pools to process work items from pools
      under pressure.  Currently, rescuer->pool is updated outside any
      locking and when an outsider looks at a rescuer, there's no way to
      tell when and whether rescuer->pool is gonna change.  While this
      doesn't currently cause any problem, it is nasty.
      
      With recent worker_maybe_bind_and_lock() changes, we can move
      rescuer->pool updates inside pool locks such that if rescuer->pool
      equals a locked pool, it's guaranteed to stay that way until the pool
      is unlocked.
      
      Move rescuer->pool inside pool->lock.
      
      This patch doesn't introduce any visible behavior difference.
      
      tj: Updated the description.
      Signed-off-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      Signed-off-by: NTejun Heo <tj@kernel.org>
      b3104104
    • L
      workqueue: change argument of worker_maybe_bind_and_lock() to @pool · f36dc67b
      Lai Jiangshan 提交于
      worker_maybe_bind_and_lock() currently takes @worker but only cares
      about @worker->pool.  This patch updates worker_maybe_bind_and_lock()
      to take @pool instead of @worker.  This will be used to better define
      synchronization rules regarding rescuer->pool updates.
      
      This doesn't introduce any functional change.
      
      tj: Updated the comments and description.
      Signed-off-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      Signed-off-by: NTejun Heo <tj@kernel.org>
      f36dc67b
    • L
      workqueue: use %current instead of worker->task in worker_maybe_bind_and_lock() · f5faa077
      Lai Jiangshan 提交于
      worker_maybe_bind_and_lock() uses both @worker->task and @current at
      the same time.  As worker_maybe_bind_and_lock() can only be called by
      the current worker task, they are always the same.
      
      Update worker_maybe_bind_and_lock() to use %current consistently.
      
      This doesn't introduce any functional change.
      
      tj: Massaged the description.
      Signed-off-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      Signed-off-by: NTejun Heo <tj@kernel.org>
      f5faa077
    • L
      workqueue: allow more off-queue flag space · 45d9550a
      Lai Jiangshan 提交于
      When a work item is off-queue, its work->data contains WORK_STRUCT_*
      and WORK_OFFQ_* flags.  As WORK_OFFQ_* flags are used only while a
      work item is off-queue, it can occupy bits of work->data which aren't
      used while off-queue.  WORK_OFFQ_* currently only use bits used by
      on-queue CWQ pointer.  As color bits aren't used while off-queue,
      there's no reason to not use them.
      
      Lower WORK_OFFQ_FLAG_BASE from WORK_STRUCT_FLAG_BITS to
      WORK_STRUCT_COLOR_SHIFT thus giving 4 more bits to off-queue flag
      space which is also used to record worker_pool ID while off-queue.
      
      This doesn't introduce any visible behavior difference.
      
      tj: Rewrote the description.
      Signed-off-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      Signed-off-by: NTejun Heo <tj@kernel.org>
      45d9550a
  3. 04 3月, 2013 9 次提交
    • L
      Linux 3.9-rc1 · 6dbe51c2
      Linus Torvalds 提交于
      6dbe51c2
    • L
      Merge tag 'disintegrate-fbdev-20121220' of git://git.infradead.org/users/dhowells/linux-headers · ea882c2e
      Linus Torvalds 提交于
      Pull fbdev UAPI disintegration from David Howells:
       "You'll be glad to here that the end is nigh for the UAPI patches.
        Only the fbdev/framebuffer piece remains now that the SCSI stuff has
        gone in.
      
        Here are the UAPI disintegration bits for the fbdev drivers.  It
        appears that Florian hasn't had time to deal with my patch, but back
        in December he did say he didn't mind if I pushed it forward."
      
      Yay.  No more uapi movement.  And hopefully no more big header file
      cleanups coming up either, it just tends to be very painful.
      
      * tag 'disintegrate-fbdev-20121220' of git://git.infradead.org/users/dhowells/linux-headers:
        UAPI: (Scripted) Disintegrate include/video
      ea882c2e
    • L
      Merge tag 'stable/for-linus-3.9-rc1-tag' of... · 8e8b180a
      Linus Torvalds 提交于
      Merge tag 'stable/for-linus-3.9-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen
      
      Pull Xen bug-fixes from Konrad Rzeszutek Wilk:
       - Update the Xen ACPI memory and CPU hotplug locking mechanism.
       - Fix PAT issues wherein various applications would not start
       - Fix handling of multiple MSI as AHCI now does it.
       - Fix ARM compile failures.
      
      * tag 'stable/for-linus-3.9-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen:
        xenbus: fix compile failure on ARM with Xen enabled
        xen/pci: We don't do multiple MSI's.
        xen/pat: Disable PAT using pat_enabled value.
        xen/acpi: xen cpu hotplug minor updates
        xen/acpi: xen memory hotplug minor updates
      8e8b180a
    • L
      Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs · 56a79b7b
      Linus Torvalds 提交于
      Pull  more VFS bits from Al Viro:
       "Unfortunately, it looks like xattr series will have to wait until the
        next cycle ;-/
      
        This pile contains 9p cleanups and fixes (races in v9fs_fid_add()
        etc), fixup for nommu breakage in shmem.c, several cleanups and a bit
        more file_inode() work"
      
      * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
        constify path_get/path_put and fs_struct.c stuff
        fix nommu breakage in shmem.c
        cache the value of file_inode() in struct file
        9p: if v9fs_fid_lookup() gets to asking server, it'd better have hashed dentry
        9p: make sure ->lookup() adds fid to the right dentry
        9p: untangle ->lookup() a bit
        9p: double iput() in ->lookup() if d_materialise_unique() fails
        9p: v9fs_fid_add() can't fail now
        v9fs: get rid of v9fs_dentry
        9p: turn fid->dlist into hlist
        9p: don't bother with private lock in ->d_fsdata; dentry->d_lock will do just fine
        more file_inode() open-coded instances
        selinux: opened file can't have NULL or negative ->f_path.dentry
      
      (In the meantime, the hlist traversal macros have changed, so this
      required a semantic conflict fixup for the newly hlistified fid->dlist)
      56a79b7b
    • L
      Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs · 1c82315a
      Linus Torvalds 提交于
      Pull btrfs fixup from Chris Mason:
       "Geert and James both sent this one in, sorry guys"
      
      * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs:
        btrfs/raid56: Add missing #include <linux/vmalloc.h>
      1c82315a
    • L
      Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux · 530ede14
      Linus Torvalds 提交于
      Pull second set of s390 patches from Martin Schwidefsky:
       "The main part of this merge are Heikos uaccess patches.  Together with
        commit 09884964 ("mm: do not grow the stack vma just because of an
        overrun on preceding vma") the user string access is hopefully fixed
        for good.
      
        In addition some bug fixes and two cleanup patches."
      
      * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux:
        s390/module: fix compile warning
        qdio: remove unused parameters
        s390/uaccess: fix kernel ds access for page table walk
        s390/uaccess: fix strncpy_from_user string length check
        input: disable i8042 PC Keyboard controller for s390
        s390/dis: Fix invalid array size
        s390/uaccess: remove pointless access_ok() checks
        s390/uaccess: fix strncpy_from_user/strnlen_user zero maxlen case
        s390/uaccess: shorten strncpy_from_user/strnlen_user
        s390/dasd: fix unresponsive device after all channel paths were lost
        s390/mm: ignore change bit for vmemmap
        s390/page table dumper: add support for change-recording override bit
      530ede14
    • L
      Merge branch 'fixes-for-3.9-latest' of... · 6977c6fc
      Linus Torvalds 提交于
      Merge branch 'fixes-for-3.9-latest' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux
      
      Pull second round of PARISC updates from Helge Deller:
       "The most important fix in this branch is the switch of io_setup,
        io_getevents and io_submit syscalls to use the available compat
        syscalls when running 32bit userspace on 64bit kernel.  Other than
        that it's mostly removal of compile warnings."
      
      * 'fixes-for-3.9-latest' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux:
        parisc: fix redefinition of SET_PERSONALITY
        parisc: do not install modules when installing kernel
        parisc: fix compile warnings triggered by atomic_sub(sizeof(),v)
        parisc: check return value of down_interruptible() in hp_sdc_rtc.c
        parisc: avoid unitialized variable warning in pa_memcpy()
        parisc: remove unused variable 'compat_val'
        parisc: switch to compat_functions of io_setup, io_getevents and io_submit
        parisc: select ARCH_WANT_FRAME_POINTERS
      6977c6fc
    • L
      Merge tag 'metag-v3.9-rc1-v4' of git://git.kernel.org/pub/scm/linux/kernel/git/jhogan/metag · 8fd5e7a2
      Linus Torvalds 提交于
      Pull new ImgTec Meta architecture from James Hogan:
       "This adds core architecture support for Imagination's Meta processor
        cores, followed by some later miscellaneous arch/metag cleanups and
        fixes which I kept separate to ease review:
      
         - Support for basic Meta 1 (ATP) and Meta 2 (HTP) core architecture
         - A few fixes all over, particularly for symbol prefixes
         - A few privilege protection fixes
         - Several cleanups (setup.c includes, split out a lot of
           metag_ksyms.c)
         - Fix some missing exports
         - Convert hugetlb to use vm_unmapped_area()
         - Copy device tree to non-init memory
         - Provide dma_get_sgtable()"
      
      * tag 'metag-v3.9-rc1-v4' of git://git.kernel.org/pub/scm/linux/kernel/git/jhogan/metag: (61 commits)
        metag: Provide dma_get_sgtable()
        metag: prom.h: remove declaration of metag_dt_memblock_reserve()
        metag: copy devicetree to non-init memory
        metag: cleanup metag_ksyms.c includes
        metag: move mm/init.c exports out of metag_ksyms.c
        metag: move usercopy.c exports out of metag_ksyms.c
        metag: move setup.c exports out of metag_ksyms.c
        metag: move kick.c exports out of metag_ksyms.c
        metag: move traps.c exports out of metag_ksyms.c
        metag: move irq enable out of irqflags.h on SMP
        genksyms: fix metag symbol prefix on crc symbols
        metag: hugetlb: convert to vm_unmapped_area()
        metag: export clear_page and copy_page
        metag: export metag_code_cache_flush_all
        metag: protect more non-MMU memory regions
        metag: make TXPRIVEXT bits explicit
        metag: kernel/setup.c: sort includes
        perf: Enable building perf tools for Meta
        metag: add boot time LNKGET/LNKSET check
        metag: add __init to metag_cache_probe()
        ...
      8fd5e7a2
    • L
      Merge branch 'for-linus' of git://git.linaro.org/people/rmk/linux-arm · 529e5fbc
      Linus Torvalds 提交于
      Pull late ARM updates from Russell King:
       "Here is the late set of ARM updates for this merge window; in here is:
      
         - The ARM parts of the broadcast timer support, core parts merged
           through tglx's tree.  This was left over from the previous merge to
           allow the dependency on tglx's tree to be resolved.
      
         - A fix to the VFP code which shows up on Raspberry Pi's, as well as
           fixing the fallout from a previous commit in this area.
      
         - A number of smaller fixes scattered throughout the ARM tree"
      
      * 'for-linus' of git://git.linaro.org/people/rmk/linux-arm:
        ARM: Fix broken commit 0cc41e4a corrupting kernel messages
        ARM: fix scheduling while atomic warning in alignment handling code
        ARM: VFP: fix emulation of second VFP instruction
        ARM: 7656/1: uImage: Error out on build of multiplatform without LOADADDR
        ARM: 7640/1: memory: tegra_ahb_enable_smmu() depends on TEGRA_IOMMU_SMMU
        ARM: 7654/1: Preserve L_PTE_VALID in pte_modify()
        ARM: 7653/2: do not scale loops_per_jiffy when using a constant delay clock
        ARM: 7651/1: remove unused smp_timer_broadcast #define
      529e5fbc