Skip to content

Commit 016862e

Browse files
committed
fuse: {io-uring} drop static queue mapping in favour of bitmaps
The two preceding cherry-picks ("Use a bitmap which queues are available" and "Distribute load among queues") switch queue selection to the per-NUMA availability/registration cpumasks. This tree also carried an alternative static cpu->qid mapping (struct fuse_queue_map, ring->numa_q_map/q_map, fuse_uring_cpu_qid_mapping()) from a different backport lineage, which the bitmap selector no longer reads. Remove the now-dead static mapping (allocation, per-queue population, teardown and the FUSE_URING_Q_THRESHOLD/FUSE_URING_Q_TRIES knobs) so only the bitmap mechanism remains. Signed-off-by: Horst Birthelmer <hbirthelmer@ddn.com>
1 parent ce153d2 commit 016862e

2 files changed

Lines changed: 6 additions & 135 deletions

File tree

fs/fuse/dev_uring.c

Lines changed: 6 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ MODULE_PARM_DESC(enable_uring,
2222
#define FUSE_RING_HEADER_PG 0
2323
#define FUSE_RING_PAYLOAD_PG 1
2424

25-
/* Threshold that determines if a better queue should be searched for */
26-
#define FUSE_URING_Q_THRESHOLD 2
27-
28-
/* Number of (re)tries to find a better queue */
29-
#define FUSE_URING_Q_TRIES 3
30-
3125
/* redfs only to allow patch backports */
3226
#define IO_URING_F_TASK_DEAD (1 << 13)
3327

@@ -235,25 +229,6 @@ static void io_pages_free(struct page ***pages, int npages)
235229
*pages = NULL;
236230
}
237231

238-
static void fuse_ring_destruct_q_map(struct fuse_queue_map *q_map)
239-
{
240-
free_cpumask_var(q_map->registered_q_mask);
241-
kfree(q_map->cpu_to_qid);
242-
}
243-
244-
static void fuse_uring_destruct_q_masks(struct fuse_ring *ring)
245-
{
246-
int node;
247-
248-
fuse_ring_destruct_q_map(&ring->q_map);
249-
250-
if (ring->numa_q_map) {
251-
for (node = 0; node < ring->nr_numa_nodes; node++)
252-
fuse_ring_destruct_q_map(&ring->numa_q_map[node]);
253-
kfree(ring->numa_q_map);
254-
}
255-
}
256-
257232
static void fuse_ring_destruct_q_masks(struct fuse_ring *ring)
258233
{
259234
free_cpumask_var(ring->avail_q_mask);
@@ -305,48 +280,12 @@ void fuse_uring_destruct(struct fuse_conn *fc)
305280
ring->queues[qid] = NULL;
306281
}
307282

308-
fuse_uring_destruct_q_masks(ring);
309283
fuse_ring_destruct_q_masks(ring);
310284
kfree(ring->queues);
311285
kfree(ring);
312286
fc->ring = NULL;
313287
}
314288

