Commit ce70f296 authored by Jonathan Richardson's avatar Jonathan Richardson Committed by Daniel Verkamp
Browse files

nvme: Remove calls to getpid() when submitting nvme requests



As of glibc version 2.3.4 onwards getpid() is no longer cached. SPDK
makes calls to it in nvme_allocate_request() which is called for each
nvme request received. This results in a system calls up to millions of
times per second which slows down nvme submissions. Since the pid never
changes, it only needs to be called once in initialization per process.
This improves the performance of nvme_allocate_request() signficantly.

Change-Id: Idee0f06484d459906b9ce1d9b7360a33119c7e56
Signed-off-by: default avatarJonathan Richardson <jonathan.richardson@broadcom.com>
Signed-off-by: default avatarScott Branden <scott.branden@broadcom.com>
Reviewed-by: default avatarRay Jui <ray.jui@broadcom.com>
Reviewed-on: https://review.gerrithub.io/407599


Reviewed-by: default avatarScott Branden <sbranden@gmail.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent e5c57409
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@
#define SPDK_NVME_DRIVER_NAME "spdk_nvme_driver"

struct nvme_driver	*g_spdk_nvme_driver;
static pid_t g_pid;

int32_t			spdk_nvme_retry_count;

@@ -126,7 +127,7 @@ nvme_allocate_request(struct spdk_nvme_qpair *qpair,
	req->payload = *payload;
	req->payload_size = payload_size;
	req->qpair = qpair;
	req->pid = getpid();
	req->pid = g_pid;

	return req;
}
@@ -256,6 +257,9 @@ nvme_driver_init(void)
	/* Any socket ID */
	int socket_id = -1;

	/* Each process needs its own pid. */
	g_pid = getpid();

	/*
	 * Only one thread from one process will do this driver init work.
	 * The primary process will reserve the shared memory and do the