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: Jonathan Richardson <jonathan.richardson@broadcom.com>
Signed-off-by: Scott Branden <scott.branden@broadcom.com>
Reviewed-by: Ray Jui <ray.jui@broadcom.com>
Reviewed-on: https://review.gerrithub.io/407599
Reviewed-by: Scott Branden <sbranden@gmail.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Jonathan Richardson 2018-02-27 18:16:05 -08:00 committed by Daniel Verkamp
parent e5c5740911
commit ce70f29662

View File

@ -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