Skip to contentSkip to conversation

rds: Fix non-atomic operation on shared flag variable

PATCH In review Håkon Bugge 3 participants 3 messages Sep 5, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rds: Fix non-atomic operation on shared flag variable

The bits in m_flags in struct rds_message are used for a plurality of reasons, and from different contexts. To avoid any missing updates to m_flags, use the atomic set_bit() instead of the non-atomic equivalent.

---
 net/rds/send.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/rds/send.c +2 -2
index 41b9f0f..058a407 100644
@@ -273,7 +273,7 @@ int rds_send_xmit(struct rds_conn_path *cp)
 			len = ntohl(rm->m_inc.i_hdr.h_len);
 			if (cp->cp_unacked_packets == 0 ||
 			    cp->cp_unacked_bytes < len) {
-				__set_bit(RDS_MSG_ACK_REQUIRED, &rm->m_flags);
+				set_bit(RDS_MSG_ACK_REQUIRED, &rm->m_flags);
 
 				cp->cp_unacked_packets =
 					rds_sysctl_max_unacked_packets;
@@ -829,7 +829,7 @@ static int rds_send_queue_rm(struct rds_sock *rs, struct rds_connection *conn,
 		 * throughput hits a certain threshold.
 		 */
 		if (rs->rs_snd_bytes >= rds_sk_sndbuf(rs) / 2)
-			__set_bit(RDS_MSG_ACK_REQUIRED, &rm->m_flags);
+			set_bit(RDS_MSG_ACK_REQUIRED, &rm->m_flags);
 
 		list_add_tail(&rm->m_sock_item, &rs->rs_send_queue);
 		set_bit(RDS_MSG_ON_SOCK, &rm->m_flags);
Signature · 1 line
2.9.3
Acked-by on v1 1/1
#1 lore raw
Quoted 26 lines · Håkon Bugge

The bits in m_flags in struct rds_message are used for a plurality of reasons, and from different contexts. To avoid any missing updates to m_flags, use the atomic set_bit() instead of the non-atomic equivalent.

---
  net/rds/send.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
net/rds/send.c +1 -1
index 41b9f0f..058a407 100644
@@ -273,7 +273,7 @@ int rds_send_xmit(struct rds_conn_path *cp)
  			len = ntohl(rm->m_inc.i_hdr.h_len);
  			if (cp->cp_unacked_packets == 0 ||
  			    cp->cp_unacked_bytes < len) {
-				__set_bit(RDS_MSG_ACK_REQUIRED, &rm->m_flags);
+				set_bit(RDS_MSG_ACK_REQUIRED, &rm->m_flags);
 
  				cp->cp_unacked_packets =
  					rds_sysctl_max_unacked_packets;

net/rds/send.c static int rds_send_queue_rm(struct rds_sock *rs, struct rds_connection *conn, · line 835

Quoted 8 lines
net/rds/send.c +1 -1
@@ -829,7 +829,7 @@ static int rds_send_queue_rm(struct rds_sock *rs, struct rds_connection *conn,
  		 * throughput hits a certain threshold.
  		 */
  		if (rs->rs_snd_bytes >= rds_sk_sndbuf(rs) / 2)
-			__set_bit(RDS_MSG_ACK_REQUIRED, &rm->m_flags);
+			set_bit(RDS_MSG_ACK_REQUIRED, &rm->m_flags);
 
  		list_add_tail(&rm->m_sock_item, &rs->rs_send_queue);
  		set_bit(RDS_MSG_ON_SOCK, &rm->m_flags);

Indeed, these couple of instances remained for the m_flags. Patch looks good. Thanks !!

maintainer
#2 lore raw
In reply to Håkon Bugge

From: Håkon Bugge <[email protected]>
Date: Tue, 5 Sep 2017 17:42:01 +0200

Quoted 7 lines

The bits in m_flags in struct rds_message are used for a plurality of reasons, and from different contexts. To avoid any missing updates to m_flags, use the atomic set_bit() instead of the non-atomic equivalent.

Applied.
--
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