public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Andy Lutomirski <luto@amacapital.net>, Ingo Molnar <mingo@kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Andy Lutomirski <luto@kernel.org>,
	Kees Cook <keescook@chromium.org>
Subject: Re: [PATCH] thread_info: use unsigned long for flags
Date: Sat, 24 Sep 2016 00:48:34 +0100	[thread overview]
Message-ID: <20160923234833.GA26666@remoulade> (raw)
In-Reply-To: <CALCETrVL6wmrOuLg1RYgYroMT7YrL3u3-8Yu4DgZs-soe9xE=w@mail.gmail.com>

[Adding Ingo, so this doesn't get lost -- please see the end of the mail]

On Fri, Sep 23, 2016 at 11:08:46AM -0700, Andy Lutomirski wrote:
> On Fri, Sep 23, 2016 at 10:24 AM, Mark Rutland <mark.rutland@arm.com> wrote:
> > The generic THREAD_INFO_IN_TASK definition of thread_info::flags is a
> > u32, matching x86 prior to the introduction of THREAD_INFO_IN_TASK.
> >
> > However, common helpers like test_ti_thread_flag() implicitly assume
> > that thread_info::flags has at least the size and alignment of unsigned
> > long, and relying on padding and alignment provided by other elements of
> > task_struct is somewhat fragile. Additionally, some architectures use
> > more that 32 bits for thread_info::flags, and others may need to in
> > future.
> >
> > With THREAD_INFO_IN_TASK, task struct follows thread_info with a long
> > field, and thus we no longer save any space as we did back in commit
> > affa219b60a11b32 ("x86: change thread_info's flag field back to 32
> > bits").
> >
> > Given all this, it makes more sense for the generic thread_info::flags
> > to be an unsigned long. Make it so.
> 
> I have only one problem with this, and it's a general objection that's
> mostly off topic: why the [expletive] do the arch-independent bitfield
> helpers think in units of variable size?  It's *absurd*, especially on
> big-endian architectures.
> 
> Now that that's out of my system, I think this patch is fine.
> Big-endian arches that opt in will have to deal with it somehow, but I
> don't see why making it 'unsigned long' is worse than anything else.
> x86 is fine with this change.

FWIW, given <linux/thread_info.h> contains/uses the helpers mentioned above, BE
arches *must* use unsigned long (or something of the same size) today, or they
wouldn't work. In v4.8-rc7 that is the case:

$ ls -l arch | wc -l
33

# Note the above includes Kconfig, so there are 32 to consider

$ git grep -W 'struct thread_info {' -- arch/*/include | \
  grep flags | grep 'unsigned long\s\+flags' | wc -l       
29

$ git grep -W 'struct thread_info {' -- arch/*/include | \
  grep flags | grep 'int\s\+flags'
arch/alpha/include/asm/thread_info.h-   unsigned int            flags;          /* low level flags */

$ git grep -W 'struct thread_info {' -- arch/*/include | \
  grep flags | grep 'u32\s\+flags' 
arch/ia64/include/asm/thread_info.h-    __u32 flags;                    /* thread_info flags (see TIF_*) */
arch/x86/include/asm/thread_info.h-     __u32                   flags;          /* low level flags */

> Acked-by: Andy Lutomirski <luto@kernel.org>
> 
> Ingo, can you apply this for 4.9 so that we can make this change
> before other arches might start depending on the field being u32?
> 
> --Andy

Thanks,
Mark.

  reply	other threads:[~2016-09-23 23:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-23 17:24 [PATCH] thread_info: use unsigned long for flags Mark Rutland
2016-09-23 18:08 ` Andy Lutomirski
2016-09-23 23:48   ` Mark Rutland [this message]
2016-09-24 16:28 ` [tip:x86/asm] thread_info: Use " tip-bot for Mark Rutland

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=20160923234833.GA26666@remoulade \
    --to=mark.rutland@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.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