Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965292AbWHWXEA (ORCPT ); Wed, 23 Aug 2006 19:04:00 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S965288AbWHWXEA (ORCPT ); Wed, 23 Aug 2006 19:04:00 -0400 Received: from e34.co.us.ibm.com ([32.97.110.152]:493 "EHLO e34.co.us.ibm.com") by vger.kernel.org with ESMTP id S965292AbWHWXD7 (ORCPT ); Wed, 23 Aug 2006 19:03:59 -0400 Subject: Re: [Devel] [PATCH 6/6] BC: kernel memory accounting (marks) From: Dave Hansen To: devel@openvz.org Cc: Andrew Morton , Rik van Riel , Chandra Seetharaman , Greg KH , Linux Kernel Mailing List , Andi Kleen , Christoph Hellwig , Andrey Savochkin , Alan Cox , Rohit Seth , Matt Helsley , Oleg Nesterov In-Reply-To: <44EC371F.7080205@sw.ru> References: <44EC31FB.2050002@sw.ru> <44EC371F.7080205@sw.ru> Content-Type: text/plain Date: Wed, 23 Aug 2006 16:03:51 -0700 Message-Id: <1156374231.12011.61.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 10077 Lines: 275 On Wed, 2006-08-23 at 15:08 +0400, Kirill Korotaev wrote: > include/asm-i386/thread_info.h | 4 ++-- > include/asm-ia64/pgalloc.h | 24 +++++++++++++++++------- > include/asm-x86_64/pgalloc.h | 12 ++++++++---- > include/asm-x86_64/thread_info.h | 5 +++-- Do you think we need to cover a few more architectures before considering merging this, or should we just fix them up as we need them? I'm working on a patch to unify as many of the alloc_thread_info() functions as I can. That should at least give you one place to modify and track the thread_info allocations. I've only compiled for x86_64 and i386, but I'm working on more. A preliminary version is attached. -- Dave --- clean-dave/include/asm-alpha/thread_info.h | 5 --- clean-dave/include/asm-frv/thread_info.h | 17 ---------- clean-dave/include/asm-h8300/thread_info.h | 8 +---- clean-dave/include/asm-i386/thread_info.h | 18 ----------- clean-dave/include/asm-m32r/thread_info.h | 17 ---------- clean-dave/include/asm-m68k/thread_info.h | 9 ----- clean-dave/include/asm-powerpc/thread_info.h | 27 ----------------- clean-dave/include/linux/thread_alloc.h | 42 +++++++++++++++++++++++++++ clean-dave/kernel/fork.c | 1 9 files changed, 47 insertions(+), 97 deletions(-) diff -puN arch/arm/kernel/process.c~unify-alloc-thread-info arch/arm/kernel/process.c diff -puN include/asm-alpha/thread_info.h~unify-alloc-thread-info include/asm-alpha/thread_info.h --- clean/include/asm-alpha/thread_info.h~unify-alloc-thread-info 2006-08-23 15:38:37.000000000 -0700 +++ clean-dave/include/asm-alpha/thread_info.h 2006-08-23 15:40:23.000000000 -0700 @@ -50,10 +50,7 @@ register struct thread_info *__current_t #define current_thread_info() __current_thread_info /* Thread information allocation. */ -#define THREAD_SIZE (2*PAGE_SIZE) -#define alloc_thread_info(tsk) \ - ((struct thread_info *) __get_free_pages(GFP_KERNEL,1)) -#define free_thread_info(ti) free_pages((unsigned long) (ti), 1) +#define THREAD_SHIFT (PAGE_SHIFT+1) #endif /* __ASSEMBLY__ */ diff -puN include/asm-frv/thread_info.h~unify-alloc-thread-info include/asm-frv/thread_info.h --- clean/include/asm-frv/thread_info.h~unify-alloc-thread-info 2006-08-23 15:40:26.000000000 -0700 +++ clean-dave/include/asm-frv/thread_info.h 2006-08-23 15:40:40.000000000 -0700 @@ -82,23 +82,6 @@ register struct thread_info *__current_t #define current_thread_info() ({ __current_thread_info; }) -/* thread information allocation */ -#ifdef CONFIG_DEBUG_STACK_USAGE -#define alloc_thread_info(tsk) \ - ({ \ - struct thread_info *ret; \ - \ - ret = kmalloc(THREAD_SIZE, GFP_KERNEL); \ - if (ret) \ - memset(ret, 0, THREAD_SIZE); \ - ret; \ - }) -#else -#define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL) -#endif - -#define free_thread_info(info) kfree(info) - #endif /* __ASSEMBLY__ */ /* diff -puN include/asm-h8300/thread_info.h~unify-alloc-thread-info include/asm-h8300/thread_info.h --- clean/include/asm-h8300/thread_info.h~unify-alloc-thread-info 2006-08-23 15:40:43.000000000 -0700 +++ clean-dave/include/asm-h8300/thread_info.h 2006-08-23 15:41:54.000000000 -0700 @@ -49,8 +49,8 @@ struct thread_info { /* * Size of kernel stack for each process. This must be a power of 2... */ -#define THREAD_SIZE 8192 /* 2 pages */ - +#define THREAD_SHIFT 1 +#define THREAD_SIZE (1<= PAGE_SHIFT - -#define THREAD_ORDER (THREAD_SHIFT - PAGE_SHIFT) - -#ifdef CONFIG_DEBUG_STACK_USAGE -#define alloc_thread_info(tsk) \ - ((struct thread_info *)__get_free_pages(GFP_KERNEL | \ - __GFP_ZERO, THREAD_ORDER)) -#else -#define alloc_thread_info(tsk) \ - ((struct thread_info *)__get_free_pages(GFP_KERNEL, THREAD_ORDER)) -#endif -#define free_thread_info(ti) free_pages((unsigned long)ti, THREAD_ORDER) - -#else /* THREAD_SHIFT < PAGE_SHIFT */ - -#ifdef CONFIG_DEBUG_STACK_USAGE -#define alloc_thread_info(tsk) kzalloc(THREAD_SIZE, GFP_KERNEL) -#else -#define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL) -#endif -#define free_thread_info(ti) kfree(ti) - -#endif /* THREAD_SHIFT < PAGE_SHIFT */ - /* how to get the thread information struct from C */ static inline struct thread_info *current_thread_info(void) { diff -puN /dev/null include/linux/thread_alloc.h --- /dev/null 2005-03-30 22:36:15.000000000 -0800 +++ clean-dave/include/linux/thread_alloc.h 2006-08-23 16:00:41.000000000 -0700 @@ -0,0 +1,42 @@ +#ifndef _LINUX_THREAD_ALLOC +#define _LINUX_THREAD_ALLOC + +#ifndef THREAD_SHIFT +#define THREAD_SHIFT PAGE_SHIFT +#endif +#ifndef THREAD_ORDER +#define THREAD_ORDER (THREAD_SHIFT - PAGE_SHIFT) +#endif + +struct thread_info; +struct task; + +#if THREAD_SHIFT >= PAGE_SHIFT +static inline struct thread_info *alloc_thread_info(struct task_struct *tsk) +{ + gfp_t flags = GFP_KERNEL; +#ifdef CONFIG_DEBUG_STACK_USAGE + flags |= __GFP_ZERO; +#endif + return (struct thread_info *)__get_free_pages(flags, THREAD_ORDER); +} +static inline void free_thread_info(struct thread_info *ti) +{ + free_pages((unsigned long)ti, THREAD_ORDER); +} +#else /* THREAD_SHIFT < PAGE_SHIFT */ +static inline struct thread_info *alloc_thread_info(struct task_struct *tsk) +{ +#ifdef CONFIG_DEBUG_STACK_USAGE + return kzalloc(THREAD_SIZE, GFP_KERNEL); +#else + return kmalloc(THREAD_SIZE, GFP_KERNEL); +#endif +} +static inline void free_thread_info(struct thread_info *ti) +{ + kfree(ti); +} +#endif /* THREAD_SHIFT < PAGE_SHIFT */ + +#endif /* _LINUX_THREAD_ALLOC */ diff -puN include/linux/thread_info.h~unify-alloc-thread-info include/linux/thread_info.h diff -puN kernel/fork.c~unify-alloc-thread-info kernel/fork.c --- clean/kernel/fork.c~unify-alloc-thread-info 2006-08-23 15:19:28.000000000 -0700 +++ clean-dave/kernel/fork.c 2006-08-23 15:47:35.000000000 -0700 @@ -45,6 +45,7 @@ #include #include #include +#include #include #include _ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/