From patchwork Wed Feb 10 04:57:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Guo, Yejun" X-Patchwork-Id: 25530 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 53CB744BDDC for ; Wed, 10 Feb 2021 07:08:13 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3B5D2689FFE; Wed, 10 Feb 2021 07:08:13 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9D59A689C22 for ; Wed, 10 Feb 2021 07:08:04 +0200 (EET) IronPort-SDR: +OFA+eO0DtDqZxCQi+Ga2duDVzOQ+u5+mPEQaHTu+zDoIHsot2kq4xmqjqUqYwEaYpYTMuolVS omP69oGWgNzQ== X-IronPort-AV: E=McAfee;i="6000,8403,9890"; a="161164376" X-IronPort-AV: E=Sophos;i="5.81,167,1610438400"; d="scan'208";a="161164376" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2021 21:08:02 -0800 IronPort-SDR: b40Ll4Sdr+QAn47ykgLBB7nmIgWrwyxWsNVKOARwnPa39u1njoBJM6KiguViXn+KcTkRBYzGaj HYaddjrhYYhw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,167,1610438400"; d="scan'208";a="587228117" Received: from yguo18-skl-u1604.sh.intel.com ([10.239.159.53]) by fmsmga005.fm.intel.com with ESMTP; 09 Feb 2021 21:08:01 -0800 From: "Guo, Yejun" To: ffmpeg-devel@ffmpeg.org Date: Wed, 10 Feb 2021 12:57:59 +0800 Message-Id: <20210210045759.14672-1-yejun.guo@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH 02/10] dnn_backend_openvino.c: fix multi-thread issue for async execution X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: yejun.guo@intel.com MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" once we mark done for the task in function infer_completion_callback, the task is possible to be release in function ff_dnn_get_async_result_ov in another thread just after it, so we need to record request queue first, instead of using task->ov_model->request_queue later. Signed-off-by: Guo, Yejun --- libavfilter/dnn/dnn_backend_openvino.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c index 48f5ba50be..ed41b721fc 100644 --- a/libavfilter/dnn/dnn_backend_openvino.c +++ b/libavfilter/dnn/dnn_backend_openvino.c @@ -178,6 +178,7 @@ static void infer_completion_callback(void *args) IEStatusCode status; RequestItem *request = args; TaskItem *task = request->tasks[0]; + SafeQueue *requestq = task->ov_model->request_queue; ie_blob_t *output_blob = NULL; ie_blob_buffer_t blob_buffer; DNNData output; @@ -243,7 +244,7 @@ static void infer_completion_callback(void *args) request->task_count = 0; if (task->async) { - if (ff_safe_queue_push_back(task->ov_model->request_queue, request) < 0) { + if (ff_safe_queue_push_back(requestq, request) < 0) { av_log(ctx, AV_LOG_ERROR, "Failed to push back request_queue.\n"); return; }