History

padata: unbind parallel jobs from specific CPUs

Padata binds the parallel part of a job to a single CPU and round-robins over all CPUs in the system for each successive job. Though the serial parts rely on per-CPU queues for correct ordering, they're not necessary for parallel work, and it improves performance to run the job locally on NUMA machines and let the scheduler pick the CPU within a node on a busy system. So, make the parallel workqueue unbound. Update the parallel workqueue's cpumask when the instance's parallel cpumask changes. Now that parallel jobs no longer run on max_active=1 workqueues, two or more parallel works that hash to the same CPU may run simultaneously, finish out of order, and so be serialized out of order. Prevent this by keeping the works sorted on the reorder list by sequence number and checking that in the reordering logic. padata_get_next becomes padata_find_next so it can be reused for the end of padata_reorder, where it's used to avoid uselessly queueing work when the next job by sequence number isn't finished yet but a later job that hashed to the same CPU has. The ENODATA case in padata_find_next no longer makes sense because parallel jobs aren't bound to specific CPUs. The EINPROGRESS case takes care of the scenario where a parallel job is potentially running on the same CPU as padata_find_next, and with only one error code left, just use NULL instead.

Daniel Jordan committed 7 years ago

Commit bfde23c1 parent 45d153c2 files · +68 −53Browse files

Showing the changes to include/linux (1 of 2 files). Show all

Unified · Split

include/linux/padata.h+3−0
@@ -35,6 +35,7 @@ struct padata_priv { · 34 unmodified lines
35 struct parallel_data *pd;35 struct parallel_data *pd;
36 int cb_cpu;36 int cb_cpu;
37 int cpu;37 int cpu;
38 unsigned int seq_nr;
38 int info;39 int info;
39 void (*parallel)(struct padata_priv *padata);40 void (*parallel)(struct padata_priv *padata);
40 void (*serial)(struct padata_priv *padata);41 void (*serial)(struct padata_priv *padata);
@@ -105,6 +106,7 @@ struct padata_cpumask { · 64 unmodified lines
105 * @reorder_objects: Number of objects waiting in the reorder queues.106 * @reorder_objects: Number of objects waiting in the reorder queues.
106 * @refcnt: Number of objects holding a reference on this parallel_data.107 * @refcnt: Number of objects holding a reference on this parallel_data.
107 * @max_seq_nr: Maximal used sequence number.108 * @max_seq_nr: Maximal used sequence number.
109 * @processed: Number of already processed objects.
108 * @cpu: Next CPU to be processed.110 * @cpu: Next CPU to be processed.
109 * @cpumask: The cpumasks in use for parallel and serial workers.111 * @cpumask: The cpumasks in use for parallel and serial workers.
110 * @reorder_work: work struct for reordering.112 * @reorder_work: work struct for reordering.
@@ -117,6 +119,7 @@ struct parallel_data { · 6 unmodified lines
117 atomic_t reorder_objects;119 atomic_t reorder_objects;
118 atomic_t refcnt;120 atomic_t refcnt;
119 atomic_t seq_nr;121 atomic_t seq_nr;
122 unsigned int processed;
120 int cpu;123 int cpu;
121 struct padata_cpumask cpumask;124 struct padata_cpumask cpumask;
122 struct work_struct reorder_work;125 struct work_struct reorder_work;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t