Show a patch.

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

{
    "id": 22874,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/22874/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/22874/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/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": "<20250225173531.2595922-5-pobrn@protonmail.com>",
    "date": "2025-02-25T17:35:59",
    "name": "[v4,4/8] libcamera: base: log: Make `LogCategory::severity_` atomic",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "28de949ca8682529e1efe225b890d6b47a320335",
    "submitter": {
        "id": 133,
        "url": "https://patchwork.libcamera.org/api/1.1/people/133/?format=api",
        "name": "Pőcze Barnabás",
        "email": "pobrn@protonmail.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/22874/mbox/",
    "series": [
        {
            "id": 5022,
            "url": "https://patchwork.libcamera.org/api/1.1/series/5022/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5022",
            "date": "2025-02-25T17:35:34",
            "name": "libcamera: base: log: Misc. changes",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/5022/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/22874/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/22874/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 EED59BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 25 Feb 2025 17:36:04 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AB53868738;\n\tTue, 25 Feb 2025 18:36:04 +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 E341468733\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 Feb 2025 18:36:03 +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=\"Op+Aslk9\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1740504963; x=1740764163;\n\tbh=/fV1VdETywMya9fkTsil5CAHlq6CajoFW63nglqmDN4=;\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=Op+Aslk9ns2jOMWrq+4o3rKXj5XDFQzELE9g5mMK7/joPBACKYJkjKVolXLK3/l3f\n\tP+Ym5a9d4TX9AjnQHSpW4Z/Jr7TvwkFShVf1P9mTauoonBrJ8a7ZOdmOLIGPVfJdnl\n\tABPFmNo8vy+BBLdBZsZG4mp3R5uSTEY8gTCbSP+9LRHei+cgI59C9ufPikyBUZ/JjN\n\tyPlk3kSwIVqF9JLyyxu71Qc0wIxs4V5xVTVLGqPmwzsvrBFvQ6gtdeyu+/854Ds+gJ\n\t4DQnOZjwOP4GWExmAlsjYZd9jfdH5vsD8O/0vl6ShTHj7gU/WkoQyDhgq5wvZAM9iY\n\tS07KUyHmUkQwQ==",
        "Date": "Tue, 25 Feb 2025 17:35:59 +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 v4 4/8] libcamera: base: log: Make `LogCategory::severity_`\n\tatomic",
        "Message-ID": "<20250225173531.2595922-5-pobrn@protonmail.com>",
        "In-Reply-To": "<20250225173531.2595922-1-pobrn@protonmail.com>",
        "References": "<20250225173531.2595922-1-pobrn@protonmail.com>",
        "Feedback-ID": "20568564:user:proton",
        "X-Pm-Message-ID": "6bbedb749388dd20e7b118b7c3c0a7063f51f0a6",
        "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 6d2c93019..4137d87a4 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 a43ed9684..ce3f04547 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": [
        "v4",
        "4/8"
    ]
}