On 6/18/23 09:07, Yu Kuai wrote:
+static void update_tag_sharing_busy(struct tag_sharing *tag_sharing) +{ + unsigned int count = atomic_inc_return(&tag_sharing->fail_count); + unsigned long last_period = READ_ONCE(tag_sharing->period); + + if (time_after(jiffies, last_period + HZ) && + cmpxchg_relaxed(&tag_sharing->period, last_period, jiffies) == + last_period) + atomic_sub(count / 2, &tag_sharing->fail_count); +}
For new code, try_cmpxchg_relaxed() is preferred over cmpxchg_relaxed().
struct tag_sharing { struct list_head node; unsigned int available_tags; + atomic_t fail_count; + unsigned long period; };
Please consider renaming "period" into "latest_reduction" or any other name that make the purpose of this member clear. Thanks, Bart.