All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Paoloni, Gabriele" <gabriele.paoloni@intel.com>
To: "i33399_yamaguchi@aisin-aw.co.jp"
	<i33399_yamaguchi@aisin-aw.co.jp>,
	"linux-safety@lists.elisa.tech" <linux-safety@lists.elisa.tech>
Cc: "safety-architecture@lists.elisa.tech"
	<safety-architecture@lists.elisa.tech>
Subject: Re: [ELISA Safety Architecture WG] [linux-safety] [RFC PATCH 2/2] bust_spinlocks: do not decrement oops_in_progress unconditionally
Date: Tue, 13 Oct 2020 13:39:12 +0000	[thread overview]
Message-ID: <MN2PR11MB41588FAE4D4D0E9C4590793F88040@MN2PR11MB4158.namprd11.prod.outlook.com> (raw)
In-Reply-To: <B5A52225FE7FBE4EA743EA87175029980128AA18D9@SMAIL-JP-MBX02.intra.aisin-aw.co.jp>

> -----Original Message-----
> From: safety-architecture@lists.elisa.tech <safety-
> architecture@lists.elisa.tech> On Behalf Of i33399_yamaguchi@aisin-
> aw.co.jp
> Sent: Tuesday, October 13, 2020 3:07 PM
> To: Paoloni, Gabriele <gabriele.paoloni@intel.com>; linux-
> safety@lists.elisa.tech
> Cc: safety-architecture@lists.elisa.tech
> Subject: Re: [ELISA Safety Architecture WG] [linux-safety] [RFC PATCH 2/2]
> bust_spinlocks: do not decrement oops_in_progress unconditionally
> 
> Hi Gab
> 
> I think so, this patch is good.
> If you agree to my opinion, please more improve.
> In a very rare case, the oops_in_progress could be a negative value.  Because
> this decrement/increment is a read-modified statement.  On the other hand,
> shouldn't take exclusions such as spin lock with this function.
> 
> if (!oops_in_progress)
> change to
> if (oops_in_progress <= 0)
> 
> How about?

Mmmmm what you are proposing is right, I was just wondering if it is needed....
Looking in the Kernel source code I am seeing that oops_in_progress is always set to 1 or 0
except in https://elixir.bootlin.com/linux/latest/source/kernel/debug/kdb/kdb_io.c#L578.
Here oops_in_progress is incremented and then decremented right after...
actually I am wondering if in this file we should call bust_spinlocks() instead
of directly incrementing/decremeting the variable.... 

Thanks
Gab

> 
> Best,
> /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
> Doctor of Informatics, Specialist
> Software Fundamental Technology Group
> Application Development Department
> Connected & Sharing Solutions Division
> AISIN AW CO.,LTD.
> YAMAGUCHI Naoto
> E-mail: i33399_YAMAGUCHI@aisin-aw.co.jp
> /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
> -----Original Message-----
> From: safety-architecture@lists.elisa.tech <safety-
> architecture@lists.elisa.tech> On Behalf Of Paoloni, Gabriele
> Sent: Tuesday, October 13, 2020 8:58 PM
> To: Paoloni, Gabriele <gabriele.paoloni@intel.com>; linux-
> safety@lists.elisa.tech
> Cc: safety-architecture@lists.elisa.tech
> Subject: Re: [ELISA Safety Architecture WG] [linux-safety] [RFC PATCH 2/2]
> bust_spinlocks: do not decrement oops_in_progress unconditionally
> 
> +CC safety arch mailing list
> 
> > -----Original Message-----
> > From: linux-safety@lists.elisa.tech <linux-safety@lists.elisa.tech> On
> > Behalf Of Paoloni, Gabriele
> > Sent: Tuesday, October 13, 2020 11:50 AM
> > To: linux-safety@lists.elisa.tech
> > Cc: Paoloni, Gabriele <gabriele.paoloni@intel.com>
> > Subject: [linux-safety] [RFC PATCH 2/2] bust_spinlocks: do not
> > decrement oops_in_progress unconditionally
> >
> > In the current implementation if the input flag is 0 oops_in_progress
> > is unconditionally decremented, thus allowing to become a negative
> > number. Since right now oops_in_progress is a global variable used in
> > the kernel as a conditional flag to check if oops, panic(), BUG() or
> > die() is in progress the current unconditional decrement may lead to
> > unexpected behavior in the Kernel paths conditionally executing over
> > this flag.
> >
> > This patch only decrement oops_in_progress if it is non zero
> >
> > Signed-off-by: Gabriele Paoloni <gabriele.paoloni@intel.com>
> > ---
> >  lib/bust_spinlocks.c | 7 ++++++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/bust_spinlocks.c b/lib/bust_spinlocks.c index
> > 594b270161d9..842633ac9130 100644
> > --- a/lib/bust_spinlocks.c
> > +++ b/lib/bust_spinlocks.c
> > @@ -23,6 +23,9 @@
> >   * @yes: input flag; if zero decreases oops_in_progress,
> >   * otherwise increases it.
> >   *
> > + * Note: if oops_in_progress is already 0 it will not
> > + * be decreased
> > + *
> >   */
> >  void bust_spinlocks(int yes)
> >  {
> > @@ -33,7 +36,9 @@ void bust_spinlocks(int yes)
> >  		unblank_screen();
> >  #endif
> >  		console_unblank();
> > -		if (--oops_in_progress == 0)
> > +		if (oops_in_progress)
> > +			oops_in_progress--;
> > +		if (!oops_in_progress)
> >  			wake_up_klogd();
> >  	}
> >  }
> > --
> > 2.25.1
> >
> > ---------------------------------------------------------------------
> > INTEL CORPORATION ITALIA S.p.A. con unico socio
> > Sede: Milanofiori Palazzo E 4
> > CAP 20094 Assago (MI)
> > Capitale Sociale Euro 104.000,00 interamente versato Partita I.V.A. e
> > Codice Fiscale  04236760155 Repertorio Economico Amministrativo n.
> > 997124 Registro delle Imprese di Milano nr. 183983/5281/33 Soggetta ad
> > attivita' di direzione e coordinamento di INTEL CORPORATION, USA
> >
> > This e-mail and any attachments may contain confidential material for
> > the sole use of the intended recipient(s). Any review or distribution
> > by others is strictly prohibited. If you are not the intended
> > recipient, please contact the sender and delete all copies.
> >
> >
> >
> >
> >
> 
> ---------------------------------------------------------------------
> INTEL CORPORATION ITALIA S.p.A. con unico socio
> Sede: Milanofiori Palazzo E 4
> CAP 20094 Assago (MI)
> Capitale Sociale Euro 104.000,00 interamente versato Partita I.V.A. e Codice
> Fiscale  04236760155 Repertorio Economico Amministrativo n. 997124 Registro
> delle Imprese di Milano nr. 183983/5281/33 Soggetta ad attivita' di direzione e
> coordinamento di INTEL CORPORATION, USA
> 
> This e-mail and any attachments may contain confidential material for the
> sole use of the intended recipient(s). Any review or distribution by others is
> strictly prohibited. If you are not the intended recipient, please contact the
> sender and delete all copies.
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 

