All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: dhowells@redhat.com, linux-arch@vger.kernel.org, x86@kernel.org,
	linux-ia64@vger.kernel.org, torvalds@linux-foundation.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/5] Expand the INIT_SIGNALS and INIT_SIGHAND macros and remove
Date: Tue, 02 Jan 2018 14:33:50 +0000	[thread overview]
Message-ID: <19929.1514903630@warthog.procyon.org.uk> (raw)
In-Reply-To: <alpine.DEB.2.20.1712281559410.1899@nanos>

Thomas Gleixner <tglx@linutronix.de> wrote:

> >  #define INIT_CPU_TIMERS(s)						\
> ...
> That macro is only used in init_task.c Why not moving it there and get rid
> of the whole macro maze in the header file?

The reason I didn't get rid of it is that it's got more than one expansion
point.  Same for INIT_PREV_CPUTIME and INIT_PID_LINK.

How about the attached patch?  Or do you think it's going a bit too far?

Possibly I could just move some of the #defines from the .h file to the .c
file, but otherwise leave them unexpanded.

David
---
commit ce4d0010bfc3b83f88322afa3cd9013b9c341c4d
Author: David Howells <dhowells@redhat.com>
Date:   Tue Jan 2 14:20:17 2018 +0000

    Expand some multi-use INIT_ macros and remove
    
    Expand INIT_CPU_TIMERS, INIT_PREV_CPUTIME and INIT_PID_LINK in place and
    remove the definitions.
    
    I'm not entirely sure we want to do this since each of these macros has
    multiple points of expansion - and not necessarily in the same structure in
    each case.
    
    Suggested-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: David Howells <dhowells@redhat.com>

diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index a454b8aeb938..f4d002b329cc 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -27,34 +27,6 @@ extern struct nsproxy init_nsproxy;
 extern struct group_info init_groups;
 extern struct cred init_cred;
 
-#ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
-#define INIT_PREV_CPUTIME(x)	.prev_cputime = {			\
-	.lock = __RAW_SPIN_LOCK_UNLOCKED(x.prev_cputime.lock),		\
-},
-#else
-#define INIT_PREV_CPUTIME(x)
-#endif
-
-#ifdef CONFIG_POSIX_TIMERS
-#define INIT_CPU_TIMERS(s)						\
-	.cpu_timers = {							\
-		LIST_HEAD_INIT(s.cpu_timers[0]),			\
-		LIST_HEAD_INIT(s.cpu_timers[1]),			\
-		LIST_HEAD_INIT(s.cpu_timers[2]),			\
-	},
-#else
-#define INIT_CPU_TIMERS(s)
-#endif
-
-#define INIT_PID_LINK(type) 					\
-{								\
-	.node = {						\
-		.next = NULL,					\
-		.pprev = NULL,					\
-	},							\
-	.pid = &init_struct_pid,				\
-}
-
 #define INIT_TASK_COMM "swapper"
 
 /* Attach to the init_task data structure for proper alignment */
diff --git a/init/init_task.c b/init/init_task.c
index 3ac6e754cf64..136d9896acdb 100644
--- a/init/init_task.c
+++ b/init/init_task.c
@@ -30,9 +30,15 @@ static struct signal_struct init_signals = {
 		.running	= false,
 		.checking_timer = false,
 	},
+	.cpu_timers = {
+		LIST_HEAD_INIT(init_signals.cpu_timers[0]),
+		LIST_HEAD_INIT(init_signals.cpu_timers[1]),
+		LIST_HEAD_INIT(init_signals.cpu_timers[2]),
+	},
+#endif
+#ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
+	.prev_cputime.lock = __RAW_SPIN_LOCK_UNLOCKED(init_signals.prev_cputime.lock),
 #endif
