2016-10-26 17:43:47

by Mark Rutland

[permalink] [raw]
Subject: [PATCHv2 0/2] THREAD_INFO_IN_TASK prep work for arm64+s390

Hi all,

[resending for linux-arch, apologies for spam]

Heiko and I have been working on THREAD_INFO_IN_TASK for s390 and arm64
respectively, and we're both targetting v4.10.

These are the common core changes which we both require. I've put together a
branch [1,2] based on v4.9-rc2. I intend to tag this at some point next week so
that Heiko and I have a stable base.

Until then, any and all acks appreciated. ;)

Thanks,
Mark.

Since v1:
* Rebase to v4.9-rc2
* Drop Heiko's patch that was merged before -rc2
* Add Heiko's Acked-by
* Add Andy's Reviewed-by

[1] git://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git core/ti-stack-split
[2] https://git.kernel.org/cgit/linux/kernel/git/mark/linux.git/log/?h=core/ti-stack-split

Mark Rutland (2):
thread_info: factor out restart_block
thread_info: include <current.h> for THREAD_INFO_IN_TASK

include/linux/restart_block.h | 51 +++++++++++++++++++++++++++++++++++++++++++
include/linux/thread_info.h | 42 ++---------------------------------
2 files changed, 53 insertions(+), 40 deletions(-)
create mode 100644 include/linux/restart_block.h

--
1.9.1


2016-10-26 17:43:52

by Mark Rutland

[permalink] [raw]
Subject: [PATCHv2 2/2] thread_info: include <current.h> for THREAD_INFO_IN_TASK

When CONFIG_THREAD_INFO_IN_TASK is selected, the current_thread_info()
macro relies on current having been defined prior to its use. However,
not all users of current_thread_info() include <asm/current.h>, and thus
current is not guaranteed to be defined.

When CONFIG_THREAD_INFO_IN_TASK is not selected, it's possible that
get_current() / current are based upon current_thread_info(), and
<asm/current.h> includes <asm/thread_info.h>. Thus always including
<asm/current.h> would result in circular dependences on some platforms.

To ensure both cases work, this patch includes <asm/current.h>, but only
when CONFIG_THREAD_INFO_IN_TASK is selected.

Signed-off-by: Mark Rutland <[email protected]>
Acked-by: Heiko Carstens <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
include/linux/thread_info.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
index c75c6ab..ef1f4b0 100644
--- a/include/linux/thread_info.h
+++ b/include/linux/thread_info.h
@@ -12,6 +12,7 @@
#include <linux/restart_block.h>

#ifdef CONFIG_THREAD_INFO_IN_TASK
+#include <asm/current.h>
#define current_thread_info() ((struct thread_info *)current)
#endif

--
1.9.1

2016-10-26 17:43:55

by Mark Rutland

[permalink] [raw]
Subject: [PATCHv2 1/2] thread_info: factor out restart_block

