History

padata: Replace delayed timer with immediate workqueue in padata_reorder

The function padata_reorder will use a timer when it cannot progress while completed jobs are outstanding (pd->reorder_objects > 0). This is suboptimal as if we do end up using the timer then it would have introduced a gratuitous delay of one second. In fact we can easily distinguish between whether completed jobs are outstanding and whether we can make progress. All we have to do is look at the next pqueue list. This patch does that by replacing pd->processed with pd->cpu so that the next pqueue is more accessible. A work queue is used instead of the original try_again to avoid hogging the CPU. Note that we don't bother removing the work queue in padata_flush_queues because the whole premise is broken. You cannot flush async crypto requests so it makes no sense to even try. A subsequent patch will fix it by replacing it with a ref counting scheme.

Herbert Xu committed 7 years ago

Commit 6fc4dbc1 parent 97ac82d2 files · +22 −88Browse files

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

Unified · Split

include/linux/padata.h+4−9
@@ -12,7 +12,6 @@ · 11 unmodified lines
12#include <linux/workqueue.h>12#include <linux/workqueue.h>
13#include <linux/spinlock.h>13#include <linux/spinlock.h>
14#include <linux/list.h>14#include <linux/list.h>
15#include <linux/timer.h>
16#include <linux/notifier.h>15#include <linux/notifier.h>
17#include <linux/kobject.h>16#include <linux/kobject.h>
18 17
@@ -73,18 +72,14 @@ struct padata_serial_queue { · 54 unmodified lines
73 * @serial: List to wait for serialization after reordering.72 * @serial: List to wait for serialization after reordering.
74 * @pwork: work struct for parallelization.73 * @pwork: work struct for parallelization.
75 * @swork: work struct for serialization.74 * @swork: work struct for serialization.
76 * @pd: Backpointer to the internal control structure.
77 * @work: work struct for parallelization.75 * @work: work struct for parallelization.
78 * @reorder_work: work struct for reordering.
79 * @num_obj: Number of objects that are processed by this cpu.76 * @num_obj: Number of objects that are processed by this cpu.
80 * @cpu_index: Index of the cpu.77 * @cpu_index: Index of the cpu.
81 */78 */
82struct padata_parallel_queue {79struct padata_parallel_queue {
83 struct padata_list parallel;80 struct padata_list parallel;
84 struct padata_list reorder;81 struct padata_list reorder;
85 struct parallel_data *pd;
86 struct work_struct work;82 struct work_struct work;
87 struct work_struct reorder_work;
88 atomic_t num_obj;83 atomic_t num_obj;
89 int cpu_index;84 int cpu_index;
90};85};
@@ -110,10 +105,10 @@ struct padata_cpumask { · 19 unmodified lines
110 * @reorder_objects: Number of objects waiting in the reorder queues.105 * @reorder_objects: Number of objects waiting in the reorder queues.
111 * @refcnt: Number of objects holding a reference on this parallel_data.106 * @refcnt: Number of objects holding a reference on this parallel_data.
112 * @max_seq_nr: Maximal used sequence number.107 * @max_seq_nr: Maximal used sequence number.
108 * @cpu: Next CPU to be processed.
113 * @cpumask: The cpumasks in use for parallel and serial workers.109 * @cpumask: The cpumasks in use for parallel and serial workers.
110 * @reorder_work: work struct for reordering.
114 * @lock: Reorder lock.111 * @lock: Reorder lock.
115 * @processed: Number of already processed objects.
116 * @timer: Reorder timer.
117 */112 */
118struct parallel_data {113struct parallel_data {
119 struct padata_instance *pinst;114 struct padata_instance *pinst;
@@ -122,10 +117,10 @@ struct parallel_data { · 2 unmodified lines
122 atomic_t reorder_objects;117 atomic_t reorder_objects;
123 atomic_t refcnt;118 atomic_t refcnt;
124 atomic_t seq_nr;119 atomic_t seq_nr;
120 int cpu;
125 struct padata_cpumask cpumask;121 struct padata_cpumask cpumask;
122 struct work_struct reorder_work;
126 spinlock_t lock ____cacheline_aligned;123 spinlock_t lock ____cacheline_aligned;
127 unsigned int processed;
128 struct timer_list timer;
129};124};
130 125
131/**126/**

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