uniontech inclusion category: bugfix bugzilla: NA CVE: NA
---------------------
If a node doesn't have oneline cpu, we shouldn't create presister on it.
Signed-off-by: Gou Hao gouhao@uniontech.com --- fs/eulerfs/dep.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-)
diff --git a/fs/eulerfs/dep.c b/fs/eulerfs/dep.c index 4f8bad75c0c3..e85130f7eddc 100644 --- a/fs/eulerfs/dep.c +++ b/fs/eulerfs/dep.c @@ -700,27 +700,15 @@ static int persister(void *data) return 0; }
-static inline int get_socket_num(void) -{ - int num = 0; - int cpu, sock; - for_each_possible_cpu(cpu) { - sock = cpu_to_node(cpu); - if (sock > num) - num = sock; - } - num += 1; - return num; -}
int dep_init(struct super_block *sb) { struct eufs_sb_info *sbi = EUFS_SB(sb); - int cpu; - int i, j; + int cpu, j; char name[BDEVNAME_SIZE]; int err; - int socket_num = get_socket_num(); + int socket_num, node; + unsigned long node_mask;
sbi->persistee_list = alloc_percpu(struct llist_head); if (!sbi->persistee_list) { @@ -728,11 +716,18 @@ int dep_init(struct super_block *sb) goto cleanup; }
- sbi->socket_num = socket_num; - - /* init each llist */ - for_each_possible_cpu(cpu) + socket_num = node_mask = 0; + for_each_online_cpu(cpu) { + /* init each llist */ init_llist_head(per_cpu_ptr(sbi->persistee_list, cpu)); + node = cpu_to_node(cpu); + node_mask |= 1 << node; + if (node > socket_num) + socket_num++; + } + socket_num++; + + sbi->socket_num = socket_num;
sbi->persisters = kmalloc(sizeof(struct task_struct *) * persisters_per_socket * socket_num, @@ -752,23 +747,28 @@ int dep_init(struct super_block *sb) init_waitqueue_head(&sbi->sync_wq);
bdevname(sb->s_bdev, name); - for (i = 0; i < socket_num; ++i) { + + node = -1; + while (1) { + node = find_next_bit(&node_mask, BITS_PER_LONG, node + 1); + if (node >= BITS_PER_LONG) + break; for (j = 0; j < persisters_per_socket; ++j) { - int idx = i * persisters_per_socket + j; + int idx = node * persisters_per_socket + j;
sbi->persisters[idx] = kthread_create_on_node( - persister, sb, i, "hmfs/%s-%d.%d", name, i, j); + persister, sb, node, "hmfs/%s-%d.%d", name, node, j);
if (IS_ERR(sbi->persisters[idx])) { err = PTR_ERR(sbi->persisters[idx]); pr_err("create persister %s-%d.%d error %d", - name, i, j, err); + name, node, j, err); sbi->persisters[idx] = NULL; goto cleanup; }
set_cpus_allowed_ptr(sbi->persisters[idx], - cpumask_of_node(i)); + cpumask_of_node(node));
wake_up_process(sbi->persisters[idx]); }