get:
Show a patch comment.

patch:
Update a patch comment.

put:
Update a patch comment.

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

{
    "id": 169850,
    "web_url": "http://patches.dpdk.org/comment/169850/",
    "msgid": "<dc2b3eff-c882-4571-aefe-49b34f7af18d@lysator.liu.se>",
    "list_archive_url": "https://inbox.dpdk.org/dev/dc2b3eff-c882-4571-aefe-49b34f7af18d@lysator.liu.se",
    "date": "2024-05-04T15:36:54",
    "subject": "Re: [RFC v6 5/6] eal: add atomic bit operations",
    "submitter": {
        "id": 906,
        "url": "http://patches.dpdk.org/api/people/906/?format=api",
        "name": "Mattias Rönnblom",
        "email": "hofors@lysator.liu.se"
    },
    "content": "On 2024-05-04 01:30, Tyler Retzlaff wrote:\n> On Fri, May 03, 2024 at 08:41:09AM +0200, Mattias Rönnblom wrote:\n>> On 2024-05-02 07:57, Mattias Rönnblom wrote:\n>>> Add atomic bit test/set/clear/assign/flip and\n>>> test-and-set/clear/assign/flip functions.\n>>>\n>>> All atomic bit functions allow (and indeed, require) the caller to\n>>> specify a memory order.\n>>>\n>>> RFC v6:\n>>>   * Have rte_bit_atomic_test() accept const-marked bitsets.\n>>>\n>>> RFC v4:\n>>>   * Add atomic bit flip.\n>>>   * Mark macro-generated private functions experimental.\n>>>\n>>> RFC v3:\n>>>   * Work around lack of C++ support for _Generic (Tyler Retzlaff).\n>>>\n>>> RFC v2:\n>>>   o Add rte_bit_atomic_test_and_assign() (for consistency).\n>>>   o Fix bugs in rte_bit_atomic_test_and_[set|clear]().\n>>>   o Use <rte_stdatomics.h> to support MSVC.\n>>>\n>>> Signed-off-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>\n>>> Acked-by: Morten Brørup <mb@smartsharesystems.com>\n>>> Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>\n>>> ---\n>>>   lib/eal/include/rte_bitops.h | 428 +++++++++++++++++++++++++++++++++++\n>>>   1 file changed, 428 insertions(+)\n>>>\n>>> diff --git a/lib/eal/include/rte_bitops.h b/lib/eal/include/rte_bitops.h\n>>> index caec4f36bb..9cde982113 100644\n>>> --- a/lib/eal/include/rte_bitops.h\n>>> +++ b/lib/eal/include/rte_bitops.h\n>>> @@ -21,6 +21,7 @@\n>>>   #include <rte_compat.h>\n>>>   #include <rte_debug.h>\n>>> +#include <rte_stdatomic.h>\n>>>   #ifdef __cplusplus\n>>>   extern \"C\" {\n>>> @@ -399,6 +400,202 @@ extern \"C\" {\n>>>   \t\t uint32_t *: __rte_bit_once_flip32,\t\t\\\n>>>   \t\t uint64_t *: __rte_bit_once_flip64)(addr, nr)\n>>> +/**\n>>> + * @warning\n>>> + * @b EXPERIMENTAL: this API may change without prior notice.\n>>> + *\n>>> + * Test if a particular bit in a word is set with a particular memory\n>>> + * order.\n>>> + *\n>>> + * Test a bit with the resulting memory load ordered as per the\n>>> + * specified memory order.\n>>> + *\n>>> + * @param addr\n>>> + *   A pointer to the word to query.\n>>> + * @param nr\n>>> + *   The index of the bit.\n>>> + * @param memory_order\n>>> + *   The memory order to use. See <rte_stdatomics.h> for details.\n>>> + * @return\n>>> + *   Returns true if the bit is set, and false otherwise.\n>>> + */\n>>> +#define rte_bit_atomic_test(addr, nr, memory_order)\t\t\t\\\n>>> +\t_Generic((addr),\t\t\t\t\t\t\\\n>>> +\t\t uint32_t *: __rte_bit_atomic_test32,\t\t\t\\\n>>> +\t\t const uint32_t *: __rte_bit_atomic_test32,\t\t\\\n>>> +\t\t uint64_t *: __rte_bit_atomic_test64,\t\t\t\\\n>>> +\t\t const uint64_t *: __rte_bit_atomic_test64)(addr, nr,\t\\\n>>> +\t\t\t\t\t\t\t    memory_order)\n>>\n>> Should __rte_bit_atomic_test32()'s addr parameter be marked\n>> volatile, and two volatile-marked branches added to the above list?\n> \n> off-topic comment relating to the generic type selection list above, i was\n> reading C17 DR481 recently and i think we may want to avoid providing\n> qualified and unauqlified types in the list.\n> \n> DR481: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_481\n> \n> \"the controlling expression of a generic selection shall have type\n> compatibile with at most one of the types named in its generic\n> association list.\"\n> \n\nConst and unqualified pointers are not compatible. Without the \"const \nuint32_t *\" element in the association list, passing const-qualified \npointers to rte_bit_test() will cause a compiler error.\n\nSo, if you want to support both passing const-qualified and unqualified \npointers (which you do, obviously), then you have no other option than \nto treat them separately.\n\nGCC, clang and ICC all seem to agree on this. The standard also is \npretty clear on this, from what I can tell. \"No two generic associations \nin the same generic selection shall specify compatible types.\" (6.5.1.1, \nnote *compatible*). \"For two pointer types to be compatible, both shall \nbe identically qualified and both shall be pointers to compatible \ntypes.\" (6.7.6.1)\n\n> \"the type of the controlling expression is the type of the expression as\n> if it had undergone an lvalue conversion\"\n> \n> \"lvalue conversion drops type qualifiers\"\n> \n> so the unqualified type of the controlling expression is only matched\n> selection list which i guess that means the qualified entries in the\n> list are never selected.\n> \n> i suppose the implication here is we couldn't then provide 2 inline\n> functions one for volatile qualified and for not volatile qualified.\n> \n> as for a single function where the parameter is or isn't volatile\n> qualified. if we're always forwarding to an intrinsic i've always\n> assumed (perhaps incorrectly) that the intrinsic itself did what was\n> semantically correct even without qualification.\n> \n> as you note i believe there is a convenience element in providing the\n> volatile qualified version since it means the function like macro /\n> inline function will accept both volatile qualified and unqualified\n> whereas if we did not qualify the parameter it would require the\n> caller/user to strip the volatile qualification if present with casts.\n> \n> i imagine in most cases we are just forwarding, in which case it seems\n> not horrible to provide the qualified version.\n> \n>> Both the C11-style GCC built-ins and the C11-proper atomic functions\n>> have addresses marked volatile. The Linux kernel and the old __sync\n>> GCC built-ins on the other hand, doesn't (although I think you still\n>> get volatile semantics). The only point of \"volatile\", as far as I\n>> can see, is to avoid warnings in case the user passed a\n>> volatile-marked pointer. The drawback is that *you're asking for\n>> volatile semantics*, although with the current compilers, it seems\n>> like that is what you get, regardless if you asked for it or not.\n>>\n>> Just to be clear: even these functions would accept volatile-marked\n>> pointers, non-volatile pointers should be accepted as well (and\n>> should generally be preferred).\n>>\n>> Isn't parallel programming in C lovely.\n> \n> it's super!\n> \n>>\n>> <snip>",
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 2E45843F87;\n\tSat,  4 May 2024 17:37:00 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id DA30E402D5;\n\tSat,  4 May 2024 17:36:59 +0200 (CEST)",
            "from mail.lysator.liu.se (mail.lysator.liu.se [130.236.254.3])\n by mails.dpdk.org (Postfix) with ESMTP id 7EC984014F\n for <dev@dpdk.org>; Sat,  4 May 2024 17:36:58 +0200 (CEST)",
            "from mail.lysator.liu.se (localhost [127.0.0.1])\n by mail.lysator.liu.se (Postfix) with ESMTP id 8A09F19114\n for <dev@dpdk.org>; Sat,  4 May 2024 17:36:57 +0200 (CEST)",
            "by mail.lysator.liu.se (Postfix, from userid 1004)\n id 7EC7B19039; Sat,  4 May 2024 17:36:57 +0200 (CEST)",
            "from [192.168.1.59] (h-62-63-215-114.A163.priv.bahnhof.se\n [62.63.215.114])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mail.lysator.liu.se (Postfix) with ESMTPSA id CBB2F19037;\n Sat,  4 May 2024 17:36:54 +0200 (CEST)"
        ],
        "X-Spam-Checker-Version": "SpamAssassin 4.0.0 (2022-12-13) on\n hermod.lysator.liu.se",
        "X-Spam-Level": "",
        "X-Spam-Status": "No, score=-1.3 required=5.0 tests=ALL_TRUSTED,AWL,\n T_SCC_BODY_TEXT_LINE autolearn=disabled version=4.0.0",
        "X-Spam-Score": "-1.3",
        "Message-ID": "<dc2b3eff-c882-4571-aefe-49b34f7af18d@lysator.liu.se>",
        "Date": "Sat, 4 May 2024 17:36:54 +0200",
        "MIME-Version": "1.0",
        "User-Agent": "Mozilla Thunderbird",
        "From": "=?utf-8?q?Mattias_R=C3=B6nnblom?= <hofors@lysator.liu.se>",
        "Subject": "Re: [RFC v6 5/6] eal: add atomic bit operations",
        "To": "Tyler Retzlaff <roretzla@linux.microsoft.com>",
        "Cc": "=?utf-8?q?Mattias_R=C3=B6nnblom?= <mattias.ronnblom@ericsson.com>,\n dev@dpdk.org, Heng Wang <heng.wang@ericsson.com>,\n Stephen Hemminger <stephen@networkplumber.org>, =?utf-8?q?Morten_Br=C3=B8ru?=\n\t=?utf-8?q?p?= <mb@smartsharesystems.com>",
        "References": "<20240430120810.108928-2-mattias.ronnblom@ericsson.com>\n <20240502055706.112443-1-mattias.ronnblom@ericsson.com>\n <20240502055706.112443-6-mattias.ronnblom@ericsson.com>\n <1e703819-d3b2-4127-95c2-33d32d535432@lysator.liu.se>\n <20240503233059.GA25843@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net>",
        "Content-Language": "en-US",
        "In-Reply-To": "\n <20240503233059.GA25843@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net>",
        "Content-Type": "text/plain; charset=UTF-8; format=flowed",
        "Content-Transfer-Encoding": "8bit",
        "X-Virus-Scanned": "ClamAV using ClamSMTP",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "addressed": null
}