• Daniel Jordan's avatar
    padata: allocate work structures for parallel jobs from a pool · 4611ce22
    Daniel Jordan authored
    padata allocates per-CPU, per-instance work structs for parallel jobs.  A
    do_parallel call assigns a job to a sequence number and hashes the number
    to a CPU, where the job will eventually run using the corresponding work.
    
    This approach fit with how padata used to bind a job to each CPU
    round-robin, makes less sense after commit bfde23ce ("padata: unbind
    parallel jobs from specific CPUs") because a work isn't bound to a
    particular CPU anymore, and isn't needed at all for multithreaded jobs
    because they don't have sequence numbers.
    
    Replace the per-CPU works with a preallocated pool, which allows sharing
    them between existing padata users and the upcoming multithreaded user.
    The pool will also facilitate setting NUMA-aware concurrency limits with
    later users.
    
    The pool is sized according to the number of possible CPUs.  With this
    limit, MAX_OBJ_NUM no longer makes sense, so remove it.
    
    If the global pool is exhausted, a parallel job is run in the current task
    instead to throttle a system trying to do too much in parallel.
    Signed-off-by: default avatarDaniel Jordan <daniel.m.jordan@oracle.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Tested-by: default avatarJosh Triplett <josh@joshtriplett.org>
    Cc: Alexander Duyck <alexander.h.duyck@linux.intel.com>
    Cc: Alex Williamson <alex.williamson@redhat.com>
    Cc: Dan Williams <dan.j.williams@intel.com>
    Cc: Dave Hansen <dave.hansen@linux.intel.com>
    Cc: David Hildenbrand <david@redhat.com>
    Cc: Herbert Xu <herbert@gondor.apana.org.au>
    Cc: Jason Gunthorpe <jgg@ziepe.ca>
    Cc: Jonathan Corbet <corbet@lwn.net>
    Cc: Kirill Tkhai <ktkhai@virtuozzo.com>
    Cc: Michal Hocko <mhocko@kernel.org>
    Cc: Pavel Machek <pavel@ucw.cz>
    Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Randy Dunlap <rdunlap@infradead.org>
    Cc: Robert Elliott <elliott@hpe.com>
    Cc: Shile Zhang <shile.zhang@linux.alibaba.com>
    Cc: Steffen Klassert <steffen.klassert@secunet.com>
    Cc: Steven Sistare <steven.sistare@oracle.com>
    Cc: Tejun Heo <tj@kernel.org>
    Cc: Zi Yan <ziy@nvidia.com>
    Link: http://lkml.kernel.org/r/20200527173608.2885243-4-daniel.m.jordan@oracle.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    4611ce22
padata.c 26.9 KB