Skip to content

Commit b050496

Browse files
committed
Merge tag 'dma-mapping-6.10-2024-05-31' of git://git.infradead.org/users/hch/dma-mapping
Pull dma-mapping fixes from Christoph Hellwig: - dma-mapping benchmark error handling fixes (Fedor Pchelkin) - correct a config symbol reference in the DMA API documentation (Lukas Bulwahn) * tag 'dma-mapping-6.10-2024-05-31' of git://git.infradead.org/users/hch/dma-mapping: Documentation/core-api: correct reference to SWIOTLB_DYNAMIC dma-mapping: benchmark: handle NUMA_NO_NODE correctly dma-mapping: benchmark: fix node id validation dma-mapping: benchmark: avoid needless copy_to_user if benchmark fails dma-mapping: benchmark: fix up kthread-related error handling
2 parents 7d88cc8 + 82d71b5 commit b050496

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

Documentation/core-api/swiotlb.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ alignment larger than PAGE_SIZE.
192192

193193
Dynamic swiotlb
194194
---------------
195-
When CONFIG_DYNAMIC_SWIOTLB is enabled, swiotlb can do on-demand expansion of
195+
When CONFIG_SWIOTLB_DYNAMIC is enabled, swiotlb can do on-demand expansion of
196196
the amount of memory available for allocation as bounce buffers. If a bounce
197197
buffer request fails due to lack of available space, an asynchronous background
198198
task is kicked off to allocate memory from general system memory and turn it

kernel/dma/map_benchmark.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ static int do_map_benchmark(struct map_benchmark_data *map)
101101
struct task_struct **tsk;
102102
int threads = map->bparam.threads;
103103
int node = map->bparam.node;
104-
const cpumask_t *cpu_mask = cpumask_of_node(node);
105104
u64 loops;
106105
int ret = 0;
107106
int i;
@@ -118,11 +117,13 @@ static int do_map_benchmark(struct map_benchmark_data *map)
118117
if (IS_ERR(tsk[i])) {
119118
pr_err("create dma_map thread failed\n");
120119
ret = PTR_ERR(tsk[i]);
120+
while (--i >= 0)
121+
kthread_stop(tsk[i]);
121122
goto out;
122123
}
123124

124125
if (node != NUMA_NO_NODE)
125-
kthread_bind_mask(tsk[i], cpu_mask);
126+
kthread_bind_mask(tsk[i], cpumask_of_node(node));
126127
}
127128

128129
/* clear the old value in the previous benchmark */
@@ -139,13 +140,17 @@ static int do_map_benchmark(struct map_benchmark_data *map)
139140

140141
msleep_interruptible(map->bparam.seconds * 1000);
141142

142-
/* wait for the completion of benchmark threads */
143+
/* wait for the completion of all started benchmark threads */
143144
for (i = 0; i < threads; i++) {
144-
ret = kthread_stop(tsk[i]);
145-
if (ret)
146-
goto out;
145+
int kthread_ret = kthread_stop_put(tsk[i]);
146+
147+
if (kthread_ret)
148+
ret = kthread_ret;
147149
}
148150

151+
if (ret)
152+
goto out;
153+
149154
loops = atomic64_read(&map->loops);
150155
if (likely(loops > 0)) {
151156
u64 map_variance, unmap_variance;
@@ -170,8 +175,6 @@ static int do_map_benchmark(struct map_benchmark_data *map)
170175
}
171176

172177
out:
173-
for (i = 0; i < threads; i++)
174-
put_task_struct(tsk[i]);
175178
put_device(map->dev);
176179
kfree(tsk);
177180
return ret;
@@ -208,7 +211,8 @@ static long map_benchmark_ioctl(struct file *file, unsigned int cmd,
208211
}
209212

210213
if (map->bparam.node != NUMA_NO_NODE &&
211-
!node_possible(map->bparam.node)) {
214+
(map->bparam.node < 0 || map->bparam.node >= MAX_NUMNODES ||
215+
!node_possible(map->bparam.node))) {
212216
pr_err("invalid numa node\n");
213217
return -EINVAL;
214218
}
@@ -252,6 +256,9 @@ static long map_benchmark_ioctl(struct file *file, unsigned int cmd,
252256
* dma_mask changed by benchmark
253257
*/
254258
dma_set_mask(map->dev, old_dma_mask);
259+
260+
if (ret)
261+
return ret;
255262
break;
256263
default:
257264
return -EINVAL;

0 commit comments

Comments
 (0)