All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] IB/hfi1: Fix a wrapping test (make it less strict)
@ 2017-10-13 10:56 ` Dan Carpenter
  0 siblings, 0 replies; 19+ messages in thread
From: Dan Carpenter @ 2017-10-13 10:56 UTC (permalink / raw)
  To: Mike Marciniszyn
  Cc: Dennis Dalessandro, Doug Ledford, Sean Hefty, Hal Rosenstock,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

The "2 * UINT_MAX" overflows so the test is essentially doing this:

	if ((u64)(ts - cce->timestamp) > UINT_MAX - 1) {

I've changed it to a 64bit type.

Signed-off-by: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
---
Not tested.

diff --git a/drivers/infiniband/hw/hfi1/mad.c b/drivers/infiniband/hw/hfi1/mad.c
index f4c0ffc040cc..3aeea8afd44f 100644
--- a/drivers/infiniband/hw/hfi1/mad.c
+++ b/drivers/infiniband/hw/hfi1/mad.c
@@ -3781,7 +3781,7 @@ static int __subn_get_opa_hfi1_cong_log(struct opa_smp *smp, u32 am,
 		 * required to wrap the counter are supposed to
 		 * be zeroed (CA10-49 IBTA, release 1.2.1, V1).
 		 */
-		if ((u64)(ts - cce->timestamp) > (2 * UINT_MAX))
+		if ((u64)(ts - cce->timestamp) > (2ULL * UINT_MAX))
 			continue;
 		memcpy(cong_log->events[i].local_qp_cn_entry, &cce->lqpn, 3);
 		memcpy(cong_log->events[i].remote_qp_number_cn_entry,
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH] IB/hfi1: Fix a wrapping test (make it less strict)
@ 2017-10-13 10:56 ` Dan Carpenter
  0 siblings, 0 replies; 19+ messages in thread
From: Dan Carpenter @ 2017-10-13 10:56 UTC (permalink / raw)
  To: Mike Marciniszyn
  Cc: Dennis Dalessandro, Doug Ledford, Sean Hefty, Hal Rosenstock,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

