The task_struct->tgid field is about to become deprecated, due to
pid namespaces make tasks have many pids, not one. There is one
place using it left to fix in infiniband - the make_cm_node().
This function uses the task tgid just to generate a session id,
so it's perfectly safe to use appropriate wrapper - task_tgid_nr().
Signed-off-by: Pavel Emelyanov <[email protected]>
---
drivers/infiniband/hw/nes/nes_cm.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
index 39adb26..7a06156 100644
--- a/drivers/infiniband/hw/nes/nes_cm.c
+++ b/drivers/infiniband/hw/nes/nes_cm.c
@@ -1077,7 +1077,8 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
/* get a unique session ID , add thread_id to an upcounter to handle race */
atomic_inc(&cm_core->node_cnt);
atomic_inc(&cm_core->session_id);
- cm_node->session_id = (u32)(atomic_read(&cm_core->session_id) + current->tgid);
+ cm_node->session_id = (u32)(atomic_read(&cm_core->session_id) +
+ task_tgid_nr(current));
cm_node->conn_type = cm_info->conn_type;
cm_node->apbvt_set = 0;
cm_node->accept_pend = 0;
@@ -1606,7 +1607,8 @@ static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *cm_core,
atomic_inc(&cm_core->node_cnt);
atomic_inc(&cm_core->session_id);
- listener->session_id = (u32)(atomic_read(&cm_core->session_id) + current->tgid);
+ listener->session_id = (u32)(atomic_read(&cm_core->session_id) +
+ task_tgid_nr(current));
listener->conn_type = cm_info->conn_type;
listener->backlog = cm_info->backlog;
listener->listener_state = NES_CM_LISTENER_ACTIVE_STATE;
Acked-by Glenn Streiff <[email protected]>
> From: Roland Dreier [mailto:[email protected]]
> The patch
> below compiles and links fine for me, so is the simplest fix? (I
> don't think hardware is looking at session_id behind our back, is it?)
>
> diff --git a/drivers/infiniband/hw/nes/nes_cm.c
> b/drivers/infiniband/hw/nes/nes_cm.c
> index c1a85f3..31a28e9 100644
> --- a/drivers/infiniband/hw/nes/nes_cm.c
> +++ b/drivers/infiniband/hw/nes/nes_cm.c
> @@ -365,7 +365,6 @@ static void print_core(struct nes_cm_core *core)
> if (!core)
> return;
> nes_debug(NES_DBG_CM,
> "---------------------------------------------\n");
> - nes_debug(NES_DBG_CM, "Session ID : %u \n",
> atomic_read(&core->session_id));
>
> nes_debug(NES_DBG_CM, "State : %u \n", core->state);
>
> @@ -1100,8 +1099,6 @@ static struct nes_cm_node
> *make_cm_node(struct nes_cm_core *cm_core,
> cm_node->tcp_cntxt.rcv_nxt = 0;
> /* get a unique session ID , add thread_id to an
> upcounter to handle race */
> atomic_inc(&cm_core->node_cnt);
> - atomic_inc(&cm_core->session_id);
> - cm_node->session_id =
> (u32)(atomic_read(&cm_core->session_id) + current->tgid);
> cm_node->conn_type = cm_info->conn_type;
> cm_node->apbvt_set = 0;
> cm_node->accept_pend = 0;
> @@ -1628,9 +1625,7 @@ static struct nes_cm_listener
> *mini_cm_listen(struct nes_cm_core *cm_core,
> listener->cm_core = cm_core;
> listener->nesvnic = nesvnic;
> atomic_inc(&cm_core->node_cnt);
> - atomic_inc(&cm_core->session_id);
>
> - listener->session_id =
> (u32)(atomic_read(&cm_core->session_id) + current->tgid);
> listener->conn_type = cm_info->conn_type;
> listener->backlog = cm_info->backlog;
> listener->listener_state = NES_CM_LISTENER_ACTIVE_STATE;
> @@ -1943,7 +1938,6 @@ static struct nes_cm_core
> *nes_cm_alloc_core(void)
> cm_core->state = NES_CM_STATE_INITED;
> cm_core->free_tx_pkt_max = NES_CM_DEFAULT_FREE_PKTS;
>
> - atomic_set(&cm_core->session_id, 0);
> atomic_set(&cm_core->events_posted, 0);
>
> /* init the packet lists */
> diff --git a/drivers/infiniband/hw/nes/nes_cm.h
> b/drivers/infiniband/hw/nes/nes_cm.h
> index 980fb67..7717cb2 100644
> --- a/drivers/infiniband/hw/nes/nes_cm.h
> +++ b/drivers/infiniband/hw/nes/nes_cm.h
> @@ -225,7 +225,6 @@ enum nes_cm_listener_state {
>
> struct nes_cm_listener {
> struct list_head list;
> - u64 session_id;
> struct nes_cm_core *cm_core;
> u8 loc_mac[ETH_ALEN];
> nes_addr_t loc_addr;
> @@ -242,7 +241,6 @@ struct nes_cm_listener {
>
> /* per connection node and node state information */
> struct nes_cm_node {
> - u64 session_id;
> u32 hashkey;
>
> nes_addr_t loc_addr, rem_addr;
> @@ -327,7 +325,6 @@ struct nes_cm_event {
>
> struct nes_cm_core {
> enum nes_cm_node_state state;
> - atomic_t session_id;
>
> atomic_t listen_node_cnt;
> struct nes_cm_node listen_list;
>
Thanks, I added this to my tree:
commit 0f9d8de35f49df534b79d656155d3cb1ff70f726
Author: Roland Dreier <[email protected]>
Date: Fri Mar 21 20:06:49 2008 -0700
RDMA/nes: Remove session_id from nes_cm stuff
The session_id members of struct nes_cm_listener and struct
nes_cm_node are write-only, so remove them. This allows the
session_id member of struct nes_cm_core to be removed as well, since
it is only used to write those other session_id values.
This removes the use of current->tgid (which will be deprecated)
pointed out by Pavel Emelyanov <[email protected]>.
Acked-by: Glenn Streiff <[email protected]>
Signed-off-by: Roland Dreier <[email protected]>
diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
index c1a85f3..31a28e9 100644
--- a/drivers/infiniband/hw/nes/nes_cm.c
+++ b/drivers/infiniband/hw/nes/nes_cm.c
@@ -365,7 +365,6 @@ static void print_core(struct nes_cm_core *core)
if (!core)
return;
nes_debug(NES_DBG_CM, "---------------------------------------------\n");
- nes_debug(NES_DBG_CM, "Session ID : %u \n", atomic_read(&core->session_id));
nes_debug(NES_DBG_CM, "State : %u \n", core->state);
@@ -1100,8 +1099,6 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
cm_node->tcp_cntxt.rcv_nxt = 0;
/* get a unique session ID , add thread_id to an upcounter to handle race */
atomic_inc(&cm_core->node_cnt);
- atomic_inc(&cm_core->session_id);
- cm_node->session_id = (u32)(atomic_read(&cm_core->session_id) + current->tgid);
cm_node->conn_type = cm_info->conn_type;
cm_node->apbvt_set = 0;
cm_node->accept_pend = 0;
@@ -1628,9 +1625,7 @@ static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *cm_core,
listener->cm_core = cm_core;
listener->nesvnic = nesvnic;
atomic_inc(&cm_core->node_cnt);
- atomic_inc(&cm_core->session_id);
- listener->session_id = (u32)(atomic_read(&cm_core->session_id) + current->tgid);
listener->conn_type = cm_info->conn_type;
listener->backlog = cm_info->backlog;
listener->listener_state = NES_CM_LISTENER_ACTIVE_STATE;
@@ -1943,7 +1938,6 @@ static struct nes_cm_core *nes_cm_alloc_core(void)
cm_core->state = NES_CM_STATE_INITED;
cm_core->free_tx_pkt_max = NES_CM_DEFAULT_FREE_PKTS;
- atomic_set(&cm_core->session_id, 0);
atomic_set(&cm_core->events_posted, 0);
/* init the packet lists */
diff --git a/drivers/infiniband/hw/nes/nes_cm.h b/drivers/infiniband/hw/nes/nes_cm.h
index 980fb67..7717cb2 100644
--- a/drivers/infiniband/hw/nes/nes_cm.h
+++ b/drivers/infiniband/hw/nes/nes_cm.h
@@ -225,7 +225,6 @@ enum nes_cm_listener_state {
struct nes_cm_listener {
struct list_head list;
- u64 session_id;
struct nes_cm_core *cm_core;
u8 loc_mac[ETH_ALEN];
nes_addr_t loc_addr;
@@ -242,7 +241,6 @@ struct nes_cm_listener {
/* per connection node and node state information */
struct nes_cm_node {
- u64 session_id;
u32 hashkey;
nes_addr_t loc_addr, rem_addr;
@@ -327,7 +325,6 @@ struct nes_cm_event {
struct nes_cm_core {
enum nes_cm_node_state state;
- atomic_t session_id;
atomic_t listen_node_cnt;
struct nes_cm_node listen_list;