get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 49130,
    "url": "https://patches.dpdk.org/api/patches/49130/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1545235774-9834-1-git-send-email-erik.g.carrillo@intel.com/",
    "project": {
        "id": 1,
        "url": "https://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": "<1545235774-9834-1-git-send-email-erik.g.carrillo@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1545235774-9834-1-git-send-email-erik.g.carrillo@intel.com",
    "date": "2018-12-19T16:09:34",
    "name": "[v2] timer: fix race condition",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "4eba17a1a8aae4ee45e80a910ef4daaded04bdfb",
    "submitter": {
        "id": 762,
        "url": "https://patches.dpdk.org/api/people/762/?format=api",
        "name": "Carrillo, Erik G",
        "email": "erik.g.carrillo@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1545235774-9834-1-git-send-email-erik.g.carrillo@intel.com/mbox/",
    "series": [
        {
            "id": 2874,
            "url": "https://patches.dpdk.org/api/series/2874/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=2874",
            "date": "2018-12-19T16:09:34",
            "name": "[v2] timer: fix race condition",
            "version": 2,
            "mbox": "https://patches.dpdk.org/series/2874/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/49130/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/49130/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 A73ED1B5C7;\n\tWed, 19 Dec 2018 17:10:23 +0100 (CET)",
            "from mga18.intel.com (mga18.intel.com [134.134.136.126])\n\tby dpdk.org (Postfix) with ESMTP id D8BEA1B5C2\n\tfor <dev@dpdk.org>; Wed, 19 Dec 2018 17:10:21 +0100 (CET)",
            "from fmsmga006.fm.intel.com ([10.253.24.20])\n\tby orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t19 Dec 2018 08:10:20 -0800",
            "from txasoft-yocto.an.intel.com (HELO txasoft-yocto.an.intel.com.)\n\t([10.123.72.192])\n\tby fmsmga006.fm.intel.com with ESMTP; 19 Dec 2018 08:10:20 -0800"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.56,373,1539673200\"; d=\"scan'208\";a=\"303506738\"",
        "From": "Erik Gabriel Carrillo <erik.g.carrillo@intel.com>",
        "To": "Gavin.Hu@arm.com,\n\tthomas@monjalon.net",
        "Cc": "dev@dpdk.org, rsanford@akamai.com, olivier.matz@6wind.com,\n\tstephen@networkplumber.org, bruce.richardson@intel.com",
        "Date": "Wed, 19 Dec 2018 10:09:34 -0600",
        "Message-Id": "<1545235774-9834-1-git-send-email-erik.g.carrillo@intel.com>",
        "X-Mailer": "git-send-email 1.7.10",
        "In-Reply-To": "<1543517626-142526-1-git-send-email-erik.g.carrillo@intel.com>",
        "References": "<1543517626-142526-1-git-send-email-erik.g.carrillo@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v2] timer: fix race condition",
        "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": "rte_timer_manage() adds expired timers to a \"run list\", and walks the\nlist, transitioning each timer from the PENDING to the RUNNING state.\nIf another lcore resets or stops the timer at precisely this\nmoment, the timer state would instead be set to CONFIG by that other\nlcore, which would cause timer_manage() to skip over it. This is\nexpected behavior.\n\nHowever, if a timer expires quickly enough, there exists the\nfollowing race condition that causes the timer_manage() routine to\nmisinterpret a timer in CONFIG state, resulting in lost timers:\n\n- Thread A:\n  - starts a timer with rte_timer_reset()\n  - the timer is moved to CONFIG state\n  - the spinlock associated with the appropriate skiplist is acquired\n  - timer is inserted into the skiplist\n  - the spinlock is released\n- Thread B:\n  - executes rte_timer_manage()\n  - find above timer as expired, add it to run list\n  - walk run list, see above timer still in CONFIG state, unlink it from\n    run list and continue on\n- Thread A:\n  - move timer to PENDING state\n  - return from rte_timer_reset()\n  - timer is now in PENDING state, but not actually linked into a\n    pending list or a run list and will never get processed further\n    by rte_timer_manage()\n\nThis commit fixes this race condition by only releasing the spinlock\nafter the timer state has been transitioned from CONFIG to PENDING,\nwhich prevents rte_timer_manage() from seeing an incorrect state.\n\nFixes: 9b15ba895b9f (\"timer: use a skip list\")\nSigned-off-by: Erik Gabriel Carrillo <erik.g.carrillo@intel.com>\nReviewed-by: Gavin Hu <gavin.hu@arm.com>\n---\nv2:\n - Add more detail to commit message (Gavin Hu)\n\n lib/librte_timer/rte_timer.c | 28 ++++++++++++++--------------\n 1 file changed, 14 insertions(+), 14 deletions(-)",
    "diff": "diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c\nindex 590488c..30c7b0a 100644\n--- a/lib/librte_timer/rte_timer.c\n+++ b/lib/librte_timer/rte_timer.c\n@@ -241,24 +241,17 @@ timer_get_prev_entries_for_node(struct rte_timer *tim, unsigned tim_lcore,\n \t}\n }\n \n-/*\n- * add in list, lock if needed\n+/* call with lock held as necessary\n+ * add in list\n  * timer must be in config state\n  * timer must not be in a list\n  */\n static void\n-timer_add(struct rte_timer *tim, unsigned tim_lcore, int local_is_locked)\n+timer_add(struct rte_timer *tim, unsigned int tim_lcore)\n {\n-\tunsigned lcore_id = rte_lcore_id();\n \tunsigned lvl;\n \tstruct rte_timer *prev[MAX_SKIPLIST_DEPTH+1];\n \n-\t/* if timer needs to be scheduled on another core, we need to\n-\t * lock the list; if it is on local core, we need to lock if\n-\t * we are not called from rte_timer_manage() */\n-\tif (tim_lcore != lcore_id || !local_is_locked)\n-\t\trte_spinlock_lock(&priv_timer[tim_lcore].list_lock);\n-\n \t/* find where exactly this element goes in the list of elements\n \t * for each depth. */\n \ttimer_get_prev_entries(tim->expire, tim_lcore, prev);\n@@ -282,9 +275,6 @@ timer_add(struct rte_timer *tim, unsigned tim_lcore, int local_is_locked)\n \t * NOTE: this is not atomic on 32-bit*/\n \tpriv_timer[tim_lcore].pending_head.expire = priv_timer[tim_lcore].\\\n \t\t\tpending_head.sl_next[0]->expire;\n-\n-\tif (tim_lcore != lcore_id || !local_is_locked)\n-\t\trte_spinlock_unlock(&priv_timer[tim_lcore].list_lock);\n }\n \n /*\n@@ -379,8 +369,15 @@ __rte_timer_reset(struct rte_timer *tim, uint64_t expire,\n \ttim->f = fct;\n \ttim->arg = arg;\n \n+\t/* if timer needs to be scheduled on another core, we need to\n+\t * lock the destination list; if it is on local core, we need to lock if\n+\t * we are not called from rte_timer_manage()\n+\t */\n+\tif (tim_lcore != lcore_id || !local_is_locked)\n+\t\trte_spinlock_lock(&priv_timer[tim_lcore].list_lock);\n+\n \t__TIMER_STAT_ADD(pending, 1);\n-\ttimer_add(tim, tim_lcore, local_is_locked);\n+\ttimer_add(tim, tim_lcore);\n \n \t/* update state: as we are in CONFIG state, only us can modify\n \t * the state so we don't need to use cmpset() here */\n@@ -389,6 +386,9 @@ __rte_timer_reset(struct rte_timer *tim, uint64_t expire,\n \tstatus.owner = (int16_t)tim_lcore;\n \ttim->status.u32 = status.u32;\n \n+\tif (tim_lcore != lcore_id || !local_is_locked)\n+\t\trte_spinlock_unlock(&priv_timer[tim_lcore].list_lock);\n+\n \treturn 0;\n }\n \n",
    "prefixes": [
        "v2"
    ]
}