Re: [PATCH RFC 5/7] blk-mq: record the number of times fail to get driver tag while sharing tags

From: Bart Van Assche
Date: Thu Jul 06 2023 - 14:18:48 EST


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.