{"id":14926,"url":"https://patchwork.libcamera.org/api/covers/14926/?format=json","web_url":"https://patchwork.libcamera.org/cover/14926/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20211201070728.3114247-1-hiroh@chromium.org>","date":"2021-12-01T07:07:16","name":"[libcamera-devel,v4,00/12] Introduce clang thread safety annotations","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"mbox":"https://patchwork.libcamera.org/cover/14926/mbox/","series":[{"id":2789,"url":"https://patchwork.libcamera.org/api/series/2789/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2789","date":"2021-12-01T07:07:16","name":"Introduce clang thread safety annotations","version":4,"mbox":"https://patchwork.libcamera.org/series/2789/mbox/"}],"comments":"https://patchwork.libcamera.org/api/covers/14926/comments/","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 4ACADBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  1 Dec 2021 07:07:39 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8BB7460723;\n\tWed,  1 Dec 2021 08:07:38 +0100 (CET)","from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com\n\t[IPv6:2607:f8b0:4864:20::52b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A297960592\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  1 Dec 2021 08:07:36 +0100 (CET)","by mail-pg1-x52b.google.com with SMTP id l190so22627026pge.7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Nov 2021 23:07:36 -0800 (PST)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:203:3892:a049:59ba:c772])\n\tby smtp.gmail.com with ESMTPSA id\n\tm10sm16598962pgv.75.2021.11.30.23.07.33\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 30 Nov 2021 23:07:34 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"Gbx7cCYs\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; h=from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=04k+W1XnrWIHBeI6ZH/b/JfE7ejsgYLrldfC+AWpxao=;\n\tb=Gbx7cCYsg3UgxNDEpoFeRNr/1CM4T29uN6BGZkvhItqCeL7a2ZqJrKZQaLBB4MJOpu\n\t8vF6Vp8AkoF9OVXrgh8v5W8is2i3izCyWVQXUpZlF2Y4euAKcdm8mRKPux8rvOjl3egQ\n\tPBKV6snBRcBYyarLXLShJ9Um1AAAyNYSysXPo=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=04k+W1XnrWIHBeI6ZH/b/JfE7ejsgYLrldfC+AWpxao=;\n\tb=sydsTjU+0NKxDPSJybMAvjit1ozDlbW11+ZzWeCFvaPXd84dWoCHyr+UEsNJkJcfVx\n\tcutllHkwiES1sZ0ZgQw/aaVIDuZ0b/AZRFxyrsIDQTTkql8rmyij4oq6UYDMCGZG/23D\n\tworPbgZOcnflZgwMQlHvrBLcLtaOk8qLJ2Htz6f2+HfdjdNMjReOu0o/x11xJP+n4/Cr\n\tHM6jF61Y7O86JYgceIj713msmBd1/sroglIm92xe6Ul8WyHgGCF52UXF80UDlv05mbRK\n\tLrHgOO5VeMoWzndIKmg2jp0wA45vxom++Zyl/KQxGgE+UDvD/SLIt6NkFUUhYrWWuJkd\n\tYZkw==","X-Gm-Message-State":"AOAM5302tpvMBcxzTYTw8DsRG+oXpbVK+d2IdlEcr4YC7TL3qdx7nk3I\n\tM47IcGJLsnUHE4KmMiGyB1BMHlo70xAfqw==","X-Google-Smtp-Source":"ABdhPJyLLTHUKQ5+I2Aithsr1iGgU13bePizY+EyZ7f9UvAWdjZC2x7npCn/YS8Sd0mtwFkCyDW4LA==","X-Received":"by 2002:aa7:9207:0:b0:4a4:f59a:9df with SMTP id\n\t7-20020aa79207000000b004a4f59a09dfmr4131987pfo.63.1638342454570; \n\tTue, 30 Nov 2021 23:07:34 -0800 (PST)","From":"Hirokazu Honda <hiroh@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed,  1 Dec 2021 16:07:16 +0900","Message-Id":"<20211201070728.3114247-1-hiroh@chromium.org>","X-Mailer":"git-send-email 2.34.0.rc2.393.gf8c9666880-goog","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 00/12] Introduce clang thread safety\n\tannotations","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"This introduces clang thread safety annotations and applies it\nto libcamera Android HAL adaptation layer. It is necessary to add\nnew classes that wrap std::mutex, std::unique_lock and\nstd::condition_variable with the annotations. It is because no\nC++ standard library annotates all the mutex classes today.\nlibstdc++ doesn't annotate any classes. libc++ annotates for\nstd::mutex, std::lock_guard and std::scoped_lock, but doesn't for\nstd::unique_lock.\n\nTherefore it is possible to use std::mutex if libc++ is used.\nAlthoug I don't do so In this patch series because the existing\ncode using std::mutex is not annotated yet.\n\nDocument: https://clang.llvm.org/docs/ThreadSafetyAnalysis.html\n\nChange in v4:\n* Address comments from Laurent\n* Remove thread_annotations.h include where mutex.h is included\n* 05/12: Remove document about members of Mutex classes\n\nHirokazu Honda (12):\n  libcamera: base: Introduce ConditionVariable\n  android: Consolidate mutex classes to Mutex and MutexLocker\n  v4l2: Consolidate mutex classes to Mutex and MutexLocker\n  libcamera: base: Add thread safety annotation macros\n  libcamera: base: Add mutex classes with thread safety annotations\n  libcamera: Correct include headers for Mutex classes\n  android: camera_hal_manager: Add thread safety annotation\n  android: camera_stream: Protect buffers initialization by mutex_\n  android: camera_stream: Add thread safety annotation\n  android: camera_device: Fix variables access without protection\n  android: camera_device: Add thread safety annotation\n  android: camera_request: Add thread safety annotation\n\n include/libcamera/base/meson.build          |   2 +\n include/libcamera/base/mutex.h              | 132 ++++++++++++++++++++\n include/libcamera/base/semaphore.h          |   7 +-\n include/libcamera/base/thread.h             |   4 -\n include/libcamera/base/thread_annotations.h |  80 ++++++++++++\n meson.build                                 |   1 +\n src/android/camera_device.cpp               |  10 +-\n src/android/camera_device.h                 |  17 +--\n src/android/camera_hal_manager.h            |  13 +-\n src/android/camera_request.h                |   7 +-\n src/android/camera_stream.cpp               |  15 +--\n src/android/camera_stream.h                 |  15 +--\n src/libcamera/base/meson.build              |   1 +\n src/libcamera/base/mutex.cpp                |  65 ++++++++++\n src/libcamera/base/semaphore.cpp            |   1 -\n src/libcamera/base/signal.cpp               |   2 +-\n src/libcamera/base/thread.cpp               |  14 +--\n src/libcamera/camera_manager.cpp            |   4 +-\n src/v4l2/v4l2_camera.h                      |   6 +-\n src/v4l2/v4l2_camera_proxy.cpp              |   8 +-\n src/v4l2/v4l2_camera_proxy.h                |   4 +-\n 21 files changed, 341 insertions(+), 67 deletions(-)\n create mode 100644 include/libcamera/base/mutex.h\n create mode 100644 include/libcamera/base/thread_annotations.h\n create mode 100644 src/libcamera/base/mutex.cpp\n\n--\n2.34.0.rc2.393.gf8c9666880-goog"}