From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C949DA0C3F for ; Sat, 12 Jun 2021 01:14:11 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C2FC14003F; Sat, 12 Jun 2021 01:14:11 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2052.outbound.protection.outlook.com [40.107.220.52]) by mails.dpdk.org (Postfix) with ESMTP id E060240DDB for ; Sat, 12 Jun 2021 01:14:09 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j06zw1vG4WY1/cVp8ZBpKImnCPitOxBcJTCto3ZfvmmOIPkk1LmYINxbF599DzbTImY3mmlLp8w8RvVbr96au0WqSZBNtV4pThaxEB7q6rnkUrAsg+1IZfrPcweBBFCqWPbgIWBboCNP4hJZxB4L34irTBZ/0TmWKBMeIQKafoVesqE+PuoKb7Dyw3yUlbI60+h96269AUWDBmm0E0aWiPn8zQBMoVuseGq4BJbOMxrjCt/4AVmE5l3cpVLmOwYmvSyJFrjz1F5TX4o2PtgEjz/AxnBUAyx+B/X7lNw9CXCEOESewp8qq4dwGKgcfZuk4nbWdboRU6Mpexr2DMnDGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=M7Wl7EzLJG5gzlBrmQCWkjY0DCalxSPRUz42rO7Lvtk=; b=awuAdLXJI32C24YNrZ0gviLZCYszY3MADHksYFMq9wiFU68tEK1+heHcXmJTmXOxpbDHK0qPSDt4B/GPU7qt9tsHX5thSOyzxCdSYZOX0C4B+EthIj4GwFIvpNS52eECWVcj+pDzfw0y3YidSXbHAhd44alnedfw4BNGY2uRZbNCctY4Bc4AI9bCoNaZtvH9ETfXfOR9SnbTePK/EhDQGKX23pFOHJh2gvH8q8zxaBr/RvdtxRq2kHGHwcBgYRdHe5RSebh5+Hz4tApxMCZ60GFo/wxoIbKAdCSLsZ1GSeyb5HWbI6cSJpVIMSoVTAu7VQiIY5uqVSgQa2dFNDi62g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=smartsharesystems.com smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=M7Wl7EzLJG5gzlBrmQCWkjY0DCalxSPRUz42rO7Lvtk=; b=S+NQwx4v5lvrg7jnVoq1Gdm5vOyKZPklHeTRm+XwgpUso/aLUBjvdtRZCpt++L1eKSUs0A2fXFhwnbtM5xx3VneE9ytpd6HxmbmwL8N8le18Eoe4/L+tmk+zw22Atiri1dlZo9FDtfnNjyiIhzFX7tmYr4tyem5pcyY1wfix8Pt+ZnBkX08hYzv4a1SN63oRnWMaGCQz2EeKJEYehikvCMebKc/FctogUk4fXUGxrKHuaFIueuzDVqCstKLqhVW5CpRb0wO2tN5AUGV06A2RoUmC93YlBp1QWWotb0ahdcL5VLYaUw2S6eOv0s73vwump1aXhoSWQ/vP2bKpGdkDcA== Received: from BN9PR03CA0623.namprd03.prod.outlook.com (2603:10b6:408:106::28) by BY5PR12MB4164.namprd12.prod.outlook.com (2603:10b6:a03:207::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.24; Fri, 11 Jun 2021 23:14:08 +0000 Received: from BN8NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:408:106:cafe::49) by BN9PR03CA0623.outlook.office365.com (2603:10b6:408:106::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Fri, 11 Jun 2021 23:14:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; smartsharesystems.com; dkim=none (message not signed) header.d=none;smartsharesystems.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT013.mail.protection.outlook.com (10.13.176.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4219.21 via Frontend Transport; Fri, 11 Jun 2021 23:14:07 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 11 Jun 2021 23:14:04 +0000 From: Xueming Li To: Chengwen Feng CC: Luca Boccassi , Min Hu , =?UTF-8?q?Morten=20Br=C3=B8rup?= , dpdk stable Date: Sat, 12 Jun 2021 07:03:13 +0800 Message-ID: <20210611230433.8208-99-xuemingl@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210611230433.8208-1-xuemingl@nvidia.com> References: <20210510160258.30982-229-xuemingl@nvidia.com> <20210611230433.8208-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bcdc4dbd-ff2c-4877-64bf-08d92d2e9d06 X-MS-TrafficTypeDiagnostic: BY5PR12MB4164: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZaUilP1O2QaSXShdpvdZal/2onMrBjwDFsqobVB52fxk5yriWTQYhbjXDuKn9x9ND9p+CPNv397kTGbtVqCNJ/G5zOYwqTwK+mZfmzlIpOWE7foxX6GXm3xs2oAx3tTbH0wLuijI5pAYLJHDRSmfyqOKX7AlzucKL42LiLmq+iI0qqD/Iq5mqz0EpgS+mTzDkJ5ilf4moy9wRMVi/n5/13PUXGUTYsuYjAE6fs3tUCNGT3HThPsQq8+Ql/iroh/1+TYQ6lyDfXqSvLVd4yKMW+tIWHCBtEtAz7jhQLdmap76e2CSuRBisWWtdGbX0xzhTRgpbivX4exsRKCouIeCQOP1VBPcz54z9/zHfh7F4t/szXfZddd8YDSlOm4geBgV1MTFtSb1aRdaN2ajzZbpfYBKelZVhYs5P5amkwJT8an+u6DvsJQNcG4xhnNwtz4sOj0VXpvV9F7U/hawirERLFxoSPMcwgLded/cXhvGOrNinxt0+NeemvL9D01idrch3IfsZE/MxrT5qFP+XB4ReVJgTYgVdnF7u6lMScvYE85e/mvDdZCLCY+5FlXtQ9BZk+PFWJyRMnctU8hvmbRELzH9Rph01CpqRzLg4AfxDqAn5/OHkwPYrxJUSXMK+uOxn0HF6Qngb/4ixS6XtREORZFt25K9pvxzk1cVFgysJSQ4VMewFgW++iWKfZOPekKv1ZSNsNXr5FBq/convvRVjTOgUwehdomNmpw9GFaWQP5ATJU0YrEWEXF0o2/MkjHrY9A/vuf9MLWPvalPuvx51HxYsz9r3qkNC3svypa/sw5JdfxJS6SXvdpF4Urk9J6S X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(376002)(396003)(136003)(346002)(39860400002)(46966006)(36840700001)(8936002)(6666004)(66574015)(336012)(55016002)(6286002)(82310400003)(966005)(2906002)(426003)(8676002)(82740400003)(5660300002)(356005)(54906003)(7636003)(316002)(4326008)(36756003)(53546011)(7696005)(2616005)(1076003)(186003)(26005)(16526019)(36860700001)(478600001)(70206006)(83380400001)(6916009)(36906005)(70586007)(86362001)(47076005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2021 23:14:07.3974 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bcdc4dbd-ff2c-4877-64bf-08d92d2e9d06 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4164 Subject: [dpdk-stable] patch 'ipc: use monotonic clock' has been queued to stable release 20.11.2 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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 --- >From 764a01e145779ff4f97ffa574593c20153abf487 Mon Sep 17 00:00:00 2001 From: Chengwen Feng 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 [ 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 Signed-off-by: Min Hu (Connor) Acked-by: Morten Brørup --- 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 + +[ upstream commit cc994d3922b7cd464d84fbef110dd65348e0a0da ] @@ -19 +21,0 @@ -Cc: stable@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