[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <11D2FE4DB4B8114EA7D818424F28D1414289A041@SHSMSX104.ccr.corp.intel.com>
Date: Fri, 12 Oct 2018 05:36:22 +0000
From: "Jin, Zhi" <zhi.jin@...el.com>
To: "alexander.shishkin@...ux.intel.com"
<alexander.shishkin@...ux.intel.com>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"Jin, Zhi" <zhi.jin@...el.com>
Subject: RE: [PATCH] stm class: increase pos if no free channels found
Hi Alexander,
Any comments about this patch?
BRs
Zhi Jin
> -----Original Message-----
> From: Jin, Zhi
> Sent: Thursday, September 06, 2018 3:22 PM
> To: alexander.shishkin@...ux.intel.com
> Cc: linux-kernel@...r.kernel.org; Jin, Zhi <zhi.jin@...el.com>
> Subject: [PATCH] stm class: increase pos if no free channels found
>
> Considering this case in find_free_channels():
>
> bitmap:
> +------------------+-+-+-+-+-+-+-+-+-+-+
> | ...... |0|0|0|0|0|0|0|1|0|0|
> +------------------+-+-+-+-+-+-+-+-+-+-+
>
> 1. Channel #2 has been occupied, so bit #2 is 1, and the others
> are all 0.
> 2. Another thread tries to find 4 free channels from #0.
> 3. In the 1st loop, pos starts from 0, and then it checks if the
> following 4 bits are all 0, but fails, as bit#2 is 1.
> 4. In the 2st loop, pos is not updated, and still starts from 0,
> so nothing changes against loop #1.
> 5. Dead loop ...
>
> This patch is to update the pos in step #3 to avoid the issue.
>
> Fixes: 7bd1d4093c2f ("stm class: Introduce an abstraction for System
> Trace Module devices")
> Signed-off-by: Zhi Jin <zhi.jin@...el.com>
> ---
> drivers/hwtracing/stm/core.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
> index 10bcb5d73f90..c86a979b9bd7 100644
> --- a/drivers/hwtracing/stm/core.c
> +++ b/drivers/hwtracing/stm/core.c
> @@ -244,6 +244,8 @@ static int find_free_channels(unsigned long *bitmap,
> unsigned int start,
> ;
> if (i == width)
> return pos;
> +
> + pos += i;
> }
>
> return -1;
> --
> 2.7.4
Powered by blists - more mailing lists