---------------------------------------------------------------------
INTEL CORPORATION ITALIA S.p.A. con unico socio
Sede: Milanofiori Palazzo E 4 
CAP 20094 Assago (MI)
Capitale Sociale Euro 104.000,00 interamente versato
Partita I.V.A. e Codice Fiscale  04236760155
Repertorio Economico Amministrativo n. 997124 
Registro delle Imprese di Milano nr. 183983/5281/33
Soggetta ad attivita' di direzione e coordinamento di 
INTEL CORPORATION, USA

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

  reply	other threads:[~2020-10-13 13:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-13  9:49 [RFC PATCH 0/2] improve bust_spinlocks dependability Paoloni, Gabriele
2020-10-13  9:49 ` [RFC PATCH 1/2] bust_spinlocks: add kernel-doc format doc Paoloni, Gabriele
2020-10-14  6:02   ` [linux-safety] " Lukas Bulwahn
2020-10-14 12:20     ` Paoloni, Gabriele
2020-10-13  9:49 ` [RFC PATCH 2/2] bust_spinlocks: do not decrement oops_in_progress unconditionally Paoloni, Gabriele
2020-10-14  5:53   ` [linux-safety] " Lukas Bulwahn
2020-10-14 12:05     ` Paoloni, Gabriele
2020-10-14 15:29       ` Sudip Mukherjee
2020-10-15  6:44       ` Lukas Bulwahn
     [not found] ` <163D8465C352C96E.25724@lists.elisa.tech>
2020-10-13 11:57   ` [linux-safety] [RFC PATCH 1/2] bust_spinlocks: add kernel-doc format doc Paoloni, Gabriele
     [not found] ` <163D8465D1668B95.25724@lists.elisa.tech>
2020-10-13 11:58   ` [linux-safety] [RFC PATCH 2/2] bust_spinlocks: do not decrement oops_in_progress unconditionally Paoloni, Gabriele
2020-10-13 13:07     ` [ELISA Safety Architecture WG] " I33399_YAMAGUCHI
2020-10-13 13:39       ` Paoloni, Gabriele [this message]
2020-10-14  6:04 ` [linux-safety] [RFC PATCH 0/2] improve bust_spinlocks dependability Lukas Bulwahn

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=MN2PR11MB41588FAE4D4D0E9C4590793F88040@MN2PR11MB4158.namprd11.prod.outlook.com \
    --to=gabriele.paoloni@intel.com \
    --cc=i33399_yamaguchi@aisin-aw.co.jp \
    --cc=linux-safety@lists.elisa.tech \
    --cc=safety-architecture@lists.elisa.tech \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.