Skip to contentSkip to conversation

IB/hfi1: Allocate cpu mask on the heap to silence warning

PATCH Superseded [email protected] 2 participants 3 messages Aug 3, 2016 2 messages not in the archive

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 IB/hfi1: Allocate cpu mask on the heap to silence warning

From: Tadeusz Struk <[email protected]>

If CONFIG_FRAME_WARN is small (1K) and CONFIG_NR_CPUS big then a frame size warning is triggered during build. Allocate the cpu mask dynamically to silence the warning.

---
 drivers/infiniband/hw/hfi1/affinity.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/infiniband/hw/hfi1/affinity.c +13 -7
index 79575ee873f2..62be2eda1b96 100644
@@ -682,7 +682,7 @@ int hfi1_set_sdma_affinity(struct hfi1_devdata *dd, const char *buf,
 			   size_t count)
 {
 	struct hfi1_affinity_node *entry;
-	struct cpumask mask;
+	cpumask_var_t mask;
 	int ret, i;
 
 	spin_lock(&node_affinity.lock);
@@ -692,19 +692,24 @@ int hfi1_set_sdma_affinity(struct hfi1_devdata *dd, const char *buf,
 	if (!entry)
 		return -EINVAL;
 
-	ret = cpulist_parse(buf, &mask);
-	if (ret)
+	ret = zalloc_cpumask_var(&mask, GFP_KERNEL);
+	if (!ret)
 		return ret;
 
-	if (!cpumask_subset(&mask, cpu_online_mask) || cpumask_empty(&mask)) {
+	ret = cpulist_parse(buf, mask);
+	if (ret)
+		goto out;
+
+	if (!cpumask_subset(mask, cpu_online_mask) || cpumask_empty(mask)) {
 		dd_dev_warn(dd, "Invalid CPU mask\n");
-		return -EINVAL;
+		ret = -EINVAL;
+		goto out;
 	}
 
 	mutex_lock(&sdma_affinity_mutex);
 	/* reset the SDMA interrupt affinity details */
 	init_cpu_mask_set(&entry->def_intr);
-	cpumask_copy(&entry->def_intr.mask, &mask);
+	cpumask_copy(&entry->def_intr.mask, mask);
 	/*
 	 * Reassign the affinity for each SDMA interrupt.
 	 */
@@ -720,8 +725,9 @@ int hfi1_set_sdma_affinity(struct hfi1_devdata *dd, const char *buf,
 		if (ret)
 			break;
 	}
-
 	mutex_unlock(&sdma_affinity_mutex);
+out:
+	free_cpumask_var(mask);
 	return ret ? ret : strnlen(buf, PAGE_SIZE);
 }
 
Signature · 6 lines
1.8.2.3

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
In reply to a message not in the archive
Quoted 27 lines · On Wed, Aug 03, 2016 at 02:37:21PM -0400…

From: Tadeusz Struk <[email protected]>

If CONFIG_FRAME_WARN is small (1K) and CONFIG_NR_CPUS big then a frame size warning is triggered during build. Allocate the cpu mask dynamically to silence the warning.

---
 drivers/infiniband/hw/hfi1/affinity.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/infiniband/hw/hfi1/affinity.c +1 -1
index 79575ee873f2..62be2eda1b96 100644
@@ -682,7 +682,7 @@ int hfi1_set_sdma_affinity(struct hfi1_devdata *dd, const char *buf,
 			   size_t count)
 {
 	struct hfi1_affinity_node *entry;
-	struct cpumask mask;
+	cpumask_var_t mask;
 	int ret, i;
 
 	spin_lock(&node_affinity.lock);

drivers/infiniband/hw/hfi1/affinity.c int hfi1_set_sdma_affinity(struct hfi1_devdata *dd, const char *buf, · line 697

Quoted 8 lines
drivers/infiniband/hw/hfi1/affinity.c +2 -2
@@ -692,19 +692,24 @@ int hfi1_set_sdma_affinity(struct hfi1_devdata *dd, const char *buf,
 	if (!entry)
 		return -EINVAL;
 
-	ret = cpulist_parse(buf, &mask);
-	if (ret)
+	ret = zalloc_cpumask_var(&mask, GFP_KERNEL);
+	if (!ret)
 		return ret;

Ira,
Are you aware that before this change you returned value different from zero in case of error and now you will return zero?

Thanks

author
#4 lore raw
In reply to a message not in the archive
Quoted 36 lines · On Wed, Aug 03, 2016 at 02:37:21PM -0400…
Quoted 3 lines

From: Tadeusz Struk <[email protected]>

If CONFIG_FRAME_WARN is small (1K) and CONFIG_NR_CPUS big then a

frame

drivers/infiniband/hw/hfi1/affinity.c int hfi1_set_sdma_affinity(struct hfi1_devdata

Quoted 16 lines

size warning is triggered during build.
Allocate the cpu mask dynamically to silence the warning.

---
 drivers/infiniband/hw/hfi1/affinity.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/infiniband/hw/hfi1/affinity.c +0 -0
index 79575ee873f2..62be2eda1b96 100644
@@ -682,7 +682,7 @@ int hfi1_set_sdma_affinity(struct hfi1_devdata

*dd, const char *buf,

drivers/infiniband/hw/hfi1/affinity.c int hfi1_set_sdma_affinity(struct hfi1_devdata

Quoted 9 lines
drivers/infiniband/hw/hfi1/affinity.c +1 -1
 			   size_t count)
 {
 	struct hfi1_affinity_node *entry;
-	struct cpumask mask;
+	cpumask_var_t mask;
 	int ret, i;
 
 	spin_lock(&node_affinity.lock);
@@ -692,19 +692,24 @@ int hfi1_set_sdma_affinity(struct hfi1_devdata

*dd, const char *buf,

Quoted 3 lines
drivers/infiniband/hw/hfi1/affinity.c +0 -0
 	if (!entry)
 		return -EINVAL;
 
Quoted 10 lines

drivers/infiniband/hw/hfi1/affinity.c int hfi1_set_sdma_affinity(struct hfi1_devdata *dd, const char *buf, · line 697

Quoted 5 lines
drivers/infiniband/hw/hfi1/affinity.c +2 -2
-	ret = cpulist_parse(buf, &mask);
-	if (ret)
+	ret = zalloc_cpumask_var(&mask, GFP_KERNEL);
+	if (!ret)
 		return ret;

Ira,
Are you aware that before this change you returned value different from zero in case of error and now you will return zero?

No I did not realize that zalloc_cpumask_var returns bool...

Thanks, v2 on it's way.

Ira

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html