{"id":14940,"url":"https://patchwork.libcamera.org/api/covers/14940/?format=json","web_url":"https://patchwork.libcamera.org/cover/14940/","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":"<20211201075348.3121186-1-hiroh@chromium.org>","date":"2021-12-01T07:53:36","name":"[libcamera-devel,v5,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/14940/mbox/","series":[{"id":2791,"url":"https://patchwork.libcamera.org/api/series/2791/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2791","date":"2021-12-01T07:53:36","name":"Introduce clang thread safety annotations","version":5,"mbox":"https://patchwork.libcamera.org/series/2791/mbox/"}],"comments":"https://patchwork.libcamera.org/api/covers/14940/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 D8E63BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  1 Dec 2021 07:53:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 91E6B60720;\n\tWed,  1 Dec 2021 08:53:57 +0100 (CET)","from mail-pl1-x633.google.com (mail-pl1-x633.google.com\n\t[IPv6:2607:f8b0:4864:20::633])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6825260592\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  1 Dec 2021 08:53:56 +0100 (CET)","by mail-pl1-x633.google.com with SMTP id z6so17037545plk.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Nov 2021 23:53:56 -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\tl9sm3500848pfu.55.2021.11.30.23.53.52\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 30 Nov 2021 23:53:53 -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=\"coy76HLG\"; 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=xwRdoC8kZYbR0aPkKBfZglVVOjxO3iRVsfRtx3VIt7k=;\n\tb=coy76HLGSL2zUqdPsbxA0fMrjlSlhCDD66GBCGzpgnj51qDQMUJTkd0NWEYbFmfhny\n\t/4bCC96KaQpsNb27Gtb2DBO4XHjcccGt0cE6WJlAbcwNgzgcGmLtc6YUdW148gwpCU4C\n\tC4XViBc0nyfIiWkGUqCJpDW5Ekkkl9ak9e0VY=","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=xwRdoC8kZYbR0aPkKBfZglVVOjxO3iRVsfRtx3VIt7k=;\n\tb=FuGj29MiqGcIQrX3jl/mdJxeP9MqpsX+jdW8ymP5UmPBREH46mJhg1l4CE08QmvyEt\n\trquljHuxuQoOPQXSOVbvTINnQEbV+fo4OdV5a/3I8npGDjpvFlnNuC2nMNI5SKaed4YU\n\tKi76FJtJHAbFm7pfDdVvaEu85nnSvBCIkYtY13Vc97G2VAQVc8hOY9RhzFtWmj5VBY8k\n\tiQ+CJfoDZe40ucOgRsMR6Qlt9c+DjRgwipP6jkHWwJUtDmpomouWA077E9HbDZcKaVYv\n\tckbNQ5SnSjWysPiRcJO8umgg8F+/HGMYU2In33Z9SBhkibA/E/tFUg6kM5m8hZ3d2EXz\n\tq9/A==","X-Gm-Message-State":"AOAM532xatGEgVe5HJJ7PeV+dYuJMg8OwV+PkD59FqPm5gMSeG0go6CV\n\t+dGvnVmk3t47jMtcIb+RLFqe17XE1NDM4g==","X-Google-Smtp-Source":"ABdhPJzAARZlfgqRb28VFM3vBT/wxNXpNKJjBv0bUUD0+1NfEmI1tlCgwxcAwS2euguY0x3anHM+zQ==","X-Received":"by 2002:a17:902:9b8f:b0:142:7999:67fb with SMTP id\n\ty15-20020a1709029b8f00b00142799967fbmr5599023plp.24.1638345234354; \n\tTue, 30 Nov 2021 23:53:54 -0800 (PST)","From":"Hirokazu Honda <hiroh@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed,  1 Dec 2021 16:53:36 +0900","Message-Id":"<20211201075348.3121186-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 v5 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 v5:\n* 05/12: Address comments from Laurent\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                |  56 +++++++++\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, 332 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"}