public inbox for linux-serial@vger.kernel.org
 help / color / mirror / Atom feed
From: Deepak R Varma <drv@mailo.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jirislaby@kernel.org>,
	"Maciej W. Rozycki" <macro@orcam.me.uk>,
	linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
	Saurabh Singh Sengar <ssengar@microsoft.com>,
	Praveen Kumar <kumarpraveen@linux.microsoft.com>,
	Deepak R Varma <drv@mailo.com>
Subject: Re: [PATCH v4 1/2] tty: serial: dz: convert atomic_* to refcount_* APIs for map_guard
Date: Wed, 4 Jan 2023 14:29:31 +0530	[thread overview]
Message-ID: <Y7U/8zMVwTP7NKXI@qemulion> (raw)
In-Reply-To: <Y7U4ncG4Gkd5uRsb@kroah.com>

On Wed, Jan 04, 2023 at 09:28:13AM +0100, Greg Kroah-Hartman wrote:
> On Tue, Jan 03, 2023 at 03:35:15PM +0530, Deepak R Varma wrote:
> > > > -			printk(KERN_ERR
> > > > -			       "dz: Unable to reserve MMIO resource\n");
> > > > +	refcount_inc(&mux->map_guard);
> > > > +	if (refcount_read(&mux->map_guard) == 1) {
> > >
> > > This is now racy, right?
> >
> > Hello Jiri,
> > Thank you for the feedback. You are correct. I have split a single instruction
> > in two (or more?) instructions potentially resulting in race conditions. I
> > looked through the refcount_* APIs but did not find a direct match.
> >
> >
> > Can you please comment if the the following variation will avoid race condition?
> >
> > 	if (!refcount_add_not_zero(1, &mux->map_guard)) {
> > 		refcount_inc(&mux->map_guard);
> > 		...
> > 	}
>
> What do you think?  The onus is on you to prove the conversion is
> correct, otherwise, why do the conversion at all?

Hello Greg,
Okay. Sounds good. I think the revised approach should be safer. I will work on
finding a means to prove that.

>
> Actually, why do this at all, what is the goal here?  And how was this
> tested?

The objective here is to migrate to specific and improved APIs that are already
proved to be better for different reasons as mentioned in the patch log
messages. This is as per the Linux Kernel documentation.

In terms of testing, First, I did a compile and build test of the changes.
I also wrote separate small dummy modules and tested the API transformation.
However, these modules were standalone and limited in complexity and intensity.
I will try to make these more intense, multithreaded and run the test again.

Thank you as always :)
./drv

>
> thanks,
>
> greg k-h



  reply	other threads:[~2023-01-04  9:00 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-24 16:32 [PATCH v3 0/2] tty: serial: dz: convert atomic_* to refcount_* Deepak R Varma
2022-12-24 16:33 ` [PATCH v3 1/2] tty: serial: dz: convert atomic_* to refcount_* APIs for map_guard Deepak R Varma
2022-12-26  6:21   ` [PATCH v4 " Deepak R Varma
2023-01-03  8:59   ` Jiri Slaby
2023-01-03 10:05     ` Deepak R Varma
2023-01-04  8:28       ` Greg Kroah-Hartman
2023-01-04  8:59         ` Deepak R Varma [this message]
2023-01-10  6:19     ` Deepak R Varma
2023-01-10  7:27       ` Reshetova, Elena
2023-01-10  7:47         ` Deepak R Varma
2023-01-10  7:57           ` Greg Kroah-Hartman
2022-12-24 16:34 ` [PATCH 2/2] tty: serial: dz: convert atomic_* to refcount_* APIs for irq_guard Deepak R Varma
2022-12-26  6:21   ` [PATCH v4 " Deepak R Varma
2023-01-03  9:00   ` Jiri Slaby
2023-01-03 10:09     ` Deepak R Varma
2023-01-04  8:28       ` Greg Kroah-Hartman
2023-01-04  9:00         ` Deepak R Varma
2022-12-26  6:20 ` [PATCH v4 0/2] tty: serial: dz: convert atomic_* to refcount_* Deepak R Varma

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=Y7U/8zMVwTP7NKXI@qemulion \
    --to=drv@mailo.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=kumarpraveen@linux.microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=macro@orcam.me.uk \
    --cc=ssengar@microsoft.com \
    /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