eliminate CLONE_* duplications
Subsystems (3)
PATCH 1/1 eliminate CLONE_* duplications
several archs require some CLONE_* flags (usually CLONE_VM and CLONE_UNTRACED) but can not include <linux/sched.h> because of C specific code ...
some archs (alpha,cris,ia64,ppc/64,v850) map those values via asm-offsets.c, others (cris-*,hppa/64) redefine the values in the asm code ...
this patch moves the relevant defines into a separate <linux/clone.h>, which is included by <linux/sched.h>, removes all asm-offsets.c entries and adds the <linux/clone.h> as include where the CLONE_* values are used
alternatively I could imagine to add some ugly #ifdefs to make <linux/sched.h> asm safe :)
patch is compile tested on relevant archs. please consider for inclusion.
TIA,
Herbert
---
arch/alpha/kernel/asm-offsets.c +0 -2
@@ -33,8 +33,6 @@ void foo(void)DEFINE (SIZEOF_PT_REGS ,sizeof (struct pt_regs ));DEFINE (PT_PTRACED ,PT_PTRACED ); -DEFINE (CLONE_VM ,CLONE_VM ); -DEFINE (CLONE_UNTRACED ,CLONE_UNTRACED );DEFINE (SIGCHLD ,SIGCHLD );BLANK ();
arch/alpha/kernel/entry.S +1 -0
@@ -5,6 +5,7 @@ */ #include <linux/config.h> +#include <linux/clone.h> #include <asm/asm-offsets.h> #include <asm/thread_info.h> #include <asm/pal.h>
arch/cris/arch-v10/kernel/asm-offsets.c +0 -3
@@ -40,8 +40,5 @@ int main(void)#undef ENTRY#define ENTRY (entry) DEFINE(TASK_ ## entry, offsetof(struct task_struct, entry))ENTRY (pid); -BLANK (); -DEFINE (LCLONE_VM ,CLONE_VM ); -DEFINE (LCLONE_UNTRACED ,CLONE_UNTRACED );return 0 ; }
arch/cris/arch-v10/kernel/entry.S +1 -0
@@ -266,6 +266,7 @@ #include <linux/config.h> #include <linux/linkage.h> #include <linux/sys.h> +#include <linux/clone.h> #include <asm/unistd.h> #include <asm/arch/sv_addr_ag.h> #include <asm/errno.h>
arch/cris/arch-v32/kernel/asm-offsets.c +0 -3
@@ -42,8 +42,5 @@ int main(void)#undef ENTRY#define ENTRY (entry) DEFINE(TASK_ ## entry, offsetof(struct task_struct, entry))ENTRY (pid); -BLANK (); -DEFINE (LCLONE_VM ,CLONE_VM ); -DEFINE (LCLONE_UNTRACED ,CLONE_UNTRACED );return 0 ; }
arch/frv/kernel/kernel_thread.S +1 -1
@@ -10,9 +10,9 @@ */ #include <linux/linkage.h> +#include <linux/clone.h> #include <asm/unistd.h> -#define CLONE_VM 0x00000100 /* set if VM shared between processes */ #define KERN_ERR "<3>" .section .rodata
arch/ia64/ia32/ia32_entry.S +2 -1
@@ -1,3 +1,4 @@ +#include <linux/clone.h> #include <asm/asmmacro.h> #include <asm/ia32.h> #include <asm/asm-offsets.h>
@@ -179,7 +180,7 @@ END(ia32_trace_syscall) GLOBAL_ENTRY(sys32_vfork) alloc r16=ar.pfs,2,2,4,0;; - mov out0=IA64_CLONE_VFORK|IA64_CLONE_VM|SIGCHLD // out0 = clone_flags + mov out0=CLONE_VFORK|CLONE_VM|SIGCHLD // out0 = clone_flags br.cond.sptk.few .fork1 // do the work END(sys32_vfork)
arch/ia64/kernel/asm-offsets.c +0 -4
@@ -188,11 +188,7 @@ void foo(void)DEFINE (IA64_SIGFRAME_HANDLER_OFFSET , offsetof (struct sigframe , handler));DEFINE (IA64_SIGFRAME_SIGCONTEXT_OFFSET , offsetof (struct sigframe , sc));BLANK (); -/* for assembly files which can't include sched.h: */ -DEFINE (IA64_CLONE_VFORK ,CLONE_VFORK ); -DEFINE (IA64_CLONE_VM ,CLONE_VM ); -BLANK ();DEFINE (IA64_CPUINFO_NSEC_PER_CYC_OFFSET , offsetof (struct cpuinfo_ia64 , nsec_per_cyc)); DEFINE(IA64_CPUINFO_PTCE_BASE_OFFSET,
arch/parisc/kernel/entry.S +1 -3
@@ -23,6 +23,7 @@ */ #include <linux/config.h> +#include <linux/clone.h> #include <asm/asm-offsets.h> /* we have the following possibilities to act on an interruption:
@@ -751,9 +752,6 @@ fault_vector_11: * for copy_thread/ret_ to properly set up the child. */ -#define CLONE_VM 0x100 /* Must agree with <linux/sched.h> */ -#define CLONE_UNTRACED 0x00800000 - .export __kernel_thread, code .import do_fork __kernel_thread:
arch/ppc/kernel/asm-offsets.c +0 -2
@@ -119,8 +119,6 @@ main(void)DEFINE (ORIG_GPR3 ,STACK_FRAME_OVERHEAD +offsetof(struct pt_regs , orig_gpr3));DEFINE (RESULT ,STACK_FRAME_OVERHEAD +offsetof(struct pt_regs , result));DEFINE (TRAP ,STACK_FRAME_OVERHEAD +offsetof(struct pt_regs , trap)); -DEFINE (CLONE_VM ,CLONE_VM ); -DEFINE (CLONE_UNTRACED ,CLONE_UNTRACED );DEFINE (MM_PGD , offsetof(struct mm_struct , pgd));/* About the CPU features table */
arch/ppc/kernel/misc.S +1 -0
@@ -14,6 +14,7 @@ #include <linux/config.h> #include <linux/sys.h> +#include <linux/clone.h> #include <asm/unistd.h> #include <asm/errno.h> #include <asm/processor.h>
arch/ppc64/kernel/asm-offsets.c +0 -3
@@ -160,9 +160,6 @@ int main(void)DEFINE (_SRR0,STACK_FRAME_OVERHEAD +sizeof (struct pt_regs ));DEFINE (_SRR1,STACK_FRAME_OVERHEAD +sizeof (struct pt_regs )+8 ); -DEFINE (CLONE_VM ,CLONE_VM ); -DEFINE (CLONE_UNTRACED ,CLONE_UNTRACED ); -/* About the CPU features table */ DEFINE (CPU_SPEC_ENTRY_SIZE ,sizeof (struct cpu_spec ));DEFINE (CPU_SPEC_PVR_MASK , offsetof(struct cpu_spec , pvr_mask));
arch/ppc64/kernel/misc.S +1 -0
@@ -20,6 +20,7 @@ #include <linux/config.h> #include <linux/sys.h> +#include <linux/clone.h> #include <asm/unistd.h> #include <asm/errno.h> #include <asm/processor.h>
arch/v850/kernel/asm-offsets.c +0 -4
@@ -53,9 +53,5 @@ int main (void)/* error values */ DEFINE (ENOSYS ,ENOSYS ); -/* clone flag bits */ -DEFINE (CLONE_VFORK ,CLONE_VFORK ); -DEFINE (CLONE_VM ,CLONE_VM ); -return 0 ; }
arch/v850/kernel/entry.S +1 -0
@@ -13,6 +13,7 @@ */ #include <linux/sys.h> +#include <linux/clone.h> #include <asm/entry.h> #include <asm/current.h>
include/asm-cris/arch-v10/offset.h +0 -3
@@ -27,7 +27,4 @@#define TASK_pid 141/* offsetof(struct task_struct, pid) */ -#define LCLONE_VM 256/* CLONE_VM */ -#define LCLONE_UNTRACED 8388608/* CLONE_UNTRACED */ -#endif
include/asm-cris/arch-v32/offset.h +0 -3
@@ -29,7 +29,4 @@#define TASK_pid 149/* offsetof(struct task_struct, pid) */ -#define LCLONE_VM 256/* CLONE_VM */ -#define LCLONE_UNTRACED 8388608/* CLONE_UNTRACED */ -#endif
include/linux/clone.h +32 -0
@@ -0,0 +1,32 @@ +#ifndef _LINUX_CLONE_H +#define _LINUX_CLONE_H + +/* +* cloning flags: +*/ +#define CSIGNAL 0x000000ff/* signal mask to be sent at exit */ +#define CLONE_VM 0x00000100/* set if VM shared between processes */ +#define CLONE_FS 0x00000200/* set if fs info shared between processes */ +#define CLONE_FILES 0x00000400/* set if open files shared between processes */ +#define CLONE_SIGHAND 0x00000800/* set if signal handlers and blocked signals shared */ +#define CLONE_PTRACE 0x00002000/* set if we want to let tracing continue on the child too */ +#define CLONE_VFORK 0x00004000/* set if the parent wants the child to wake it up on mm_release */ +#define CLONE_PARENT 0x00008000/* set if we want to have the same parent as the cloner */ +#define CLONE_THREAD 0x00010000/* Same thread group? */ +#define CLONE_NEWNS 0x00020000/* New namespace group? */ +#define CLONE_SYSVSEM 0x00040000/* share system V SEM_UNDO semantics */ +#define CLONE_SETTLS 0x00080000/* create a new TLS for the child */ +#define CLONE_PARENT_SETTID 0x00100000/* set the TID in the parent */ +#define CLONE_CHILD_CLEARTID 0x00200000/* clear the TID in the child */ +#define CLONE_DETACHED 0x00400000/* Unused, ignored */ +#define CLONE_UNTRACED 0x00800000/* set if the tracing process can't force CLONE_PTRACE on this clone */ +#define CLONE_CHILD_SETTID 0x01000000/* set the TID in the child */ +#define CLONE_STOPPED 0x02000000/* Start in stopped state */ + +/* +* List of flags we want to share for kernel threads, +* if only because they are not used by them anyway. +*/ +#define CLONE_KERNEL (CLONE_FS | CLONE_FILES | CLONE_SIGHAND) + +#endif
include/linux/sched.h +1 -28
@@ -36,38 +36,11 @@#include <linux/seccomp.h> #include <linux/auxvec.h> /* For AT_VECTOR_SIZE */ +#include <linux/clone.h> struct exec_domain ;/* -* cloning flags: -*/ -#define CSIGNAL 0x000000ff/* signal mask to be sent at exit */ -#define CLONE_VM 0x00000100/* set if VM shared between processes */ -#define CLONE_FS 0x00000200/* set if fs info shared between processes */ -#define CLONE_FILES 0x00000400/* set if open files shared between processes */ -#define CLONE_SIGHAND 0x00000800/* set if signal handlers and blocked signals shared */ -#define CLONE_PTRACE 0x00002000/* set if we want to let tracing continue on the child too */ -#define CLONE_VFORK 0x00004000/* set if the parent wants the child to wake it up on mm_release */ -#define CLONE_PARENT 0x00008000/* set if we want to have the same parent as the cloner */ -#define CLONE_THREAD 0x00010000/* Same thread group? */ -#define CLONE_NEWNS 0x00020000/* New namespace group? */ -#define CLONE_SYSVSEM 0x00040000/* share system V SEM_UNDO semantics */ -#define CLONE_SETTLS 0x00080000/* create a new TLS for the child */ -#define CLONE_PARENT_SETTID 0x00100000/* set the TID in the parent */ -#define CLONE_CHILD_CLEARTID 0x00200000/* clear the TID in the child */ -#define CLONE_DETACHED 0x00400000/* Unused, ignored */ -#define CLONE_UNTRACED 0x00800000/* set if the tracing process can't force CLONE_PTRACE on this clone */ -#define CLONE_CHILD_SETTID 0x01000000/* set the TID in the child */ -#define CLONE_STOPPED 0x02000000/* Start in stopped state */ - -/* -* List of flags we want to share for kernel threads, -* if only because they are not used by them anyway. -*/ -#define CLONE_KERNEL (CLONE_FS | CLONE_FILES | CLONE_SIGHAND) - -/* * These are the constant used to fake the fixed-point load-average * counting. Some notes: * - 11 bit fractions expand to 22 bits by the multiplies: this gives
Hi,
Quoted 3 lines · Herbert Poetzl
some archs (alpha,cris,ia64,ppc/64,v850) map those values via
asm-offsets.c, others (cris-*,hppa/64) redefine the values in the asm code ...
Please fix cris-*,hppa/64 instead to use asm-offsets.c.
bye, Roman
Quoted 9 lines · Roman Zippel
Hi,
Quoted 3 lines · Herbert Poetzl
some archs (alpha,cris,ia64,ppc/64,v850) map those values via
asm-offsets.c, others (cris-*,hppa/64) redefine the values in the asm code ...Please fix cris-*,hppa/64 instead to use
asm-offsets.c.
please elaborate _why_ we would want a bunch of additional DEFINE entries in each arch instead of a simple include file?
TIA,
Herbert
Quoted 6 lines
bye, Roman
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Hi,
Quoted 3 lines · Herbert Poetzl
please elaborate _why_ we would want a bunch of additional DEFINE entries in each arch instead of a simple include file?
It's more important to keep related definition together and organize them logically, than spreading definitions over zillion header files for the only purpose to be usable from asm.
If you want to cleanup sched.h and properly break it up, please go ahead, but I'm afraid that will be a lot more work than adding a few defines to asm-offsets.c.
bye, Roman
Quoted 8 lines · Roman Zippel
Hi,
Quoted 3 lines · Herbert Poetzl
please elaborate _why_ we would want a bunch of additional DEFINE entries in each arch instead of a simple include file?
Quoted 5 lines
It's more important to keep related definition together and organize them logically, than spreading definitions over zillion header files for the only purpose to be usable from asm. If you want to cleanup
sched.hand properly break it up, please go ahead, but I'm afraid that will be a lot more work than adding a few defines toasm-offsets.c.
well, I thought that is what my patch did, so please could you elaborate on the 'properly' part, as this might be the missing information here ...
TIA,
Herbert
Quoted 6 lines
bye, Roman
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Hi,
Quoted 3 lines · Herbert Poetzl
well, I thought that is what my patch did, so please could you elaborate on the 'properly' part, as this might be the missing information here ...
"It's more important to keep related definition together and organize them logically."
bye, Roman
Quoted 10 lines · Roman Zippel
Hi,
Quoted 3 lines · Herbert Poetzl
well, I thought that is what my patch did, so please could you elaborate on the 'properly' part, as this might be the missing information here ...
"It's more important to keep related definition together and organize them logically."
hmm, looks like we are dancing around in circles here so please forgive my direct (and repeated) question:
_what_ do you consider 'logically organized' because putting all the CLONE_* stuff into a separate file is pretty logical for me ... but obviously not for you.
I have absolutely no problem with different, more logical splitups, and I'm willing to break down the entire sched.h if that will help the cause ... so please enlighten me here ...
TIA,
Herbert
Quoted 6 lines
bye, Roman
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Hi,
(Sorry for the delay.)
Quoted 3 lines · Herbert Poetzl
_what_ do you consider 'logically organized' because putting all the CLONE_* stuff into a separate file is pretty logical for me ... but obviously not for you.
"logically organized" mainly means reducing dependencies by organizing them by their logical dependencies. If a large header file is included by a lot of other files, some parts maybe separated to reduce header dependencies. The same can be done for config dependencies, so that a config change doesn't necessarily recompiles the whole kernel.
Your change doesn't reduce any dependecies and it's not such a big cleanup:
arch/alpha/kernel/asm-offsets.c | 2 -- arch/alpha/kernel/entry.S | 1 + arch/cris/arch-v10/kernel/asm-offsets.c | 3 --- arch/cris/arch-v10/kernel/entry.S | 1 + arch/cris/arch-v32/kernel/asm-offsets.c | 3 --- arch/frv/kernel/kernel_thread.S | 2 +- arch/ia64/ia32/ia32_entry.S | 3 ++- arch/ia64/kernel/asm-offsets.c | 4 ---- arch/parisc/kernel/entry.S | 4 +--- arch/ppc/kernel/asm-offsets.c | 2 -- arch/ppc/kernel/misc.S | 1 + arch/ppc64/kernel/asm-offsets.c | 3 --- arch/ppc64/kernel/misc.S | 1 + arch/v850/kernel/asm-offsets.c | 4 ---- arch/v850/kernel/entry.S | 1 + include/asm-cris/arch-v10/offset.h | 3 --- include/asm-cris/arch-v32/offset.h | 3 --- include/linux/clone.h | 32 ++++++++++++++++++++++++++++++++ include/linux/sched.h | 30 +----------------------------- 19 files changed, 42 insertions(+), 61 deletions(-)
The noise generated by the separation is larger than the avoided duplication.
The hardcoded defines actually do need fixing, frv is especially bad, as it even has hardcoded structure offsets.
Quoted 4 lines
I have absolutely no problem with different, more logical splitups, and I'm willing to break down the entire
sched.hif that will help the cause ... so please enlighten me here ...
sched.h is especially challenging due to dependencies between headers under asm and linux. It's not just splitting sched.h, it also requires analyzing its dependencies.
bye, Roman
Quoted 3 lines · Roman Zippel
Hi,
(Sorry for the delay.)
no big deal ...
Quoted 8 lines · Herbert Poetzl
Quoted 4 lines
_what_ do you consider 'logically organized' because putting all the CLONE_* stuff into a separate file is pretty logical for me ... but obviously not for you.
"logically organized" mainly means reducing dependencies by organizing them by their logical dependencies.
did you consider that separating out the clone stuff might be that basis for reducing dependencies?
Quoted 7 lines
If a large header file is included by a lot of other files, some parts maybe separated to reduce header dependencies. The same can be done for config dependencies, so that a config change doesn't necessarily recompiles the whole kernel.
Your change doesn't reduce any dependecies and it's not such a big cleanup:
aha, so we want a big all-in-one patch now which does many changes at once, instead of a small (and obvious) cleanup first, then later maybe a restructuring ... yes?
Quoted 21 lines
arch/alpha/kernel/asm-offsets.c | 2 -- arch/alpha/kernel/entry.S | 1 + arch/cris/arch-v10/kernel/asm-offsets.c | 3 --- arch/cris/arch-v10/kernel/entry.S | 1 + arch/cris/arch-v32/kernel/asm-offsets.c | 3 --- arch/frv/kernel/kernel_thread.S | 2 +- arch/ia64/ia32/ia32_entry.S | 3 ++- arch/ia64/kernel/asm-offsets.c | 4 ---- arch/parisc/kernel/entry.S | 4 +--- arch/ppc/kernel/asm-offsets.c | 2 -- arch/ppc/kernel/misc.S | 1 + arch/ppc64/kernel/asm-offsets.c | 3 --- arch/ppc64/kernel/misc.S | 1 + arch/v850/kernel/asm-offsets.c | 4 ---- arch/v850/kernel/entry.S | 1 + include/asm-cris/arch-v10/offset.h | 3 --- include/asm-cris/arch-v32/offset.h | 3 --- include/linux/clone.h | 32 ++++++++++++++++++++++++++++++++ include/linux/sched.h | 30 +----------------------------- 19 files changed, 42 insertions(+), 61 deletions(-)
Quoted 2 lines
The noise generated by the separation is larger than the avoided duplication.
hmm, interesting argument ...
Quoted 2 lines
The hardcoded defines actually do need fixing, frv is especially bad, as it even has hardcoded structure offsets.
so instead of fixing the issue properly, we 'mend' it by adding new code to */asm-offsets.c
Quoted 8 lines
Quoted 4 lines
I have absolutely no problem with different, more logical splitups, and I'm willing to break down the entire
sched.hif that will help the cause ... so please enlighten me here ...
sched.his especially challenging due to dependencies between headers under asm and linux. It's not just splittingsched.h, it also requires analyzing its dependencies.
which you obviously think is nothing I can do 'properly' ...
thanks for the info,
Herbert
Quoted 1 line
bye, Roman
Hi,
Quoted 5 lines · Herbert Poetzl
Quoted 2 lines
"logically organized" mainly means reducing dependencies by organizing them by their logical dependencies.
did you consider that separating out the clone stuff might be that basis for reducing dependencies?
Not in this form, all users of this flag need other definitions from sched.h.
Quoted 5 lines
Quoted 2 lines
The hardcoded defines actually do need fixing, frv is especially bad, as it even has hardcoded structure offsets.
so instead of fixing the issue properly, we
'mend' it by adding new code to*/asm-offsets.c
Using asm-offsets.c _is_ a proper solution.
Quoted 6 lines
Quoted 3 lines
sched.his especially challenging due to dependencies between headers under asm and linux. It's not just splittingsched.h, it also requires analyzing its dependencies.which you obviously think is nothing I can do
'properly' ...
I don't know, but I know that it does require a large amount of experience in this area.
bye, Roman