Hello, On Tue, Jul 02, 2024 at 07:57:18AM +0000, Xiu Jianfeng wrote: > struct misc_res { > u64 max; > + u64 watermark; atomic64_t is probably better here. > atomic64_t usage; > atomic64_t events; > }; ... > +static void misc_cg_update_watermark(struct misc_res *res, u64 new_usage) > +{ > + u64 old; > + How about just while (true)? > + do { > + old = READ_ONCE(res->watermark); here, you can use atomic64_read(). > + if (new_usage <= old) > + break; > + if (cmpxchg(&res->watermark, old, new_usage) == old) and atomic64_cmpxchg(). > + break; > + } while (1); > +} Thanks. -- tejun