From patchwork Tue Jul 18 16:11:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wan-Teh Chang X-Patchwork-Id: 4356 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.1.76 with SMTP id 73csp1777004vsb; Tue, 18 Jul 2017 09:18:18 -0700 (PDT) X-Received: by 10.28.109.218 with SMTP id b87mr2460345wmi.125.1500394698088; Tue, 18 Jul 2017 09:18:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500394698; cv=none; d=google.com; s=arc-20160816; b=C/5ROogVv/IbTe9OIw5u+8gduMgSpEQjqrZiamXMwSOCkM190YL57BBB8X4QpexC8O B3ghc7NUieBLLN0yxZ4rnQgho3vmkZCFnHYWtIaMC63YPlPWtkqs5i13IYe3NdmyxB1U JSiEOY4jnBAoFEnQsgH0s5m6/l7WQ2M/2sKzjtNqv7duXAjDLhowM/4LiwDcggK/gDh1 XaGniuL+G5SahSGQqq8j9PPwDxs/hFV1PDaGBqLfSoWwnBzq38ggPqyLpyUbheFq7loM BMO+lE3o8/btZLHbZkjpHflF3ve+4QMANq7IMu69tky0RCFVaPTlt2TkOyElHubhFCVE bGdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=aerB/T/i3HGP1sc5Ucb27GL/5xYjuBehwtVbl+rI7MA=; b=i/Ciq7cDXsOd0vyUi+WISr0HYP0fMiyGqDNuQQDu/SCIFIcelYsFd8g2j2rosXEOwD u47FcQ07tDaE7PHc+0n0xfN9HtQAcCxKREhfsQ+I/mbuuu1AprzaAEZKNGW2A7iw87hL weOVQaThlKYbnlsEcTiicqnzf3B8ym4M2LzagMMe18bvoWNvmC6PfItKZztBkrX3yLQm JDqCCX9nYHXmqGEi9SjH0gsweGPZm2JDLhYJtpkZXUeh58d6UriCThx7GAdNuXUtbGkv l/YrJ4YusCFKJObrbPG01MrQi3Rq34j6wdqRqtpxFFId5IQxQOHSWfA0DEZZBGMQQdVA BW/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.b=tBxsiwL3; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 26si2139673wrv.234.2017.07.18.09.18.16; Tue, 18 Jul 2017 09:18:18 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.b=tBxsiwL3; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AC647689924; Tue, 18 Jul 2017 19:18:06 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf0-f177.google.com (mail-pf0-f177.google.com [209.85.192.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B9D55689223 for ; Tue, 18 Jul 2017 19:18:00 +0300 (EEST) Received: by mail-pf0-f177.google.com with SMTP id e199so13674328pfh.2 for ; Tue, 18 Jul 2017 09:18:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:subject:date:message-id; bh=Eyjrc7rqUpRWkyh9GrlFTuwBc1MI4xj7dNBmkIkoqf8=; b=tBxsiwL3e0ypTimW/iy/7nhKAyjwxfWrIoDR5PgC/aeC8xun95OpsT8ZXIM97ugI1h 39DgaZ9NplNL3c4a5ESPLp+b0xoaMFxpab0hKDA38EqA9owuGctRwzAeAZLeFnbFVyIn +xJHpyb9TugL1p37wlcjUDag4pV4fIm7+UEKPsdDL/nw9Gpsy7FcbvSlS18QTYJzg94+ xIcK2xzETjgTmW52+0WiL9j9wR2bdb62RO5ZG+uWps3HyDMULvt1pOAgR0gUd2Yknhlt DCVtFWyX2cjQcghkxzp7bmYB8hd6Fm3Ej6p65Gp5hZzLurEJdkcIEGnpMQ6Jt7vxh95b qerg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=Eyjrc7rqUpRWkyh9GrlFTuwBc1MI4xj7dNBmkIkoqf8=; b=SXlNXR9sUmjWUPahi84KgteAz+nHrv5MUDY3+LszhReFSwhczy6vEvoPy3mFphBtIL tmCxEzQBi1Kg2tV3RGHWBuWMXdhMlDEeGTj7TeyShnldM3Rwzytn0N9FYsqYK1ePvxjO U6Pku2JzCnRmac2sX2OsfCeL/9cNZN7+hRcm2mCt2H+a2P3L2B85s2K1YzshXspO96l+ RHaE00cBaOxptLjbrB8W8l0qHtntQ7eWBlkIBveQXk0sa9BK9DZ9NNm7bA8KcciIKjqD b4bIQSsQbcTTZ/nXODHV3Mrrc5UTK6ZU6xnQCIbJFS0BBMog+ST/y5T8vgX6KDW/1ljG 6rJg== X-Gm-Message-State: AIVw111IO0IPCDSolCd57x9p7Sq7SQuWEc9vLmSEvxe+EuL7tFOx6bnV Nogwp3jXhJpUrVSwmL3LPQ== X-Received: by 10.84.229.15 with SMTP id b15mr2535319plk.195.1500394314997; Tue, 18 Jul 2017 09:11:54 -0700 (PDT) Received: from wtc-desktop.mtv.corp.google.com ([100.98.5.29]) by smtp.googlemail.com with ESMTPSA id r62sm7395565pfl.45.2017.07.18.09.11.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Jul 2017 09:11:53 -0700 (PDT) From: Wan-Teh Chang To: ffmpeg-devel@ffmpeg.org Date: Tue, 18 Jul 2017 09:11:09 -0700 Message-Id: <20170718161109.19163-1-wtc@google.com> X-Mailer: git-send-email 2.13.2.932.g7449e964c-goog Subject: [FFmpeg-devel] [PATCH] pthread_frame: revert 2e664b9c1e73c80aab91070c1eb7676f04bdd12d. 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The patch does not fix the tsan warning it was intended to fix. Reverting the patch moves the av_log() back to the outside of the lock. Signed-off-by: Wan-Teh Chang --- libavcodec/pthread_frame.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index 2cea232a36..08e182c3d1 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -570,11 +570,12 @@ void ff_thread_report_progress(ThreadFrame *f, int n, int field) p = f->owner[field]->internal->thread_ctx; - pthread_mutex_lock(&p->progress_mutex); if (atomic_load_explicit(&p->debug_threads, memory_order_relaxed)) av_log(f->owner[field], AV_LOG_DEBUG, "%p finished %d field %d\n", progress, n, field); + pthread_mutex_lock(&p->progress_mutex); + atomic_store_explicit(&progress[field], n, memory_order_release); pthread_cond_broadcast(&p->progress_cond); @@ -592,10 +593,11 @@ void ff_thread_await_progress(ThreadFrame *f, int n, int field) p = f->owner[field]->internal->thread_ctx; - pthread_mutex_lock(&p->progress_mutex); if (atomic_load_explicit(&p->debug_threads, memory_order_relaxed)) av_log(f->owner[field], AV_LOG_DEBUG, "thread awaiting %d field %d from %p\n", n, field, progress); + + pthread_mutex_lock(&p->progress_mutex); while (atomic_load_explicit(&progress[field], memory_order_relaxed) < n) pthread_cond_wait(&p->progress_cond, &p->progress_mutex); pthread_mutex_unlock(&p->progress_mutex);