[dpdk-stable] patch 'ipc: use monotonic clock' has been queued to stable release 20.11.2
Xueming Li
xuemingl at nvidia.com
Sat Jun 12 01:03:13 CEST 2021
Hi,
FYI, your patch has been queued to stable release 20.11.2
Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 06/14/21. So please
shout if anyone has objections.
Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.
Queued patches are on a temporary branch at:
https://github.com/steevenlee/dpdk
This queued commit can be viewed at:
https://github.com/steevenlee/dpdk/commit/764a01e145779ff4f97ffa574593c20153abf487
Thanks.
Xueming Li <xuemingl at nvidia.com>
---
>From 764a01e145779ff4f97ffa574593c20153abf487 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen at huawei.com>
Date: Tue, 11 May 2021 18:41:23 +0800
Subject: [PATCH] ipc: use monotonic clock
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: Luca Boccassi <bluca at debian.org>
[ upstream commit cc994d3922b7cd464d84fbef110dd65348e0a0da ]
Currently, the mp uses gettimeofday() API to get the time, and used as
timeout parameter.
But the time which gets from gettimeofday() API isn't monotonically
increasing. The process may fail if the system time is changed.
This fixes it by using clock_gettime() API with monotonic attribution.
Fixes: 783b6e54971d ("eal: add synchronous multi-process communication")
Fixes: f05e26051c15 ("eal: add IPC asynchronous request")
Signed-off-by: Chengwen Feng <fengchengwen at huawei.com>
Signed-off-by: Min Hu (Connor) <humin29 at huawei.com>
Acked-by: Morten Brørup <mb at smartsharesystems.com>
---
lib/librte_eal/common/eal_common_proc.c | 27 ++++++++++++-------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/common/eal_common_proc.c
index 6d1af3c0e7..dc4a2efa82 100644
--- a/lib/librte_eal/common/eal_common_proc.c
+++ b/lib/librte_eal/common/eal_common_proc.c
@@ -490,14 +490,11 @@ async_reply_handle_thread_unsafe(void *arg)
struct pending_request *req = (struct pending_request *)arg;
enum async_action action;
struct timespec ts_now;
- struct timeval now;
- if (gettimeofday(&now, NULL) < 0) {
+ if (clock_gettime(CLOCK_MONOTONIC, &ts_now) < 0) {
RTE_LOG(ERR, EAL, "Cannot get current time\n");
goto no_trigger;
}
- ts_now.tv_nsec = now.tv_usec * 1000;
- ts_now.tv_sec = now.tv_sec;
action = process_async_request(req, &ts_now);
@@ -896,6 +893,7 @@ mp_request_sync(const char *dst, struct rte_mp_msg *req,
struct rte_mp_reply *reply, const struct timespec *ts)
{
int ret;
+ pthread_condattr_t attr;
struct rte_mp_msg msg, *tmp;
struct pending_request pending_req, *exist;
@@ -904,7 +902,9 @@ mp_request_sync(const char *dst, struct rte_mp_msg *req,
strlcpy(pending_req.dst, dst, sizeof(pending_req.dst));
pending_req.request = req;
pending_req.reply = &msg;
- pthread_cond_init(&pending_req.sync.cond, NULL);
+ pthread_condattr_init(&attr);
+ pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
+ pthread_cond_init(&pending_req.sync.cond, &attr);
exist = find_pending_request(dst, req->name);
if (exist) {
@@ -967,8 +967,7 @@ rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply,
int dir_fd, ret = -1;
DIR *mp_dir;
struct dirent *ent;
- struct timeval now;
- struct timespec end;
+ struct timespec now, end;
const struct internal_config *internal_conf =
eal_get_internal_configuration();
@@ -987,15 +986,15 @@ rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply,
return -1;
}
- if (gettimeofday(&now, NULL) < 0) {
+ if (clock_gettime(CLOCK_MONOTONIC, &now) < 0) {
RTE_LOG(ERR, EAL, "Failed to get current time\n");
rte_errno = errno;
goto end;
}
- end.tv_nsec = (now.tv_usec * 1000 + ts->tv_nsec) % 1000000000;
+ end.tv_nsec = (now.tv_nsec + ts->tv_nsec) % 1000000000;
end.tv_sec = now.tv_sec + ts->tv_sec +
- (now.tv_usec * 1000 + ts->tv_nsec) / 1000000000;
+ (now.tv_nsec + ts->tv_nsec) / 1000000000;
/* for secondary process, send request to the primary process only */
if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
@@ -1069,7 +1068,7 @@ rte_mp_request_async(struct rte_mp_msg *req, const struct timespec *ts,
int dir_fd, ret = 0;
DIR *mp_dir;
struct dirent *ent;
- struct timeval now;
+ struct timespec now;
struct timespec *end;
bool dummy_used = false;
const struct internal_config *internal_conf =
@@ -1086,7 +1085,7 @@ rte_mp_request_async(struct rte_mp_msg *req, const struct timespec *ts,
return -1;
}
- if (gettimeofday(&now, NULL) < 0) {
+ if (clock_gettime(CLOCK_MONOTONIC, &now) < 0) {
RTE_LOG(ERR, EAL, "Failed to get current time\n");
rte_errno = errno;
return -1;
@@ -1108,9 +1107,9 @@ rte_mp_request_async(struct rte_mp_msg *req, const struct timespec *ts,
end = ¶m->end;
reply = ¶m->user_reply;
- end->tv_nsec = (now.tv_usec * 1000 + ts->tv_nsec) % 1000000000;
+ end->tv_nsec = (now.tv_nsec + ts->tv_nsec) % 1000000000;
end->tv_sec = now.tv_sec + ts->tv_sec +
- (now.tv_usec * 1000 + ts->tv_nsec) / 1000000000;
+ (now.tv_nsec + ts->tv_nsec) / 1000000000;
reply->nb_sent = 0;
reply->nb_received = 0;
reply->msgs = NULL;
--
2.25.1
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2021-06-12 06:53:59.172910100 +0800
+++ 0099-ipc-use-monotonic-clock.patch 2021-06-12 06:53:56.450000000 +0800
@@ -1 +1 @@
-From cc994d3922b7cd464d84fbef110dd65348e0a0da Mon Sep 17 00:00:00 2001
+From 764a01e145779ff4f97ffa574593c20153abf487 Mon Sep 17 00:00:00 2001
@@ -7,0 +8,3 @@
+Cc: Luca Boccassi <bluca at debian.org>
+
+[ upstream commit cc994d3922b7cd464d84fbef110dd65348e0a0da ]
@@ -19 +21,0 @@
-Cc: stable at dpdk.org
@@ -25 +27 @@
- lib/eal/common/eal_common_proc.c | 27 +++++++++++++--------------
+ lib/librte_eal/common/eal_common_proc.c | 27 ++++++++++++-------------
@@ -28 +30 @@
-diff --git a/lib/eal/common/eal_common_proc.c b/lib/eal/common/eal_common_proc.c
+diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/common/eal_common_proc.c
@@ -30,2 +32,2 @@
---- a/lib/eal/common/eal_common_proc.c
-+++ b/lib/eal/common/eal_common_proc.c
+--- a/lib/librte_eal/common/eal_common_proc.c
++++ b/lib/librte_eal/common/eal_common_proc.c
More information about the stable
mailing list