get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 48417,
    "url": "http://patches.dpdk.org/api/patches/48417/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1543517626-142526-1-git-send-email-erik.g.carrillo@intel.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": "<1543517626-142526-1-git-send-email-erik.g.carrillo@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1543517626-142526-1-git-send-email-erik.g.carrillo@intel.com",
    "date": "2018-11-29T18:53:46",
    "name": "[1/1] timer: fix race condition",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "4eba17a1a8aae4ee45e80a910ef4daaded04bdfb",
    "submitter": {
        "id": 762,
        "url": "http://patches.dpdk.org/api/people/762/?format=api",
        "name": "Carrillo, Erik G",
        "email": "erik.g.carrillo@intel.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/1543517626-142526-1-git-send-email-erik.g.carrillo@intel.com/mbox/",
    "series": [
        {
            "id": 2617,
            "url": "http://patches.dpdk.org/api/series/2617/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=2617",
            "date": "2018-11-29T18:53:46",
            "name": "[1/1] timer: fix race condition",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/2617/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/48417/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/48417/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 62D191B4B9;\n\tThu, 29 Nov 2018 19:53:38 +0100 (CET)",
            "from mga12.intel.com (mga12.intel.com [192.55.52.136])\n\tby dpdk.org (Postfix) with ESMTP id E43A92C01\n\tfor <dev@dpdk.org>; Thu, 29 Nov 2018 19:53:36 +0100 (CET)",
            "from orsmga001.jf.intel.com ([10.7.209.18])\n\tby fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t29 Nov 2018 10:53:36 -0800",
            "from wcpqa1.an.intel.com ([10.123.72.207])\n\tby orsmga001.jf.intel.com with ESMTP; 29 Nov 2018 10:53:35 -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,295,1539673200\"; d=\"scan'208\";a=\"113829940\"",
        "From": "Erik Gabriel Carrillo <erik.g.carrillo@intel.com>",
        "To": "rsanford@akamai.com",
        "Cc": "dev@dpdk.org",
        "Date": "Thu, 29 Nov 2018 12:53:46 -0600",
        "Message-Id": "<1543517626-142526-1-git-send-email-erik.g.carrillo@intel.com>",
        "X-Mailer": "git-send-email 1.7.10",
        "Subject": "[dpdk-dev] [PATCH 1/1] 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 skiplist\n    and will never get processed further 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>\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": [
        "1/1"
    ]
}