The "2 * UINT_MAX" overflows so the test is essentially doing this:

	if ((u64)(ts - cce->timestamp) > UINT_MAX - 1) {

I've changed it to a 64bit type.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Not tested.

diff --git a/drivers/infiniband/hw/hfi1/mad.c b/drivers/infiniband/hw/hfi1/mad.c
index f4c0ffc040cc..3aeea8afd44f 100644
--- a/drivers/infiniband/hw/hfi1/mad.c
+++ b/drivers/infiniband/hw/hfi1/mad.c
@@ -3781,7 +3781,7 @@ static int __subn_get_opa_hfi1_cong_log(struct opa_smp *smp, u32 am,
 		 * required to wrap the counter are supposed to
 		 * be zeroed (CA10-49 IBTA, release 1.2.1, V1).
 		 */
-		if ((u64)(ts - cce->timestamp) > (2 * UINT_MAX))
+		if ((u64)(ts - cce->timestamp) > (2ULL * UINT_MAX))
 			continue;
 		memcpy(cong_log->events[i].local_qp_cn_entry, &cce->lqpn, 3);
 		memcpy(cong_log->events[i].remote_qp_number_cn_entry,

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH] IB/hfi1: Fix a wrapping test (make it less strict)
  2017-10-13 10:56 ` Dan Carpenter
@ 2017-10-23 15:05   ` Doug Ledford
  -1 siblings, 0 replies; 19+ messages in thread
From: Doug Ledford @ 2017-10-23 15:05 UTC (permalink / raw)
  To: Dan Carpenter, Mike Marciniszyn
  Cc: Dennis Dalessandro, Sean Hefty, Hal Rosenstock, linux-rdma,
	kernel-janitors

On Fri, 2017-10-13 at 13:56 +0300, Dan Carpenter wrote:
> The "2 * UINT_MAX" overflows so the test is essentially doing this:
> 
> 	if ((u64)(ts - cce->timestamp) > UINT_MAX - 1) {
> 
> I've changed it to a 64bit type.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> Not tested.
> 
> diff --git a/drivers/infiniband/hw/hfi1/mad.c
> b/drivers/infiniband/hw/hfi1/mad.c
> index f4c0ffc040cc..3aeea8afd44f 100644
> --- a/drivers/infiniband/hw/hfi1/mad.c
> +++ b/drivers/infiniband/hw/hfi1/mad.c
> @@ -3781,7 +3781,7 @@ static int __subn_get_opa_hfi1_cong_log(struct
> opa_smp *smp, u32 am,
>  		 * required to wrap the counter are supposed to
>  		 * be zeroed (CA10-49 IBTA, release 1.2.1, V1).
>  		 */
> -		if ((u64)(ts - cce->timestamp) > (2 * UINT_MAX))
> +		if ((u64)(ts - cce->timestamp) > (2ULL * UINT_MAX))
>  			continue;
>  		memcpy(cong_log->events[i].local_qp_cn_entry, &cce-
> >lqpn, 3);
>  		memcpy(cong_log-
> >events[i].remote_qp_number_cn_entry,

Denny, I'm looking for feedback from you on this patch.  This fixes a
bug, my only concern is that the code used to work with the bug, could
this make the code not work?

-- 
Doug Ledford <dledford@redhat.com>
    GPG KeyID: B826A3330E572FDD
    Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] IB/hfi1: Fix a wrapping test (make it less strict)
@ 2017-10-23 15:05   ` Doug Ledford
  0 siblings, 0 replies; 19+ messages in thread
From: Doug Ledford @ 2017-10-23 15:05 UTC (permalink / raw)
  To: Dan Carpenter, Mike Marciniszyn
  Cc: Dennis Dalessandro, Sean Hefty, Hal Rosenstock, linux-rdma,
	kernel-janitors

On Fri, 2017-10-13 at 13:56 +0300, Dan Carpenter wrote:
> The "2 * UINT_MAX" overflows so the test is essentially doing this:
> 
> 	if ((u64)(ts - cce->timestamp) > UINT_MAX - 1) {
> 
> I've changed it to a 64bit type.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> Not tested.
> 
> diff --git a/drivers/infiniband/hw/hfi1/mad.c
> b/drivers/infiniband/hw/hfi1/mad.c
> index f4c0ffc040cc..3aeea8afd44f 100644
> --- a/drivers/infiniband/hw/hfi1/mad.c
> +++ b/drivers/infiniband/hw/hfi1/mad.c
> @@ -3781,7 +3781,7 @@ static int __subn_get_opa_hfi1_cong_log(struct
> opa_smp *smp, u32 am,
>  		 * required to wrap the counter are supposed to
>  		 * be zeroed (CA10-49 IBTA, release 1.2.1, V1).
>  		 */
> -		if ((u64)(ts - cce->timestamp) > (2 * UINT_MAX))
> +		if ((u64)(ts - cce->timestamp) > (2ULL * UINT_MAX))
>  			continue;
>  		memcpy(cong_log->events[i].local_qp_cn_entry, &cce-
> >lqpn, 3);
>  		memcpy(cong_log-
> >events[i].remote_qp_number_cn_entry,

Denny, I'm looking for feedback from you on this patch.  This fixes a
bug, my only concern is that the code used to work with the bug, could
this make the code not work?

-- 
Doug Ledford <dledford@redhat.com>
    GPG KeyID: B826A3330E572FDD
    Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] IB/hfi1: Fix a wrapping test (make it less strict)
       [not found]   ` <1508771116.3325.0.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2017-10-23 17:57       ` Dennis Dalessandro
  0 siblings, 0 replies; 19+ messages in thread
From: Dennis Dalessandro @ 2017-10-23 17:57 UTC (permalink / raw)
  To: Doug Ledford, Dan Carpenter, Mike Marciniszyn
  Cc: Sean Hefty, Hal Rosenstock, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

On 10/23/2017 11:05 AM, Doug Ledford wrote:
> On Fri, 2017-10-13 at 13:56 +0300, Dan Carpenter wrote:
>> The "2 * UINT_MAX" overflows so the test is essentially doing this:
>>
>> 	if ((u64)(ts - cce->timestamp) > UINT_MAX - 1) {
>>
>> I've changed it to a 64bit type.
>>
>> Signed-off-by: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
>> ---
>> Not tested.
>>
>> diff --git a/drivers/infiniband/hw/hfi1/mad.c
>> b/drivers/infiniband/hw/hfi1/mad.c
>> index f4c0ffc040cc..3aeea8afd44f 100644
>> --- a/drivers/infiniband/hw/hfi1/mad.c
>> +++ b/drivers/infiniband/hw/hfi1/mad.c
>> @@ -3781,7 +3781,7 @@ static int __subn_get_opa_hfi1_cong_log(struct
>> opa_smp *smp, u32 am,
>>   		 * required to wrap the counter are supposed to
>>   		 * be zeroed (CA10-49 IBTA, release 1.2.1, V1).
>>   		 */
>> -		if ((u64)(ts - cce->timestamp) > (2 * UINT_MAX))
>> +		if ((u64)(ts - cce->timestamp) > (2ULL * UINT_MAX))
>>   			continue;
>>   		memcpy(cong_log->events[i].local_qp_cn_entry, &cce-
>>> lqpn, 3);
>>   		memcpy(cong_log-
>>> events[i].remote_qp_number_cn_entry,
> 
> Denny, I'm looking for feedback from you on this patch.  This fixes a
> bug, my only concern is that the code used to work with the bug, could
> this make the code not work?
> 

Mike and I have been looking at this. The code seems to work as it is 
but fails with Dan's patch. We are still looking at it, but I'd advise 
against pulling just yet. It's not something for 4.14.

-Denny
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] IB/hfi1: Fix a wrapping test (make it less strict)
@ 2017-10-23 17:57       ` Dennis Dalessandro
  0 siblings, 0 replies; 19+ messages in thread
From: Dennis Dalessandro @ 2017-10-23 17:57 UTC (permalink / raw)
  To: Doug Ledford, Dan Carpenter, Mike Marciniszyn
  Cc: Sean Hefty, Hal Rosenstock, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

On 10/23/2017 11:05 AM, Doug Ledford wrote:
> On Fri, 2017-10-13 at 13:56 +0300, Dan Carpenter wrote:
>> The "2 * UINT_MAX" overflows so the test is essentially doing this:
>>
>> 	if ((u64)(ts - cce->timestamp) > UINT_MAX - 1) {
>>
>> I've changed it to a 64bit type.
>>
>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>> ---
>> Not tested.
>>
>> diff --git a/drivers/infiniband/hw/hfi1/mad.c
>> b/drivers/infiniband/hw/hfi1/mad.c
>> index f4c0ffc040cc..3aeea8afd44f 100644
>> --- a/drivers/infiniband/hw/hfi1/mad.c
>> +++ b/drivers/infiniband/hw/hfi1/mad.c
>> @@ -3781,7 +3781,7 @@ static int __subn_get_opa_hfi1_cong_log(struct
>> opa_smp *smp, u32 am,
>>   		 * required to wrap the counter are supposed to
>>   		 * be zeroed (CA10-49 IBTA, release 1.2.1, V1).
>>   		 */
>> -		if ((u64)(ts - cce->timestamp) > (2 * UINT_MAX))
>> +		if ((u64)(ts - cce->timestamp) > (2ULL * UINT_MAX))
>>   			continue;
>>   		memcpy(cong_log->events[i].local_qp_cn_entry, &cce-
>>> lqpn, 3);
>>   		memcpy(cong_log-
>>> events[i].remote_qp_number_cn_entry,
> 
> Denny, I'm looking for feedback from you on this patch.  This fixes a
> bug, my only concern is that the code used to work with the bug, could
> this make the code not work?
> 

Mike and I have been looking at this. The code seems to work as it is 
but fails with Dan's patch. We are still looking at it, but I'd advise 
against pulling just yet. It's not something for 4.14.

-Denny

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] IB/hfi1: Fix a wrapping test (make it less strict)
  2017-10-23 17:57       ` Dennis Dalessandro
@ 2017-10-23 18:33         ` Doug Ledford
  -1 siblings, 0 replies; 19+ messages in thread
From: Doug Ledford @ 2017-10-23 18:33 UTC (permalink / raw)
  To: Dennis Dalessandro, Dan Carpenter, Mike Marciniszyn
  Cc: Sean Hefty, Hal Rosenstock, linux-rdma, kernel-janitors

On Mon, 2017-10-23 at 13:57 -0400, Dennis Dalessandro wrote:
> On 10/23/2017 11:05 AM, Doug Ledford wrote:
> > On Fri, 2017-10-13 at 13:56 +0300, Dan Carpenter wrote:
> > > The "2 * UINT_MAX" overflows so the test is essentially doing
> > > this:
> > > 
> > > 	if ((u64)(ts - cce->timestamp) > UINT_MAX - 1) {
> > > 
> > > I've changed it to a 64bit type.
> > > 
> > > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > > ---
> > > Not tested.
> > > 
> > > diff --git a/drivers/infiniband/hw/hfi1/mad.c
> > > b/drivers/infiniband/hw/hfi1/mad.c
> > > index f4c0ffc040cc..3aeea8afd44f 100644
> > > --- a/drivers/infiniband/hw/hfi1/mad.c
> > > +++ b/drivers/infiniband/hw/hfi1/mad.c
> > > @@ -3781,7 +3781,7 @@ static int
> > > __subn_get_opa_hfi1_cong_log(struct
> > > opa_smp *smp, u32 am,
> > >   		 * required to wrap the counter are supposed to
> > >   		 * be zeroed (CA10-49 IBTA, release 1.2.1, V1).
> > >   		 */
> > > -		if ((u64)(ts - cce->timestamp) > (2 * UINT_MAX))
> > > +		if ((u64)(ts - cce->timestamp) > (2ULL *
> > > UINT_MAX))
> > >   			continue;
> > >   		memcpy(cong_log->events[i].local_qp_cn_entry,
> > > &cce-
> > > > lqpn, 3);
> > > 
> > >   		memcpy(cong_log-
> > > > events[i].remote_qp_number_cn_entry,
> > 
> > Denny, I'm looking for feedback from you on this patch.  This fixes
> > a
> > bug, my only concern is that the code used to work with the bug,
> > could
> > this make the code not work?
> > 
> 
> Mike and I have been looking at this. The code seems to work as it
> is 
> but fails with Dan's patch. We are still looking at it, but I'd
> advise 
> against pulling just yet. It's not something for 4.14.

That's what I was afraid of: by fixing a C language bug, you expose the
fact that there is a subtle logic bug that's only been working because
of the C language bug ;-).

I'll hold off until you send this patch through with whatever
incremental changes are needed elsewhere to make it work.

-- 
Doug Ledford <dledford@redhat.com>
    GPG KeyID: B826A3330E572FDD
    Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] IB/hfi1: Fix a wrapping test (make it less strict)
@ 2017-10-23 18:33         ` Doug Ledford
  0 siblings, 0 replies; 19+ messages in thread
From: Doug Ledford @ 2017-10-23 18:33 UTC (permalink / raw)
  To: Dennis Dalessandro, Dan Carpenter, Mike Marciniszyn
  Cc: Sean Hefty, Hal Rosenstock, linux-rdma, kernel-janitors

On Mon, 2017-10-23 at 13:57 -0400, Dennis Dalessandro wrote:
> On 10/23/2017 11:05 AM, Doug Ledford wrote:
> > On Fri, 2017-10-13 at 13:56 +0300, Dan Carpenter wrote:
> > > The "2 * UINT_MAX" overflows so the test is essentially doing
> > > this:
> > > 
> > > 	if ((u64)(ts - cce->timestamp) > UINT_MAX - 1) {
> > > 
> > > I've changed it to a 64bit type.
> > > 
> > > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > > ---
> > > Not tested.
> > > 
> > > diff --git a/drivers/infiniband/hw/hfi1/mad.c
> > > b/drivers/infiniband/hw/hfi1/mad.c
> > > index f4c0ffc040cc..3aeea8afd44f 100644
> > > --- a/drivers/infiniband/hw/hfi1/mad.c
> > > +++ b/drivers/infiniband/hw/hfi1/mad.c
> > > @@ -3781,7 +3781,7 @@ static int
> > > __subn_get_opa_hfi1_cong_log(struct
> > > opa_smp *smp, u32 am,
> > >   		 * required to wrap the counter are supposed to
> > >   		 * be zeroed (CA10-49 IBTA, release 1.2.1, V1).
> > >   		 */
> > > -		if ((u64)(ts - cce->timestamp) > (2 * UINT_MAX))
> > > +		if ((u64)(ts - cce->timestamp) > (2ULL *
> > > UINT_MAX))
> > >   			continue;
> > >   		memcpy(cong_log->events[i].local_qp_cn_entry,
> > > &cce-
> > > > lqpn, 3);
> > > 
> > >   		memcpy(cong_log-
> > > > events[i].remote_qp_number_cn_entry,
> > 
> > Denny, I'm looking for feedback from you on this patch.  This fixes
> > a
> > bug, my only concern is that the code used to work with the bug,
> > could
> > this make the code not work?
> > 
> 
> Mike and I have been looking at this. The code seems to work as it
> is 
> but fails with Dan's patch. We are still looking at it, but I'd
> advise 
> against pulling just yet. It's not something for 4.14.

That's what I was afraid of: by fixing a C language bug, you expose the
fact that there is a subtle logic bug that's only been working because
of the C language bug ;-).

I'll hold off until you send this patch through with whatever
incremental changes are needed elsewhere to make it work.

-- 
Doug Ledford <dledford@redhat.com>
    GPG KeyID: B826A3330E572FDD
    Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] IB/hfi1: Fix a wrapping test (make it less strict)
  2017-10-23 18:33         ` Doug Ledford
@ 2017-10-23 19:04           ` Jason Gunthorpe
  -1 siblings, 0 replies; 19+ messages in thread
From: Jason Gunthorpe @ 2017-10-23 19:04 UTC (permalink / raw)
  To: Doug Ledford
  Cc: Dennis Dalessandro, Dan Carpenter, Mike Marciniszyn, Sean Hefty,
	Hal Rosenstock, linux-rdma, kernel-janitors

On Mon, Oct 23, 2017 at 02:33:46PM -0400, Doug Ledford wrote:
> > > > @@ -3781,7 +3781,7 @@ static int
> > > > __subn_get_opa_hfi1_cong_log(struct
> > > > opa_smp *smp, u32 am,
> > > >   		 * required to wrap the counter are supposed to
> > > >   		 * be zeroed (CA10-49 IBTA, release 1.2.1, V1).
> > > >   		 */
> > > > -		if ((u64)(ts - cce->timestamp) > (2 * UINT_MAX))
> > > > +		if ((u64)(ts - cce->timestamp) > (2ULL *
> > > > UINT_MAX))

This is really weird looking. Both ts and cce->timestamp are s64, why
do the convoluted conversion to unsigned? And surely UINT_MAX is not
the right thing..

if ((ts - cce->timestamp)/2 > 0xFFFFFFFF)

?

ktime_get is defined to be monotonic, so ts - cce->timestamp should
never go negative.

Jason

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] IB/hfi1: Fix a wrapping test (make it less strict)
@ 2017-10-23 19:04           ` Jason Gunthorpe
  0 siblings, 0 replies; 19+ messages in thread
From: Jason Gunthorpe @ 2017-10-23 19:04 UTC (permalink / raw)
  To: Doug Ledford
  Cc: Dennis Dalessandro, Dan Carpenter, Mike Marciniszyn, Sean Hefty,
	Hal Rosenstock, linux-rdma, kernel-janitors

On Mon, Oct 23, 2017 at 02:33:46PM -0400, Doug Ledford wrote:
> > > > @@ -3781,7 +3781,7 @@ static int
> > > > __subn_get_opa_hfi1_cong_log(struct
> > > > opa_smp *smp, u32 am,
> > > >   		 * required to wrap the counter are supposed to
> > > >   		 * be zeroed (CA10-49 IBTA, release 1.2.1, V1).
> > > >   		 */
> > > > -		if ((u64)(ts - cce->timestamp) > (2 * UINT_MAX))
> > > > +		if ((u64)(ts - cce->timestamp) > (2ULL *
> > > > UINT_MAX))

This is really weird looking. Both ts and cce->timestamp are s64, why
do the convoluted conversion to unsigned? And surely UINT_MAX is not
the right thing..

if ((ts - cce->timestamp)/2 > 0xFFFFFFFF)

?

ktime_get is defined to be monotonic, so ts - cce->timestamp should
never go negative.

Jason

^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [PATCH] IB/hfi1: Fix a wrapping test (make it less strict)
  2017-10-23 19:04           ` Jason Gunthorpe
  (?)
@ 2017-10-24 19:54           ` Marciniszyn, Mike
       [not found]             ` <32E1700B9017364D9B60AED9960492BC3443EB1C-RjuIdWtd+YbTXloPLtfHfbfspsVTdybXVpNB7YpNyf8@public.gmane.org>
  -1 siblings, 1 reply; 19+ messages in thread
From: Marciniszyn, Mike @ 2017-10-24 19:54 UTC (permalink / raw)
  To: Jason Gunthorpe, Doug Ledford
  Cc: Dalessandro, Dennis, Dan Carpenter, Hefty, Sean, Hal Rosenstock,
	linux-rdma, kernel-janitors

> Subject: Re: [PATCH] IB/hfi1: Fix a wrapping test (make it less strict)
> 
> On Mon, Oct 23, 2017 at 02:33:46PM -0400, Doug Ledford wrote:
> > > > > @@ -3781,7 +3781,7 @@ static int
> > > > > __subn_get_opa_hfi1_cong_log(struct
> > > > > opa_smp *smp, u32 am,
> > > > >   		 * required to wrap the counter are supposed to
> > > > >   		 * be zeroed (CA10-49 IBTA, release 1.2.1, V1).
> > > > >   		 */
> > > > > -		if ((u64)(ts - cce->timestamp) > (2 * UINT_MAX))
> > > > > +		if ((u64)(ts - cce->timestamp) > (2ULL *
> > > > > UINT_MAX))
> 
> This is really weird looking. Both ts and cce->timestamp are s64, why
> do the convoluted conversion to unsigned? And surely UINT_MAX is not
> the right thing..
> 
> if ((ts - cce->timestamp)/2 > 0xFFFFFFFF)
> 
> ?
> 
> ktime_get is defined to be monotonic, so ts - cce->timestamp should
> never go negative.
> 

I agree that this is an issue.

My proposal:
- Change s64 to u64 for ts and in timestamp in opa_hfi1_cong_log_event_internal
- Change the calls:
        ktime_to_ns(ktime_get()) / 1024
        -- to --
        ktime_get_ns() / 1024
- Change to use Jason's test from above with UINT_MAX

Dan, we can do the patch or you can send a v2?

Mike


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] IB/hfi1: Fix a wrapping test (make it less strict)
       [not found]             ` <32E1700B9017364D9B60AED9960492BC3443EB1C-RjuIdWtd+YbTXloPLtfHfbfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2017-10-24 20:02                 ` Jason Gunthorpe
  2017-10-25  5:14                 ` Dan Carpenter
  1 sibling, 0 replies; 19+ messages in thread
From: Jason Gunthorpe @ 2017-10-24 20:02 UTC (permalink / raw)
  To: Marciniszyn, Mike
  Cc: Doug Ledford, Dalessandro, Dennis, Dan Carpenter, Hefty, Sean,
	Hal Rosenstock, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

On Tue, Oct 24, 2017 at 07:54:40PM +0000, Marciniszyn, Mike wrote:

> - Change to use Jason's test from above with UINT_MAX

UINT_MAX isn't U32_MAX, is it?

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] IB/hfi1: Fix a wrapping test (make it less strict)
@ 2017-10-24 20:02                 ` Jason Gunthorpe
  0 siblings, 0 replies; 19+ messages in thread
From: Jason Gunthorpe @ 2017-10-24 20:02 UTC (permalink / raw)
  To: Marciniszyn, Mike
  Cc: Doug Ledford, Dalessandro, Dennis, Dan Carpenter, Hefty, Sean,
	Hal Rosenstock, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

On Tue, Oct 24, 2017 at 07:54:40PM +0000, Marciniszyn, Mike wrote:

> - Change to use Jason's test from above with UINT_MAX

UINT_MAX isn't U32_MAX, is it?

Jason

^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [PATCH] IB/hfi1: Fix a wrapping test (make it less strict)
       [not found]                 ` <20171024200216.GA15994-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
@ 2017-10-24 20:03                     ` Marciniszyn, Mike
  2017-10-25  5:27                     ` Dan Carpenter
  1 sibling, 0 replies; 19+ messages in thread
From: Marciniszyn, Mike @ 2017-10-24 20:03 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Doug Ledford, Dalessandro, Dennis, Dan Carpenter, Hefty, Sean,
	Hal Rosenstock, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA


> 
> > - Change to use Jason's test from above with UINT_MAX
> 
> UINT_MAX isn't U32_MAX, is it?
> 

Yes.  My bad.

Mike
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [PATCH] IB/hfi1: Fix a wrapping test (make it less strict)
@ 2017-10-24 20:03                     ` Marciniszyn, Mike
  0 siblings, 0 replies; 19+ messages in thread
From: Marciniszyn, Mike @ 2017-10-24 20:03 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Doug Ledford, Dalessandro, Dennis, Dan Carpenter, Hefty, Sean,
	Hal Rosenstock, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA


> 
> > - Change to use Jason's test from above with UINT_MAX
> 
> UINT_MAX isn't U32_MAX, is it?
> 

Yes.  My bad.

Mike

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] IB/hfi1: Fix a wrapping test (make it less strict)
       [not found]             ` <32E1700B9017364D9B60AED9960492BC3443EB1C-RjuIdWtd+YbTXloPLtfHfbfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2017-10-25  5:14                 ` Dan Carpenter
  2017-10-25  5:14                 ` Dan Carpenter
  1 sibling, 0 replies; 19+ messages in thread
From: Dan Carpenter @ 2017-10-25  5:14 UTC (permalink / raw)
  To: Marciniszyn, Mike
  Cc: Jason Gunthorpe, Doug Ledford, Dalessandro, Dennis, Hefty, Sean,
	Hal Rosenstock, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

On Tue, Oct 24, 2017 at 07:54:40PM +0000, Marciniszyn, Mike wrote:
> > Subject: Re: [PATCH] IB/hfi1: Fix a wrapping test (make it less strict)
> > 
> > On Mon, Oct 23, 2017 at 02:33:46PM -0400, Doug Ledford wrote:
> > > > > > @@ -3781,7 +3781,7 @@ static int
> > > > > > __subn_get_opa_hfi1_cong_log(struct
> > > > > > opa_smp *smp, u32 am,
> > > > > >   		 * required to wrap the counter are supposed to
> > > > > >   		 * be zeroed (CA10-49 IBTA, release 1.2.1, V1).
> > > > > >   		 */
> > > > > > -		if ((u64)(ts - cce->timestamp) > (2 * UINT_MAX))
> > > > > > +		if ((u64)(ts - cce->timestamp) > (2ULL *
> > > > > > UINT_MAX))
> > 
> > This is really weird looking. Both ts and cce->timestamp are s64, why
> > do the convoluted conversion to unsigned? And surely UINT_MAX is not
> > the right thing..
> > 
> > if ((ts - cce->timestamp)/2 > 0xFFFFFFFF)
> > 
> > ?
> > 
> > ktime_get is defined to be monotonic, so ts - cce->timestamp should
> > never go negative.
> > 
> 
> I agree that this is an issue.
> 
> My proposal:
> - Change s64 to u64 for ts and in timestamp in opa_hfi1_cong_log_event_internal
> - Change the calls:
>         ktime_to_ns(ktime_get()) / 1024
>         -- to --
>         ktime_get_ns() / 1024
> - Change to use Jason's test from above with UINT_MAX
> 
> Dan, we can do the patch or you can send a v2?
> 

Can you do the patch and give me a Reported-by tag?

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] IB/hfi1: Fix a wrapping test (make it less strict)
@ 2017-10-25  5:14                 ` Dan Carpenter
  0 siblings, 0 replies; 19+ messages in thread
From: Dan Carpenter @ 2017-10-25  5:14 UTC (permalink / raw)
  To: Marciniszyn, Mike
  Cc: Jason Gunthorpe, Doug Ledford, Dalessandro, Dennis, Hefty, Sean,
	Hal Rosenstock, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

On Tue, Oct 24, 2017 at 07:54:40PM +0000, Marciniszyn, Mike wrote:
> > Subject: Re: [PATCH] IB/hfi1: Fix a wrapping test (make it less strict)
> > 
> > On Mon, Oct 23, 2017 at 02:33:46PM -0400, Doug Ledford wrote:
> > > > > > @@ -3781,7 +3781,7 @@ static int
> > > > > > __subn_get_opa_hfi1_cong_log(struct
> > > > > > opa_smp *smp, u32 am,
> > > > > >   		 * required to wrap the counter are supposed to
> > > > > >   		 * be zeroed (CA10-49 IBTA, release 1.2.1, V1).
> > > > > >   		 */
> > > > > > -		if ((u64)(ts - cce->timestamp) > (2 * UINT_MAX))
> > > > > > +		if ((u64)(ts - cce->timestamp) > (2ULL *
> > > > > > UINT_MAX))
> > 
> > This is really weird looking. Both ts and cce->timestamp are s64, why
> > do the convoluted conversion to unsigned? And surely UINT_MAX is not
> > the right thing..
> > 
> > if ((ts - cce->timestamp)/2 > 0xFFFFFFFF)
> > 
> > ?
> > 
> > ktime_get is defined to be monotonic, so ts - cce->timestamp should
> > never go negative.
> > 
> 
> I agree that this is an issue.
> 
> My proposal:
> - Change s64 to u64 for ts and in timestamp in opa_hfi1_cong_log_event_internal
> - Change the calls:
>         ktime_to_ns(ktime_get()) / 1024
>         -- to --
>         ktime_get_ns() / 1024
> - Change to use Jason's test from above with UINT_MAX
> 
> Dan, we can do the patch or you can send a v2?
> 

Can you do the patch and give me a Reported-by tag?

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] IB/hfi1: Fix a wrapping test (make it less strict)
       [not found]                 ` <20171024200216.GA15994-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
@ 2017-10-25  5:27                     ` Dan Carpenter
  2017-10-25  5:27                     ` Dan Carpenter
  1 sibling, 0 replies; 19+ messages in thread
From: Dan Carpenter @ 2017-10-25  5:27 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Marciniszyn, Mike, Doug Ledford, Dalessandro, Dennis, Hefty,
	Sean, Hal Rosenstock, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

On Tue, Oct 24, 2017 at 02:02:16PM -0600, Jason Gunthorpe wrote:
> On Tue, Oct 24, 2017 at 07:54:40PM +0000, Marciniszyn, Mike wrote:
> 
> > - Change to use Jason's test from above with UINT_MAX
> 
> UINT_MAX isn't U32_MAX, is it?

They are always the same.

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] IB/hfi1: Fix a wrapping test (make it less strict)
@ 2017-10-25  5:27                     ` Dan Carpenter
  0 siblings, 0 replies; 19+ messages in thread
From: Dan Carpenter @ 2017-10-25  5:27 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Marciniszyn, Mike, Doug Ledford, Dalessandro, Dennis, Hefty,
	Sean, Hal Rosenstock, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

On Tue, Oct 24, 2017 at 02:02:16PM -0600, Jason Gunthorpe wrote:
> On Tue, Oct 24, 2017 at 07:54:40PM +0000, Marciniszyn, Mike wrote:
> 
> > - Change to use Jason's test from above with UINT_MAX
> 
> UINT_MAX isn't U32_MAX, is it?

They are always the same.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2017-10-25  5:27 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-13 10:56 [PATCH] IB/hfi1: Fix a wrapping test (make it less strict) Dan Carpenter
2017-10-13 10:56 ` Dan Carpenter
2017-10-23 15:05 ` Doug Ledford
2017-10-23 15:05   ` Doug Ledford
     [not found]   ` <1508771116.3325.0.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-10-23 17:57     ` Dennis Dalessandro
2017-10-23 17:57       ` Dennis Dalessandro
2017-10-23 18:33       ` Doug Ledford
2017-10-23 18:33         ` Doug Ledford
2017-10-23 19:04         ` Jason Gunthorpe
2017-10-23 19:04           ` Jason Gunthorpe
2017-10-24 19:54           ` Marciniszyn, Mike
     [not found]             ` <32E1700B9017364D9B60AED9960492BC3443EB1C-RjuIdWtd+YbTXloPLtfHfbfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2017-10-24 20:02               ` Jason Gunthorpe
2017-10-24 20:02                 ` Jason Gunthorpe
     [not found]                 ` <20171024200216.GA15994-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-10-24 20:03                   ` Marciniszyn, Mike
2017-10-24 20:03                     ` Marciniszyn, Mike
2017-10-25  5:27                   ` Dan Carpenter
2017-10-25  5:27                     ` Dan Carpenter
2017-10-25  5:14               ` Dan Carpenter
2017-10-25  5:14                 ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.