)]}'
{"id":"userspace-rcu~8443","triplet_id":"userspace-rcu~master~I3e625f1689462f8eb9f1223b5b24b1a754bad324","project":"userspace-rcu","branch":"master","topic":"fix-futex-race","hashtags":[],"change_id":"I3e625f1689462f8eb9f1223b5b24b1a754bad324","subject":"Fix: call_rcu: futex wait: handle spurious futex wakeups","status":"MERGED","created":"2022-06-22 20:50:52.000000000","updated":"2022-06-27 14:30:14.000000000","submitted":"2022-06-27 14:30:14.000000000","submitter":{"_account_id":1000009,"name":"Mathieu Desnoyers","email":"mathieu.desnoyers@efficios.com","username":"compudj","avatars":[{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d32","height":32},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d56","height":56},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d100","height":100},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d120","height":120}]},"total_comment_count":0,"unresolved_comment_count":0,"has_review_started":true,"submission_id":"8441-fix-futex-race","meta_rev_id":"eb7f0ee15e7e5dc8ecba328a5f21b583438545bc","_number":8443,"virtual_id_number":8443,"owner":{"_account_id":1000009,"name":"Mathieu Desnoyers","email":"mathieu.desnoyers@efficios.com","username":"compudj","avatars":[{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d32","height":32},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d56","height":56},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d100","height":100},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d120","height":120}]},"actions":{},"labels":{"Code-Review":{"all":[{"value":0,"_account_id":1000009,"name":"Mathieu Desnoyers","email":"mathieu.desnoyers@efficios.com","username":"compudj","avatars":[{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d32","height":32},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d56","height":56},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d100","height":100},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d120","height":120}]}],"values":{"-2":"This shall not be merged","-1":"I would prefer this is not merged as is"," 0":"No score","+1":"Looks good to me, but someone else must approve","+2":"Looks good to me, approved"},"description":"","default_value":0,"optional":true},"Verified":{"all":[{"value":0,"_account_id":1000009,"name":"Mathieu Desnoyers","email":"mathieu.desnoyers@efficios.com","username":"compudj","avatars":[{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d32","height":32},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d56","height":56},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d100","height":100},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d120","height":120}]}],"values":{"-2":"Failure","-1":"Not built"," 0":"No score","+1":"Unstable","+2":"Success"},"description":"CI Build results","default_value":0,"optional":true},"CI-Build":{"all":[{"value":0,"_account_id":1000009,"name":"Mathieu Desnoyers","email":"mathieu.desnoyers@efficios.com","username":"compudj","avatars":[{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d32","height":32},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d56","height":56},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d100","height":100},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d120","height":120}]}],"values":{" 0":"No score","+1":"Trigger a CI build"},"description":"Trigger CI builds","default_value":0,"optional":true},"Smoke-Build-Lvl1":{"all":[{"value":0,"_account_id":1000009,"name":"Mathieu Desnoyers","email":"mathieu.desnoyers@efficios.com","username":"compudj","avatars":[{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d32","height":32},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d56","height":56},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d100","height":100},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d120","height":120}]}],"values":{" 0":"No score","+1":"Trigger a level 1 smoke build"},"description":"Trigger Level 1 Smoke builds","default_value":0,"optional":true},"Smoke-Build-Lvl2":{"all":[{"value":0,"_account_id":1000009,"name":"Mathieu Desnoyers","email":"mathieu.desnoyers@efficios.com","username":"compudj","avatars":[{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d32","height":32},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d56","height":56},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d100","height":100},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d120","height":120}]}],"values":{" 0":"No score","+1":"Trigger a level 2 smoke build"},"description":"Trigger Level 2 Smoke builds","default_value":0,"optional":true}},"removable_reviewers":[],"reviewers":{},"pending_reviewers":{},"reviewer_updates":[],"messages":[{"id":"02ec125b3b02ae588857e443ed7e3e60c608cf18","tag":"autogenerated:gerrit:newPatchSet","author":{"_account_id":1000009,"name":"Mathieu Desnoyers","email":"mathieu.desnoyers@efficios.com","username":"compudj","avatars":[{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d32","height":32},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d56","height":56},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d100","height":100},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d120","height":120}]},"date":"2022-06-22 20:50:52.000000000","message":"Uploaded patch set 1.","accounts_in_message":[],"_revision_number":1},{"id":"4f7a63353f12f3b219ef958dcdfb1f19fd6f6fd4","tag":"autogenerated:gerrit:newPatchSet","author":{"_account_id":1000009,"name":"Mathieu Desnoyers","email":"mathieu.desnoyers@efficios.com","username":"compudj","avatars":[{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d32","height":32},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d56","height":56},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d100","height":100},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d120","height":120}]},"date":"2022-06-23 19:09:31.000000000","message":"Uploaded patch set 2.","accounts_in_message":[],"_revision_number":2},{"id":"eb7f0ee15e7e5dc8ecba328a5f21b583438545bc","tag":"autogenerated:gerrit:merged","author":{"_account_id":1000009,"name":"Mathieu Desnoyers","email":"mathieu.desnoyers@efficios.com","username":"compudj","avatars":[{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d32","height":32},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d56","height":56},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d100","height":100},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d120","height":120}]},"date":"2022-06-27 14:30:14.000000000","message":"Change has been successfully pushed.","accounts_in_message":[],"_revision_number":3}],"current_revision_number":3,"current_revision":"98d705dd32be11b3f134b5aed87f9c201c028c10","revisions":{"d807e8c00d2a1d462e5fe1865cf9b2f6d5603e23":{"kind":"REWORK","_number":1,"created":"2022-06-22 20:50:52.000000000","uploader":{"_account_id":1000009,"name":"Mathieu Desnoyers","email":"mathieu.desnoyers@efficios.com","username":"compudj","avatars":[{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d32","height":32},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d56","height":56},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d100","height":100},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d120","height":120}]},"ref":"refs/changes/43/8443/1","fetch":{"anonymous http":{"url":"https://review.lttng.org/userspace-rcu","ref":"refs/changes/43/8443/1","commands":{"Branch":"git fetch https://review.lttng.org/userspace-rcu refs/changes/43/8443/1 \u0026\u0026 git checkout -b change-8443 FETCH_HEAD","Checkout":"git fetch https://review.lttng.org/userspace-rcu refs/changes/43/8443/1 \u0026\u0026 git checkout FETCH_HEAD","Cherry Pick":"git fetch https://review.lttng.org/userspace-rcu refs/changes/43/8443/1 \u0026\u0026 git cherry-pick FETCH_HEAD","Format Patch":"git fetch https://review.lttng.org/userspace-rcu refs/changes/43/8443/1 \u0026\u0026 git format-patch -1 --stdout FETCH_HEAD","Pull":"git pull https://review.lttng.org/userspace-rcu refs/changes/43/8443/1","Reset To":"git fetch https://review.lttng.org/userspace-rcu refs/changes/43/8443/1 \u0026\u0026 git reset --hard FETCH_HEAD"}}},"commit":{"parents":[{"commit":"36196841c226f812e292d804dff795a79afe9705","subject":"Fix: urcu: futex wait: handle spurious futex wakeups","web_links":[{"name":"gitweb","tooltip":"Open in GitWeb","url":"/gitweb?p\u003duserspace-rcu.git;a\u003dcommit;h\u003d36196841c226f812e292d804dff795a79afe9705"}]}],"author":{"name":"Mathieu Desnoyers","email":"mathieu.desnoyers@efficios.com","date":"2022-06-22 20:38:06.000000000","tz":-240},"committer":{"name":"Mathieu Desnoyers","email":"mathieu.desnoyers@efficios.com","date":"2022-06-22 20:38:06.000000000","tz":-240},"subject":"Fix: call_rcu: futex wait: handle spurious futex wakeups","message":"Fix: call_rcu: futex wait: handle spurious futex wakeups\n\nFrom futex(5):\n\n       FUTEX_WAIT\n              Returns 0 if the caller was woken up.  Note that a  wake-up  can\n              also  be caused by common futex usage patterns in unrelated code\n              that happened to have previously used the  futex  word\u0027s  memory\n              location  (e.g., typical futex-based implementations of Pthreads\n              mutexes can cause this under some conditions).  Therefore, call‐\n              ers should always conservatively assume that a return value of 0\n              can mean a spurious wake-up, and  use  the  futex  word\u0027s  value\n              (i.e.,  the user-space synchronization scheme) to decide whether\n              to continue to block or not.\n\nWe therefore need to validate whether the value differs from -1 in\nuser-space after the call to FUTEX_WAIT returns 0.\n\nSigned-off-by: Mathieu Desnoyers \u003cmathieu.desnoyers@efficios.com\u003e\nChange-Id: I3e625f1689462f8eb9f1223b5b24b1a754bad324\n","web_links":[{"name":"gitweb","tooltip":"Open in GitWeb","url":"/gitweb?p\u003duserspace-rcu.git;a\u003dcommit;h\u003dd807e8c00d2a1d462e5fe1865cf9b2f6d5603e23"}],"resolve_conflicts_web_links":[{"name":"gitweb","tooltip":"Open in GitWeb","url":"/gitweb?p\u003duserspace-rcu.git;a\u003dcommit;h\u003dd807e8c00d2a1d462e5fe1865cf9b2f6d5603e23"}]},"branch":"refs/heads/master"},"bf1852a23113c553fdc0992f3016e8652784142e":{"kind":"TRIVIAL_REBASE_WITH_MESSAGE_UPDATE","_number":2,"created":"2022-06-23 19:09:31.000000000","uploader":{"_account_id":1000009,"name":"Mathieu Desnoyers","email":"mathieu.desnoyers@efficios.com","username":"compudj","avatars":[{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d32","height":32},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d56","height":56},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d100","height":100},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d120","height":120}]},"ref":"refs/changes/43/8443/2","fetch":{"anonymous http":{"url":"https://review.lttng.org/userspace-rcu","ref":"refs/changes/43/8443/2","commands":{"Branch":"git fetch https://review.lttng.org/userspace-rcu refs/changes/43/8443/2 \u0026\u0026 git checkout -b change-8443 FETCH_HEAD","Checkout":"git fetch https://review.lttng.org/userspace-rcu refs/changes/43/8443/2 \u0026\u0026 git checkout FETCH_HEAD","Cherry Pick":"git fetch https://review.lttng.org/userspace-rcu refs/changes/43/8443/2 \u0026\u0026 git cherry-pick FETCH_HEAD","Format Patch":"git fetch https://review.lttng.org/userspace-rcu refs/changes/43/8443/2 \u0026\u0026 git format-patch -1 --stdout FETCH_HEAD","Pull":"git pull https://review.lttng.org/userspace-rcu refs/changes/43/8443/2","Reset To":"git fetch https://review.lttng.org/userspace-rcu refs/changes/43/8443/2 \u0026\u0026 git reset --hard FETCH_HEAD"}}},"commit":{"parents":[{"commit":"34c0b948417e9f85b6e62560ce8f372b1a0672c1","subject":"Fix: workqueue: futex wait: handle spurious futex wakeups","web_links":[{"name":"gitweb","tooltip":"Open in GitWeb","url":"/gitweb?p\u003duserspace-rcu.git;a\u003dcommit;h\u003d34c0b948417e9f85b6e62560ce8f372b1a0672c1"}]}],"author":{"name":"Mathieu Desnoyers","email":"mathieu.desnoyers@efficios.com","date":"2022-06-22 20:38:06.000000000","tz":-240},"committer":{"name":"Mathieu Desnoyers","email":"mathieu.desnoyers@efficios.com","date":"2022-06-23 19:09:31.000000000","tz":-240},"subject":"Fix: call_rcu: futex wait: handle spurious futex wakeups","message":"Fix: call_rcu: futex wait: handle spurious futex wakeups\n\nObserved issue\n\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n\nThe urcu call_rcu() and rcu_barrier() each implement a futex wait/wakeup\nscheme identical to the workqueue code, which has an issue with spurious\nwakeups.\n\n* call_rcu\n\nA spurious wakeup on call_rcu_wait can cause call_rcu_wait to return\nwith a crdp-\u003efutex state of -1, which is unexpected. It would cause the\nfollowing loops in call_rcu_thread() to decrement the crdp-\u003efutex to\nvalues below -1, thus actively using CPU time as values will be\ndecremented to very low negative values until the futex value underflows\nback to 0. The state is *not* restored to 0 when the callback list is\nfound to be non-empty, so this unexpected state will persist until the\ncrdp-\u003efutex state underflows back to 0, or until the call_rcu_thread is\nstopped. What prevents this from having too much user-observable effects\nis that the call rcu thread has a 10ms sleep between loops, to favor\nbatching of callbacks. Therefore, rather than being a purely 100% active\nbusy-wait, this scenario leads to a busy-wait which is paced by 10ms\nsleeps.\n\nTherefore the observed issue will be that the call_rcu_thread will\nunexpectedly wake up the CPU each 10ms after this spurious wakeup\nhappens.\n\n* rcu_barrier\n\nA spurious wakeup on call_rcu_completion_wait can cause\ncall_rcu_completion_wait to return with a completion-\u003efutex state of -1,\nwhich is unexpected. It would cause the following loops in rcu_barrier()\nto decrement the completion-\u003efutex to values below -1, thus actively\nusing CPU time as values will be decremented to very low negative values\nuntil either the barrier count reaches 0 or until the futex value\nunderflows to 0.\n\nTherefore the observed issue will be that rcu_barrier() will\nunexpectedly use a lot of CPU time when this spurious wakeup happens.\n\nThese issues will cause spurious unexpected high CPU use, but will not\nlead to data corruption.\n\nCause\n\u003d\u003d\u003d\u003d\u003d\n\nFrom futex(5):\n\n       FUTEX_WAIT\n              Returns 0 if the caller was woken up.  Note that a  wake-up  can\n              also  be caused by common futex usage patterns in unrelated code\n              that happened to have previously used the  futex  word\u0027s  memory\n              location  (e.g., typical futex-based implementations of Pthreads\n              mutexes can cause this under some conditions).  Therefore, call‐\n              ers should always conservatively assume that a return value of 0\n              can mean a spurious wake-up, and  use  the  futex  word\u0027s  value\n              (i.e.,  the user-space synchronization scheme) to decide whether\n              to continue to block or not.\n\nSolution\n\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n\nWe therefore need to validate whether the value differs from -1 in\nuser-space after the call to FUTEX_WAIT returns 0.\n\nKnown drawbacks\n\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n\nNone.\n\nSigned-off-by: Mathieu Desnoyers \u003cmathieu.desnoyers@efficios.com\u003e\nChange-Id: I3e625f1689462f8eb9f1223b5b24b1a754bad324\n","web_links":[{"name":"gitweb","tooltip":"Open in GitWeb","url":"/gitweb?p\u003duserspace-rcu.git;a\u003dcommit;h\u003dbf1852a23113c553fdc0992f3016e8652784142e"}],"resolve_conflicts_web_links":[{"name":"gitweb","tooltip":"Open in GitWeb","url":"/gitweb?p\u003duserspace-rcu.git;a\u003dcommit;h\u003dbf1852a23113c553fdc0992f3016e8652784142e"}]},"branch":"refs/heads/master"},"98d705dd32be11b3f134b5aed87f9c201c028c10":{"kind":"NO_CHANGE","_number":3,"created":"2022-06-27 14:30:14.000000000","uploader":{"_account_id":1000009,"name":"Mathieu Desnoyers","email":"mathieu.desnoyers@efficios.com","username":"compudj","avatars":[{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d32","height":32},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d56","height":56},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d100","height":100},{"url":"https://www.gravatar.com/avatar/7326b3e1d32b971a5e69d9730228c428.jpg?d\u003dretro\u0026r\u003dr\u0026s\u003d120","height":120}]},"ref":"refs/changes/43/8443/3","fetch":{"anonymous http":{"url":"https://review.lttng.org/userspace-rcu","ref":"refs/changes/43/8443/3","commands":{"Branch":"git fetch https://review.lttng.org/userspace-rcu refs/changes/43/8443/3 \u0026\u0026 git checkout -b change-8443 FETCH_HEAD","Checkout":"git fetch https://review.lttng.org/userspace-rcu refs/changes/43/8443/3 \u0026\u0026 git checkout FETCH_HEAD","Cherry Pick":"git fetch https://review.lttng.org/userspace-rcu refs/changes/43/8443/3 \u0026\u0026 git cherry-pick FETCH_HEAD","Format Patch":"git fetch https://review.lttng.org/userspace-rcu refs/changes/43/8443/3 \u0026\u0026 git format-patch -1 --stdout FETCH_HEAD","Pull":"git pull https://review.lttng.org/userspace-rcu refs/changes/43/8443/3","Reset To":"git fetch https://review.lttng.org/userspace-rcu refs/changes/43/8443/3 \u0026\u0026 git reset --hard FETCH_HEAD"}}},"commit":{"parents":[{"commit":"80c34c2de3d970eb82049798357743cfa71e8b54","subject":"Fix: workqueue: futex wait: handle spurious futex wakeups","web_links":[{"name":"gitweb","tooltip":"Open in GitWeb","url":"/gitweb?p\u003duserspace-rcu.git;a\u003dcommit;h\u003d80c34c2de3d970eb82049798357743cfa71e8b54"}]}],"author":{"name":"Mathieu Desnoyers","email":"mathieu.desnoyers@efficios.com","date":"2022-06-22 20:38:06.000000000","tz":-240},"committer":{"name":"Mathieu Desnoyers","email":"mathieu.desnoyers@efficios.com","date":"2022-06-27 14:30:13.000000000","tz":-240},"subject":"Fix: call_rcu: futex wait: handle spurious futex wakeups","message":"Fix: call_rcu: futex wait: handle spurious futex wakeups\n\nObserved issue\n\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n\nThe urcu call_rcu() and rcu_barrier() each implement a futex wait/wakeup\nscheme identical to the workqueue code, which has an issue with spurious\nwakeups.\n\n* call_rcu\n\nA spurious wakeup on call_rcu_wait can cause call_rcu_wait to return\nwith a crdp-\u003efutex state of -1, which is unexpected. It would cause the\nfollowing loops in call_rcu_thread() to decrement the crdp-\u003efutex to\nvalues below -1, thus actively using CPU time as values will be\ndecremented to very low negative values until the futex value underflows\nback to 0. The state is *not* restored to 0 when the callback list is\nfound to be non-empty, so this unexpected state will persist until the\ncrdp-\u003efutex state underflows back to 0, or until the call_rcu_thread is\nstopped. What prevents this from having too much user-observable effects\nis that the call rcu thread has a 10ms sleep between loops, to favor\nbatching of callbacks. Therefore, rather than being a purely 100% active\nbusy-wait, this scenario leads to a busy-wait which is paced by 10ms\nsleeps.\n\nTherefore the observed issue will be that the call_rcu_thread will\nunexpectedly wake up the CPU each 10ms after this spurious wakeup\nhappens.\n\n* rcu_barrier\n\nA spurious wakeup on call_rcu_completion_wait can cause\ncall_rcu_completion_wait to return with a completion-\u003efutex state of -1,\nwhich is unexpected. It would cause the following loops in rcu_barrier()\nto decrement the completion-\u003efutex to values below -1, thus actively\nusing CPU time as values will be decremented to very low negative values\nuntil either the barrier count reaches 0 or until the futex value\nunderflows to 0.\n\nTherefore the observed issue will be that rcu_barrier() will\nunexpectedly use a lot of CPU time when this spurious wakeup happens.\n\nThese issues will cause spurious unexpected high CPU use, but will not\nlead to data corruption.\n\nCause\n\u003d\u003d\u003d\u003d\u003d\n\nFrom futex(5):\n\n       FUTEX_WAIT\n              Returns 0 if the caller was woken up.  Note that a  wake-up  can\n              also  be caused by common futex usage patterns in unrelated code\n              that happened to have previously used the  futex  word\u0027s  memory\n              location  (e.g., typical futex-based implementations of Pthreads\n              mutexes can cause this under some conditions).  Therefore, call‐\n              ers should always conservatively assume that a return value of 0\n              can mean a spurious wake-up, and  use  the  futex  word\u0027s  value\n              (i.e.,  the user-space synchronization scheme) to decide whether\n              to continue to block or not.\n\nSolution\n\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n\nWe therefore need to validate whether the value differs from -1 in\nuser-space after the call to FUTEX_WAIT returns 0.\n\nKnown drawbacks\n\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n\nNone.\n\nSigned-off-by: Mathieu Desnoyers \u003cmathieu.desnoyers@efficios.com\u003e\nChange-Id: I3e625f1689462f8eb9f1223b5b24b1a754bad324\n","web_links":[{"name":"gitweb","tooltip":"Open in GitWeb","url":"/gitweb?p\u003duserspace-rcu.git;a\u003dcommit;h\u003d98d705dd32be11b3f134b5aed87f9c201c028c10"}],"resolve_conflicts_web_links":[{"name":"gitweb","tooltip":"Open in GitWeb","url":"/gitweb?p\u003duserspace-rcu.git;a\u003dcommit;h\u003d98d705dd32be11b3f134b5aed87f9c201c028c10"}]},"branch":"refs/heads/master"}},"requirements":[],"submit_records":[],"submit_requirements":[]}
