Home » Mailing lists » Devel » [PATCH] BC: resource beancounters (v2)  
	
		
		
			| Re:  [PATCH 6/6] BC: kernel memory accounting (marks) [message #5583 is a reply to message #5548] | 
			Wed, 23 August 2006 23:03    | 
		 
		
			
				
				
				
					
						  
						Dave Hansen
						 Messages: 240 Registered: October 2005 
						
					 | 
					Senior Member  | 
					 | 
		 
		 
	 | 
 
	
		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-inf o	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-inf o	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<<THREAD_SHIFT) 
  
 /* how to get the thread information struct from C */ 
 static inline struct thread_info *current_thread_info(void) 
@@ -65,10 +65,6 @@ static inline struct thread_info *curren 
 	return ti; 
 } 
  
-/* thread information allocation */ 
-#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) 
 #endif /* __ASSEMBLY__ */ 
  
 /* 
diff -puN include/asm-i386/thread_info.h~unify-alloc-thread-info include/asm-i386/thread_info.h 
---  clean/include/asm-i386/thread_info.h~unify-alloc-thread-info	2006-08-23 15:19:27.000000000 -0700 
+++ clean-dave/include/asm-i386/thread_info.h	2006-08-23 15:33:30.000000000 -0700 
@@ -92,24 +92,6 @@ static inline struct thread_info *curren 
 { 
 	return (struct thread_info *)(current_stack_pointer & ~(THREAD_SIZE - 1)); 
 } 
- 
-/* 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) 
- 
 #else /* !__ASSEMBLY__ */ 
  
 /* how to get the thread information struct from ASM */ 
diff -puN include/asm-ia64/thread_info.h~unify-alloc-thread-info include/asm-ia64/thread_info.h 
diff -puN include/asm-m32r/thread_info.h~unify-alloc-thread-info include/asm-m32r/thread_info.h 
---  clean/include/asm-m32r/thread_info.h~unify-alloc-thread-info	2006-08-23 15:44:38.000000000 -0700 
+++ clean-dave/include/asm-m32r/thread_info.h	2006-08-23 15:44:51.000000000 -0700 
@@ -94,23 +94,6 @@ static inline struct thread_info *curren 
 	return ti; 
 } 
  
-/* 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) 
- 
 #define TI_FLAG_FAULT_CODE_SHIFT	28 
  
 static inline void set_thread_fault_code(unsigned int val) 
diff -puN include/asm-m68k/thread_info.h~unify-alloc-thread-info include/asm-m68k/thread_info.h 
---  clean/include/asm-m68k/thread_info.h~unify-alloc-thread-info	2006-08-23 15:44:52.000000000 -0700 
+++ clean-dave/include/asm-m68k/thread_info.h	2006-08-23 15:45:32.000000000 -0700 
@@ -24,14 +24,7 @@ struct thread_info { 
 	},					\ 
 } 
  
-/* THREAD_SIZE should be 8k, so handle differently for 4k and 8k machines */ 
-#if PAGE_SHIFT == 13 /* 8k machines */ 
-#define alloc_thread_info(tsk)   ((struct thread_info *)__get_free_pages(GFP_KERNEL,0)) 
-#define free_thread_info(ti)  free_pages((unsigned long)(ti),0) 
-#else /* otherwise assume 4k pages */ 
-#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) 
-#endif /* PAGE_SHIFT == 13 */ 
+#define THREAD_SHIFT	1 
  
 #define init_thread_info	(init_task.thread.info) 
 #define init_stack		(init_thread_union.stack) 
