From: Steven Rostedt <rostedt@goodmis.org>
To: Jiri Kosina <jikos@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
luca abeni <luca.abeni@santannapisa.it>,
Peter Zijlstra <peterz@infradead.org>,
Daniel Bristot de Oliveira <bristot@redhat.com>,
Juri Lelli <juri.lelli@arm.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Mathieu Poirier <mathieu.poirier@linaro.org>,
Mike Galbraith <efault@gmx.de>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched/deadline: Use bools for the state flags
Date: Tue, 21 Nov 2017 07:56:09 -0500 [thread overview]
Message-ID: <20171121075609.1384b92e@gandalf.local.home> (raw)
In-Reply-To: <nycvar.YFH.7.76.1711211234090.11505@cbobk.fhfr.pm>
On Tue, 21 Nov 2017 12:43:53 +0100 (CET)
Jiri Kosina <jikos@kernel.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
next prev parent reply other threads:[~2017-11-21 12:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-21 10:44 Jiri Kosina
2017-11-21 10:52 ` Thomas Gleixner
2017-11-21 11:43 ` Jiri Kosina
2017-11-21 12:00 ` [PATCH v2] sched/deadline: Use unsigned type " Jiri Kosina
2017-11-21 16:22 ` Ingo Molnar
2017-11-21 12:56 ` Steven Rostedt [this message]
2017-11-21 15:53 ` [PATCH] sched/deadline: Use bools " Linus Torvalds
2017-11-21 10:56 ` Luca Abeni
2017-11-21 13:06 ` Peter Zijlstra
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=20171121075609.1384b92e@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=bristot@redhat.com \
--cc=efault@gmx.de \
--cc=jikos@kernel.org \
--cc=juri.lelli@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luca.abeni@santannapisa.it \
--cc=mathieu.poirier@linaro.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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
all inboxes | Powered by JetHome®