From ea8f0a8afbe2be286fa68f10377f6dbe5b402442 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 8 Jul 2015 15:41:22 +0000 Subject: [PATCH 1/4] nightly build: Add kernel version 4.1 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6409 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- nightly/conf/nightly.conf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nightly/conf/nightly.conf b/nightly/conf/nightly.conf index 46a9338f2..cb2a17a3e 100644 --- a/nightly/conf/nightly.conf +++ b/nightly/conf/nightly.conf @@ -3,7 +3,8 @@ ABT_DETAILS="x86_64" ABT_JOBS=5 ABT_KERNELS=" \ -4.0.7 \ +4.1 \ +4.0.7-nc \ 3.19.7-nc \ 3.18.8-nc \ 3.17.8-nc \ From b448c6edf44b8202bf491e61d1937fc08ff416d9 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 8 Jul 2015 18:23:24 +0000 Subject: [PATCH 2/4] ib_srpt: Add support for systems with more than 64 CPU's Avoid that the following warning is reported on systems with more than 64 CPU's: WARNING: CPU: 0 PID: 4762 at drivers/scst/srpt/ib_srpt.c:4179 init_module+0x1d8f42/0x1db887 [ib_srpt]() Call Trace: [] dump_stack+0x46/0x58 [] warn_slowpath_common+0x8c/0xc0 [] warn_slowpath_null+0x1a/0x20 [] init_module+0x1d8f42/0x1db887 [ib_srpt] [] ? 0xffffffffa0233000 [] ? 0xffffffffa005e000 [] ib_register_client+0x87/0xc0 [ib_core] [] init_module+0xef/0x1000 [ib_srpt] [] ? 0xffffffffa005e000 [] do_one_initcall+0x8c/0x1c0 [] ? __vunmap+0xc2/0x110 [] load_module+0x1b03/0x22a0 [] ? show_initstate+0x60/0x60 [] SyS_finit_module+0x8e/0x90 [] system_call_fastpath+0x12/0x17 Reported-by: Jack Wang git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6410 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 58 ++++++++++++++++++++++++++++------------------ srpt/src/ib_srpt.h | 4 +--- 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index d419a38f3..600439a9e 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -2433,13 +2433,11 @@ static u8 srpt_next_comp_vector(struct srpt_port *sport) u8 comp_vector; mutex_lock(&sport->mutex); - comp_vector = find_next_bit(sport->comp_v_mask, COMP_V_MASK_SIZE, - sport->comp_vector); - if (comp_vector >= COMP_V_MASK_SIZE) - comp_vector = find_next_bit(sport->comp_v_mask, - COMP_V_MASK_SIZE, 0); - sBUG_ON(comp_vector >= COMP_V_MASK_SIZE); - sport->comp_vector = comp_vector + 1; + comp_vector = cpumask_next(sport->comp_vector, &sport->comp_v_mask); + if (comp_vector >= nr_cpu_ids) + comp_vector = cpumask_next(-1, &sport->comp_v_mask); + sBUG_ON(comp_vector >= nr_cpu_ids); + sport->comp_vector = comp_vector; mutex_unlock(&sport->mutex); return comp_vector; @@ -3840,8 +3838,16 @@ static ssize_t show_comp_v_mask(struct kobject *kobj, if (!sport) goto out; - res = sprintf(buf, "%#lx\n%s", sport->comp_v_mask[0], - SCST_SYSFS_KEY_MARK "\n"); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28) + res = cpumask_scnprintf(buf, PAGE_SIZE, sport->comp_v_mask); +#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0) + res = cpumask_scnprintf(buf, PAGE_SIZE, &sport->comp_v_mask); +#else + res = scnprintf(buf, PAGE_SIZE, "%*pb", + cpumask_pr_args(&sport->comp_v_mask)); +#endif + res += scnprintf(&buf[res], PAGE_SIZE - res, "\n%s\n", + SCST_SYSFS_KEY_MARK); out: return res; @@ -3856,24 +3862,34 @@ static ssize_t store_comp_v_mask(struct kobject *kobj, struct srpt_port *sport = scst_tgt_get_tgt_priv(scst_tgt); struct srpt_device *sdev; int res = -E_TGT_PRIV_NOT_YET_SET; - unsigned long mask; + cpumask_var_t mask; + unsigned int i1, i2; if (!sport) goto out; sdev = sport->sdev; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39) - res = kstrtoul(buf, 16, &mask); + res = -ENOMEM; + if (!alloc_cpumask_var(&mask, GFP_KERNEL)) + goto out; +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0) + res = bitmap_parse(buf, count, cpumask_bits(mask), + NR_CPUS); #else - res = strict_strtoul(buf, 16, &mask); + res = cpumask_parse(buf, mask); #endif if (res) - goto out; + goto free_mask; res = -EINVAL; - if (mask == 0 || mask >= (1ULL << sdev->device->num_comp_vectors)) - goto out; - sport->comp_v_mask[0] = mask; + i1 = cpumask_next(-1, mask); + i2 = cpumask_next(sdev->device->num_comp_vectors - 1, mask); + if (i1 >= nr_cpu_ids || + (i2 >= sdev->device->num_comp_vectors && i2 < nr_cpu_ids)) + goto free_mask; + cpumask_copy(&sport->comp_v_mask, mask); res = count; +free_mask: + free_cpumask_var(mask); out: return res; } @@ -4190,11 +4206,9 @@ static void srpt_add_one(struct ib_device *device) INIT_LIST_HEAD(&sport->nexus_list); init_waitqueue_head(&sport->ch_releaseQ); mutex_init(&sport->mutex); - for (j = 0; j < sdev->device->num_comp_vectors; j++) { - if (WARN_ON_ONCE(j >= COMP_V_MASK_SIZE)) - break; - __set_bit(j, sport->comp_v_mask); - } + sport->comp_vector = -1; + for (j = 0; j < sdev->device->num_comp_vectors; j++) + cpumask_set_cpu(j, &sport->comp_v_mask); #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) && !defined(BACKPORT_LINUX_WORKQUEUE_TO_2_6_19) /* * A vanilla 2.6.19 or older kernel without backported OFED diff --git a/srpt/src/ib_srpt.h b/srpt/src/ib_srpt.h index 5e87a4141..62e87615d 100644 --- a/srpt/src/ib_srpt.h +++ b/srpt/src/ib_srpt.h @@ -138,8 +138,6 @@ enum { DEFAULT_MAX_RDMA_SIZE = 65536, RDMA_COMPL_TIMEOUT_S = 80, - - COMP_V_MASK_SIZE = 64, }; #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 1, 0) && \ @@ -434,7 +432,7 @@ struct srpt_port { struct mutex mutex; struct list_head nexus_list; struct scst_tgt *scst_tgt; - DECLARE_BITMAP(comp_v_mask, COMP_V_MASK_SIZE); + cpumask_t comp_v_mask; u8 comp_vector; bool enabled; }; From 44542c9752db26170c1d2dc5604a463cfa3c4c8b Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 9 Jul 2015 19:11:04 +0000 Subject: [PATCH 3/4] ib_srpt: Follow-up for r6410 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6411 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 600439a9e..6cb4c4461 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -3872,8 +3872,7 @@ static ssize_t store_comp_v_mask(struct kobject *kobj, if (!alloc_cpumask_var(&mask, GFP_KERNEL)) goto out; #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0) - res = bitmap_parse(buf, count, cpumask_bits(mask), - NR_CPUS); + res = bitmap_parse(buf, count, cpumask_bits(mask), nr_cpumask_bits); #else res = cpumask_parse(buf, mask); #endif From ac156d84c0253576aae7ef7fd13d40fa0dc20a1c Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 9 Jul 2015 19:12:09 +0000 Subject: [PATCH 4/4] scst.h: Add cpumask_var_t for kernel versions before 2.6.28 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6412 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/scst.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scst/include/scst.h b/scst/include/scst.h index 8b9f490d2..c95b6e143 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -150,7 +150,12 @@ static inline int scsi_bidi_cmnd(struct scsi_cmnd *cmd) } #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28) && defined(__LINUX_CPUMASK_H) +/* + * See also patch "cpumask: introduce new API, without changing anything" + * (commit ID 2d3854a37e8b). + */ +typedef cpumask_t cpumask_var_t[1]; #define cpumask_bits(maskp) ((maskp)->bits) #ifdef CONFIG_CPUMASK_OFFSTACK /* Assuming NR_CPUS is huge, a runtime limit is more efficient. Also,