Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

FEAT: manual control of completion events generation [DRAFT] #1743

Open
grom72 opened this issue May 18, 2022 · 0 comments
Open

FEAT: manual control of completion events generation [DRAFT] #1743

grom72 opened this issue May 18, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@grom72
Copy link
Contributor

grom72 commented May 18, 2022

FEAT: manual control of completion events generation

Rationale

Each time rpma_conn_wait() is called, it arms CQ to trigger a new event as soon as the next work completion is ready.

rpma/src/conn.c

Line 275 in e711430

errno = ibv_req_notify_cq(ev_cq, 0 /* all completions */);

That may cause unnecessary event generation if an application can not consume completions fast enough.
To avoid that two improvements are needed:

  • block the next event triggering setup inside rpma_conn_wait()
  • provide an API to arm CQ to generate a new event with the next work completion prepared

Description

The new semantic of the rpma_conn_wait() can be as follow:
librpma.h:

...
#define RPMA_CONN_POSTPONE_NOTIFY_REQ 1
...
int
rpma_conn_wait(struct rpma_conn *conn, int flags, struct rpma_cq **cq, bool *is_rcq)
{
...
	if (!(flags & RPMA_CONN_POSTPONE_NOTIFY_REQ)) {
		errno = ibv_req_notify_cq(ev_cq, 0 /* all completions */);
		if (errno) {
			*cq = NULL;
			RPMA_LOG_ERROR_WITH_ERRNO(errno, "ibv_req_notify_cq()");
			return RPMA_E_PROVIDER;
		}
	}
}

and a new API call to trigger events on completion:

int
rpma_cq_wait_req(rpma_cq *cq, int flags) {
	if (cq == NULL)
		return RPMA_E_INVAL;
	errno = ibv_req_notify_cq(cq->cq, flags /* all completions */);
	if (errno) {
		RPMA_LOG_ERROR_WITH_ERRNO(errno, "ibv_req_notify_cq()");
		return RPMA_E_PROVIDER;
	}
}

With such an approach we are able to support the following pattern of completions processing:

	while (1) {
		if ((ret = rpma_conn_wait(conn, &cq, NULL, RPMA_CONN_POSTPONE_NOTIFY_REQ)))
			return ret;
		if ((ret = rpma_cq_get_wc(cq, MAX_N_WC, wc, &num_got))) {
			if (ret == RPMA_E_NO_COMPLETION) {
				rpma_cq_wait_req(cq, 0);
				continue;
			}
			return ret;
		}
		process_comp(wc, num_got);
		if ((ret = rpma_cq_wait_req(cq, 0)))
			return ret;
		if ((ret = rpma_cq_get_wc(cq, MAX_N_WC, wc, &num_got))) {
			if (ret == RPMA_E_NO_COMPLETION) {
				continue;
			}
			return ret;
		}
	}
@grom72 grom72 added the enhancement New feature or request label May 18, 2022
grom72 added a commit to grom72/rpma that referenced this issue Jun 29, 2022
pmem#1743 will be implemented later.
This PR intorduce only the flag to be able to mergee all new examples
with target API.
grom72 added a commit to grom72/rpma that referenced this issue Jun 29, 2022
pmem#1743 will be implemented later.
This PR intorduce only the flag to be able to mergee all new examples
with target API.
grom72 added a commit to grom72/rpma that referenced this issue Jun 30, 2022
pmem#1743 will be implemented later.
This PR intorduces only the flags argument to be able to merge
all new examples with thw new API.
grom72 added a commit to grom72/rpma that referenced this issue Jun 30, 2022
pmem#1743 will be implemented later.
This PR introduces only the flags argument to be able to merge
all new examples with the new API.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant