net/smc: updates 2020-09-10
Subsystems (5)
cover net/smc: updates 2020-09-10
Please apply the following patch series for smc to netdev's net-next tree.
This patch series is a mix of various improvements and cleanups. The patches 1 and 10 improve the handling of large parallel workloads. Patch 8 corrects a kernel config default for config CCWGROUP on s390. Patch 9 allows userspace tools to retrieve socket information for more sockets.
Guvenc Gulce (2):
s390/net: Add SMC config as one of the defaults of CCWGROUP net/smc: Use the retry mechanism for netlink messages
Karsten Graul (1):
net/smc: use separate work queues for different worker types
Ursula Braun (7):
net/smc: reduce active tcp_listen workers net/smc: introduce better field names net/smc: dynamic allocation of CLC proposal buffer net/smc: common routine for CLC accept and confirm net/smc: improve server ISM device determination net/smc: reduce smc_listen_decline() calls net/smc: immediate freeing in smc_lgr_cleanup_early()
drivers/s390/net/Kconfig | 2 +- net/smc/af_smc.c | 216 +++++++++++++++++++--------------- net/smc/smc.h | 7 ++ net/smc/smc_cdc.c | 4 +- net/smc/smc_clc.c | 243 ++++++++++++++++++--------------------- net/smc/smc_clc.h | 93 +++++++-------- net/smc/smc_close.c | 7 +- net/smc/smc_core.c | 56 ++++----- net/smc/smc_core.h | 11 +- net/smc/smc_diag.c | 30 +++-- net/smc/smc_llc.c | 2 +- net/smc/smc_pnet.c | 5 +- net/smc/smc_tx.c | 10 +- 13 files changed, 357 insertions(+), 329 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/10 net/smc: reduce active tcp_listen workers
From: Ursula Braun <[email protected]>
SMC starts a separate tcp_listen worker for every SMC socket in state SMC_LISTEN, and can accept an incoming connection request only, if this worker is really running and waiting in kernel_accept(). But the number of running workers is limited.
This patch reworks the listening SMC code and starts a tcp_listen worker after the SYN-ACK handshake on the internal clc-socket only.
--- net/smc/af_smc.c | 38 +++++++++++++++++++++++++++++++------- net/smc/smc.h | 2 ++ net/smc/smc_close.c | 7 +++---- 3 files changed, 36 insertions(+), 11 deletions(-)
net/smc/af_smc.c +31 -7
@@ -940,10 +940,10 @@ static int smc_clcsock_accept(struct smc_sock *lsmc, struct smc_sock **new_smc)mutex_lock (&lsmc->clcsock_release_lock);if (lsmc->clcsock) - rc =kernel_accept (lsmc->clcsock, &new_clcsock,0 ); + rc =kernel_accept (lsmc->clcsock, &new_clcsock,SOCK_NONBLOCK );mutex_unlock (&lsmc->clcsock_release_lock);lock_sock (lsk); -if (rc <0 ) +if (rc <0 && rc != -EAGAIN ) lsk->sk_err = -rc;if (rc <0 || lsk->sk_state ==SMC_CLOSED ) { new_sk->sk_prot->unhash (new_sk);
@@ -956,6 +956,10 @@ static int smc_clcsock_accept(struct smc_sock *lsmc, struct smc_sock **new_smc) goto out; } +/* new clcsock has inherited the smc listen-specific sk_data_ready +* function; switch it back to the original sk_data_ready function +*/ + new_clcsock->sk->sk_data_ready = lsmc->clcsk_data_ready; (*new_smc)->clcsock = new_clcsock; out:return rc;
@@ -1406,7 +1410,7 @@ static void smc_tcp_listen_work(struct work_struct *work)lock_sock (lsk);while (lsk->sk_state ==SMC_LISTEN ) { rc =smc_clcsock_accept (lsmc, &new_smc); -if (rc) +if (rc)/* clcsock accept queue empty or error */ goto out;if (!new_smc)continue ;
@@ -1426,7 +1430,23 @@ static void smc_tcp_listen_work(struct work_struct *work) out:release_sock (lsk); -sock_put (&lsmc->sk);/* sock_hold in smc_listen */ +sock_put (&lsmc->sk);/* sock_hold in smc_clcsock_data_ready() */ +} + +static void smc_clcsock_data_ready (struct sock *listen_clcsock) +{ +struct smc_sock *lsmc; + + lsmc = (struct smc_sock *) + ((uintptr_t )listen_clcsock->sk_user_data & ~SK_USER_DATA_NOCOPY ); +if (!lsmc) +return ; + lsmc->clcsk_data_ready (listen_clcsock); +if (lsmc->sk.sk_state ==SMC_LISTEN ) { +sock_hold (&lsmc->sk);/* sock_put in smc_tcp_listen_work() */ +if (!schedule_work (&lsmc->tcp_listen_work)) +sock_put (&lsmc->sk); + } }static int smc_listen (struct socket *sock,int backlog)
@@ -1455,15 +1475,19 @@ static int smc_listen(struct socket *sock, int backlog)if (!smc->use_fallback)tcp_sk (smc->clcsock->sk)->syn_smc =1 ; +/* save original sk_data_ready function and establish +* smc-specific sk_data_ready function +*/ + smc->clcsk_data_ready = smc->clcsock->sk->sk_data_ready; + smc->clcsock->sk->sk_data_ready = smc_clcsock_data_ready; + smc->clcsock->sk->sk_user_data = + (void *)((uintptr_t )smc |SK_USER_DATA_NOCOPY ); rc =kernel_listen (smc->clcsock, backlog);if (rc) goto out; sk->sk_max_ack_backlog = backlog; sk->sk_ack_backlog =0 ; sk->sk_state =SMC_LISTEN ; -sock_hold (sk);/* sock_hold in tcp_listen_worker */ -if (!schedule_work (&smc->tcp_listen_work)) -sock_put (sk); out:release_sock (sk);
net/smc/smc.h +2 -0
@@ -201,6 +201,8 @@ struct smc_connection {struct smc_sock {/* smc sock container */ struct sock sk;struct socket *clcsock;/* internal tcp socket */ +void (*clcsk_data_ready)(struct sock *sk); +/* original data_ready fct. **/ struct smc_connection conn;/* smc connection */ struct smc_sock *listen_smc;/* listen parent */ struct work_struct connect_work;/* handle non-blocking connect*/
net/smc/smc_close.c +3 -4
@@ -208,12 +208,11 @@ int smc_close_active(struct smc_sock *smc)break ;case SMC_LISTEN : sk->sk_state =SMC_CLOSED ; + smc->clcsock->sk->sk_data_ready = smc->clcsk_data_ready; + smc->clcsock->sk->sk_user_data =NULL ; sk->sk_state_change (sk);/* wake up accept */ -if (smc->clcsock && smc->clcsock->sk) { +if (smc->clcsock && smc->clcsock->sk) rc =kernel_sock_shutdown (smc->clcsock,SHUT_RDWR ); -/* wake up kernel_accept of smc_tcp_listen_worker */ - smc->clcsock->sk->sk_data_ready (smc->clcsock->sk); - }smc_close_cleanup_listen (sk);release_sock (sk);flush_work (&smc->tcp_listen_work);
Signature · 1 line
2.17.1
PATCH 2/10 net/smc: introduce better field names
In reply to Karsten GraulFrom: Ursula Braun <[email protected]>
Field names "srv_first_contact" and "cln_first_contact" are misleading, since they apply to both, server and client. Rename them to "first_contact_peer" and "first_contact_local".
Rename "ism_gid" by the more precise name "ism_peer_gid". Rename version constant "SMC_CLC_V1" into "SMC_V1".
No functional change.
--- net/smc/af_smc.c | 66 +++++++++++++++++++++++----------------------- net/smc/smc.h | 2 ++ net/smc/smc_clc.c | 16 +++++------ net/smc/smc_clc.h | 3 +-- net/smc/smc_core.c | 16 +++++------ net/smc/smc_core.h | 9 +++---- 6 files changed, 55 insertions(+), 57 deletions(-)
net/smc/af_smc.c +33 -33
@@ -523,11 +523,11 @@ static int smc_connect_decline_fallback(struct smc_sock *smc, int reason_code)/* abort connecting */ static int smc_connect_abort (struct smc_sock *smc,int reason_code, -int local_contact) +int local_first) {bool is_smcd = smc->conn.lgr->is_smcd; -if (local_contact ==SMC_FIRST_CONTACT ) +if (local_first)smc_lgr_cleanup_early (&smc->conn);else smc_conn_free (&smc->conn);
@@ -615,7 +615,7 @@ static int smc_connect_rdma(struct smc_sock *smc, ini->is_smcd = false; ini->ib_lcl = &aclc->lcl; ini->ib_clcqpn =ntoh24 (aclc->qpn); - ini->srv_first_contact = aclc->hdr.flag; + ini->first_contact_peer = aclc->hdr.flag;mutex_lock (&smc_client_lgr_pending); reason_code =smc_conn_create (smc, ini);
@@ -626,7 +626,7 @@ static int smc_connect_rdma(struct smc_sock *smc,smc_conn_save_peer_info (smc, aclc); -if (ini->cln_first_contact ==SMC_FIRST_CONTACT ) { +if (ini->first_contact_local) { link = smc->conn.lnk; }else {/* set link that was assigned by server */
@@ -643,51 +643,51 @@ static int smc_connect_rdma(struct smc_sock *smc, }if (!link)return smc_connect_abort (smc,SMC_CLC_DECL_NOSRVLINK , - ini->cln_first_contact); + ini->first_contact_local); smc->conn.lnk = link; }/* create send buffer and rmb */ if (smc_buf_create (smc, false))return smc_connect_abort (smc,SMC_CLC_DECL_MEM , - ini->cln_first_contact); + ini->first_contact_local); -if (ini->cln_first_contact ==SMC_FIRST_CONTACT ) +if (ini->first_contact_local)smc_link_save_peer_info (link, aclc);if (smc_rmb_rtoken_handling (&smc->conn, link, aclc))return smc_connect_abort (smc,SMC_CLC_DECL_ERR_RTOK , - ini->cln_first_contact); + ini->first_contact_local);smc_close_init (smc);smc_rx_init (smc); -if (ini->cln_first_contact ==SMC_FIRST_CONTACT ) { +if (ini->first_contact_local) {if (smc_ib_ready_link (link))return smc_connect_abort (smc,SMC_CLC_DECL_ERR_RDYLNK , - ini->cln_first_contact); + ini->first_contact_local); }else {if (smcr_lgr_reg_rmbs (link, smc->conn.rmb_desc))return smc_connect_abort (smc,SMC_CLC_DECL_ERR_REGRMB , - ini->cln_first_contact); + ini->first_contact_local); }smc_rmb_sync_sg_for_device (&smc->conn); reason_code =smc_clc_send_confirm (smc);if (reason_code)return smc_connect_abort (smc, reason_code, - ini->cln_first_contact); + ini->first_contact_local);smc_tx_init (smc); -if (ini->cln_first_contact ==SMC_FIRST_CONTACT ) { +if (ini->first_contact_local) {/* QP confirmation over RoCE fabric */ smc_llc_flow_initiate (link->lgr,SMC_LLC_FLOW_ADD_LINK ); reason_code =smcr_clnt_conf_first_link (smc);smc_llc_flow_stop (link->lgr, &link->lgr->llc_flow_lcl);if (reason_code)return smc_connect_abort (smc, reason_code, - ini->cln_first_contact); + ini->first_contact_local); }mutex_unlock (&smc_client_lgr_pending);
@@ -707,8 +707,8 @@ static int smc_connect_ism(struct smc_sock *smc,int rc =0 ; ini->is_smcd = true; - ini->ism_gid = aclc->gid; - ini->srv_first_contact = aclc->hdr.flag; + ini->ism_peer_gid = aclc->gid; + ini->first_contact_peer = aclc->hdr.flag;/* there is only one lgr role for SMC-D; use server lock */ mutex_lock (&smc_server_lgr_pending);
@@ -724,7 +724,7 @@ static int smc_connect_ism(struct smc_sock *smc,return smc_connect_abort (smc, (rc == -ENOSPC ) ?SMC_CLC_DECL_MAX_DMB :SMC_CLC_DECL_MEM , - ini->cln_first_contact); + ini->first_contact_local);smc_conn_save_peer_info (smc, aclc);smc_close_init (smc);
@@ -733,7 +733,7 @@ static int smc_connect_ism(struct smc_sock *smc, rc =smc_clc_send_confirm (smc);if (rc) -return smc_connect_abort (smc, rc, ini->cln_first_contact); +return smc_connect_abort (smc, rc, ini->first_contact_local);mutex_unlock (&smc_server_lgr_pending);smc_copy_sock_settings_to_clc (smc);
@@ -1127,10 +1127,10 @@ static void smc_listen_out_err(struct smc_sock *new_smc)/* listen worker: decline and fall back if possible */ static void smc_listen_decline (struct smc_sock *new_smc,int reason_code, -int local_contact) +bool local_first) {/* RDMA setup failed, switch back to TCP */ -if (local_contact ==SMC_FIRST_CONTACT ) +if (local_first)smc_lgr_cleanup_early (&new_smc->conn);else smc_conn_free (&new_smc->conn);
@@ -1190,7 +1190,7 @@ static int smc_listen_ism_init(struct smc_sock *new_smc,int rc; pclc_smcd =smc_get_clc_msg_smcd (pclc); - ini->ism_gid = pclc_smcd->gid; + ini->ism_peer_gid = pclc_smcd->gid; rc =smc_conn_create (new_smc, ini);if (rc)return rc;
@@ -1199,7 +1199,7 @@ static int smc_listen_ism_init(struct smc_sock *new_smc,if (smc_ism_cantalk (new_smc->conn.lgr->peer_gid, new_smc->conn.lgr->vlan_id, new_smc->conn.lgr->smcd)) { -if (ini->cln_first_contact ==SMC_FIRST_CONTACT ) +if (ini->first_contact_local)smc_lgr_cleanup_early (&new_smc->conn);else smc_conn_free (&new_smc->conn);
@@ -1209,7 +1209,7 @@ static int smc_listen_ism_init(struct smc_sock *new_smc,/* Create send and receive buffers */ rc =smc_buf_create (new_smc, true);if (rc) { -if (ini->cln_first_contact ==SMC_FIRST_CONTACT ) +if (ini->first_contact_local)smc_lgr_cleanup_early (&new_smc->conn);else smc_conn_free (&new_smc->conn);
@@ -1221,11 +1221,11 @@ static int smc_listen_ism_init(struct smc_sock *new_smc, }/* listen worker: register buffers */ -static int smc_listen_rdma_reg (struct smc_sock *new_smc,int local_contact) +static int smc_listen_rdma_reg (struct smc_sock *new_smc,bool local_first) {struct smc_connection *conn = &new_smc->conn; -if (local_contact !=SMC_FIRST_CONTACT ) { +if (!local_first) {if (smcr_lgr_reg_rmbs (conn->lnk, conn->rmb_desc))return SMC_CLC_DECL_ERR_REGRMB ; }
@@ -1237,12 +1237,12 @@ static int smc_listen_rdma_reg(struct smc_sock *new_smc, int local_contact)/* listen worker: finish RDMA setup */ static int smc_listen_rdma_finish (struct smc_sock *new_smc,struct smc_clc_msg_accept_confirm *cclc, -int local_contact) +bool local_first) {struct smc_link *link = new_smc->conn.lnk;int reason_code =0 ; -if (local_contact ==SMC_FIRST_CONTACT ) +if (local_first)smc_link_save_peer_info (link, cclc);if (smc_rmb_rtoken_handling (&new_smc->conn, link, cclc)) {
@@ -1250,7 +1250,7 @@ static int smc_listen_rdma_finish(struct smc_sock *new_smc, goto decline; } -if (local_contact ==SMC_FIRST_CONTACT ) { +if (local_first) {if (smc_ib_ready_link (link)) { reason_code =SMC_CLC_DECL_ERR_RDYLNK ; goto decline;
@@ -1265,7 +1265,7 @@ static int smc_listen_rdma_finish(struct smc_sock *new_smc,return 0 ; decline: -smc_listen_decline (new_smc, reason_code, local_contact); +smc_listen_decline (new_smc, reason_code, local_first);return reason_code; }
@@ -1358,13 +1358,13 @@ static void smc_listen_work(struct work_struct *work) rc =smc_listen_rdma_init (new_smc, &ini);if (rc) goto out_unlock; - rc =smc_listen_rdma_reg (new_smc, ini.cln_first_contact); + rc =smc_listen_rdma_reg (new_smc, ini.first_contact_local);if (rc) goto out_unlock; }/* send SMC Accept CLC message */ - rc =smc_clc_send_accept (new_smc, ini.cln_first_contact); + rc =smc_clc_send_accept (new_smc, ini.first_contact_local);if (rc) goto out_unlock;
@@ -1384,7 +1384,7 @@ static void smc_listen_work(struct work_struct *work)/* finish worker */ if (!ism_supported) { rc =smc_listen_rdma_finish (new_smc, &cclc, - ini.cln_first_contact); + ini.first_contact_local);mutex_unlock (&smc_server_lgr_pending);if (rc)return ;
@@ -1396,7 +1396,7 @@ static void smc_listen_work(struct work_struct *work) out_unlock:mutex_unlock (&smc_server_lgr_pending); out_decl: -smc_listen_decline (new_smc, rc, ini.cln_first_contact); +smc_listen_decline (new_smc, rc, ini.first_contact_local); }static void smc_tcp_listen_work (struct work_struct *work)
net/smc/smc.h +2 -0
@@ -18,6 +18,8 @@#include "smc_ib.h" +#define SMC_V1 1/* SMC version V1 */ +#define SMCPROTO_SMC 0/* SMC protocol, IPv4 */ #define SMCPROTO_SMC6 1/* SMC protocol, IPv6 */
net/smc/smc_clc.c +8 -8
@@ -320,7 +320,7 @@ int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen, } datlen =ntohs (clcm->length);if ((len <sizeof (struct smc_clc_msg_hdr )) || - (clcm->version <SMC_CLC_V1 ) || + (clcm->version <SMC_V1 ) || ((clcm->type !=SMC_CLC_DECLINE ) && (clcm->type != expected_type))) { smc->sk.sk_err =EPROTO ;
@@ -389,7 +389,7 @@ int smc_clc_send_decline(struct smc_sock *smc, u32 peer_diag_info)memcpy (dclc.hdr.eyecatcher,SMC_EYECATCHER ,sizeof (SMC_EYECATCHER )); dclc.hdr.type =SMC_CLC_DECLINE ; dclc.hdr.length =htons (sizeof (struct smc_clc_msg_decline )); - dclc.hdr.version =SMC_CLC_V1 ; + dclc.hdr.version =SMC_V1 ; dclc.hdr.flag = (peer_diag_info ==SMC_CLC_DECL_SYNCERR ) ?1 :0 ;if ((!smc->conn.lgr || !smc->conn.lgr->is_smcd) &&smc_ib_is_valid_local_systemid ())
@@ -434,7 +434,7 @@ int smc_clc_send_proposal(struct smc_sock *smc, int smc_type,memset (&pclc,0 ,sizeof (pclc));memcpy (pclc.hdr.eyecatcher,SMC_EYECATCHER ,sizeof (SMC_EYECATCHER )); pclc.hdr.type =SMC_CLC_PROPOSAL ; - pclc.hdr.version =SMC_CLC_V1 ;/* SMC version */ + pclc.hdr.version =SMC_V1 ;/* SMC version */ pclc.hdr.path = smc_type;if (smc_type ==SMC_TYPE_R || smc_type ==SMC_TYPE_B ) {/* add SMC-R specifics */
@@ -499,8 +499,8 @@ int smc_clc_send_confirm(struct smc_sock *smc)/* send SMC Confirm CLC msg */ memset (&cclc,0 ,sizeof (cclc)); cclc.hdr.type =SMC_CLC_CONFIRM ; - cclc.hdr.version =SMC_CLC_V1 ;/* SMC version */ -if (smc->conn.lgr->is_smcd) { + cclc.hdr.version =SMC_V1 ;/* SMC version */ +if (conn->lgr->is_smcd) {/* SMC-D specific settings */ memcpy (cclc.hdr.eyecatcher,SMCD_EYECATCHER ,sizeof (SMCD_EYECATCHER ));
@@ -557,7 +557,7 @@ int smc_clc_send_confirm(struct smc_sock *smc) }/* send CLC ACCEPT message across internal TCP socket */ -int smc_clc_send_accept (struct smc_sock *new_smc,int srv_first_contact) +int smc_clc_send_accept (struct smc_sock *new_smc,bool srv_first_contact) {struct smc_connection *conn = &new_smc->conn;struct smc_clc_msg_accept_confirm aclc;
@@ -568,11 +568,11 @@ int smc_clc_send_accept(struct smc_sock *new_smc, int srv_first_contact)memset (&aclc,0 ,sizeof (aclc)); aclc.hdr.type =SMC_CLC_ACCEPT ; - aclc.hdr.version =SMC_CLC_V1 ;/* SMC version */ + aclc.hdr.version =SMC_V1 ;/* SMC version */ if (srv_first_contact) aclc.hdr.flag =1 ; -if (new_smc->conn.lgr->is_smcd) { +if (conn->lgr->is_smcd) {/* SMC-D specific settings */ aclc.hdr.length =htons (SMCD_CLC_ACCEPT_CONFIRM_LEN ); memcpy(aclc.hdr.eyecatcher, SMCD_EYECATCHER,
net/smc/smc_clc.h +1 -2
@@ -22,7 +22,6 @@#define SMC_CLC_CONFIRM 0x03#define SMC_CLC_DECLINE 0x04 -#define SMC_CLC_V1 0x1/* SMC version */ #define SMC_TYPE_R 0/* SMC-R only */ #define SMC_TYPE_D 1/* SMC-D only */ #define SMC_TYPE_N 2/* neither SMC-R nor SMC-D */
@@ -200,6 +199,6 @@ int smc_clc_send_decline(struct smc_sock *smc, u32 peer_diag_info);int smc_clc_send_proposal (struct smc_sock *smc,int smc_type,struct smc_init_info *ini);int smc_clc_send_confirm (struct smc_sock *smc); -int smc_clc_send_accept (struct smc_sock *smc,int srv_first_contact); +int smc_clc_send_accept (struct smc_sock *smc,bool srv_first_contact);#endif
net/smc/smc_core.c +8 -8
@@ -418,7 +418,7 @@ static int smc_lgr_create(struct smc_sock *smc, struct smc_init_info *ini)if (ini->is_smcd) {/* SMC-D specific settings */ get_device (&ini->ism_dev->dev); - lgr->peer_gid = ini->ism_gid; + lgr->peer_gid = ini->ism_peer_gid; lgr->smcd = ini->ism_dev; lgr_list = &ini->ism_dev->lgr_list; lgr_lock = &lgr->smcd->lgr_lock;
@@ -1296,9 +1296,9 @@ int smc_conn_create(struct smc_sock *smc, struct smc_init_info *ini) lgr_list = ini->is_smcd ? &ini->ism_dev->lgr_list : &smc_lgr_list.list; lgr_lock = ini->is_smcd ? &ini->ism_dev->lgr_lock : &smc_lgr_list.lock; - ini->cln_first_contact =SMC_FIRST_CONTACT ; + ini->first_contact_local =1 ; role = smc->listen_smc ?SMC_SERV :SMC_CLNT ; -if (role ==SMC_CLNT && ini->srv_first_contact) +if (role ==SMC_CLNT && ini->first_contact_peer)/* create new link group as well */ goto create;
@@ -1307,14 +1307,14 @@ int smc_conn_create(struct smc_sock *smc, struct smc_init_info *ini)list_for_each_entry (lgr, lgr_list, list) {write_lock_bh (&lgr->conns_lock);if ((ini->is_smcd ? -smcd_lgr_match (lgr, ini->ism_dev, ini->ism_gid) : +smcd_lgr_match (lgr, ini->ism_dev, ini->ism_peer_gid) :smcr_lgr_match (lgr, ini->ib_lcl, role, ini->ib_clcqpn)) && !lgr->sync_err && lgr->vlan_id == ini->vlan_id && (role ==SMC_CLNT || ini->is_smcd || lgr->conns_num <SMC_RMBS_PER_LGR_MAX )) {/* link group found */ - ini->cln_first_contact =SMC_REUSE_CONTACT ; + ini->first_contact_local =0 ; conn->lgr = lgr; rc =smc_lgr_register_conn (conn, false);write_unlock_bh (&lgr->conns_lock);
@@ -1328,8 +1328,8 @@ int smc_conn_create(struct smc_sock *smc, struct smc_init_info *ini)if (rc)return rc; -if (role ==SMC_CLNT && !ini->srv_first_contact && - ini->cln_first_contact ==SMC_FIRST_CONTACT ) { +if (role ==SMC_CLNT && !ini->first_contact_peer && + ini->first_contact_local) {/* Server reuses a link group, but Client wants to start * a new one * send out_of_sync decline, reason synchr. error
@@ -1338,7 +1338,7 @@ int smc_conn_create(struct smc_sock *smc, struct smc_init_info *ini) } create: -if (ini->cln_first_contact ==SMC_FIRST_CONTACT ) { +if (ini->first_contact_local) { rc =smc_lgr_create (smc, ini);if (rc) goto out;
net/smc/smc_core.h +3 -6
@@ -137,9 +137,6 @@ struct smc_link {#define SMC_LINKS_PER_LGR_MAX 3#define SMC_SINGLE_LINK 0 -#define SMC_FIRST_CONTACT 1/* first contact to a peer */ -#define SMC_REUSE_CONTACT 0/* follow-on contact to a peer*/ -/* tx/rx buffer list element for sndbufs list and rmbs list of a lgr */ struct smc_buf_desc {struct list_head list;
@@ -294,9 +291,9 @@ struct smc_clc_msg_local;struct smc_init_info {u8 is_smcd; +u8 first_contact_peer; +u8 first_contact_local;unsigned short vlan_id; -int srv_first_contact; -int cln_first_contact;/* SMC-R */ struct smc_clc_msg_local *ib_lcl;struct smc_ib_device *ib_dev;
@@ -304,7 +301,7 @@ struct smc_init_info {u8 ib_port;u32 ib_clcqpn;/* SMC-D */ -u64 ism_gid; +u64 ism_peer_gid;struct smcd_dev *ism_dev; };
Signature · 1 line
2.17.1
PATCH 3/10 net/smc: dynamic allocation of CLC proposal buffer
In reply to Karsten GraulFrom: Ursula Braun <[email protected]>
Reduce stack size for smc_listen_work() and smc_clc_send_proposal() by dynamic allocation of the CLC buffer to be received or sent.
--- net/smc/af_smc.c | 13 +++++-- net/smc/smc_clc.c | 88 +++++++++++++++++++++++++++-------------------- net/smc/smc_clc.h | 15 ++++---- 3 files changed, 67 insertions(+), 49 deletions(-)
net/smc/af_smc.c +10 -3
@@ -1276,10 +1276,10 @@ static void smc_listen_work(struct work_struct *work) smc_listen_work);struct socket *newclcsock = new_smc->clcsock;struct smc_clc_msg_accept_confirm cclc; +struct smc_clc_msg_proposal_area *buf;struct smc_clc_msg_proposal *pclc;struct smc_init_info ini = {0 };bool ism_supported = false; -u8 buf[SMC_CLC_MAX_LEN ];int rc =0 ;if (new_smc->listen_smc->sk.sk_state !=SMC_LISTEN )
@@ -1301,8 +1301,13 @@ static void smc_listen_work(struct work_struct *work)/* do inband token exchange - * wait for and receive SMC Proposal CLC message */ - pclc = (struct smc_clc_msg_proposal *)&buf; - rc =smc_clc_wait_msg (new_smc, pclc,SMC_CLC_MAX_LEN , + buf =kzalloc (sizeof (*buf),GFP_KERNEL ); +if (!buf) { + rc =SMC_CLC_DECL_MEM ; + goto out_decl; + } + pclc = (struct smc_clc_msg_proposal *)buf; + rc =smc_clc_wait_msg (new_smc, pclc,sizeof (*buf),SMC_CLC_PROPOSAL ,CLC_WAIT_TIME );if (rc) goto out_decl;
@@ -1382,6 +1387,7 @@ static void smc_listen_work(struct work_struct *work) }/* finish worker */ +kfree (buf);if (!ism_supported) { rc =smc_listen_rdma_finish (new_smc, &cclc, ini.first_contact_local);
@@ -1397,6 +1403,7 @@ static void smc_listen_work(struct work_struct *work)mutex_unlock (&smc_server_lgr_pending); out_decl:smc_listen_decline (new_smc, rc, ini.first_contact_local); +kfree (buf); }static void smc_tcp_listen_work (struct work_struct *work)
net/smc/smc_clc.c +50 -38
133 lines not on this page · raw message
net/smc/smc_clc.h +7 -8
@@ -110,14 +110,13 @@ struct smc_clc_msg_proposal { /* clc proposal message sent by Linux */__be16 iparea_offset;/* offset to IP address information area */ }__aligned(4) ; -#define SMC_CLC_PROPOSAL_MAX_OFFSET 0x28 -#define SMC_CLC_PROPOSAL_MAX_PREFIX (SMC_CLC_MAX_V6_PREFIX * \ - sizeof(struct smc_clc_ipv6_prefix)) -#define SMC_CLC_MAX_LEN (sizeof(struct smc_clc_msg_proposal) + \ - SMC_CLC_PROPOSAL_MAX_OFFSET + \ - sizeof(struct smc_clc_msg_proposal_prefix) + \ - SMC_CLC_PROPOSAL_MAX_PREFIX + \ - sizeof(struct smc_clc_msg_trail)) +struct smc_clc_msg_proposal_area { +struct smc_clc_msg_proposal pclc_base; +struct smc_clc_msg_smcd pclc_smcd; +struct smc_clc_msg_proposal_prefix pclc_prfx; +struct smc_clc_ipv6_prefix pclc_prfx_ipv6[SMC_CLC_MAX_V6_PREFIX ]; +struct smc_clc_msg_trail pclc_trl; +};struct smc_clc_msg_accept_confirm {/* clc accept / confirm message */ struct smc_clc_msg_hdr hdr;
Signature · 1 line
2.17.1
PATCH 4/10 net/smc: common routine for CLC accept and confirm
In reply to Karsten GraulFrom: Ursula Braun <[email protected]>
smc_clc_send_accept() and smc_clc_send_confirm() are quite similar. Move common code into a separate function smc_clc_send_confirm_accept(). And introduce separate SMCD and SMCR struct definitions for CLC accept resp. confirm.
No functional change.
--- net/smc/af_smc.c | 36 +++++------ net/smc/smc_clc.c | 147 ++++++++++++++++++--------------------------- net/smc/smc_clc.h | 74 ++++++++++++----------- net/smc/smc_core.c | 4 +- 4 files changed, 118 insertions(+), 143 deletions(-)
net/smc/af_smc.c +19 -17
@@ -436,10 +436,10 @@ static int smcr_clnt_conf_first_link(struct smc_sock *smc)static void smcr_conn_save_peer_info (struct smc_sock *smc,struct smc_clc_msg_accept_confirm *clc) { -int bufsize =smc_uncompress_bufsize (clc->rmbe_size); +int bufsize =smc_uncompress_bufsize (clc->r0.rmbe_size); - smc->conn.peer_rmbe_idx = clc->rmbe_idx; - smc->conn.local_tx_ctrl.token =ntohl (clc->rmbe_alert_token); + smc->conn.peer_rmbe_idx = clc->r0.rmbe_idx; + smc->conn.local_tx_ctrl.token =ntohl (clc->r0.rmbe_alert_token); smc->conn.peer_rmbe_size = bufsize;atomic_set (&smc->conn.peer_rmbe_space, smc->conn.peer_rmbe_size); smc->conn.tx_off = bufsize * (smc->conn.peer_rmbe_idx -1 );
@@ -448,10 +448,10 @@ static void smcr_conn_save_peer_info(struct smc_sock *smc,static void smcd_conn_save_peer_info (struct smc_sock *smc,struct smc_clc_msg_accept_confirm *clc) { -int bufsize =smc_uncompress_bufsize (clc->dmbe_size); +int bufsize =smc_uncompress_bufsize (clc->d0.dmbe_size); - smc->conn.peer_rmbe_idx = clc->dmbe_idx; - smc->conn.peer_token = clc->token; + smc->conn.peer_rmbe_idx = clc->d0.dmbe_idx; + smc->conn.peer_token = clc->d0.token;/* msg header takes up space in the buffer */ smc->conn.peer_rmbe_size = bufsize -sizeof (struct smcd_cdc_msg );atomic_set (&smc->conn.peer_rmbe_space, smc->conn.peer_rmbe_size);
@@ -470,11 +470,11 @@ static void smc_conn_save_peer_info(struct smc_sock *smc,static void smc_link_save_peer_info (struct smc_link *link,struct smc_clc_msg_accept_confirm *clc) { - link->peer_qpn =ntoh24 (clc->qpn); -memcpy (link->peer_gid, clc->lcl.gid,SMC_GID_SIZE ); -memcpy (link->peer_mac, clc->lcl.mac,sizeof (link->peer_mac)); - link->peer_psn =ntoh24 (clc->psn); - link->peer_mtu = clc->qp_mtu; + link->peer_qpn =ntoh24 (clc->r0.qpn); +memcpy (link->peer_gid, clc->r0.lcl.gid,SMC_GID_SIZE ); +memcpy (link->peer_mac, clc->r0.lcl.mac,sizeof (link->peer_mac)); + link->peer_psn =ntoh24 (clc->r0.psn); + link->peer_mtu = clc->r0.qp_mtu; }static void smc_switch_to_fallback (struct smc_sock *smc)
@@ -613,8 +613,8 @@ static int smc_connect_rdma(struct smc_sock *smc,struct smc_link *link; ini->is_smcd = false; - ini->ib_lcl = &aclc->lcl; - ini->ib_clcqpn =ntoh24 (aclc->qpn); + ini->ib_lcl = &aclc->r0.lcl; + ini->ib_clcqpn =ntoh24 (aclc->r0.qpn); ini->first_contact_peer = aclc->hdr.flag;mutex_lock (&smc_client_lgr_pending);
@@ -634,9 +634,11 @@ static int smc_connect_rdma(struct smc_sock *smc,for (i =0 ; i <SMC_LINKS_PER_LGR_MAX ; i++) {struct smc_link *l = &smc->conn.lgr->lnk[i]; -if (l->peer_qpn ==ntoh24 (aclc->qpn) && - !memcmp (l->peer_gid, &aclc->lcl.gid,SMC_GID_SIZE ) && - !memcmp (l->peer_mac, &aclc->lcl.mac,sizeof (l->peer_mac))) { +if (l->peer_qpn ==ntoh24 (aclc->r0.qpn) && + !memcmp (l->peer_gid, &aclc->r0.lcl.gid, +SMC_GID_SIZE ) && + !memcmp (l->peer_mac, &aclc->r0.lcl.mac, +sizeof (l->peer_mac))) { link = l;break ; }
@@ -707,7 +709,7 @@ static int smc_connect_ism(struct smc_sock *smc,int rc =0 ; ini->is_smcd = true; - ini->ism_peer_gid = aclc->gid; + ini->ism_peer_gid = aclc->d0.gid; ini->first_contact_peer = aclc->hdr.flag;/* there is only one lgr role for SMC-D; use server lock */
net/smc/smc_clc.c +58 -89
186 lines not on this page · raw message
net/smc/smc_clc.h +39 -35
85 lines not on this page · raw message
net/smc/smc_core.c +2 -2
@@ -1892,8 +1892,8 @@ int smc_rmb_rtoken_handling(struct smc_connection *conn,struct smc_link *lnk, struct smc_clc_msg_accept_confirm *clc) { - conn->rtoken_idx = smc_rtoken_add(lnk, clc->rmb_dma_addr, - clc->rmb_rkey); + conn->rtoken_idx = smc_rtoken_add(lnk, clc->r0.rmb_dma_addr, + clc->r0.rmb_rkey);if (conn->rtoken_idx <0 )return conn->rtoken_idx;return 0 ;
Signature · 1 line
2.17.1
PATCH 5/10 net/smc: improve server ISM device determination
In reply to Karsten GraulFrom: Ursula Braun <[email protected]>
Move check whether peer can be reached into smc_pnet_find_ism_by_pnetid(). Thus searching continues for another ism device, if check fails.
--- net/smc/af_smc.c | 17 +++-------------- net/smc/smc_clc.h | 1 - net/smc/smc_pnet.c | 5 ++++- 3 files changed, 7 insertions(+), 16 deletions(-)
net/smc/af_smc.c +3 -14
@@ -1188,26 +1188,12 @@ static int smc_listen_ism_init(struct smc_sock *new_smc,struct smc_clc_msg_proposal *pclc, struct smc_init_info *ini) { - struct smc_clc_msg_smcd *pclc_smcd; int rc; - pclc_smcd =smc_get_clc_msg_smcd (pclc); - ini->ism_peer_gid = pclc_smcd->gid; rc =smc_conn_create (new_smc, ini);if (rc)return rc; -/* Check if peer can be reached via ISM device */ -if (smc_ism_cantalk (new_smc->conn.lgr->peer_gid, - new_smc->conn.lgr->vlan_id, - new_smc->conn.lgr->smcd)) { -if (ini->first_contact_local) -smc_lgr_cleanup_early (&new_smc->conn); -else -smc_conn_free (&new_smc->conn); -return SMC_CLC_DECL_SMCDNOTALK ; - } -/* Create send and receive buffers */ rc =smc_buf_create (new_smc, true);if (rc) {
@@ -1338,7 +1324,10 @@ static void smc_listen_work(struct work_struct *work)/* check if ISM is available */ if (pclc->hdr.path ==SMC_TYPE_D || pclc->hdr.path ==SMC_TYPE_B ) { +struct smc_clc_msg_smcd *pclc_smcd =smc_get_clc_msg_smcd (pclc); + ini.is_smcd = true;/* prepare ISM check */ + ini.ism_peer_gid = pclc_smcd->gid; rc =smc_find_ism_device (new_smc, &ini);if (!rc) rc =smc_listen_ism_init (new_smc, pclc, &ini);
net/smc/smc_clc.h +0 -1
@@ -37,7 +37,6 @@#define SMC_CLC_DECL_NOSMCDEV 0x03030000/* no SMC device found (R or D) */ #define SMC_CLC_DECL_NOSMCDDEV 0x03030001/* no SMC-D device found */ #define SMC_CLC_DECL_NOSMCRDEV 0x03030002/* no SMC-R device found */ -#define SMC_CLC_DECL_SMCDNOTALK 0x03030003/* SMC-D dev can't talk to peer */ #define SMC_CLC_DECL_MODEUNSUPP 0x03040000/* smc modes do not match (R or D)*/ #define SMC_CLC_DECL_RMBE_EC 0x03050000/* peer has eyecatcher in RMBE */ #define SMC_CLC_DECL_OPTUNSUPP 0x03060000/* fastopen sockopt not supported */
net/smc/smc_pnet.c +4 -1
@@ -928,7 +928,10 @@ static void smc_pnet_find_ism_by_pnetid(struct net_device *ndev,mutex_lock (&smcd_dev_list.mutex);list_for_each_entry (ismdev, &smcd_dev_list.list, list) {if (smc_pnet_match (ismdev->pnetid, ndev_pnetid) && - !ismdev->going_away) { + !ismdev->going_away && + (!ini->ism_peer_gid || + !smc_ism_cantalk (ini->ism_peer_gid, ini->vlan_id, + ismdev))) { ini->ism_dev = ismdev;break ; }
Signature · 1 line
2.17.1
PATCH 6/10 net/smc: reduce smc_listen_decline() calls
In reply to Karsten GraulFrom: Ursula Braun <[email protected]>
smc_listen_work() contains already an smc_listen_decline() exit. Use this exit for smc_listen_rdma_finish() problems as well.
--- net/smc/af_smc.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-)
net/smc/af_smc.c +6 -16
@@ -1233,27 +1233,17 @@ static int smc_listen_rdma_finish(struct smc_sock *new_smc,if (local_first)smc_link_save_peer_info (link, cclc); -if (smc_rmb_rtoken_handling (&new_smc->conn, link, cclc)) { - reason_code =SMC_CLC_DECL_ERR_RTOK ; - goto decline; - } +if (smc_rmb_rtoken_handling (&new_smc->conn, link, cclc)) +return SMC_CLC_DECL_ERR_RTOK ;if (local_first) { -if (smc_ib_ready_link (link)) { - reason_code =SMC_CLC_DECL_ERR_RDYLNK ; - goto decline; - } +if (smc_ib_ready_link (link)) +return SMC_CLC_DECL_ERR_RDYLNK ;/* QP confirmation over RoCE fabric */ smc_llc_flow_initiate (link->lgr,SMC_LLC_FLOW_ADD_LINK ); reason_code =smcr_serv_conf_first_link (new_smc);smc_llc_flow_stop (link->lgr, &link->lgr->llc_flow_lcl); -if (reason_code) - goto decline; } -return 0 ; - -decline: -smc_listen_decline (new_smc, reason_code, local_first);return reason_code; }
@@ -1382,9 +1372,9 @@ static void smc_listen_work(struct work_struct *work)if (!ism_supported) { rc =smc_listen_rdma_finish (new_smc, &cclc, ini.first_contact_local); -mutex_unlock (&smc_server_lgr_pending);if (rc) -return ; + goto out_unlock; +mutex_unlock (&smc_server_lgr_pending); }smc_conn_save_peer_info (new_smc, &cclc);smc_listen_out_connected (new_smc);
Signature · 1 line
2.17.1
PATCH 7/10 net/smc: immediate freeing in smc_lgr_cleanup_early()
In reply to Karsten GraulFrom: Ursula Braun <[email protected]>
smc_lgr_cleanup_early() schedules the free worker with delay. DMB unregistering occurs in this delayed worker increasing the risk to reach the SMCD SBA limit without need. Terminate the linkgroup immediately, since termination means early DMB unregistering.
For SMCD the global smc_server_lgr_pending lock is given up early. A linkgroup to be given up with smc_lgr_cleanup_early() may already contain more than one connection. Using __smc_lgr_terminate() in smc_lgr_cleanup_early() covers this.
And consolidate smc_ism_put_vlan() and smc_put_device() into smc_lgr_free() only.
--- net/smc/smc_core.c | 23 ++++------------------- net/smc/smc_core.h | 1 - 2 files changed, 4 insertions(+), 20 deletions(-)
net/smc/smc_core.c +4 -19
@@ -34,7 +34,6 @@#define SMC_LGR_NUM_INCR 256#define SMC_LGR_FREE_DELAY_SERV (600 * HZ)#define SMC_LGR_FREE_DELAY_CLNT (SMC_LGR_FREE_DELAY_SERV + 10 * HZ) -#define SMC_LGR_FREE_DELAY_FAST (8 * HZ)static struct smc_lgr_list smc_lgr_list = {/* established link groups */ .lock =__SPIN_LOCK_UNLOCKED (smc_lgr_list.lock),
@@ -70,7 +69,7 @@ static void smc_lgr_schedule_free_work(struct smc_link_group *lgr)* creation. For client use a somewhat higher removal delay time, * otherwise there is a risk of out-of-sync link groups. */ -if (!lgr->freeing && !lgr->freefast) { +if (!lgr->freeing) { mod_delayed_work(system_wq, &lgr->free_work, (!lgr->is_smcd && lgr->role == SMC_CLNT) ? SMC_LGR_FREE_DELAY_CLNT :
@@ -78,15 +77,6 @@ static void smc_lgr_schedule_free_work(struct smc_link_group *lgr) } } -void smc_lgr_schedule_free_work_fast (struct smc_link_group *lgr) -{ -if (!lgr->freeing && !lgr->freefast) { - lgr->freefast =1 ; -mod_delayed_work (system_wq, &lgr->free_work, -SMC_LGR_FREE_DELAY_FAST ); - } -} -/* Register connection's alert token in our lookup structure. * To use rbtrees we have to implement our own insert core. * Requires @conns_lock
@@ -227,7 +217,7 @@ void smc_lgr_cleanup_early(struct smc_connection *conn)if (!list_empty (lgr_list))list_del_init (lgr_list);spin_unlock_bh (lgr_lock); -smc_lgr_schedule_free_work_fast (lgr); +__smc_lgr_terminate (lgr, true); }static void smcr_lgr_link_deactivate_all (struct smc_link_group *lgr)
@@ -399,7 +389,6 @@ static int smc_lgr_create(struct smc_sock *smc, struct smc_init_info *ini) lgr->is_smcd = ini->is_smcd; lgr->sync_err =0 ; lgr->terminating =0 ; - lgr->freefast =0 ; lgr->freeing =0 ; lgr->vlan_id = ini->vlan_id;mutex_init (&lgr->sndbufs_lock);
@@ -825,10 +814,8 @@ static void smc_lgr_free(struct smc_link_group *lgr)smc_lgr_free_bufs (lgr);if (lgr->is_smcd) { -if (!lgr->terminating) { -smc_ism_put_vlan (lgr->smcd, lgr->vlan_id); -put_device (&lgr->smcd->dev); - } +smc_ism_put_vlan (lgr->smcd, lgr->vlan_id); +put_device (&lgr->smcd->dev);if (!atomic_dec_return (&lgr->smcd->lgr_cnt))wake_up (&lgr->smcd->lgrs_deleted); }else {
@@ -889,8 +876,6 @@ static void smc_lgr_cleanup(struct smc_link_group *lgr)if (lgr->is_smcd) {smc_ism_signal_shutdown (lgr);smcd_unregister_all_dmbs (lgr); -smc_ism_put_vlan (lgr->smcd, lgr->vlan_id); -put_device (&lgr->smcd->dev); }else {u32 rsn = lgr->llc_termination_rsn;
net/smc/smc_core.h +0 -1
@@ -227,7 +227,6 @@ struct smc_link_group {struct work_struct terminate_work;/* abnormal lgr termination */ u8 sync_err : 1; /* lgr no longer fits to peer */ u8 terminating : 1;/* lgr is terminating */ - u8 freefast : 1; /* free worker scheduled fast */ u8 freeing : 1; /* lgr is being freed */bool is_smcd;/* SMC-R or SMC-D */
Signature · 1 line
2.17.1
PATCH 8/10 s390/net: add SMC config as one of the defaults of CCWGROUP
In reply to Karsten GraulFrom: Guvenc Gulce <[email protected]>
arch/s390/net/pnet.c uses ccwgroup function dev_is_ccwgroup() in pnetid_by_dev_port().
For s390 the net/smc code makes use of function pnetid_by_dev_port(). Make sure ccwgroup is built into the kernel, if smc is to be built into the kernel.
--- drivers/s390/net/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/net/Kconfig +1 -1
@@ -107,7 +107,7 @@ config QETH_OSX config CCWGROUP tristate - default (LCS || CTCM || QETH) + default (LCS || CTCM || QETH || SMC) config ISM tristate "Support for ISM vPCI Adapter"
Signature · 1 line
2.17.1
PATCH 9/10 net/smc: use the retry mechanism for netlink messages
In reply to Karsten GraulFrom: Guvenc Gulce <[email protected]>
When the netlink messages to be sent to the userspace are too big for a single netlink message, send them in chunks using the netlink_dump infrastructure. Modify the smc diag dump code so that it can signal to the netlink_dump infrastructure that it needs to send more data.
--- net/smc/smc_diag.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-)
net/smc/smc_diag.c +23 -7
@@ -22,6 +22,15 @@#include "smc.h" #include "smc_core.h" +struct smc_diag_dump_ctx { +int pos[2 ]; +}; + +static struct smc_diag_dump_ctx *smc_dump_context (struct netlink_callback *cb) +{ +return (struct smc_diag_dump_ctx *)cb->ctx; +} +static void smc_gid_be16_convert (__u8 *buf,u8 *gid_raw) { sprintf(buf, "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x",
@@ -193,13 +202,15 @@ static int __smc_diag_dump(struct sock *sk, struct sk_buff *skb, }static int smc_diag_dump_proto (struct proto *prot,struct sk_buff *skb, -struct netlink_callback *cb) +struct netlink_callback *cb,int p_type) { +struct smc_diag_dump_ctx *cb_ctx =smc_dump_context (cb);struct net *net =sock_net (skb->sk); +int snum = cb_ctx->pos[p_type];struct nlattr *bc =NULL ;struct hlist_head *head; +int rc =0 , num =0 ;struct sock *sk; -int rc =0 ;read_lock (&prot->h.smc_hash->lock); head = &prot->h.smc_hash->ht;
@@ -209,13 +220,18 @@ static int smc_diag_dump_proto(struct proto *prot, struct sk_buff *skb,sk_for_each (sk, head) {if (!net_eq (sock_net (sk), net))continue ; +if (num < snum) + goto next; rc =__smc_diag_dump (sk, skb, cb,nlmsg_data (cb->nlh), bc); -if (rc) -break ; +if (rc <0 ) + goto out; +next: + num++; } out:read_unlock (&prot->h.smc_hash->lock); + cb_ctx->pos[p_type] = num;return rc; }
@@ -223,10 +239,10 @@ static int smc_diag_dump(struct sk_buff *skb, struct netlink_callback *cb) {int rc =0 ; - rc =smc_diag_dump_proto (&smc_proto, skb, cb); + rc =smc_diag_dump_proto (&smc_proto, skb, cb,SMCPROTO_SMC );if (!rc) - rc =smc_diag_dump_proto (&smc_proto6, skb, cb); -return rc; +smc_diag_dump_proto (&smc_proto6, skb, cb,SMCPROTO_SMC6 ); +return skb->len; }static int smc_diag_handler_dump (struct sk_buff *skb,struct nlmsghdr *h)
Signature · 1 line
2.17.1
PATCH 10/10 net/smc: use separate work queues for different worker types
In reply to Karsten GraulThere are 6 types of workers which exist per smc connection. 3 of them are used for listen and handshake processing, another 2 are used for close and abort processing and 1 is the tx worker that moves calls to sleeping functions into a worker.
To prevent flooding of the system work queue when many connections are opened or closed at the same time (some pattern uperf implements), move those workers to one of 3 smc-specific work queues. Two work queues are module-global and used for handshake and close workers. The third work queue is defined per link group and used by the tx workers that may sleep waiting for resources of this link group.
And in smc_llc_enqueue() queue the llc_event_work work to the system prio work queue because its critical that this work is started fast.
--- net/smc/af_smc.c | 34 ++++++++++++++++++++++++++-------- net/smc/smc.h | 3 +++ net/smc/smc_cdc.c | 4 ++-- net/smc/smc_core.c | 13 +++++++++++-- net/smc/smc_core.h | 1 + net/smc/smc_llc.c | 2 +- net/smc/smc_tx.c | 10 +++++----- 7 files changed, 49 insertions(+), 18 deletions(-)
net/smc/af_smc.c +26 -8
@@ -55,6 +55,9 @@ static DEFINE_MUTEX(smc_client_lgr_pending); /* serialize link group* creation on client */ +struct workqueue_struct *smc_hs_wq;/* wq for handshake work */ +struct workqueue_struct *smc_close_wq;/* wq for close work */ +static void smc_tcp_listen_work (struct work_struct *);static void smc_connect_work (struct work_struct *);
@@ -905,7 +908,7 @@ static int smc_connect(struct socket *sock, struct sockaddr *addr,if (smc->use_fallback) goto out;if (flags &O_NONBLOCK ) { -if (schedule_work (&smc->connect_work)) +if (queue_work (smc_hs_wq, &smc->connect_work)) smc->connect_nonblock =1 ; rc = -EINPROGRESS ; }else {
@@ -1412,7 +1415,7 @@ static void smc_tcp_listen_work(struct work_struct *work) new_smc->sk.sk_sndbuf = lsmc->sk.sk_sndbuf; new_smc->sk.sk_rcvbuf = lsmc->sk.sk_rcvbuf;sock_hold (&new_smc->sk);/* sock_put in passive closing */ -if (!schedule_work (&new_smc->smc_listen_work)) +if (!queue_work (smc_hs_wq, &new_smc->smc_listen_work))sock_put (&new_smc->sk); }
@@ -1432,7 +1435,7 @@ static void smc_clcsock_data_ready(struct sock *listen_clcsock) lsmc->clcsk_data_ready (listen_clcsock);if (lsmc->sk.sk_state ==SMC_LISTEN ) {sock_hold (&lsmc->sk);/* sock_put in smc_tcp_listen_work() */ -if (!schedule_work (&lsmc->tcp_listen_work)) +if (!queue_work (smc_hs_wq, &lsmc->tcp_listen_work))sock_put (&lsmc->sk); } }
@@ -1800,8 +1803,8 @@ static int smc_setsockopt(struct socket *sock, int level, int optname, sk->sk_state != SMC_LISTEN && sk->sk_state != SMC_CLOSED) {if (val) -mod_delayed_work (system_wq, &smc->conn.tx_work, -0 ); +mod_delayed_work (smc->conn.lgr->tx_wq, + &smc->conn.tx_work,0 ); }break ;case TCP_CORK :
@@ -1809,8 +1812,8 @@ static int smc_setsockopt(struct socket *sock, int level, int optname, sk->sk_state != SMC_LISTEN && sk->sk_state != SMC_CLOSED) {if (!val) -mod_delayed_work (system_wq, &smc->conn.tx_work, -0 ); +mod_delayed_work (smc->conn.lgr->tx_wq, + &smc->conn.tx_work,0 ); }break ;case TCP_DEFER_ACCEPT :
@@ -2093,10 +2096,19 @@ static int __init smc_init(void)if (rc) goto out_pernet_subsys; + rc = -ENOMEM ; + smc_hs_wq =alloc_workqueue ("smc_hs_wq" ,0 ,0 ); +if (!smc_hs_wq) + goto out_pnet; + + smc_close_wq =alloc_workqueue ("smc_close_wq" ,0 ,0 ); +if (!smc_close_wq) + goto out_alloc_hs_wq; + rc =smc_core_init ();if (rc) {pr_err ("%s: smc_core_init fails with %d\n" , __func__, rc); - goto out_pnet; + goto out_alloc_wqs; } rc =smc_llc_init ();
@@ -2148,6 +2160,10 @@ static int __init smc_init(void)proto_unregister (&smc_proto); out_core:smc_core_exit (); +out_alloc_wqs: +destroy_workqueue (smc_close_wq); +out_alloc_hs_wq: +destroy_workqueue (smc_hs_wq); out_pnet:smc_pnet_exit (); out_pernet_subsys:
@@ -2162,6 +2178,8 @@ static void __exit smc_exit(void)sock_unregister (PF_SMC );smc_core_exit ();smc_ib_unregister_client (); +destroy_workqueue (smc_close_wq); +destroy_workqueue (smc_hs_wq);proto_unregister (&smc_proto6);proto_unregister (&smc_proto);smc_pnet_exit ();
net/smc/smc.h +3 -0
@@ -239,6 +239,9 @@ static inline struct smc_sock *smc_sk(const struct sock *sk)return (struct smc_sock *)sk; } +extern struct workqueue_struct *smc_hs_wq;/* wq for handshake work */ +extern struct workqueue_struct *smc_close_wq;/* wq for close work */ +#define SMC_SYSTEMID_LEN 8extern u8 local_systemid[SMC_SYSTEMID_LEN ];/* unique system identifier */
net/smc/smc_cdc.c +2 -2
@@ -299,7 +299,7 @@ static void smc_cdc_msg_validate(struct smc_sock *smc, struct smc_cdc_msg *cdc, conn->lnk = link;spin_unlock_bh (&conn->send_lock);sock_hold (&smc->sk);/* sock_put in abort_work */ -if (!schedule_work (&conn->abort_work)) +if (!queue_work (smc_close_wq, &conn->abort_work))sock_put (&smc->sk); } }
@@ -368,7 +368,7 @@ static void smc_cdc_msg_recv_action(struct smc_sock *smc, smc->clcsock->sk->sk_shutdown |=RCV_SHUTDOWN ;sock_set_flag (&smc->sk,SOCK_DONE );sock_hold (&smc->sk);/* sock_put in close_work */ -if (!schedule_work (&conn->close_work)) +if (!queue_work (smc_close_wq, &conn->close_work))sock_put (&smc->sk); } }
net/smc/smc_core.c +11 -2
@@ -386,6 +386,12 @@ static int smc_lgr_create(struct smc_sock *smc, struct smc_init_info *ini) rc =SMC_CLC_DECL_MEM ; goto ism_put_vlan; } + lgr->tx_wq =alloc_workqueue ("smc_tx_wq-%*phN" ,0 ,0 , +SMC_LGR_ID_SIZE , &lgr->id); +if (!lgr->tx_wq) { + rc = -ENOMEM ; + goto free_lgr; + } lgr->is_smcd = ini->is_smcd; lgr->sync_err =0 ; lgr->terminating =0 ;
@@ -426,7 +432,7 @@ static int smc_lgr_create(struct smc_sock *smc, struct smc_init_info *ini) lnk = &lgr->lnk[link_idx]; rc =smcr_link_init (lgr, lnk, link_idx, ini);if (rc) - goto free_lgr; + goto free_wq; lgr_list = &smc_lgr_list.list; lgr_lock = &smc_lgr_list.lock;atomic_inc (&lgr_cnt);
@@ -437,6 +443,8 @@ static int smc_lgr_create(struct smc_sock *smc, struct smc_init_info *ini)spin_unlock_bh (lgr_lock);return 0 ; +free_wq: +destroy_workqueue (lgr->tx_wq); free_lgr:kfree (lgr); ism_put_vlan:
@@ -506,7 +514,7 @@ static int smc_switch_cursor(struct smc_sock *smc, struct smc_cdc_tx_pend *pend, smc->sk.sk_state != SMC_CLOSED) { rc = smcr_cdc_msg_send_validation(conn, pend, wr_buf); if (!rc) { - schedule_delayed_work(&conn->tx_work, 0); + queue_delayed_work(conn->lgr->tx_wq, &conn->tx_work, 0); smc->sk.sk_data_ready(&smc->sk); } } else {
@@ -813,6 +821,7 @@ static void smc_lgr_free(struct smc_link_group *lgr) }smc_lgr_free_bufs (lgr); +destroy_workqueue (lgr->tx_wq);if (lgr->is_smcd) {smc_ism_put_vlan (lgr->smcd, lgr->vlan_id);put_device (&lgr->smcd->dev);
net/smc/smc_core.h +1 -0
@@ -225,6 +225,7 @@ struct smc_link_group {u8 id[SMC_LGR_ID_SIZE ];/* unique lgr id */ struct delayed_work free_work;/* delayed freeing of an lgr */ struct work_struct terminate_work;/* abnormal lgr termination */ +struct workqueue_struct *tx_wq;/* wq for conn. tx workers */ u8 sync_err : 1; /* lgr no longer fits to peer */ u8 terminating : 1;/* lgr is terminating */ u8 freeing : 1; /* lgr is being freed */
net/smc/smc_llc.c +1 -1
@@ -1691,7 +1691,7 @@ static void smc_llc_enqueue(struct smc_link *link, union smc_llc_msg *llc)spin_lock_irqsave (&lgr->llc_event_q_lock, flags);list_add_tail (&qentry->list, &lgr->llc_event_q);spin_unlock_irqrestore (&lgr->llc_event_q_lock, flags); -schedule_work (&lgr->llc_event_work); +queue_work (system_highpri_wq, &lgr->llc_event_work); }/* copy received msg and add it to the event queue */
net/smc/smc_tx.c +5 -5
@@ -228,8 +228,8 @@ int smc_tx_sendmsg(struct smc_sock *smc, struct msghdr *msg, size_t len)/* for a corked socket defer the RDMA writes if there * is still sufficient sndbuf_space available */ -schedule_delayed_work (&conn->tx_work, -SMC_TX_CORK_DELAY ); +queue_delayed_work (conn->lgr->tx_wq, &conn->tx_work, +SMC_TX_CORK_DELAY ); elsesmc_tx_sndbuf_nonempty (conn ); }/* while (msg_data_left(msg)) */
@@ -499,7 +499,7 @@ static int smcr_tx_sndbuf_nonempty(struct smc_connection *conn)if (conn->killed)return -EPIPE ; rc =0 ; -mod_delayed_work (system_wq, &conn->tx_work, +mod_delayed_work (conn->lgr->tx_wq, &conn->tx_work,SMC_TX_WORK_DELAY ); }return rc;
@@ -623,8 +623,8 @@ void smc_tx_consumer_update(struct smc_connection *conn, bool force)return ;if ((smc_cdc_get_slot_and_msg_send (conn) <0 ) && !conn->killed) { -schedule_delayed_work (&conn->tx_work, -SMC_TX_WORK_DELAY ); +queue_delayed_work (conn->lgr->tx_wq, &conn->tx_work, +SMC_TX_WORK_DELAY );return ; } }
Signature · 1 line
2.17.1
David Miller
maintainerFrom: Karsten Graul <[email protected]>
Date: Thu, 10 Sep 2020 18:48:19 +0200
Quoted 7 lines
Please apply the following patch series for smc to netdev's net-next tree.
This patch series is a mix of various improvements and cleanups. The patches 1 and 10 improve the handling of large parallel workloads. Patch 8 corrects a kernel config default for config CCWGROUP on s390. Patch 9 allows userspace tools to retrieve socket information for more sockets.
Series applied, thank you.