[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20171121075609.1384b92e@gandalf.local.home>
Date: Tue, 21 Nov 2017 07:56:09 -0500
From: Steven Rostedt <rostedt@...dmis.org>
To: Jiri Kosina <jikos@...nel.org>
Cc: Thomas Gleixner <tglx@...utronix.de>,
luca abeni <luca.abeni@...tannapisa.it>,
Peter Zijlstra <peterz@...radead.org>,
Daniel Bristot de Oliveira <bristot@...hat.com>,
Juri Lelli <juri.lelli@....com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Mathieu Poirier <mathieu.poirier@...aro.org>,
Mike Galbraith <efault@....de>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] sched/deadline: Use bools for the state flags
On Tue, 21 Nov 2017 12:43:53 +0100 (CET)
Jiri Kosina <jikos@...nel.org> wrote:
> On Tue, 21 Nov 2017, Thomas Gleixner wrote:
>
> > > Commit
> > >
> > > 799ba82de01e ("sched/deadline: Use C bitfields for the state flags")
> > >
> > > converted state flags into one-bit signed int. Signed one-bit type can be
> > > either 0 or -1, which is going to cause a problem once 1 is assigned to it
> > > and then the value later tested against 1.
> > >
> > > The current code is okay, as all the checks are (non-)zero check, but I
> > > believe that we'd rather be safe than sorry here; remove the fragility by
> > > converting the state flags to bool.
> > >
> > > This also silences annoying sparse complaints about this very issue when
> > > compiling any code that includes sched.h.
> >
> > What's wrong with making these bitfields 'unsigned int' ?
>
> Surely that works as well. I chose bool as that's in line with the actual
> semantics, but I can of course resend with unsigned type if that's
> preferred for one reason or another.
Note, bool is different, as it must take up at least one byte, and up
to 4 bytes on different architectures. A bool variable needs to be able
to be stored without modifying anything else.
Thus, changing:
int a : 1;
int b : 1;
int c : 1;
int d : 1;
to
bool a;
bool b;
bool c;
bool d;
at best increases the size required from 1 byte to 4 bytes, and at
worse, it increases it from one byte to 16 bytes.
-- Steve
Powered by blists - more mailing lists