Show a patch.

GET /api/patches/22804/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 22804,
    "url": "https://patchwork.libcamera.org/api/patches/22804/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/22804/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20250217185433.306833-5-pobrn@protonmail.com>",
    "date": "2025-02-17T18:54:54",
    "name": "[v3,4/8] libcamera: base: log: Make `LogCategory::severity_` atomic",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "28de949ca8682529e1efe225b890d6b47a320335",
    "submitter": {
        "id": 133,
        "url": "https://patchwork.libcamera.org/api/people/133/?format=api",
        "name": "Pőcze Barnabás",
        "email": "pobrn@protonmail.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/22804/mbox/",
    "series": [
        {
            "id": 5007,
            "url": "https://patchwork.libcamera.org/api/series/5007/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5007",
            "date": "2025-02-17T18:54:35",
            "name": "libcamera: base: log: Misc. changes",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/5007/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/22804/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/22804/checks/",
    "tags": {},
    "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 1DC30C3200\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 17 Feb 2025 18:55:01 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BE5BC68691;\n\tMon, 17 Feb 2025 19:55:00 +0100 (CET)",
            "from mail-40131.protonmail.ch (mail-40131.protonmail.ch\n\t[185.70.40.131])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D2B7E6867F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 17 Feb 2025 19:54:58 +0100 (CET)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=protonmail.com header.i=@protonmail.com\n\theader.b=\"fcYnlJQX\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1739818498; x=1740077698;\n\tbh=APHFt1qeWUYoQjFwTkfxA7g56I/2fDczwSkYYslrItc=;\n\th=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:\n\tFeedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:\n\tMessage-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post;\n\tb=fcYnlJQXvmd3NIYOPStfGFivrMpTDC6QizWcFOYC9nHiZjlH0DrDjR2bC0/k/XZe8\n\tVyTslx5IJLaGqLfk4vxLGHeJ7+l37kkYDwRzy5icH67rq3yrpPnJFrYF7LvxdZMxGs\n\tJn/XSipETtvP87QR7bh7EJkttbkWJZCdUoTZenvWsWmW2rUnKGU1uouu+xllkgt4zX\n\tVNnDqfBwbhxj7JqmIk8Qv8Xo8Y0YhLncy3pXF+bvaU/vhnODcVevUrjRyTciKOi+RW\n\tljjS5lVeo6T9DWzkxrMwal/HOtwpeo1v1ita5a2VWDG8VliVW3MnhPk1XoT0AVZdFW\n\twQUVIYDNlkYwQ==",
        "Date": "Mon, 17 Feb 2025 18:54:54 +0000",
        "To": "libcamera-devel@lists.libcamera.org",
        "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>",
        "Cc": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tJacopo Mondi <jacopo.mondi@ideasonboard.com>",
        "Subject": "[PATCH v3 4/8] libcamera: base: log: Make `LogCategory::severity_`\n\tatomic",
        "Message-ID": "<20250217185433.306833-5-pobrn@protonmail.com>",
        "In-Reply-To": "<20250217185433.306833-1-pobrn@protonmail.com>",
        "References": "<20250217185433.306833-1-pobrn@protonmail.com>",
        "Feedback-ID": "20568564:user:proton",
        "X-Pm-Message-ID": "23c4234b7c99a5eac8b19e151ac2b3f4c0f7bf49",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=utf-8",
        "Content-Transfer-Encoding": "quoted-printable",
        "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": "The severity of a log category may be changed from a different thread,\nso it is important to ensure that the reads and writes happen atomically.\nUsing `std::memory_order_relaxed` should not introduce any synchronization\noverhead, it should only guarantee that the operation itself is atomic.\n\nSecondly, inline `LogCategory::setSeverity()`, as it is merely an\nassignment, so going through a DSO call is a big pessimization.\n`LogCategory` is not part of the public API, so this change has\nno external effects.\n\nThirdly, assert that the atomic variable is lock free so as to ensure\nit won't silently fall back to libatomic (or similar) on any platform.\nIf this assertion fails, this needs to be revisited.\n\nSigned-off-by: Barnabás Pőcze <pobrn@protonmail.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n include/libcamera/base/log.h | 9 ++++++---\n src/libcamera/base/log.cpp   | 5 +----\n 2 files changed, 7 insertions(+), 7 deletions(-)",
    "diff": "diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h\nindex 66f665905..6c809e38a 100644\n--- a/include/libcamera/base/log.h\n+++ b/include/libcamera/base/log.h\n@@ -7,6 +7,7 @@\n \n #pragma once\n \n+#include <atomic>\n #include <sstream>\n \n #include <libcamera/base/private.h>\n@@ -31,8 +32,8 @@ public:\n \tstatic LogCategory *create(const char *name);\n \n \tconst std::string &name() const { return name_; }\n-\tLogSeverity severity() const { return severity_; }\n-\tvoid setSeverity(LogSeverity severity);\n+\tLogSeverity severity() const { return severity_.load(std::memory_order_relaxed); }\n+\tvoid setSeverity(LogSeverity severity) { severity_.store(severity, std::memory_order_relaxed); }\n \n \tstatic const LogCategory &defaultCategory();\n \n@@ -40,7 +41,9 @@ private:\n \texplicit LogCategory(const char *name);\n \n \tconst std::string name_;\n-\tLogSeverity severity_;\n+\n+\tstd::atomic<LogSeverity> severity_;\n+\tstatic_assert(decltype(severity_)::is_always_lock_free);\n };\n \n #define LOG_DECLARE_CATEGORY(name)\t\t\t\t\t\\\ndiff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp\nindex 7043be711..e2c2eea8f 100644\n--- a/src/libcamera/base/log.cpp\n+++ b/src/libcamera/base/log.cpp\n@@ -810,15 +810,12 @@ LogCategory::LogCategory(const char *name)\n  */\n \n /**\n+ * \\fn LogCategory::setSeverity(LogSeverity severity)\n  * \\brief Set the severity of the log category\n  *\n  * Messages of severity higher than or equal to the severity of the log category\n  * are printed, other messages are discarded.\n  */\n-void LogCategory::setSeverity(LogSeverity severity)\n-{\n-\tseverity_ = severity;\n-}\n \n /**\n  * \\brief Retrieve the default log category\n",
    "prefixes": [
        "v3",
        "4/8"
    ]
}