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
1212 #include <linux/workqueue.h>
1313 #include <linux/spinlock.h>
1414 #include <linux/list.h>
15−#include <linux/timer.h>
1615 #include <linux/notifier.h>
1716 #include <linux/kobject.h>
1817
@@ -73,18 +72,14 @@ struct padata_serial_queue { · 54 unmodified lines
7372 * @serial: List to wait for serialization after reordering.
7473 * @pwork: work struct for parallelization.
7574 * @swork: work struct for serialization.
76− * @pd: Backpointer to the internal control structure.
7775 * @work: work struct for parallelization.
78− * @reorder_work: work struct for reordering.
7976 * @num_obj: Number of objects that are processed by this cpu.
8077 * @cpu_index: Index of the cpu.
8178 */
8279 struct padata_parallel_queue {
8380 struct padata_list parallel;
8481 struct padata_list reorder;
85− struct parallel_data *pd;
8682 struct work_struct work;
87− struct work_struct reorder_work;
8883 atomic_t num_obj;
8984 int cpu_index;
9085 };
@@ -110,10 +105,10 @@ struct padata_cpumask { · 19 unmodified lines
110105 * @reorder_objects: Number of objects waiting in the reorder queues.
111106 * @refcnt: Number of objects holding a reference on this parallel_data.
112107 * @max_seq_nr: Maximal used sequence number.
108+ * @cpu: Next CPU to be processed.
113109 * @cpumask: The cpumasks in use for parallel and serial workers.
110+ * @reorder_work: work struct for reordering.
114111 * @lock: Reorder lock.
115− * @processed: Number of already processed objects.
116− * @timer: Reorder timer.
117112 */
118113 struct parallel_data {
119114 struct padata_instance *pinst;
@@ -122,10 +117,10 @@ struct parallel_data { · 2 unmodified lines
122117 atomic_t reorder_objects;
123118 atomic_t refcnt;
124119 atomic_t seq_nr;
120+ int cpu;
125121 struct padata_cpumask cpumask;
122+ struct work_struct reorder_work;
126123 spinlock_t lock ____cacheline_aligned;
127− unsigned int processed;
128− struct timer_list timer;
129124 };
130125
131126 /**

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