diff -puN include/asm-powerpc/thread_info.h~unify-alloc-thread-info include/asm-powerpc/thread_info.h 
---  clean/include/asm-powerpc/thread_info.h~unify-alloc-thread-i nfo	2006-08-07 12:21:11.000000000 -0700 
+++ clean-dave/include/asm-powerpc/thread_info.h	2006-08-23 15:48:09.000000000 -0700 
@@ -62,33 +62,6 @@ struct thread_info { 
 #define init_thread_info	(init_thread_union.thread_info) 
 #define init_stack		(init_thread_union.stack) 
  
-/* thread information allocation */ 
- 
-#if THREAD_SHIFT >= 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 <linux/cn_proc.h> 
 #include <linux/delayacct.h> 
 #include <linux/taskstats_kern.h> 
+#include <linux/thread_alloc.h> 
  
 #include <asm/pgtable.h> 
 #include <asm/pgalloc.h> 
_
...
  
		
		
		
 |  
	| 
		
	 | 
 
 
 |  
  
 
	
	  | 
	 | 
	
		[PATCH] BC: resource beancounters (v2)
		By:  dev on Wed, 23 August 2006 10:44  
	 | 
 
	  | 
	 | 
	
		[PATCH 1/6] BC: kconfig
		By:  dev on Wed, 23 August 2006 10:59  
	 | 
 
	  | 
	 | 
	
		Re: [PATCH 1/6] BC: kconfig
		
	 | 
 
	  | 
	 | 
	
		Re:  [PATCH 1/6] BC: kconfig
		
	 | 
 
	  | 
	 | 
	
		Re:  [PATCH 1/6] BC: kconfig
		
	 | 
 
	  | 
	 | 
	
		Re:  [PATCH 1/6] BC: kconfig
		By:  dev on Fri, 25 August 2006 11:27  
	 | 
 
	  | 
	 | 
	
		Re:  [PATCH 1/6] BC: kconfig
		By:  dev on Fri, 25 August 2006 11:31  
	 | 
 
	  | 
	 | 
	
		Re:  [PATCH 1/6] BC: kconfig
		By:  rdunlap on Wed, 23 August 2006 22:29  
	 | 
 
	  | 
	 | 
	
		Re:  [PATCH 1/6] BC: kconfig
		
	 | 
 
	  | 
	 | 
	
		Re: [PATCH 1/6] BC: kconfig
		
	 | 
 
	  | 
	 | 
	
		Re: [ckrm-tech] [PATCH 1/6] BC: kconfig
		By:  dev on Thu, 24 August 2006 11:47  
	 | 
 
	  | 
	 | 
	
		Re: [ckrm-tech] [PATCH 1/6] BC: kconfig
		
	 | 
 
	  | 
	 | 
	
		[PATCH 2/6] BC: beancounters core (API)
		By:  dev on Wed, 23 August 2006 11:00  
	 | 
 
	  | 
	 | 
	
		Re: [PATCH 2/6] BC: beancounters core (API)
		
	 | 
 
	  | 
	 | 
	
		Re: [PATCH 2/6] BC: beancounters core (API)
		By:  dev on Wed, 23 August 2006 13:25  
	 | 
 
	  | 
	 | 
	
		Re: [PATCH 2/6] BC: beancounters core (API)
		
	 | 
 
	  | 
	 | 
	
		Re: [PATCH 2/6] BC: beancounters core (API)
		By:  dev on Wed, 23 August 2006 13:46  
	 | 
 
	  | 
	 | 
	
		Re: [PATCH 2/6] BC: beancounters core (API)
		
	 | 
 
	  | 
	 | 
	
		Re: [PATCH 2/6] BC: beancounters core (API)
		
	 | 
 
	  | 
	 | 
	
		Re: [PATCH 2/6] BC: beancounters core (API)
		
	 | 
 
	  | 
	 | 
	
		Re: [PATCH 2/6] BC: beancounters core (API)
		
	 | 
 
	  | 
	 | 
	
		Re: [PATCH 2/6] BC: beancounters core (API)
		
	 | 
 
	  | 
	 | 
	
		Re: [PATCH 2/6] BC: beancounters core (API)
		By:  dev on Thu, 24 August 2006 12:03  
	 | 
 
	  | 
	 | 
	
		Re: [PATCH 2/6] BC: beancounters core (API)
		
	 | 
 
	  | 
	 | 
	
		Re: [PATCH 2/6] BC: beancounters core (API)
		By:  dev on Fri, 25 August 2006 10:51  
	 | 
 
	  | 
	 | 
	
		Re: [PATCH 2/6] BC: beancounters core (API)
		
	 | 
 
	  | 
	 | 
	
		[PATCH 3/6] BC: context inheriting and changing
		By:  dev on Wed, 23 August 2006 11:02  
	 | 
 
	  | 
	 | 
	
		[PATCH 4/6] BC: user interface (syscalls)
		By:  dev on Wed, 23 August 2006 11:03  
	 | 
 
	  | 
	 | 
	
		Re: [PATCH 4/6] BC: user interface (syscalls)
		By:  dev on Wed, 23 August 2006 13:40  
	 | 
 
	  | 
	 | 
	
		Re: [PATCH 4/6] BC: user interface (syscalls)
		
	 | 
 
	  | 
	 | 
	
		Re: [PATCH 4/6] BC: user interface (syscalls)
		By:  Alan Cox on Wed, 23 August 2006 17:08  
	 | 
 
	  | 
	 | 
	
		Re: [PATCH 4/6] BC: user interface (syscalls)
		
	 | 
 
	  | 
	 | 
	
		Re: [PATCH 4/6] BC: user interface (syscalls)
		By:  Alan Cox on Thu, 24 August 2006 10:42  
	 | 
 
	  | 
	 | 
	
		Re: [PATCH 4/6] BC: user interface (syscalls)
		
	 | 
 
	  | 
	 | 
	
		Re: [PATCH 4/6] BC: user interface (syscalls)
		By:  dev on Fri, 25 August 2006 10:54  
	 | 
 
	  | 
	 | 
	
		Re: [PATCH 4/6] BC: user interface (syscalls)
		
	 | 
 
	  | 
	 | 
	
		Re: [PATCH 4/6] BC: user interface (syscalls)
		
	 | 
 
	  | 
	 | 
	
		[PATCH 5/6] BC: kernel memory accounting (core)
		By:  dev on Wed, 23 August 2006 11:04  
	 | 
 
	  | 
	 | 
	
		Re: [PATCH 5/6] BC: kernel memory accounting (core)
		
	 | 
 
	  | 
	 | 
	
		Re: [PATCH 5/6] BC: kernel memory accounting (core)
		
	 | 
 
	  | 
	 | 
	
		Re: [PATCH 5/6] BC: kernel memory accounting (core)
		By:  dev on Fri, 25 August 2006 10:06  
	 | 
 
	  | 
	 | 
	
		[PATCH 6/6] BC: kernel memory accounting (marks)
		By:  dev on Wed, 23 August 2006 11:05  
	 | 
 
	  | 
	 | 
	
		Re:  [PATCH 6/6] BC: kernel memory accounting (marks)
		
	 | 
 
	  | 
	 | 
	
		Re:  [PATCH 6/6] BC: kernel memory accounting (marks)
		By:  dev on Tue, 29 August 2006 09:52  
	 | 
 
	  | 
	 | 
	
		Re:  [PATCH 6/6] BC: kernel memory accounting (marks)
		
	 | 
 
	  | 
	 | 
	
		Re:  [PATCH 6/6] BC: kernel memory accounting (marks)
		
	 | 
 
	  | 
	 | 
	
		Re:  [PATCH 6/6] BC: kernel memory accounting (marks)
		
	 | 
 
	  | 
	 | 
	
		Re:  [PATCH 6/6] BC: kernel memory accounting (marks)
		
	 | 
 
	  | 
	 | 
	
		Re:  [PATCH 6/6] BC: kernel memory accounting (marks)
		By:  dev on Tue, 29 August 2006 14:34  
	 | 
 
	  | 
	 | 
	
		Re:  [PATCH 6/6] BC: kernel memory accounting (marks)
		By:  dev on Tue, 29 August 2006 15:53  
	 | 
 
	  | 
	 | 
	
		Re: [PATCH] BC: resource beancounters (v2)
		
	 | 
 
	  | 
	 | 
	
		Re: [PATCH] BC: resource beancounters (v2)
		
	 | 
 
	  | 
	 | 
	
		Re: [PATCH] BC: resource beancounters (v2)
		By:  dev on Fri, 25 August 2006 11:47  
	 | 
 
	  | 
	 | 
	
		Re: [PATCH] BC: resource beancounters (v2)
		
	 | 
 
	  | 
	 | 
	
		Re: [PATCH] BC: resource beancounters (v2)
		
	 | 
 
	  | 
	 | 
	
		Re: [PATCH] BC: resource beancounters (v2)
		By:  dev on Mon, 28 August 2006 08:27  
	 | 
 
	  | 
	 | 
	
		Re: [PATCH] BC: resource beancounters (v2)
		
	 | 
 
	  | 
	 | 
	
		Re: BC: resource beancounters (v2)
		
	 | 
 
	  | 
	 | 
	
		Re: BC: resource beancounters (v2)
		
	 | 
 
	  | 
	 | 
	
		Re: BC: resource beancounters (v2)
		
	 | 
 
	  | 
	 | 
	
		Re: BC: resource beancounters (v2)
		
	 | 
 
	  | 
	 | 
	
		Re: BC: resource beancounters (v2)
		By:  Alan Cox on Sat, 26 August 2006 16:16  
	 | 
 
	  | 
	 | 
	
		Re: BC: resource beancounters (v2)
		
	 | 
 
	  | 
	 | 
	
		Re:  Re: BC: resource beancounters (v2)
		By:  kir on Mon, 28 August 2006 17:40  
	 | 
 
	  | 
	 | 
	
		Re:  Re: BC: resource beancounters (v2)
		
	 | 
 
	  | 
	 | 
	
		Re:  Re: BC: resource beancounters (v2)
		By:  Alan Cox on Tue, 29 August 2006 10:15  
	 | 
 
	  | 
	 | 
	
		Re:  Re: BC: resource beancounters (v2)
		
	 | 
 
	  | 
	 | 
	
		Re:  Re: BC: resource beancounters (v2)
		By:  Alan Cox on Tue, 29 August 2006 18:46  
	 | 
 
	  | 
	 | 
	
		Re:  Re: BC: resource beancounters (v2)
		
	 | 
 
	  | 
	 | 
	
		Re: [PATCH] BC: resource beancounters (v2)
		By:  dev on Tue, 29 August 2006 15:33  
	 | 
 
	  | 
	 | 
	
		Re: [PATCH] BC: resource beancounters (v2)
		
	 | 
 
	  | 
	 | 
	
		Re: [PATCH] BC: resource beancounters (v2)
		
	 | 
 
	  | 
	 | 
	
		Re: [PATCH] BC: resource beancounters (v2)
		
	 | 
 
	  | 
	 | 
	
		Re: [PATCH] BC: resource beancounters (v2)
		By:  Alan Cox on Thu, 24 August 2006 10:38  
	 | 
 
	  | 
	 | 
	
		Re: [PATCH] BC: resource beancounters (v2)
		By:  Alan Cox on Fri, 25 August 2006 15:36  
	 | 
 
	  | 
	 | 
	
		Re: [PATCH] BC: resource beancounters (v2)
		
	 | 
  
Goto Forum:
 
 Current Time: Tue Nov 04 02:08:03 GMT 2025 
 Total time taken to generate the page: 0.22083 seconds 
 |