Skip to contentSkip to conversation

IB/core: Suppress a sparse warning

PATCH In review Bart Van Assche 4 participants 7 messages Mar 10, 2014 – Mar 12, 2014 6 messages not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 IB/core: Suppress a sparse warning

Suppress the following sparse warning:

include/rdma/ib_addr.h:187:24: warning: cast removes address space of expression

Cc Moni Shoua <monis-VPRAkNaXOzVWk0Htik3J/[email protected]>
Cc Or Gerlitz <ogerlitz-VPRAkNaXOzVWk0Htik3J/[email protected]>
Cc Roland Dreier <[email protected]>
---
 include/rdma/ib_addr.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/rdma/ib_addr.h +1 -1
index ce55906..bf11511 100644
@@ -184,7 +184,7 @@ static inline void iboe_addr_get_sgid(struct rdma_dev_addr *dev_addr,
 
 	dev = dev_get_by_index(&init_net, dev_addr->bound_dev_if);
 	if (dev) {
-		ip4 = (struct in_device *)dev->ip_ptr;
+		ip4 = (__force struct in_device *)dev->ip_ptr;
 		if (ip4 && ip4->ifa_list && ip4->ifa_list->ifa_address)
 			ipv6_addr_set_v4mapped(ip4->ifa_list->ifa_address,
 					       (struct in6_addr *)gid);
Signature · 6 lines
1.8.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 4 lines · Bart Van Assche

Suppress the following sparse warning:

include/rdma/ib_addr.h:187:24: warning: cast removes address space of expression

You should explain why there's a warning here, and why is it safe to cast. (I believe it's related to RCU domain ?)

Regards.

Quoted 21 lines
Cc Moni Shoua <monis-VPRAkNaXOzVWk0Htik3J/[email protected]>
Cc Or Gerlitz <ogerlitz-VPRAkNaXOzVWk0Htik3J/[email protected]>
Cc Roland Dreier <[email protected]>
---
 include/rdma/ib_addr.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/rdma/ib_addr.h +1 -1
index ce55906..bf11511 100644
@@ -184,7 +184,7 @@ static inline void iboe_addr_get_sgid(struct rdma_dev_addr *dev_addr,
 
 	dev = dev_get_by_index(&init_net, dev_addr->bound_dev_if);
 	if (dev) {
-		ip4 = (struct in_device *)dev->ip_ptr;
+		ip4 = (__force struct in_device *)dev->ip_ptr;
 		if (ip4 && ip4->ifa_list && ip4->ifa_list->ifa_address)
 			ipv6_addr_set_v4mapped(ip4->ifa_list->ifa_address,
 					       (struct in6_addr *)gid);
Signature · 8 lines
Yann Droneaud
OPTEYA


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1394458406.3257.53.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/[email protected]

#4 lore raw
Quoted 6 lines · Yann Droneaud
Quoted 2 lines · Bart Van Assche

Suppress the following sparse warning:
include/rdma/ib_addr.h:187:24: warning: cast removes address space of expression

You should explain why there's a warning here, and why is it safe to cast. (I believe it's related to RCU domain ?)

Hello Yann,

Now that I've had a closer look at the code in include/rdma/ib_addr.h, that code probably isn't safe. How about the (untested) patch below ?

include/rdma/ib_addr.h +1 -1
index ce55906..5a416ac 100644
@@ -184,7 +184,7 @@ static inline void iboe_addr_get_sgid(struct rdma_dev_addr *dev_addr,
 
 	dev = dev_get_by_index(&init_net, dev_addr->bound_dev_if);
 	if (dev) {
-		ip4 = (struct in_device *)dev->ip_ptr;
+		ip4 = __in_dev_get_rcu(dev);
 		if (ip4 && ip4->ifa_list && ip4->ifa_list->ifa_address)
 			ipv6_addr_set_v4mapped(ip4->ifa_list->ifa_address,
 					       (struct in6_addr *)gid);
Signature · 7 lines
1.8.4.5


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw

Hi,

Quoted 5 lines · Bart Van Assche
Quoted 4 lines · Yann Droneaud
Quoted 2 lines · Bart Van Assche

Suppress the following sparse warning:
include/rdma/ib_addr.h:187:24: warning: cast removes address space of expression

Quoted 8 lines
Quoted 2 lines

You should explain why there's a warning here, and why is it safe to cast. (I believe it's related to RCU domain ?)

Hello Yann,

Now that I've had a closer look at the code in include/rdma/ib_addr.h, that code probably isn't safe. How about the (untested) patch below ?

Thanks for investigating.

I'm not an expert in RCU, but I believe it then miss the RCU annotations around the RCU reader section (ensure correct ordering if I recall correctly).

Cc "Paul E. McKenney" <[email protected]>

include/rdma/ib_addr.h static inline void iboe_addr_get_sgid(struct rdma_dev_addr *dev_addr, · line 186

Quoted 8 lines
include/rdma/ib_addr.h +0 -0
index ce55906..5a416ac 100644
@@ -184,7 +184,7 @@ static inline void iboe_addr_get_sgid(struct rdma_dev_addr *dev_addr,
 
 	dev = dev_get_by_index(&init_net, dev_addr->bound_dev_if);
 	if (dev) {

+ rcu_read_lock();

Quoted 6 lines
include/rdma/ib_addr.h +1 -1
-		ip4 = (struct in_device *)dev->ip_ptr;
+		ip4 = __in_dev_get_rcu(dev);
 
 		if (ip4 && ip4->ifa_list && ip4->ifa_list->ifa_address)
 			ipv6_addr_set_v4mapped(ip4->ifa_list->ifa_address,

(struct in6_addr *)gid);

+ rcu_read_unlock();

Regards.

Signature · 8 lines
Yann Droneaud
OPTEYA


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1394463733.3257.62.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/[email protected]

#8 lore raw
Quoted 17 lines · Yann Droneaud

Hi,

Quoted 5 lines · Bart Van Assche
Quoted 4 lines · Yann Droneaud
Quoted 2 lines · Bart Van Assche

Suppress the following sparse warning:
include/rdma/ib_addr.h:187:24: warning: cast removes address space of expression

Quoted 8 lines
Quoted 2 lines

You should explain why there's a warning here, and why is it safe to cast. (I believe it's related to RCU domain ?)

Hello Yann,

Now that I've had a closer look at the code in include/rdma/ib_addr.h, that code probably isn't safe. How about the (untested) patch below ?

Quoted 7 lines

Thanks for investigating.

I'm not an expert in RCU, but I believe it then miss the RCU annotations around the RCU reader section (ensure correct ordering if I recall correctly).

Cc "Paul E. McKenney" <[email protected]>

If the rcu_read_lock() isn't supplied by all callers to this function, then yes, it needs to be supplied as Yann shows below.

The CONFIG_PROVE_RCU=y Kconfig option can help determine that they are needed, but of course cannot prove that they are not needed, at least not unless you have a workload that exercises all possible calls to this function.

Thanx, Paul

Quoted 21 lines
Quoted 8 lines
include/rdma/ib_addr.h +0 -0
index ce55906..5a416ac 100644
@@ -184,7 +184,7 @@ static inline void iboe_addr_get_sgid(struct rdma_dev_addr *dev_addr,
 
 	dev = dev_get_by_index(&init_net, dev_addr->bound_dev_if);
 	if (dev) {
(quoted diff) +1 -0
+		rcu_read_lock();
Quoted 7 lines
include/rdma/ib_addr.h +1 -1
-		ip4 = (struct in_device *)dev->ip_ptr;
+		ip4 = __in_dev_get_rcu(dev);
 
 		if (ip4 && ip4->ifa_list && ip4->ifa_list->ifa_address)
 			ipv6_addr_set_v4mapped(ip4->ifa_list->ifa_address,

(struct in6_addr *)gid);

(quoted diff) +1 -0
+		rcu_read_unlock();
Quoted 7 lines

Regards.

Signature · 2 lines
Yann Droneaud
OPTEYA

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20140310160803.GC21124-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org

#10 lore raw
Quoted 26 lines · Paul E. McKenney
Quoted 17 lines · Yann Droneaud

Hi,

Quoted 5 lines · Bart Van Assche
Quoted 4 lines · Yann Droneaud
Quoted 2 lines · Bart Van Assche

Suppress the following sparse warning:
include/rdma/ib_addr.h:187:24: warning: cast removes address space of expression

Quoted 8 lines
Quoted 2 lines

You should explain why there's a warning here, and why is it safe to cast. (I believe it's related to RCU domain ?)

Hello Yann,

Now that I've had a closer look at the code in include/rdma/ib_addr.h, that code probably isn't safe. How about the (untested) patch below ?

Quoted 7 lines

Thanks for investigating.

I'm not an expert in RCU, but I believe it then miss the RCU annotations around the RCU reader section (ensure correct ordering if I recall correctly).

Cc "Paul E. McKenney" <[email protected]>
Quoted 7 lines

If the rcu_read_lock() isn't supplied by all callers to this function, then yes, it needs to be supplied as Yann shows below.

The CONFIG_PROVE_RCU=y Kconfig option can help determine that they are needed, but of course cannot prove that they are not needed, at least not unless you have a workload that exercises all possible calls to this function.

Hello Moni,

I think this warning got introduced via commit "IB/cma: IBoE (RoCE) IP-based GID addressing" (7b85627b9f02f9b0fb2ef5f021807f4251135857; December 12, 2013). Can you follow this up further ?

Thanks,

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#12 lore raw
Quoted 32 lines · Bart Van Assche
Quoted 21 lines · Paul E. McKenney
Quoted 20 lines · Yann Droneaud

Hi,

Quoted 11 lines · Bart Van Assche
Quoted 5 lines · Yann Droneaud
Quoted 2 lines · Bart Van Assche

Suppress the following sparse warning:
include/rdma/ib_addr.h:187:24: warning: cast removes address space of expression

You should explain why there's a warning here, and why is it safe to cast. (I believe it's related to RCU domain ?)

Hello Yann,

Now that I've had a closer look at the code in include/rdma/ib_addr.h, that code probably isn't safe. How about the (untested) patch below ?

Thanks for investigating.

I'm not an expert in RCU, but I believe it then miss the RCU annotations around the RCU reader section (ensure correct ordering if I recall correctly).

Quoted 8 lines
Quoted 1 line
Cc "Paul E. McKenney" <[email protected]>

If the rcu_read_lock() isn't supplied by all callers to this function, then yes, it needs to be supplied as Yann shows below.

The CONFIG_PROVE_RCU=y Kconfig option can help determine that they are needed, but of course cannot prove that they are not needed, at least not unless you have a workload that exercises all possible calls to this function.

Hello Moni,

Quoted 7 lines

I think this warning got introduced via commit "IB/cma: IBoE (RoCE) IP-based GID addressing" (7b85627b9f02f9b0fb2ef5f021807f4251135857; December 12, 2013). Can you follow this up further ?

Thanks,

Bart.

Sure. I'll look into it.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html