get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 53050,
    "url": "http://patches.dpdk.org/api/patches/53050/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20190424123320.19610-3-mattias.ronnblom@ericsson.com/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20190424123320.19610-3-mattias.ronnblom@ericsson.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20190424123320.19610-3-mattias.ronnblom@ericsson.com",
    "date": "2019-04-24T12:33:20",
    "name": "[RFC,v3,2/2] eal: introduce random generator function with upper bound",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "a93ecebb82c4e9a411017dbbca9f5f791de9b7be",
    "submitter": {
        "id": 1077,
        "url": "http://patches.dpdk.org/api/people/1077/?format=api",
        "name": "Mattias Rönnblom",
        "email": "mattias.ronnblom@ericsson.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20190424123320.19610-3-mattias.ronnblom@ericsson.com/mbox/",
    "series": [
        {
            "id": 4447,
            "url": "http://patches.dpdk.org/api/series/4447/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=4447",
            "date": "2019-04-24T12:33:18",
            "name": "Pseudo-random number generation improvements",
            "version": 3,
            "mbox": "http://patches.dpdk.org/series/4447/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/53050/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/53050/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id B1F361B4E3;\n\tWed, 24 Apr 2019 14:33:39 +0200 (CEST)",
            "from sesbmg22.ericsson.net (sesbmg22.ericsson.net [193.180.251.48])\n\tby dpdk.org (Postfix) with ESMTP id 9A1B71B2B0\n\tfor <dev@dpdk.org>; Wed, 24 Apr 2019 14:33:37 +0200 (CEST)",
            "from ESESBMB501.ericsson.se (Unknown_Domain [153.88.183.114])\n\tby sesbmg22.ericsson.net (Symantec Mail Security) with SMTP id\n\t67.F3.06164.1A750CC5; Wed, 24 Apr 2019 14:33:37 +0200 (CEST)",
            "from ESESBMB502.ericsson.se (153.88.183.169) by\n\tESESBMB501.ericsson.se (153.88.183.168) with Microsoft SMTP Server\n\t(version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id\n\t15.1.1713.5; Wed, 24 Apr 2019 14:33:36 +0200",
            "from selio1a020.lmera.ericsson.se (153.88.183.153) by\n\tsmtp.internal.ericsson.com (153.88.183.185) with Microsoft SMTP\n\tServer id\n\t15.1.1713.5 via Frontend Transport; Wed, 24 Apr 2019 14:33:36 +0200",
            "from breslau.lmera.ericsson.se (breslau.lmera.ericsson.se\n\t[150.132.109.241])\n\tby selio1a020.lmera.ericsson.se (8.15.1+Sun/8.15.1) with ESMTP id\n\tx3OCXNAe010622; Wed, 24 Apr 2019 14:33:36 +0200 (CEST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801;\n\tc=relaxed/relaxed; \n\tq=dns/txt; i=@ericsson.com; t=1556109217; x=1558701217;\n\th=From:Sender:Reply-To:Subject:Date:Message-ID:To:CC:MIME-Version:Content-Type:\n\tContent-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From:\n\tResent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id:\n\tList-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive;\n\tbh=mVt6qNT+KVb8TgSEPSLAqv4/01tiUkrrU+5bjs//QJ8=;\n\tb=E5IiUjgIiKHArPagpefqOUQH8pTNSy2csls1y06+363Y41Ccodn+39P51hcDCpJ3\n\t9pi1fn/nPkwLHfSPi/YueiaESzASxmxNx0jBwHS+4gQ2qXlmR63/UL1TzReDRKrn\n\tF6hoalFTaBbZSLnrPt4QXuDKwGwt9D0b4AMmcZCIzE4=;",
        "X-AuditID": "c1b4fb30-6ddff70000001814-07-5cc057a15456",
        "From": "=?utf-8?q?Mattias_R=C3=B6nnblom?= <mattias.ronnblom@ericsson.com>",
        "To": "<dev@dpdk.org>",
        "CC": "<nhorman@tuxdriver.com>, <stephen@networkplumber.org>, =?utf-8?q?Matti?=\n\t=?utf-8?q?as_R=C3=B6nnblom?= <mattias.ronnblom@ericsson.com>",
        "Date": "Wed, 24 Apr 2019 14:33:20 +0200",
        "Message-ID": "<20190424123320.19610-3-mattias.ronnblom@ericsson.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20190424123320.19610-1-mattias.ronnblom@ericsson.com>",
        "References": "<e105eedd-bd18-5375-13b6-0123cfff2ae8@ericsson.com>\n\t<20190424123320.19610-1-mattias.ronnblom@ericsson.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"UTF-8\"",
        "Content-Transfer-Encoding": "8bit",
        "X-Brightmail-Tracker": "H4sIAAAAAAAAA+NgFrrGLMWRmVeSWpSXmKPExsUyM2J7ke7C8AMxBot/8Vq8+7SdyeJW80k2\n\ti8V35ByYPX4tWMrq0XNyHpPHle+rGQOYo7hsUlJzMstSi/TtErgy5px6y1awTbLi3YutjA2M\n\tbaJdjJwcEgImElO7HrB2MXJxCAkcZZRYeOkmM4TzjVFi64J7zCBVQgIXGSU2fi+GSFxmlFh3\n\teRo7SIJNwFNi8rtuFhBbREBIYunHy2BxZoEGoFFbOUBsYQF/ieNNSxlBbBYBVYkPG88ArePg\n\t4BVwkrh1WgXiCnmJ1RsOgO3iFHCWOPByASPE3gqJd3+/g43kFRCUODnzCQvEeE2J1u2/oVbJ\n\tSzRvnQ11p5bE/SVfmCcwCs1C0jILScssJC0LGJlXMYoWpxYn5aYbGemlFmUmFxfn5+nlpZZs\n\tYgSG9sEtvw12ML587niIUYCDUYmHV8v5QIwQa2JZcWXuIUYJDmYlEV6T7ftjhHhTEiurUovy\n\t44tKc1KLDzFKc7AoifNGr94TIySQnliSmp2aWpBaBJNl4uCUamAMF0rXS2qW5RfJF9ojVHfP\n\tfJ5y1td54nmWDEt8Rdjsw76d4uieuva6SsCJa1fjzy7amGl+97jbQYXNZ1KeBU/wrfiSsHLX\n\tLfYpMnH/5okXidy+eU9w8vIkufjmEtf3d5k2LlTIXbWCaRuHzYbwL/2n/gdmZh1bLpQYZPP0\n\t79LTaXM2bV5S5xenxFKckWioxVxUnAgAzvtOL2kCAAA=",
        "Subject": "[dpdk-dev] [RFC v3 2/2] eal: introduce random generator function\n\twith upper bound",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<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\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Add a function rte_rand_max() which generates an uniformly distributed\npseudo-random number less than a user-specified upper bound.\n\nThe commonly used pattern rte_rand() % SOME_VALUE creates biased\nresults (as in some values in the range are more frequently occurring\nthan others) if SOME_VALUE is not a power of 2.\n\nSigned-off-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>\n---\n lib/librte_eal/common/include/rte_random.h | 16 +++++++++\n lib/librte_eal/common/rte_random.c         | 39 ++++++++++++++++++++++\n lib/librte_eal/rte_eal_version.map         |  1 +\n 3 files changed, 56 insertions(+)",
    "diff": "diff --git a/lib/librte_eal/common/include/rte_random.h b/lib/librte_eal/common/include/rte_random.h\nindex 66dfe8ae7..cd29f3249 100644\n--- a/lib/librte_eal/common/include/rte_random.h\n+++ b/lib/librte_eal/common/include/rte_random.h\n@@ -47,6 +47,22 @@ rte_srand(uint64_t seedval);\n uint64_t\n rte_rand(void);\n \n+/**\n+ * Generates a pseudo-random number with an upper bound.\n+ *\n+ * This function returns an uniformly distributed (unbiased) random\n+ * number less than a user-specified maximum value.\n+ *\n+ * If called from lcore threads, this function is thread-safe.\n+ *\n+ * @param upper_bound\n+ *   The upper bound of the generated number.\n+ * @return\n+ *   A pseudo-random value between 0 and (upper_bound-1).\n+ */\n+uint64_t\n+rte_rand_max(uint64_t upper_bound);\n+\n #ifdef __cplusplus\n }\n #endif\ndiff --git a/lib/librte_eal/common/rte_random.c b/lib/librte_eal/common/rte_random.c\nindex 85dfd0cde..03a186337 100644\n--- a/lib/librte_eal/common/rte_random.c\n+++ b/lib/librte_eal/common/rte_random.c\n@@ -131,6 +131,45 @@ rte_rand(void)\n \treturn __rte_rand_lfsr258(state);\n }\n \n+uint64_t __rte_experimental\n+rte_rand_max(uint64_t upper_bound)\n+{\n+\tstruct rte_rand_state *state;\n+\tuint8_t ones;\n+\tuint8_t leading_zeros;\n+\tuint64_t mask = ~((uint64_t)0);\n+\tuint64_t res;\n+\n+\tif (unlikely(upper_bound < 2))\n+\t\treturn 0;\n+\n+\tstate = __rte_rand_get_state();\n+\n+\tones = __builtin_popcountll(upper_bound);\n+\n+\t/* Handle power-of-2 upper_bound as a special case, since it\n+\t * has no bias issues.\n+\t */\n+\tif (unlikely(ones == 1))\n+\t\treturn __rte_rand_lfsr258(state) & (upper_bound - 1);\n+\n+\t/* The approach to avoiding bias is to create a mask that\n+\t * stretches beyond the request value range, and up to the\n+\t * next power-of-2. In case the masked generated random value\n+\t * is equal to or greater than the upper bound, just discard\n+\t * the value and generate a new one.\n+\t */\n+\n+\tleading_zeros = __builtin_clzll(upper_bound);\n+\tmask >>= leading_zeros;\n+\n+\tdo {\n+\t\tres = __rte_rand_lfsr258(state) & mask;\n+\t} while (unlikely(res >= upper_bound));\n+\n+\treturn res;\n+}\n+\n RTE_INIT(rte_rand_init)\n {\n \trte_srand(rte_get_timer_cycles());\ndiff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map\nindex 381351749..1d3a54021 100644\n--- a/lib/librte_eal/rte_eal_version.map\n+++ b/lib/librte_eal/rte_eal_version.map\n@@ -376,6 +376,7 @@ EXPERIMENTAL {\n \trte_mp_request_async;\n \trte_mp_sendmsg;\n \trte_option_register;\n+\trte_rand_max;\n \trte_realloc_socket;\n \trte_service_lcore_attr_get;\n \trte_service_lcore_attr_reset_all;\n",
    "prefixes": [
        "RFC",
        "v3",
        "2/2"
    ]
}