Hi,

On Thu, 11 Jan 2007, Geert Uytterhoeven wrote:

> Hmm, upon closer look, there are more conflicts between
> <asm/asm-offsets.h> and other header files, and
> arch/m68k/kernel/ptrace.c does need some of the PT_* definitions from
> <asm/ptrace.h>, so I can't just kill them. I guess I'll have to rename the
> conflicting ones in asm-offsets.
> 
> First patch (still fails to build the whole tree) below.

Below is an alternative approach (which at least compiles :) ), which 
avoids any direct or indirect dependency on task structure information. 
Only the init_task definition is a little ugly as there is currently no 
way to get the task_struct without pulling all of sched.h

bye, Roman

---
 arch/m68k/kernel/asm-offsets.c |    2 +-
 arch/m68k/kernel/head.S        |    2 +-
 arch/m68k/kernel/process.c     |   18 ++++++++++++++----
 include/asm-ia64/thread_info.h |    1 +
 include/asm-m68k/thread_info.h |   14 +++++++++++++-
 include/asm-m68k/processor.h   |    3 ---
 include/linux/sched.h          |   12 +++++++-----
 kernel/fork.c                  |    2 ++
 8 files changed, 39 insertions(+), 15 deletions(-)

Index: linux-2.6/arch/m68k/kernel/asm-offsets.c
===================================================================
--- linux-2.6.orig/arch/m68k/kernel/asm-offsets.c
+++ linux-2.6/arch/m68k/kernel/asm-offsets.c
@@ -26,7 +26,7 @@ int main(void)
        DEFINE(TASK_FLAGS, offsetof(struct task_struct, flags));
        DEFINE(TASK_PTRACE, offsetof(struct task_struct, ptrace));
        DEFINE(TASK_THREAD, offsetof(struct task_struct, thread));
-       DEFINE(TASK_INFO, offsetof(struct task_struct, thread.info));
+       DEFINE(TASK_INFO, -sizeof(struct thread_info));
        DEFINE(TASK_MM, offsetof(struct task_struct, mm));
        DEFINE(TASK_ACTIVE_MM, offsetof(struct task_struct, active_mm));
 
Index: linux-2.6/arch/m68k/kernel/head.S
===================================================================
--- linux-2.6.orig/arch/m68k/kernel/head.S
+++ linux-2.6/arch/m68k/kernel/head.S
@@ -1520,7 +1520,7 @@ L(cache_done):
 /*
  * Setup initial stack pointer
  */
-       lea     init_task,%curptr
+       lea     init_m68k_task-TASK_INFO,%curptr
        lea     init_thread_union+THREAD_SIZE,%sp
 
        putc    'K'
Index: linux-2.6/arch/m68k/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/m68k/kernel/process.c
+++ linux-2.6/arch/m68k/kernel/process.c
@@ -48,14 +48,24 @@ struct mm_struct init_mm = INIT_MM(init_
 
 EXPORT_SYMBOL(init_mm);
 
-union thread_union init_thread_union
+union thread_union {
+       struct task_struct *task;
+       unsigned char stack[THREAD_SIZE];
+} init_thread_union
 __attribute__((section(".data.init_task"), aligned(THREAD_SIZE)))
-       = { INIT_THREAD_INFO(init_task) };
+       = { .task = &init_task };
 
 /* initial task structure */
-struct task_struct init_task = INIT_TASK(init_task);
+struct m68k_task {
+       struct thread_info info;
+       struct task_struct task;
+} init_m68k_task = {
+       .info = INIT_THREAD_INFO(init_task),
+       .task = INIT_TASK(init_task),
+};
+EXPORT_SYMBOL(init_m68k_task);
 
-EXPORT_SYMBOL(init_task);
+struct kmem_cache *task_struct_cachep;
 
 asmlinkage void ret_from_fork(void);
 
Index: linux-2.6/include/asm-ia64/thread_info.h
===================================================================
--- linux-2.6.orig/include/asm-ia64/thread_info.h
+++ linux-2.6/include/asm-ia64/thread_info.h
@@ -68,6 +68,7 @@ struct thread_info {
 #define end_of_stack(p) (unsigned long *)((void *)(p) + IA64_RBS_OFFSET)
 
 #define __HAVE_ARCH_TASK_STRUCT_ALLOCATOR
+#define setup_task_alloc()     ((void)0)
 #define alloc_task_struct()    ((struct task_struct 
*)__get_free_pages(GFP_KERNEL | __GFP_COMP, KERNEL_STACK_SIZE_ORDER))
 #define free_task_struct(tsk)  free_pages((unsigned long) (tsk), 
