From 23f1c6e1f15ea4b457e40c91ee9d3768b7da253e Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Mon, 6 Apr 2020 12:59:35 -0400 Subject: [PATCH] LU-13004 lnet: don't embed whole lnet_md in lnet_event Of the several fields that are copied into the lnet_md which is embedded in an lnet_event, only three are ever used: start, user_ptr, md_options Rather than allocating space for the whole structure, copying only some in, and then using even fewer; just store the fields that are needed. Note that a comment suggests that the "threshold" value is interesting, but this value is never used. The comment has been removed. Test-Parameters: trivial Signed-off-by: Mr NeilBrown Change-Id: I7a69b52a65dda815b533c605f581e22fc4445be0 Reviewed-on: https://review.whamcloud.com/37840 Tested-by: jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Shaun Tancheff Reviewed-by: Oleg Drokin --- lnet/include/lnet/lib-lnet.h | 2 +- lnet/include/uapi/linux/lnet/lnet-types.h | 9 +++-- lnet/lnet/api-ni.c | 6 +-- lnet/lnet/lib-md.c | 17 ++------- lnet/lnet/lib-move.c | 4 +- lnet/lnet/lib-msg.c | 4 +- lnet/lnet/peer.c | 10 ++--- lnet/selftest/rpc.c | 4 +- lustre/ptlrpc/events.c | 63 ++++++++++++++++--------------- 9 files changed, 56 insertions(+), 63 deletions(-) diff --git a/lnet/include/lnet/lib-lnet.h b/lnet/include/lnet/lib-lnet.h index 1179129..c4e5550 100644 --- a/lnet/include/lnet/lib-lnet.h +++ b/lnet/include/lnet/lib-lnet.h @@ -767,7 +767,7 @@ lnet_copy_flat2kiov(unsigned int ndiov, struct bio_vec *dkiov, void lnet_me_unlink(struct lnet_me *me); void lnet_md_unlink(struct lnet_libmd *md); -void lnet_md_deconstruct(struct lnet_libmd *lmd, struct lnet_md *umd); +void lnet_md_deconstruct(struct lnet_libmd *lmd, struct lnet_event *ev); struct page *lnet_kvaddr_to_page(unsigned long vaddr); int lnet_cpt_of_md(struct lnet_libmd *md, unsigned int offset); diff --git a/lnet/include/uapi/linux/lnet/lnet-types.h b/lnet/include/uapi/linux/lnet/lnet-types.h index ba41d6e..616e80c 100644 --- a/lnet/include/uapi/linux/lnet/lnet-types.h +++ b/lnet/include/uapi/linux/lnet/lnet-types.h @@ -629,11 +629,12 @@ struct lnet_event { */ struct lnet_handle_md md_handle; /** - * A snapshot of the state of the MD immediately after the event has - * been processed. In particular, the threshold field in md will - * reflect the value of the threshold after the operation occurred. + * A snapshot of relevant state of the MD immediately after the event + * has been processed. */ - struct lnet_md md; + void *md_start; + void *md_user_ptr; + unsigned int md_options; /** * 64 bits of out-of-band user data. Only valid for LNET_EVENT_PUT. * \see LNetPut diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index f59d581..c5ffd6d 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -1674,7 +1674,7 @@ lnet_ping_target_destroy(void) static void lnet_ping_target_event_handler(struct lnet_event *event) { - struct lnet_ping_buffer *pbuf = event->md.user_ptr; + struct lnet_ping_buffer *pbuf = event->md_user_ptr; if (event->unlinked) lnet_ping_buffer_decref(pbuf); @@ -1947,7 +1947,7 @@ int lnet_push_target_post(struct lnet_ping_buffer *pbuf, static void lnet_push_target_event_handler(struct lnet_event *ev) { - struct lnet_ping_buffer *pbuf = ev->md.user_ptr; + struct lnet_ping_buffer *pbuf = ev->md_user_ptr; CDEBUG(D_NET, "type %d status %d unlinked %d\n", ev->type, ev->status, ev->unlinked); @@ -4099,7 +4099,7 @@ struct ping_data { static void lnet_ping_event_handler(struct lnet_event *event) { - struct ping_data *pd = event->md.user_ptr; + struct ping_data *pd = event->md_user_ptr; CDEBUG(D_NET, "ping event (%d %d)%s\n", event->type, event->status, diff --git a/lnet/lnet/lib-md.c b/lnet/lnet/lib-md.c index 5927de6..0d1cc3e 100644 --- a/lnet/lnet/lib-md.c +++ b/lnet/lnet/lib-md.c @@ -266,20 +266,11 @@ lnet_md_link(struct lnet_libmd *md, lnet_handler_t handler, int cpt) /* must be called with lnet_res_lock held */ void -lnet_md_deconstruct(struct lnet_libmd *lmd, struct lnet_md *umd) +lnet_md_deconstruct(struct lnet_libmd *lmd, struct lnet_event *ev) { - /* NB this doesn't copy out all the iov entries so when a - * discontiguous MD is copied out, the target gets to know the - * original iov pointer (in start) and the number of entries it had - * and that's all. - */ - umd->start = lmd->md_start; - umd->length = ((lmd->md_options & LNET_MD_KIOV) == 0) ? - lmd->md_length : lmd->md_niov; - umd->threshold = lmd->md_threshold; - umd->max_size = lmd->md_max_size; - umd->options = lmd->md_options; - umd->user_ptr = lmd->md_user_ptr; + ev->md_start = lmd->md_start; + ev->md_options = lmd->md_options; + ev->md_user_ptr = lmd->md_user_ptr; } static int diff --git a/lnet/lnet/lib-move.c b/lnet/lnet/lib-move.c index b18e6dd..5330e1a 100644 --- a/lnet/lnet/lib-move.c +++ b/lnet/lnet/lib-move.c @@ -3686,7 +3686,7 @@ lnet_handle_recovery_reply(struct lnet_mt_event_info *ev_info, void lnet_mt_event_handler(struct lnet_event *event) { - struct lnet_mt_event_info *ev_info = event->md.user_ptr; + struct lnet_mt_event_info *ev_info = event->md_user_ptr; struct lnet_ping_buffer *pbuf; /* TODO: remove assert */ @@ -3719,7 +3719,7 @@ lnet_mt_event_handler(struct lnet_event *event) } if (event->unlinked) { LIBCFS_FREE(ev_info, sizeof(*ev_info)); - pbuf = LNET_PING_INFO_TO_BUFFER(event->md.start); + pbuf = LNET_PING_INFO_TO_BUFFER(event->md_start); lnet_ping_buffer_decref(pbuf); } } diff --git a/lnet/lnet/lib-msg.c b/lnet/lnet/lib-msg.c index 0c469d4..93058cd 100644 --- a/lnet/lnet/lib-msg.c +++ b/lnet/lnet/lib-msg.c @@ -48,7 +48,7 @@ lnet_build_unlink_event(struct lnet_libmd *md, struct lnet_event *ev) ev->status = 0; ev->unlinked = 1; ev->type = LNET_EVENT_UNLINK; - lnet_md_deconstruct(md, &ev->md); + lnet_md_deconstruct(md, ev); lnet_md2handle(&ev->md_handle, md); EXIT; } @@ -360,7 +360,7 @@ lnet_msg_attach_md(struct lnet_msg *msg, struct lnet_libmd *md, /* build umd in event */ lnet_md2handle(&msg->msg_ev.md_handle, md); - lnet_md_deconstruct(md, &msg->msg_ev.md); + lnet_md_deconstruct(md, &msg->msg_ev); } static int diff --git a/lnet/lnet/peer.c b/lnet/lnet/peer.c index 283839c..c77417a 100644 --- a/lnet/lnet/peer.c +++ b/lnet/lnet/peer.c @@ -1961,7 +1961,7 @@ void lnet_peer_push_event(struct lnet_event *ev) struct lnet_ping_buffer *pbuf; struct lnet_peer *lp; - pbuf = LNET_PING_INFO_TO_BUFFER(ev->md.start + ev->offset); + pbuf = LNET_PING_INFO_TO_BUFFER(ev->md_start + ev->offset); /* lnet_find_peer() adds a refcount */ lp = lnet_find_peer(ev->source.nid); @@ -2264,7 +2264,7 @@ lnet_discovery_event_ack(struct lnet_peer *lp, struct lnet_event *ev) { struct lnet_ping_buffer *pbuf; - pbuf = LNET_PING_INFO_TO_BUFFER(ev->md.start); + pbuf = LNET_PING_INFO_TO_BUFFER(ev->md_start); spin_lock(&lp->lp_lock); lp->lp_state &= ~LNET_PEER_PUSH_SENT; lp->lp_push_error = ev->status; @@ -2301,7 +2301,7 @@ lnet_discovery_event_reply(struct lnet_peer *lp, struct lnet_event *ev) goto out; } - pbuf = LNET_PING_INFO_TO_BUFFER(ev->md.start); + pbuf = LNET_PING_INFO_TO_BUFFER(ev->md_start); if (pbuf->pb_info.pi_magic == __swab32(LNET_PROTO_PING_MAGIC)) lnet_swap_pinginfo(pbuf); @@ -2509,7 +2509,7 @@ lnet_discovery_event_unlink(struct lnet_peer *lp, struct lnet_event *ev) */ static void lnet_discovery_event_handler(struct lnet_event *event) { - struct lnet_peer *lp = event->md.user_ptr; + struct lnet_peer *lp = event->md_user_ptr; struct lnet_ping_buffer *pbuf; int rc; @@ -2539,7 +2539,7 @@ static void lnet_discovery_event_handler(struct lnet_event *event) } lnet_net_lock(LNET_LOCK_EX); if (event->unlinked) { - pbuf = LNET_PING_INFO_TO_BUFFER(event->md.start); + pbuf = LNET_PING_INFO_TO_BUFFER(event->md_start); lnet_ping_buffer_decref(pbuf); lnet_peer_decref_locked(lp); } diff --git a/lnet/selftest/rpc.c b/lnet/selftest/rpc.c index 6d71a02..5ebd0e5 100644 --- a/lnet/selftest/rpc.c +++ b/lnet/selftest/rpc.c @@ -1407,7 +1407,7 @@ static void srpc_lnet_ev_handler(struct lnet_event *ev) { struct srpc_service_cd *scd; - struct srpc_event *rpcev = ev->md.user_ptr; + struct srpc_event *rpcev = ev->md_user_ptr; struct srpc_client_rpc *crpc; struct srpc_server_rpc *srpc; struct srpc_buffer *buffer; @@ -1486,7 +1486,7 @@ srpc_lnet_ev_handler(struct lnet_event *ev) LASSERT(ev->type != LNET_EVENT_UNLINK || sv->sv_shuttingdown); - buffer = container_of(ev->md.start, struct srpc_buffer, + buffer = container_of(ev->md_start, struct srpc_buffer, buf_msg); buffer->buf_peer = ev->source; buffer->buf_self = ev->target.nid; diff --git a/lustre/ptlrpc/events.c b/lustre/ptlrpc/events.c index b6d4cdd..0578529 100644 --- a/lustre/ptlrpc/events.c +++ b/lustre/ptlrpc/events.c @@ -48,7 +48,7 @@ struct percpu_ref ptlrpc_pending; */ void request_out_callback(struct lnet_event *ev) { - struct ptlrpc_cb_id *cbid = ev->md.user_ptr; + struct ptlrpc_cb_id *cbid = ev->md_user_ptr; struct ptlrpc_request *req = cbid->cbid_arg; bool wakeup = false; ENTRY; @@ -88,18 +88,19 @@ void request_out_callback(struct lnet_event *ev) */ void reply_in_callback(struct lnet_event *ev) { - struct ptlrpc_cb_id *cbid = ev->md.user_ptr; - struct ptlrpc_request *req = cbid->cbid_arg; - ENTRY; + struct ptlrpc_cb_id *cbid = ev->md_user_ptr; + struct ptlrpc_request *req = cbid->cbid_arg; + ENTRY; - DEBUG_REQ(D_NET, req, "type %d, status %d", ev->type, ev->status); + DEBUG_REQ(D_NET, req, "type %d, status %d", ev->type, ev->status); - LASSERT (ev->type == LNET_EVENT_PUT || ev->type == LNET_EVENT_UNLINK); - LASSERT (ev->md.start == req->rq_repbuf); - LASSERT (ev->offset + ev->mlength <= req->rq_repbuf_len); - /* We've set LNET_MD_MANAGE_REMOTE for all outgoing requests - for adaptive timeouts' early reply. */ - LASSERT((ev->md.options & LNET_MD_MANAGE_REMOTE) != 0); + LASSERT(ev->type == LNET_EVENT_PUT || ev->type == LNET_EVENT_UNLINK); + LASSERT(ev->md_start == req->rq_repbuf); + LASSERT(ev->offset + ev->mlength <= req->rq_repbuf_len); + /* We've set LNET_MD_MANAGE_REMOTE for all outgoing requests + * for adaptive timeouts' early reply. + */ + LASSERT((ev->md_options & LNET_MD_MANAGE_REMOTE) != 0); spin_lock(&req->rq_lock); @@ -179,10 +180,10 @@ out_wake: */ void client_bulk_callback(struct lnet_event *ev) { - struct ptlrpc_cb_id *cbid = ev->md.user_ptr; - struct ptlrpc_bulk_desc *desc = cbid->cbid_arg; - struct ptlrpc_request *req; - ENTRY; + struct ptlrpc_cb_id *cbid = ev->md_user_ptr; + struct ptlrpc_bulk_desc *desc = cbid->cbid_arg; + struct ptlrpc_request *req; + ENTRY; LASSERT((ptlrpc_is_bulk_put_sink(desc->bd_type) && ev->type == LNET_EVENT_PUT) || @@ -289,22 +290,22 @@ static void ptlrpc_req_add_history(struct ptlrpc_service_part *svcpt, */ void request_in_callback(struct lnet_event *ev) { - struct ptlrpc_cb_id *cbid = ev->md.user_ptr; + struct ptlrpc_cb_id *cbid = ev->md_user_ptr; struct ptlrpc_request_buffer_desc *rqbd = cbid->cbid_arg; struct ptlrpc_service_part *svcpt = rqbd->rqbd_svcpt; - struct ptlrpc_service *service = svcpt->scp_service; - struct ptlrpc_request *req; - ENTRY; + struct ptlrpc_service *service = svcpt->scp_service; + struct ptlrpc_request *req; + ENTRY; - LASSERT (ev->type == LNET_EVENT_PUT || - ev->type == LNET_EVENT_UNLINK); - LASSERT ((char *)ev->md.start >= rqbd->rqbd_buffer); - LASSERT ((char *)ev->md.start + ev->offset + ev->mlength <= - rqbd->rqbd_buffer + service->srv_buf_size); + LASSERT(ev->type == LNET_EVENT_PUT || + ev->type == LNET_EVENT_UNLINK); + LASSERT((char *)ev->md_start >= rqbd->rqbd_buffer); + LASSERT((char *)ev->md_start + ev->offset + ev->mlength <= + rqbd->rqbd_buffer + service->srv_buf_size); - CDEBUG((ev->status == 0) ? D_NET : D_ERROR, - "event type %d, status %d, service %s\n", - ev->type, ev->status, service->srv_name); + CDEBUG((ev->status == 0) ? D_NET : D_ERROR, + "event type %d, status %d, service %s\n", + ev->type, ev->status, service->srv_name); if (ev->unlinked) { /* If this is the last request message to fit in the @@ -335,7 +336,7 @@ void request_in_callback(struct lnet_event *ev) * flags are reset and scalars are zero. We only set the message * size to non-zero if this was a successful receive. */ req->rq_xid = ev->match_bits; - req->rq_reqbuf = ev->md.start + ev->offset; + req->rq_reqbuf = ev->md_start + ev->offset; if (ev->type == LNET_EVENT_PUT && ev->status == 0) req->rq_reqdata_len = ev->mlength; ktime_get_real_ts64(&req->rq_arrival_time); @@ -391,7 +392,7 @@ void request_in_callback(struct lnet_event *ev) */ void reply_out_callback(struct lnet_event *ev) { - struct ptlrpc_cb_id *cbid = ev->md.user_ptr; + struct ptlrpc_cb_id *cbid = ev->md_user_ptr; struct ptlrpc_reply_state *rs = cbid->cbid_arg; struct ptlrpc_service_part *svcpt = rs->rs_svcpt; ENTRY; @@ -436,7 +437,7 @@ void reply_out_callback(struct lnet_event *ev) */ void server_bulk_callback(struct lnet_event *ev) { - struct ptlrpc_cb_id *cbid = ev->md.user_ptr; + struct ptlrpc_cb_id *cbid = ev->md_user_ptr; struct ptlrpc_bulk_desc *desc = cbid->cbid_arg; ENTRY; @@ -482,7 +483,7 @@ void server_bulk_callback(struct lnet_event *ev) static void ptlrpc_master_callback(struct lnet_event *ev) { - struct ptlrpc_cb_id *cbid = ev->md.user_ptr; + struct ptlrpc_cb_id *cbid = ev->md_user_ptr; void (*callback)(struct lnet_event *ev) = cbid->cbid_fn; /* Honestly, it's best to find out early. */ -- 1.8.3.1