315-
static int fuse_uring_init_q_map(struct fuse_queue_map *q_map, size_t nr_cpu)
316-
{
317-
if (!zalloc_cpumask_var(&q_map->registered_q_mask, GFP_KERNEL_ACCOUNT))
318-
return -ENOMEM;
319-
320-
q_map->cpu_to_qid = kcalloc(nr_cpu, sizeof(*q_map->cpu_to_qid),
321-
GFP_KERNEL_ACCOUNT);
322-
if (!q_map->cpu_to_qid)
323-
return -ENOMEM;
324-
325-
return 0;
326-
}
327-
328-
static int fuse_uring_create_q_masks(struct fuse_ring *ring, size_t nr_queues)
329-
{
330-
int err, node;
331-
332-
err = fuse_uring_init_q_map(&ring->q_map, nr_queues);
333-
if (err)
334-
return err;
335-
336-
ring->numa_q_map = kcalloc(ring->nr_numa_nodes,
337-
sizeof(*ring->numa_q_map),
338-
GFP_KERNEL_ACCOUNT);
339-
if (!ring->numa_q_map)
340-
return -ENOMEM;
341-
for (node = 0; node < ring->nr_numa_nodes; node++) {
342-
err = fuse_uring_init_q_map(&ring->numa_q_map[node],
343-
nr_queues);
344-
if (err)
345-
return err;
346-
}
347-
return 0;
348-
}
349-
350289
static int fuse_ring_create_q_masks(struct fuse_ring *ring, int nr_queues)
351290
{
352291
if (!zalloc_cpumask_var(&ring->avail_q_mask, GFP_KERNEL_ACCOUNT))
@@ -355,19 +294,19 @@ static int fuse_ring_create_q_masks(struct fuse_ring *ring, int nr_queues)
355294
if (!zalloc_cpumask_var(&ring->registered_q_mask, GFP_KERNEL_ACCOUNT))
356295
return -ENOMEM;
357296

358-
ring->per_numa_avail_q_mask = kmalloc_array(ring->nr_numa_nodes,
359-
sizeof(struct cpumask *),
360-
GFP_KERNEL_ACCOUNT);
297+
ring->per_numa_avail_q_mask = kcalloc(ring->nr_numa_nodes,
298+
sizeof(*ring->per_numa_avail_q_mask),
299+
GFP_KERNEL_ACCOUNT);
361300
if (!ring->per_numa_avail_q_mask)
362301
return -ENOMEM;
363302
for (int node = 0; node < ring->nr_numa_nodes; node++)
364303
if (!zalloc_cpumask_var(&ring->per_numa_avail_q_mask[node],
365304
GFP_KERNEL_ACCOUNT))
366305
return -ENOMEM;
367306

368-
ring->numa_registered_q_mask = kmalloc_array(ring->nr_numa_nodes,
369-
sizeof(struct cpumask *),
370-
GFP_KERNEL_ACCOUNT);
307+
ring->numa_registered_q_mask = kcalloc(ring->nr_numa_nodes,
308+
sizeof(*ring->numa_registered_q_mask),
309+
GFP_KERNEL_ACCOUNT);
371310
if (!ring->numa_registered_q_mask)
372311
return -ENOMEM;
373312
for (int node = 0; node < ring->nr_numa_nodes; node++) {
@@ -404,10 +343,6 @@ static struct fuse_ring *fuse_uring_create(struct fuse_conn *fc)
404343
max_payload_size = max(FUSE_MIN_READ_BUFFER, fc->max_write);
405344
max_payload_size = max(max_payload_size, fc->max_pages * PAGE_SIZE);
406345

407-
err = fuse_uring_create_q_masks(ring, nr_queues);
408-
if (err)
409-
goto out_err;
410-
411346
err = fuse_ring_create_q_masks(ring, nr_queues);
412347
if (err)
413348
goto out_err;
@@ -431,43 +366,18 @@ static struct fuse_ring *fuse_uring_create(struct fuse_conn *fc)
431366
return ring;
432367

433368
out_err:
434-
fuse_uring_destruct_q_masks(ring);
435369
fuse_ring_destruct_q_masks(ring);
436370
kfree(ring->queues);
437371
kfree(ring);
438372
return res;
439373
}
440374

441-
static void fuse_uring_cpu_qid_mapping(struct fuse_ring *ring, int qid,
442-
struct fuse_queue_map *q_map,
443-
int node)
444-
{
445-
int cpu, qid_idx, mapping_count = 0;
446-
size_t nr_queues;
447-
448-
cpumask_set_cpu(qid, q_map->registered_q_mask);
449-
nr_queues = cpumask_weight(q_map->registered_q_mask);
450-
for (cpu = 0; cpu < ring->max_nr_queues; cpu++) {
451-
if (node != -1 && cpu_to_node(cpu) != node)
452-
continue;
453-
454-
qid_idx = mapping_count % nr_queues;
455-
q_map->cpu_to_qid[cpu] = cpumask_nth(qid_idx,
456-
q_map->registered_q_mask);
457-
mapping_count++;
458-
pr_debug("%s node=%d qid=%d qid_idx=%d nr_queues=%zu %d->%d\n",
459-
__func__, node, qid, qid_idx, nr_queues, cpu,
460-
q_map->cpu_to_qid[cpu]);
461-
}
462-
}
463-
464375
static struct fuse_ring_queue *fuse_uring_create_queue(struct fuse_ring *ring,
465376
int qid)
466377
{
467378
struct fuse_conn *fc = ring->fc;
468379
struct fuse_ring_queue *queue;
469380
struct list_head *pq;
470-
int node;
471381

472382
queue = kzalloc(sizeof(*queue), GFP_KERNEL_ACCOUNT);
473383
if (!queue)
@@ -507,21 +417,6 @@ static struct fuse_ring_queue *fuse_uring_create_queue(struct fuse_ring *ring,
507417
*/
508418
WRITE_ONCE(ring->queues[qid], queue);
509419

510-
/* Static mapping from cpu to per numa queues */
511-
node = cpu_to_node(qid);
512-
fuse_uring_cpu_qid_mapping(ring, qid, &ring->numa_q_map[node], node);
513-
514-
/*
515-
* smp_store_release, as the variable is read without fc->lock and
516-
* we need to avoid compiler re-ordering of updating the nr_queues
517-
* and setting ring->numa_queues[node].cpu_to_qid above
518-
*/
519-
smp_store_release (&ring->numa_q_map[node].nr_queues,
520-
ring->numa_q_map[node].nr_queues + 1);
521-
522-
/* global mapping */
523-
fuse_uring_cpu_qid_mapping(ring, qid, &ring->q_map, -1);
524-
525420
spin_unlock(&fc->lock);
526421

527422
return queue;
@@ -703,13 +598,6 @@ void fuse_uring_stop_queues(struct fuse_ring *ring)
703598
}
704599
}
705600

706-
/* Reset all queue masks, we won't process any more IO */
707-
cpumask_clear(ring->q_map.registered_q_mask);
708-
for (node = 0; node < ring->nr_numa_nodes; node++) {
709-
if (ring->numa_q_map)
710-
cpumask_clear(ring->numa_q_map[node].registered_q_mask);
711-
}
712-
713601
if (atomic_read(&ring->queue_refs) > 0) {
714602
ring->teardown_time = jiffies;
715603
INIT_DELAYED_WORK(&ring->async_teardown_work,

fs/fuse/dev_uring_i.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,6 @@ struct fuse_ring_queue {
111111
bool stopped;
112112
};
113113

114-
struct fuse_queue_map {
115-
/* Tracks which queues are registered */
116-
cpumask_var_t registered_q_mask;
117-
118-
/* number of registered queues */
119-
size_t nr_queues;
120-
121-
/* cpu to qid mapping */
122-
int *cpu_to_qid;
123-
};
124-
125114
/**
126115
* Describes if uring is for communication and holds alls the data needed
127116
* for uring communication
@@ -146,12 +135,6 @@ struct fuse_ring {
146135
*/
147136
unsigned int stop_debug_log : 1;
148137

149-
/* per numa node queue tracking */
150-
struct fuse_queue_map *numa_q_map;
151-
152-
/* all queue tracking */
153-
struct fuse_queue_map q_map;
154-
155138
/* Tracks which queues are available (empty) globally */
156139
cpumask_var_t avail_q_mask;
157140

0 commit comments

Comments
 (0)