KERNEL_STACK_SIZE_ORDER)
 
Index: linux-2.6/include/asm-m68k/thread_info.h
===================================================================
--- linux-2.6.orig/include/asm-m68k/thread_info.h
+++ linux-2.6/include/asm-m68k/thread_info.h
@@ -36,7 +36,7 @@ struct thread_info {
 #define init_thread_info       (init_task.thread.info)
 #define init_stack             (init_thread_union.stack)
 
-#define task_thread_info(tsk)  (&(tsk)->thread.info)
+#define task_thread_info(tsk)  ((struct thread_info *)(tsk) - 1)
 #define task_stack_page(tsk)   ((void *)(tsk)->stack)
 #define current_thread_info()  task_thread_info(current)
 
@@ -49,6 +49,18 @@ struct thread_info {
 
 #define end_of_stack(p) ((unsigned long *)(p)->thread_info + 1)
 
+#define __HAVE_ARCH_TASK_STRUCT_ALLOCATOR
+#define setup_task_alloc()     (task_struct_cachep = 
kmem_cache_create("task_struct", \
+                                       sizeof(struct task_struct) + 
sizeof(struct thread_info), \
+                                       L1_CACHE_BYTES, SLAB_PANIC, NULL, NULL))
+#define alloc_task_struct()    kmem_cache_alloc(task_struct_cachep, GFP_KERNEL)
+#define free_task_struct(tsk)  kmem_cache_free(task_struct_cachep, (tsk))
+
+#define init_task              (*(struct task_struct *)(((struct thread_info 
*)&init_m68k_task) + 1))
+
+extern struct kmem_cache *task_struct_cachep;
+extern struct m68k_task init_m68k_task;
+
 /* entry.S relies on these definitions!
  * bits 0-7 are tested at every exception exit
  * bits 8-15 are also tested at syscall exit
Index: linux-2.6/include/asm-m68k/processor.h
===================================================================
--- linux-2.6.orig/include/asm-m68k/processor.h
+++ linux-2.6/include/asm-m68k/processor.h
@@ -13,7 +13,6 @@
  */
 #define current_text_addr() ({ __label__ _l; _l: &&_l;})
 
-#include <linux/thread_info.h>
 #include <asm/segment.h>
 #include <asm/fpu.h>
 #include <asm/ptrace.h>
@@ -67,14 +66,12 @@ struct thread_struct {
        unsigned long  fp[8*3];
        unsigned long  fpcntl[3];       /* fp control regs */
        unsigned char  fpstate[FPSTATESIZE];  /* floating point state */
-       struct thread_info info;
 };
 
 #define INIT_THREAD  {                                                 \
        .ksp    = sizeof(init_stack) + (unsigned long) init_stack,      \
        .sr     = PS_S,                                                 \
        .fs     = __KERNEL_DS,                                          \
-       .info   = INIT_THREAD_INFO(init_task),                          \
 }
 
 /*
Index: linux-2.6/include/linux/sched.h
===================================================================
--- linux-2.6.orig/include/linux/sched.h
+++ linux-2.6/include/linux/sched.h
@@ -1202,11 +1202,6 @@ void yield(void);
  */
 extern struct exec_domain      default_exec_domain;
 
-union thread_union {
-       struct thread_info thread_info;
-       unsigned long stack[THREAD_SIZE/sizeof(long)];
-};
-
 #ifndef __HAVE_ARCH_KSTACK_END
 static inline int kstack_end(void *addr)
 {
@@ -1217,8 +1212,15 @@ static inline int kstack_end(void *addr)
 }
 #endif
 
+#ifndef __HAVE_ARCH_TASK_STRUCT_ALLOCATOR
+union thread_union {
+       struct thread_info thread_info;
+       unsigned long stack[THREAD_SIZE/sizeof(long)];
+};
+
 extern union thread_union init_thread_union;
 extern struct task_struct init_task;
+#endif
 
 extern struct   mm_struct init_mm;
 
Index: linux-2.6/kernel/fork.c
===================================================================
--- linux-2.6.orig/kernel/fork.c
+++ linux-2.6/kernel/fork.c
@@ -136,6 +136,8 @@ void __init fork_init(unsigned long memp
        task_struct_cachep =
                kmem_cache_create("task_struct", sizeof(struct task_struct),
                        ARCH_MIN_TASKALIGN, SLAB_PANIC, NULL, NULL);
+#else
+       setup_task_alloc();
 #endif
 
        /*
-
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to