lkml.org 
[lkml]   [2021]   [Feb]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v3 1/7] seqnum_ops: Introduce Sequence Number Ops
From
Date
On 2/5/21 2:58 AM, Greg KH wrote:
> On Wed, Feb 03, 2021 at 11:11:57AM -0700, Shuah Khan wrote:
>> +static inline u32 seqnum32_inc(struct seqnum32 *seq)
>> +{
>> + atomic_t val = ATOMIC_INIT(seq->seqnum);
>> +
>> + seq->seqnum = (u32) atomic_inc_return(&val);
>> + if (seq->seqnum >= UINT_MAX)
>> + pr_info("Sequence Number overflow %u detected\n",
>> + seq->seqnum);
>> + return seq->seqnum;
>
> As Peter points out, this is doing doing what you think it is doing :(
>
> Why do you not just have seq->seqnum be a real atomic variable? Trying
> to switch to/from one like this does not work as there is no
> "atomic-ness" happening here at all.
>

Yes. This is sloppy on my part. As Peter and Rafael also pointed. I have
to start paying more attention to my inner voice.

thanks,
-- Shuah



\
 
 \ /
  Last update: 2021-02-05 21:08    [W:0.094 / U:0.768 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site