Patch Detail
Show a patch.
GET /api/1.1/patches/22946/?format=api
{ "id": 22946, "url": "https://patchwork.libcamera.org/api/1.1/patches/22946/?format=api", "web_url": "https://patchwork.libcamera.org/patch/22946/", "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": "<20250310170326.185273-1-barnabas.pocze@ideasonboard.com>", "date": "2025-03-10T17:03:26", "name": "[v1] libcamera: v4l2_videodevice: `lastUsedCounter_` need not be atomic", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "6c174dddf2bba907665416be2d43a00ade774769", "submitter": { "id": 216, "url": "https://patchwork.libcamera.org/api/1.1/people/216/?format=api", "name": "Barnabás Pőcze", "email": "barnabas.pocze@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/22946/mbox/", "series": [ { "id": 5054, "url": "https://patchwork.libcamera.org/api/1.1/series/5054/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5054", "date": "2025-03-10T17:03:26", "name": "[v1] libcamera: v4l2_videodevice: `lastUsedCounter_` need not be atomic", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5054/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/22946/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/22946/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 30301C32F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 10 Mar 2025 17:03:36 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D2753687FA;\n\tMon, 10 Mar 2025 18:03:35 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F36B7687F0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 10 Mar 2025 18:03:33 +0100 (CET)", "from pb-laptop.local (185.221.143.221.nat.pool.zt.hu\n\t[185.221.143.221])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 489CA227\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 10 Mar 2025 18:01:56 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"SzGFI+nB\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1741626117;\n\tbh=u2Km0sfP+5a7CydMFT5g/+2GpinsHbRIKaubxO57OYQ=;\n\th=From:To:Subject:Date:From;\n\tb=SzGFI+nB0MKu8rAPITK55oB0pH2bEnBfIp1mVlpYFhS1evDcvqhF/DSiiai3y3C4N\n\tt2YuNxjs+v2BJXGfTmwtzgep+Q2lG9Xp6x1btIw7qIfJWA7iM6WQE6k2Y7XCbqp47+\n\t846w+gE4W808ObSJ/Ny1v8nqXWoFituMym1VeQFk=", "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[PATCH v1] libcamera: v4l2_videodevice: `lastUsedCounter_` need not\n\tbe atomic", "Date": "Mon, 10 Mar 2025 18:03:26 +0100", "Message-ID": "<20250310170326.185273-1-barnabas.pocze@ideasonboard.com>", "X-Mailer": "git-send-email 2.48.1", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "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 `V4L2BufferCache` type is not thread-safe. Its `lastUsedCounter_`\nmember is not used in contexts where its atomicity would matter.\nSo it does not need to be have an atomic type.\n\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n include/libcamera/internal/v4l2_videodevice.h | 2 +-\n src/libcamera/v4l2_videodevice.cpp | 4 ++--\n 2 files changed, 3 insertions(+), 3 deletions(-)", "diff": "diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\nindex f021c2a01..e52b50c67 100644\n--- a/include/libcamera/internal/v4l2_videodevice.h\n+++ b/include/libcamera/internal/v4l2_videodevice.h\n@@ -158,7 +158,7 @@ private:\n \t\tstd::vector<Plane> planes_;\n \t};\n \n-\tstd::atomic<uint64_t> lastUsedCounter_;\n+\tuint64_t lastUsedCounter_;\n \tstd::vector<Entry> cache_;\n \t/* \\todo Expose the miss counter through an instrumentation API. */\n \tunsigned int missCounter_;\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex e241eb47b..f5b3fa09d 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -190,7 +190,7 @@ V4L2BufferCache::V4L2BufferCache(const std::vector<std::unique_ptr<FrameBuffer>>\n {\n \tfor (const std::unique_ptr<FrameBuffer> &buffer : buffers)\n \t\tcache_.emplace_back(true,\n-\t\t\t\t lastUsedCounter_.fetch_add(1, std::memory_order_acq_rel),\n+\t\t\t\t lastUsedCounter_++,\n \t\t\t\t *buffer.get());\n }\n \n@@ -258,7 +258,7 @@ int V4L2BufferCache::get(const FrameBuffer &buffer)\n \t\treturn -ENOENT;\n \n \tcache_[use] = Entry(false,\n-\t\t\t lastUsedCounter_.fetch_add(1, std::memory_order_acq_rel),\n+\t\t\t lastUsedCounter_++,\n \t\t\t buffer);\n \n \treturn use;\n", "prefixes": [ "v1" ] }