linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] rds: ib: force endiannes annotation
@ 2019-04-30  3:12 Nicholas Mc Guire
  2019-04-30  4:25 ` santosh.shilimkar
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Nicholas Mc Guire @ 2019-04-30  3:12 UTC (permalink / raw)
  To: Santosh Shilimkar
  Cc: David S. Miller, netdev, linux-rdma, rds-devel, linux-kernel,
	Nicholas Mc Guire

While the endiannes is being handled correctly as indicated by the comment
above the offending line - sparse was unhappy with the missing annotation
as be64_to_cpu() expects a __be64 argument. To mitigate this annotation
all involved variables are changed to a consistent __le64 and the
 conversion to uint64_t delayed to the call to rds_cong_map_updated().

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---

Problem located by an experimental coccinelle script to locate
patters that make sparse unhappy (false positives):
net/rds/ib_recv.c:827:23: warning: cast to restricted __le64

V2: Edward Cree <ecree@solarflare.com> rejected the need for using __force
    here - instead solve the sparse issue by updating all of the involved
    variables - which results in an identical binary as well without using
    the __force "solution" to the sparse warning. Thanks !

Patch was compile-tested with: x86_64_defconfig + INFINIBAND=m, RDS_RDMA=m

Patch was verified not to change the binary by diffing the
generated object code before and after applying the patch.

Patch is against 5.1-rc6 (localversion-next is 20190429)

 net/rds/ib_recv.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
index 7055985..8946c89 100644
--- a/net/rds/ib_recv.c
+++ b/net/rds/ib_recv.c
@@ -772,7 +772,7 @@ static void rds_ib_cong_recv(struct rds_connection *conn,
 	unsigned long frag_off;
 	unsigned long to_copy;
 	unsigned long copied;
-	uint64_t uncongested = 0;
+	__le64 uncongested = 0;
 	void *addr;
 
 	/* catch completely corrupt packets */
@@ -789,7 +789,7 @@ static void rds_ib_cong_recv(struct rds_connection *conn,
 	copied = 0;
 
 	while (copied < RDS_CONG_MAP_BYTES) {
-		uint64_t *src, *dst;
+		__le64 *src, *dst;
 		unsigned int k;
 
 		to_copy = min(RDS_FRAG_SIZE - frag_off, PAGE_SIZE - map_off);
@@ -824,9 +824,7 @@ static void rds_ib_cong_recv(struct rds_connection *conn,
 	}
 
 	/* the congestion map is in little endian order */
-	uncongested = le64_to_cpu(uncongested);
-
-	rds_cong_map_updated(map, uncongested);
+	rds_cong_map_updated(map, le64_to_cpu(uncongested));
 }
 
 static void rds_ib_process_recv(struct rds_connection *conn,
-- 
2.1.4

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

* Re: [PATCH V2] rds: ib: force endiannes annotation
  2019-04-30  3:12 [PATCH V2] rds: ib: force endiannes annotation Nicholas Mc Guire
@ 2019-04-30  4:25 ` santosh.shilimkar
  2019-04-30 11:43 ` Christoph Hellwig
  2019-05-01 21:15 ` David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: santosh.shilimkar @ 2019-04-30  4:25 UTC (permalink / raw)
  To: Nicholas Mc Guire
  Cc: David S. Miller, netdev, linux-rdma, rds-devel, linux-kernel



On 4/29/19 8:12 PM, Nicholas Mc Guire wrote:
> While the endiannes is being handled correctly as indicated by the comment
> above the offending line - sparse was unhappy with the missing annotation
> as be64_to_cpu() expects a __be64 argument. To mitigate this annotation
> all involved variables are changed to a consistent __le64 and the
>   conversion to uint64_t delayed to the call to rds_cong_map_updated().
> 
> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
> ---
> 
> Problem located by an experimental coccinelle script to locate
> patters that make sparse unhappy (false positives):
> net/rds/ib_recv.c:827:23: warning: cast to restricted __le64
> 
> V2: Edward Cree <ecree@solarflare.com> rejected the need for using __force
>      here - instead solve the sparse issue by updating all of the involved
>      variables - which results in an identical binary as well without using
>      the __force "solution" to the sparse warning. Thanks !
> 
> Patch was compile-tested with: x86_64_defconfig + INFINIBAND=m, RDS_RDMA=m
> 
> Patch was verified not to change the binary by diffing the
> generated object code before and after applying the patch.
> 
Thanks. I was worried about this macro magic o.w

Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>

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

* Re: [PATCH V2] rds: ib: force endiannes annotation
  2019-04-30  3:12 [PATCH V2] rds: ib: force endiannes annotation Nicholas Mc Guire
  2019-04-30  4:25 ` santosh.shilimkar
@ 2019-04-30 11:43 ` Christoph Hellwig
  2019-04-30 12:54   ` Nicholas Mc Guire
  2019-05-01 21:15 ` David Miller
  2 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2019-04-30 11:43 UTC (permalink / raw)
  To: Nicholas Mc Guire
  Cc: Santosh Shilimkar, David S. Miller, netdev, linux-rdma,
	rds-devel, linux-kernel

The patch looks good, but the force in the subject sounds weird now.

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

* Re: [PATCH V2] rds: ib: force endiannes annotation
  2019-04-30 11:43 ` Christoph Hellwig
@ 2019-04-30 12:54   ` Nicholas Mc Guire
  0 siblings, 0 replies; 5+ messages in thread
From: Nicholas Mc Guire @ 2019-04-30 12:54 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Nicholas Mc Guire, Santosh Shilimkar, David S. Miller, netdev,
	linux-rdma, rds-devel, linux-kernel

On Tue, Apr 30, 2019 at 04:43:21AM -0700, Christoph Hellwig wrote:
> The patch looks good, but the force in the subject sounds weird now.


True - but last time I renamed the subject when seindg a V2 I
wsa told not to do that - the rational was if I rename it and
call it V2 -then there is no V1...

If thats nonsense - then I'll resend with a new commit subject

thx!
hofrat

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

* Re: [PATCH V2] rds: ib: force endiannes annotation
  2019-04-30  3:12 [PATCH V2] rds: ib: force endiannes annotation Nicholas Mc Guire
  2019-04-30  4:25 ` santosh.shilimkar
  2019-04-30 11:43 ` Christoph Hellwig
@ 2019-05-01 21:15 ` David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2019-05-01 21:15 UTC (permalink / raw)
  To: hofrat; +Cc: santosh.shilimkar, netdev, linux-rdma, rds-devel, linux-kernel

From: Nicholas Mc Guire <hofrat@osadl.org>
Date: Tue, 30 Apr 2019 05:12:57 +0200

> While the endiannes is being handled correctly as indicated by the comment
> above the offending line - sparse was unhappy with the missing annotation
> as be64_to_cpu() expects a __be64 argument. To mitigate this annotation
> all involved variables are changed to a consistent __le64 and the
>  conversion to uint64_t delayed to the call to rds_cong_map_updated().
> 
> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>

Applied.

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

end of thread, other threads:[~2019-05-01 21:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-30  3:12 [PATCH V2] rds: ib: force endiannes annotation Nicholas Mc Guire
2019-04-30  4:25 ` santosh.shilimkar
2019-04-30 11:43 ` Christoph Hellwig
2019-04-30 12:54   ` Nicholas Mc Guire
2019-05-01 21:15 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).