-	INIT_CPU_TIMERS(init_signals)
-	INIT_PREV_CPUTIME(init_signals)
 };
 
 static struct sighand_struct init_sighand = {
@@ -107,13 +113,19 @@ struct task_struct init_task
 	.blocked	= {{0}},
 	.alloc_lock	= __SPIN_LOCK_UNLOCKED(init_task.alloc_lock),
 	.journal_info	= NULL,
-	INIT_CPU_TIMERS(init_task)
+#ifdef CONFIG_POSIX_TIMERS
+	.cpu_timers = {
+		LIST_HEAD_INIT(init_task.cpu_timers[0]),
+		LIST_HEAD_INIT(init_task.cpu_timers[1]),
+		LIST_HEAD_INIT(init_task.cpu_timers[2]),
+	},
+#endif
 	.pi_lock	= __RAW_SPIN_LOCK_UNLOCKED(init_task.pi_lock),
 	.timer_slack_ns = 50000, /* 50 usec default slack */
 	.pids = {
-		[PIDTYPE_PID]  = INIT_PID_LINK(PIDTYPE_PID),
-		[PIDTYPE_PGID] = INIT_PID_LINK(PIDTYPE_PGID),
-		[PIDTYPE_SID]  = INIT_PID_LINK(PIDTYPE_SID),
+		[PIDTYPE_PID ].pid = &init_struct_pid,
+		[PIDTYPE_PGID].pid = &init_struct_pid,
+		[PIDTYPE_SID ].pid = &init_struct_pid,
 	},
 	.thread_group	= LIST_HEAD_INIT(init_task.thread_group),
 	.thread_node	= LIST_HEAD_INIT(init_signals.thread_head),
@@ -143,7 +155,9 @@ struct task_struct init_task
 	.pi_waiters	= RB_ROOT_CACHED,
 	.pi_top_task	= NULL,
 #endif
-	INIT_PREV_CPUTIME(init_task)
+#ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
+	.prev_cputime.lock = __RAW_SPIN_LOCK_UNLOCKED(init_task.prev_cputime.lock),
+#endif
 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
 	.vtime.seqcount	= SEQCNT_ZERO(init_task.vtime_seqcount),
 	.vtime.starttime = 0,

  reply	other threads:[~2018-01-02 14:33 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-08 15:51 [PATCH 0/5] Consolidate init_task handling and expand macros David Howells
2017-12-08 15:51 ` [PATCH 1/5] Construct init thread stack in the linker script rather than by union David Howells
2017-12-08 15:51   ` David Howells
2017-12-08 15:54   ` Does this break IA64 Linux? David Howells
2017-12-08 18:30     ` Luck, Tony
2017-12-08 18:30       ` Luck, Tony
2017-12-08 19:04       ` David Howells
2017-12-08 19:04         ` David Howells
2017-12-08 22:14         ` Luck, Tony
2017-12-08 22:14           ` Luck, Tony
2017-12-08 22:24           ` David Howells
2017-12-08 22:33             ` Luck, Tony
2017-12-08 22:33               ` Luck, Tony
2017-12-08 15:51 ` [PATCH 2/5] Expand INIT_TASK() in init/init_task.c and remove David Howells
2017-12-08 15:51 ` [PATCH 3/5] Expand various INIT_* macros " David Howells
2017-12-08 15:51 ` [PATCH 4/5] Expand the INIT_SIGNALS and INIT_SIGHAND " David Howells
2017-12-28 15:04   ` Thomas Gleixner
2017-12-28 15:04     ` Thomas Gleixner
2018-01-02 14:33     ` David Howells [this message]
2018-01-17 11:14       ` Thomas Gleixner
2018-01-17 11:14         ` Thomas Gleixner
2017-12-08 15:51 ` [PATCH 5/5] Expand INIT_STRUCT_PID " David Howells
2017-12-08 15:56 ` Adding init_task consolidation patches to linux-next David Howells
2017-12-10 20:08   ` Stephen Rothwell
2017-12-10 20:08     ` Stephen Rothwell
2017-12-14 18:21     ` David Howells
2017-12-14 18:32       ` Palmer Dabbelt
2017-12-14 18:32         ` Palmer Dabbelt
2017-12-14 18:32         ` Palmer Dabbelt
2017-12-15  8:36         ` David Howells
2017-12-15 18:52           ` Palmer Dabbelt
2017-12-15 18:52             ` Palmer Dabbelt
2017-12-15 18:52             ` Palmer Dabbelt
2017-12-15  2:49   ` Stephen Rothwell
2017-12-15  2:49     ` Stephen Rothwell

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=19929.1514903630@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-ia64@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=x86@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 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.