diff options
author | Patrick Williams <iawillia@us.ibm.com> | 2014-06-11 12:16:21 -0500 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2014-06-24 13:52:22 -0500 |
commit | aaadc0e5955551542ddc5fc84cc54dd32f8d9788 (patch) | |
tree | d5a7089f3948f2811794cfb5c28dca67ee21cbdc /src/kernel/deferred.C | |
parent | f81a76dc1e804534b3190b4aa64b83f707bd24a3 (diff) | |
download | talos-hostboot-aaadc0e5955551542ddc5fc84cc54dd32f8d9788.tar.gz talos-hostboot-aaadc0e5955551542ddc5fc84cc54dd32f8d9788.zip |
Resolve deadlock conditions in deferred work queue.
CQ: SW264983
Backport: release-fips811
Change-Id: Id3a3bc0b7367e61f2725af17975fe3ba068f69a9
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/11555
Tested-by: Jenkins Server
Reviewed-by: Douglas R. Gilbert <dgilbert@us.ibm.com>
Reviewed-by: Andrew J. Geissler <andrewg@us.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/kernel/deferred.C')
-rw-r--r-- | src/kernel/deferred.C | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/kernel/deferred.C b/src/kernel/deferred.C index ffa16d742..2e77a125d 100644 --- a/src/kernel/deferred.C +++ b/src/kernel/deferred.C @@ -31,10 +31,20 @@ reinterpret_cast<DeferredWork*>((item)->iv_cpus_and_next & 0xFFFFFFFF) /** Set the DeferredWork pointer part of a iv_cpus_and_next instance var. */ -#define DEFERRED_QUEUE_SET_NEXT_PTR(item) \ - (item)->iv_cpus_and_next = \ - ((item)->iv_cpus_and_next & 0xFFFFFFFF00000000ull) | \ - reinterpret_cast<uint64_t>(item) +#define DEFERRED_QUEUE_SET_NEXT_PTR(tail,item) \ + { \ + uint64_t old_value = 0; \ + uint64_t new_value = 0; \ + do \ + { \ + old_value = (tail)->iv_cpus_and_next; \ + new_value = (old_value & 0xFFFFFFFF00000000ull) | \ + reinterpret_cast<uint64_t>(item); \ + } \ + while (!__sync_bool_compare_and_swap(&(tail)->iv_cpus_and_next, \ + old_value, \ + new_value)); \ + } /** Extract the CPU count portion of a iv_cpus_and_next instance var. */ #define DEFERRED_QUEUE_GET_CPU_COUNT(item) (item)->iv_cpus_and_next >> 32 @@ -79,7 +89,7 @@ void DeferredQueue::_insert(DeferredWork* i_work) } // Add work item to the end of the list. - DEFERRED_QUEUE_SET_NEXT_PTR(i_work); + DEFERRED_QUEUE_SET_NEXT_PTR(tail, i_work); } lock.unlock(); @@ -125,6 +135,9 @@ void DeferredQueue::_complete(DeferredWork* i_work) old_ptr = iv_cpus_and_next; } while(!__sync_bool_compare_and_swap(&iv_cpus_and_next, old_ptr, new_ptr)); + // Clean up our own queue pointer. + DEFERRED_QUEUE_SET_NEXT_PTR(i_work, (DeferredWork*)NULL); + // Get the CPU count from the old object pointer and wait until those // CPUs get into i_work. old_ptr >>= 32; |