diff mbox

[V9,02/13] powerpc, perf: Change type of the bhrb_users variable

Message ID 1434370268-19056-3-git-send-email-khandual@linux.vnet.ibm.com (mailing list archive)
State Superseded
Headers show

Commit Message

Anshuman Khandual June 15, 2015, 12:10 p.m. UTC
This patch just changes data type of bhrb_users variable from
int to unsigned int because it never contains a negative value.

Reported-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
---
 arch/powerpc/perf/core-book3s.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Daniel Axtens June 25, 2015, 5:42 a.m. UTC | #1
> -	int				bhrb_users;
> +	unsigned int			bhrb_users;

OK, so this is a good start.

A quick git grep for bhrb_users reveals this:
perf/core-book3s.c:     WARN_ON_ONCE(cpuhw->bhrb_users < 0);

That occurs in power_pmu_bhrb_disable, immediately following a decrement
of bhrb_users. Now that the test can never be true, this patch should
change the function to check if bhrb_users is 0 before decrementing.

>  	void				*bhrb_context;
>  	struct	perf_branch_stack	bhrb_stack;
>  	struct	perf_branch_entry	bhrb_entries[BHRB_MAX_ENTRIES];
Anshuman Khandual June 25, 2015, 12:51 p.m. UTC | #2
On 06/25/2015 11:12 AM, Daniel Axtens wrote:
>> -	int				bhrb_users;
>> +	unsigned int			bhrb_users;
> 
> OK, so this is a good start.
> 
> A quick git grep for bhrb_users reveals this:
> perf/core-book3s.c:     WARN_ON_ONCE(cpuhw->bhrb_users < 0);
> 
> That occurs in power_pmu_bhrb_disable, immediately following a decrement
> of bhrb_users. Now that the test can never be true, this patch should
> change the function to check if bhrb_users is 0 before decrementing.

Sure. Would replace with 'WARN_ON_ONCE(!cpuhw->bhrb_users)' before
decrementing bhrb_users in the function.
diff mbox

Patch

diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index c246e65..9798f00 100644
--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -53,7 +53,7 @@  struct cpu_hw_events {
 
 	/* BHRB bits */
 	u64				bhrb_filter;	/* BHRB HW branch filter */
-	int				bhrb_users;
+	unsigned int			bhrb_users;
 	void				*bhrb_context;
 	struct	perf_branch_stack	bhrb_stack;
 	struct	perf_branch_entry	bhrb_entries[BHRB_MAX_ENTRIES];