diff options
author | Dave Airlie | 2023-12-12 11:32:33 +1000 |
---|---|---|
committer | Dave Airlie | 2023-12-12 11:32:33 +1000 |
commit | c1ee197d64f49c9e2a6c8e6a168083c411c1362c (patch) | |
tree | ec8568a9d11ce55989c212efc4769cccc680964e /lib/objpool.c | |
parent | a60501d7c2d3e70b3545b9b96576628e369d8e85 (diff) | |
parent | a39b6ac3781d46ba18193c9dbb2110f31e9bffe9 (diff) |
Backmerge tag 'v6.7-rc5' into drm-next
Linux 6.7-rc5
Alex requested this for some amdkfd work relying on the symbols exports.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'lib/objpool.c')
-rw-r--r-- | lib/objpool.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/objpool.c b/lib/objpool.c index ce0087f64400..cfdc02420884 100644 --- a/lib/objpool.c +++ b/lib/objpool.c @@ -201,6 +201,23 @@ static inline void *objpool_try_get_slot(struct objpool_head *pool, int cpu) while (head != READ_ONCE(slot->last)) { void *obj; + /* + * data visibility of 'last' and 'head' could be out of + * order since memory updating of 'last' and 'head' are + * performed in push() and pop() independently + * + * before any retrieving attempts, pop() must guarantee + * 'last' is behind 'head', that is to say, there must + * be available objects in slot, which could be ensured + * by condition 'last != head && last - head <= nr_objs' + * that is equivalent to 'last - head - 1 < nr_objs' as + * 'last' and 'head' are both unsigned int32 + */ + if (READ_ONCE(slot->last) - head - 1 >= pool->nr_objs) { + head = READ_ONCE(slot->head); + continue; + } + /* obj must be retrieved before moving forward head */ obj = READ_ONCE(slot->entries[head & slot->mask]); |