Skip to contentSkip to conversation

perf: arm_spe: remove unnecessary zero check

PATCH In review luanshi 2 participants 2 messages Feb 26, 2020 – Mar 9, 2020 Arm PMU profiling and debugging

lore
Share & tools
lore

luanshi

author
#0 lore raw

PATCH 1/1 perf: arm_spe: remove unnecessary zero check

The "nr_pages" variable has been checked before, it can't be zero, so a check here would be useless.

---
 drivers/perf/arm_spe_pmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/perf/arm_spe_pmu.c +1 -1
index 4e4984a..b72c048 100644
@@ -831,7 +831,7 @@ static void *arm_spe_pmu_setup_aux(struct perf_event *event, void **pages,
 	 * parts and give userspace a fighting chance of getting some
 	 * useful data out of it.
 	 */
-	if (!nr_pages || (snapshot && (nr_pages & 1)))
+	if (snapshot && (nr_pages & 1))
 		return NULL;
 
 	if (cpu == -1)
Signature · 1 line
1.8.3.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 3 lines · luanshi

The "nr_pages" variable has been checked before, it can't be zero, so a check here would be useless.

As the commit message states, a done:

| /* We need at least two pages for this to work. */
| if (nr_pages < 2)
|         return NULL;

... so this looks sensible to me:

Mark.

Quoted 20 lines
---
 drivers/perf/arm_spe_pmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/perf/arm_spe_pmu.c +1 -1
index 4e4984a..b72c048 100644
@@ -831,7 +831,7 @@ static void *arm_spe_pmu_setup_aux(struct perf_event *event, void **pages,
 	 * parts and give userspace a fighting chance of getting some
 	 * useful data out of it.
 	 */
-	if (!nr_pages || (snapshot && (nr_pages & 1)))
+	if (snapshot && (nr_pages & 1))
 		return NULL;
 
 	if (cpu == -1)
Signature · 1 line
1.8.3.1