From patchwork Wed Feb 10 09:34:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Guo, Yejun" X-Patchwork-Id: 25539 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 49315449CE2 for ; Wed, 10 Feb 2021 11:44:44 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2477168A2BB; Wed, 10 Feb 2021 11:44:44 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B8166689EEC for ; Wed, 10 Feb 2021 11:44:37 +0200 (EET) IronPort-SDR: 476FSrXxvQi4+wjfEqV0ulKo4Ssu7fAZfd5thCAcox7VzNnyBggW5/gv6v1Qewh6Al5DXkSr7J eSRHp5ssMaNQ== X-IronPort-AV: E=McAfee;i="6000,8403,9890"; a="201144853" X-IronPort-AV: E=Sophos;i="5.81,167,1610438400"; d="scan'208";a="201144853" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2021 01:44:35 -0800 IronPort-SDR: 80ZjCPSrn0wbPWHVGHpSPkNkXqsh7g9ZlTRXtCbxc4gXAxsqm9DaEfh4uoOvGdD6G3qvxJkgV7 tWNSqlUacqaQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,167,1610438400"; d="scan'208";a="488706552" Received: from yguo18-skl-u1604.sh.intel.com ([10.239.159.53]) by fmsmga001.fm.intel.com with ESMTP; 10 Feb 2021 01:44:34 -0800 From: "Guo, Yejun" To: ffmpeg-devel@ffmpeg.org Date: Wed, 10 Feb 2021 17:34:24 +0800 Message-Id: <20210210093432.9135-2-yejun.guo@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210210093432.9135-1-yejun.guo@intel.com> References: <20210210093432.9135-1-yejun.guo@intel.com> Subject: [FFmpeg-devel] [PATCH V2 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; }