Since commit f56141e3e2d9aabf ("all arches, signal: move restart_block
to struct task_struct"), thread_info and restart_block have been
logically distinct, yet struct restart_block is still defined in
<linux/thread_info.h>.

At least one architecture (erroneously) uses restart_block as part of
its thread_info, and thus the definition of restart_block must come
before the include of <asm/thread_info>. Subsequent patches in this
series need to shuffle the order of includes and definitions in
<linux/thread_info.h>, and will make this ordering fragile.

This patch moves the definition of restart_block out to its own header.
This serves as generic cleanup, logically separating thread_info and
restart_block, and also makes it easier to avoid fragility.

Signed-off-by: Mark Rutland <[email protected]>
Reviewed-by: Andy Lutomirski <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
include/linux/restart_block.h | 51 +++++++++++++++++++++++++++++++++++++++++++
include/linux/thread_info.h | 41 +---------------------------------
2 files changed, 52 insertions(+), 40 deletions(-)
create mode 100644 include/linux/restart_block.h

diff --git a/include/linux/restart_block.h b/include/linux/restart_block.h
new file mode 100644
index 0000000..0d905d8
--- /dev/null
+++ b/include/linux/restart_block.h
@@ -0,0 +1,51 @@
+/*
+ * Common syscall restarting data
+ */
+#ifndef __LINUX_RESTART_BLOCK_H
+#define __LINUX_RESTART_BLOCK_H
+
+#include <linux/compiler.h>
+#include <linux/types.h>
+
+struct timespec;
+struct compat_timespec;
+struct pollfd;
+
+/*
+ * System call restart block.
+ */
+struct restart_block {
+ long (*fn)(struct restart_block *);
+ union {
+ /* For futex_wait and futex_wait_requeue_pi */
+ struct {
+ u32 __user *uaddr;
+ u32 val;
+ u32 flags;
+ u32 bitset;
+ u64 time;
+ u32 __user *uaddr2;
+ } futex;
+ /* For nanosleep */
+ struct {
+ clockid_t clockid;
+ struct timespec __user *rmtp;
+#ifdef CONFIG_COMPAT
+ struct compat_timespec __user *compat_rmtp;
+#endif
+ u64 expires;
+ } nanosleep;
+ /* For poll */
+ struct {
+ struct pollfd __user *ufds;
+ int nfds;
+ int has_timeout;
+ unsigned long tv_sec;
+ unsigned long tv_nsec;
+ } poll;
+ };
+};
+
+extern long do_no_restart_syscall(struct restart_block *parm);
+
+#endif /* __LINUX_RESTART_BLOCK_H */
diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
index 2873baf..c75c6ab 100644
--- a/include/linux/thread_info.h
+++ b/include/linux/thread_info.h
@@ -9,51 +9,12 @@

#include <linux/types.h>
#include <linux/bug.h>
-
-struct timespec;
-struct compat_timespec;
+#include <linux/restart_block.h>

#ifdef CONFIG_THREAD_INFO_IN_TASK
#define current_thread_info() ((struct thread_info *)current)
#endif

-/*
- * System call restart block.
- */
-struct restart_block {
- long (*fn)(struct restart_block *);
- union {
- /* For futex_wait and futex_wait_requeue_pi */
- struct {
- u32 __user *uaddr;
- u32 val;
- u32 flags;
- u32 bitset;
- u64 time;
- u32 __user *uaddr2;
- } futex;
- /* For nanosleep */
- struct {
- clockid_t clockid;
- struct timespec __user *rmtp;
-#ifdef CONFIG_COMPAT
- struct compat_timespec __user *compat_rmtp;
-#endif
- u64 expires;
- } nanosleep;
- /* For poll */
- struct {
- struct pollfd __user *ufds;
- int nfds;
- int has_timeout;
- unsigned long tv_sec;
- unsigned long tv_nsec;
- } poll;
- };
-};
-
-extern long do_no_restart_syscall(struct restart_block *parm);
-
#include <linux/bitops.h>
#include <asm/thread_info.h>

--
1.9.1

2016-11-02 15:56:57

by Mark Rutland

[permalink] [raw]
Subject: Re: [PATCHv2 0/2] THREAD_INFO_IN_TASK prep work for arm64+s390

On Wed, Oct 26, 2016 at 06:43:05PM +0100, Mark Rutland wrote:
> Heiko and I have been working on THREAD_INFO_IN_TASK for s390 and arm64
> respectively, and we're both targetting v4.10.
>
> These are the common core changes which we both require. I've put together a
> branch [1,2] based on v4.9-rc2. I intend to tag this at some point next week so
> that Heiko and I have a stable base.

As a heads-up, I've collated the tags I've received in the last few days, along
with the comment Andy requested in the v1 thread, and tagged this as
core-ti-stack-split [1].

Thanks,
Mark.

[1] git://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git core-ti-stack-split

2016-11-10 18:13:47

by Mark Rutland

[permalink] [raw]
Subject: Re: [PATCHv2 0/2] THREAD_INFO_IN_TASK prep work for arm64+s390

Hi Heiko,

On Wed, Nov 02, 2016 at 03:56:26PM +0000, Mark Rutland wrote:
> On Wed, Oct 26, 2016 at 06:43:05PM +0100, Mark Rutland wrote:
> > Heiko and I have been working on THREAD_INFO_IN_TASK for s390 and arm64
> > respectively, and we're both targetting v4.10.
> >
> > These are the common core changes which we both require. I've put together a
> > branch [1,2] based on v4.9-rc2. I intend to tag this at some point next week so
> > that Heiko and I have a stable base.
>
> As a heads-up, I've collated the tags I've received in the last few days, along
> with the comment Andy requested in the v1 thread, and tagged this as
> core-ti-stack-split [1].
>
> Thanks,
> Mark.
>
> [1] git://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git core-ti-stack-split

I believe that Catalin's hoping to take my arm64 patches for v4.10,
using the above tag as a base.

What's the plan for s390? Are you happy to do the same?

Thanks,
Mark.

2016-11-11 09:16:38

by Heiko Carstens

[permalink] [raw]
Subject: Re: [PATCHv2 0/2] THREAD_INFO_IN_TASK prep work for arm64+s390

Hi Mark,

> On Wed, Nov 02, 2016 at 03:56:26PM +0000, Mark Rutland wrote:
> > On Wed, Oct 26, 2016 at 06:43:05PM +0100, Mark Rutland wrote:
> > > Heiko and I have been working on THREAD_INFO_IN_TASK for s390 and arm64
> > > respectively, and we're both targetting v4.10.
> > >
> > > These are the common core changes which we both require. I've put together a
> > > branch [1,2] based on v4.9-rc2. I intend to tag this at some point next week so
> > > that Heiko and I have a stable base.
> >
> > As a heads-up, I've collated the tags I've received in the last few days, along
> > with the comment Andy requested in the v1 thread, and tagged this as
> > core-ti-stack-split [1].
> >
> > Thanks,
> > Mark.
> >
> > [1] git://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git core-ti-stack-split
>
> I believe that Catalin's hoping to take my arm64 patches for v4.10,
> using the above tag as a base.
>
> What's the plan for s390? Are you happy to do the same?

We intend to merge the s390 variant also for v4.10. Our approach has
changed however: we came to the conclusion that having a per-cpu preempt
count will generate better code on s390; so Martin implemented that.

And while being at it he also moved the rest of the s390 specific stuff out
of our struct thread_info. The corresponding patches will be pushed to

git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git features

branch soon.

In result we will have a struct thread_info that only contains the flags
field like x86 does.
So we don't depend an any other patches anymore...

2016-11-11 15:42:47

by Martin Schwidefsky

[permalink] [raw]
Subject: Re: [PATCHv2 0/2] THREAD_INFO_IN_TASK prep work for arm64+s390

On Fri, 11 Nov 2016 10:16:22 +0100
Heiko Carstens <[email protected]> wrote:

> Hi Mark,
>
> > On Wed, Nov 02, 2016 at 03:56:26PM +0000, Mark Rutland wrote:
> > > On Wed, Oct 26, 2016 at 06:43:05PM +0100, Mark Rutland wrote:
> > > > Heiko and I have been working on THREAD_INFO_IN_TASK for s390 and arm64
> > > > respectively, and we're both targetting v4.10.
> > > >
> > > > These are the common core changes which we both require. I've put together a
> > > > branch [1,2] based on v4.9-rc2. I intend to tag this at some point next week so
> > > > that Heiko and I have a stable base.
> > >
> > > As a heads-up, I've collated the tags I've received in the last few days, along
> > > with the comment Andy requested in the v1 thread, and tagged this as
> > > core-ti-stack-split [1].
> > >
> > > Thanks,
> > > Mark.
> > >
> > > [1] git://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git core-ti-stack-split
> >
> > I believe that Catalin's hoping to take my arm64 patches for v4.10,
> > using the above tag as a base.
> >
> > What's the plan for s390? Are you happy to do the same?
>
> We intend to merge the s390 variant also for v4.10. Our approach has
> changed however: we came to the conclusion that having a per-cpu preempt
> count will generate better code on s390; so Martin implemented that.
>
> And while being at it he also moved the rest of the s390 specific stuff out
> of our struct thread_info. The corresponding patches will be pushed to
>
> git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git features
>
> branch soon.
>
> In result we will have a struct thread_info that only contains the flags
> field like x86 does.
> So we don't depend an any other patches anymore...

Just pushed our collected works to the features branch, in case you are
interested.

--
blue skies,
Martin.

"Reality continues to ruin my life." - Calvin.

2016-11-11 16:24:23

by Mark Rutland

[permalink] [raw]
Subject: Re: [PATCHv2 0/2] THREAD_INFO_IN_TASK prep work for arm64+s390

On Fri, Nov 11, 2016 at 04:42:37PM +0100, Martin Schwidefsky wrote:
> On Fri, 11 Nov 2016 10:16:22 +0100
> Heiko Carstens <[email protected]> wrote:
> > > On Wed, Nov 02, 2016 at 03:56:26PM +0000, Mark Rutland wrote:
> > > > On Wed, Oct 26, 2016 at 06:43:05PM +0100, Mark Rutland wrote:

> > > > [1] git://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git core-ti-stack-split
> > >
> > > I believe that Catalin's hoping to take my arm64 patches for v4.10,
> > > using the above tag as a base.
> > >
> > > What's the plan for s390? Are you happy to do the same?
> >
> > We intend to merge the s390 variant also for v4.10. Our approach has
> > changed however: we came to the conclusion that having a per-cpu preempt
> > count will generate better code on s390; so Martin implemented that.
> >
> > And while being at it he also moved the rest of the s390 specific stuff out
> > of our struct thread_info. The corresponding patches will be pushed to
> >
> > git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git features

> Just pushed our collected works to the features branch, in case you are
> interested.

Thanks for the heads-up!

It doesn't look like we can do similar for arm64 (we don't have anything
akin to the lowcore stuff), but it certainly seems nicer for s390.

Thanks,
Mark.