linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Luck, Tony" <tony.luck@intel.com>
To: Shuah Khan <skhan@linuxfoundation.org>
Cc: Greg KH <gregkh@linuxfoundation.org>,
	corbet@lwn.net, peterz@infradead.org, keescook@chromium.org,
	rafael@kernel.org, lenb@kernel.org, james.morse@arm.com,
	bp@alien8.de, devel@driverdev.osuosl.org,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-acpi@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v3 1/7] seqnum_ops: Introduce Sequence Number Ops
Date: Fri, 5 Feb 2021 14:16:21 -0800	[thread overview]
Message-ID: <20210205221621.GA74059@agluck-desk2.amr.corp.intel.com> (raw)
In-Reply-To: <2fe15f90-2e33-d018-0d5d-cabe3846ed98@linuxfoundation.org>

On Fri, Feb 05, 2021 at 01:03:18PM -0700, Shuah Khan wrote:
> 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.

What's the end goal with this sequence number type?

Apart from the functional issues with this code already pointed
out, it doesn't seem overly useful to just print the *value* of
the sequence number when it hits the max value.  It might be
more helpful if each instance had a seq->name field that is
used here to tell the user *which* user of sequence numbers
had seen the wrap arounnd.

But that just begs the question of what should users of sequence
numbers do when wrap around occurs? Any user that can run through
sequence numbers at greater than 10 Hz is going to cause a problem
for systems that stay running for years.

Maybe you should force users to code for wraparound by initializing
to something like 0xffffff00 so that they all get a wraparound event
quickly, rather than slowly, (same as was done with jiffies)?

  reply	other threads:[~2021-02-06  2:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-03 18:11 [PATCH v3 0/7] Introduce Sequence Number Ops Shuah Khan
2021-02-03 18:11 ` [PATCH v3 1/7] seqnum_ops: " Shuah Khan
2021-02-04  9:20   ` Peter Zijlstra
2021-02-05  9:58   ` Greg KH
2021-02-05 20:03     ` Shuah Khan
2021-02-05 22:16       ` Luck, Tony [this message]
2021-02-08  3:55   ` Randy Dunlap
2021-02-03 18:11 ` [PATCH v3 2/7] selftests: lib:test_seqnum_ops: add new test for seqnum_ops Shuah Khan
2021-02-03 18:11 ` [PATCH v3 3/7] drivers/acpi: convert seqno to use seqnum_ops Shuah Khan
2021-02-04 14:01   ` Rafael J. Wysocki
2021-02-03 18:12 ` [PATCH v3 4/7] drivers/acpi/apei: convert seqno to seqnum_ops Shuah Khan
2021-02-03 18:12 ` [PATCH v3 5/7] drivers/staging/rtl8723bs: convert event_seq to use seqnum_ops Shuah Khan
2021-02-03 18:12 ` [PATCH v3 6/7] drivers/staging/rtl8188eu: " Shuah Khan
2021-02-03 18:12 ` [PATCH v3 7/7] kobject: convert uevent_seqnum to seqnum_ops Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210205221621.GA74059@agluck-desk2.amr.corp.intel.com \
    --to=tony.luck@intel.com \
    --cc=bp@alien8.de \
    --cc=corbet@lwn.net \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=james.morse@arm.com \
    --cc=keescook@chromium.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rafael@kernel.org \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).