introduce TASK_SIZE_OF() for all arches
Subsystems (2)
RFC PATCH 1/1 introduce TASK_SIZE_OF() for all arches
For the /proc/<pid>/pagemap code[1], we need to able to query how much virtual address space a particular task has. The trick is that we do it through /proc and can't use TASK_SIZE since it references "current" on some arches. The process opening the /proc file might be a 32-bit process opening a 64-bit process's pagemap file.
x86_64 already has a TASK_SIZE_OF() macro:
#define TASK_SIZE_OF(child) ((test_tsk_thread_flag(child, TIF_IA32)) ? IA32_PAGE_OFFSET : TASK_SIZE64)
I'd like to have that for other architectures. So, add it for all the architectures that actually use "current" in their TASK_SIZE. For the others, just add a quick #define in sched.h to use plain old TASK_SIZE.
1. http://www.linuxworld.com/news/2007/042407-kernel.html
---
lxc-dave/include/asm-ia64/processor.h | 3 ++- lxc-dave/include/asm-parisc/processor.h | 3 ++- lxc-dave/include/asm-powerpc/processor.h | 4 +++- lxc-dave/include/asm-s390/processor.h | 2 ++ lxc-dave/include/linux/sched.h | 4 ++++ 5 files changed, 13 insertions(+), 3 deletions(-)
include/asm-ia64/processor.h renamed from include/asm-ia64/processor.h~task_size_of +2 -1
@@ -31,7 +31,8 @@* each (assuming 8KB page size), for a total of 8TB of user virtual * address space. */ -#define TASK_SIZE (current->thread.task_size) +#define TASK_SIZE_OF (tsk) ((tsk)->thread.task_size) +#define TASK_SIZE TASK_SIZE_OF(current)/* * This decides where the kernel will search for a free chunk of vm
include/asm-parisc/processor.h renamed from include/asm-parisc/processor.h~task_size_of +2 -1
@@ -32,7 +32,8 @@#endif #define current_text_addr () ({ void *pc; current_ia(pc); pc; }) -#define TASK_SIZE (current->thread.task_size) +#define TASK_SIZE_OF (tsk) ((tsk)->thread.task_size) +#define TASK_SIZE (current->thread.task_size)#define TASK_UNMAPPED_BASE (current->thread.map_base)#define DEFAULT_TASK_SIZE32 (0xFFF00000UL)
include/asm-powerpc/processor.h renamed from include/asm-powerpc/processor.h~task_size_of +3 -1
@@ -107,7 +107,9 @@ extern struct task_struct *last_task_use*/ #define TASK_SIZE_USER32 (0x0000000100000000UL - (1*PAGE_SIZE)) -#define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \ +#define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \ + TASK_SIZE_USER32 : TASK_SIZE_USER64) +#define TASK_SIZE_OF (tsk) (test_tsk_thread_flag(tsk, TIF_32BIT) ? \ TASK_SIZE_USER32 : TASK_SIZE_USER64)/* This decides where the kernel will search for a free chunk of vm
include/asm-s390/processor.h renamed from include/asm-s390/processor.h~task_size_of +2 -0
@@ -75,6 +75,8 @@ extern struct task_struct *last_task_use# define TASK_SIZE (test_thread_flag(TIF_31BIT) ? \ (0x80000000UL) : (0x40000000000UL)) +# define TASK_SIZE_OF (tsk) (test_tsk_thread_flag(tsk, TIF_31BIT) ? \ + (0x80000000UL) : (0x40000000000UL))# define TASK_UNMAPPED_BASE (TASK_SIZE / 2)# define DEFAULT_TASK_SIZE (0x40000000000UL)
include/linux/sched.h renamed from include/linux/sched.h~task_size_of +4 -0
@@ -1712,6 +1712,10 @@ static inline void inc_syscw(struct task }#endif +#ifndef TASK_SIZE_OF +#define TASK_SIZE_OF (tsk) TASK_SIZE +#endif +#endif /* __KERNEL__ */ #endif
_
Quoted 4 lines · Dave Hansen
I'd like to have that for other architectures. So, add it for all the architectures that actually use "current" in their
TASK_SIZE. For the others, just add a quick #define insched.hto use plain oldTASK_SIZE.
MIPS seems to do things a little differently ... Ralf, what should Dave be doing here?
#define TASK_SIZE32 0x7fff8000UL
#define TASK_SIZE 0x10000000000UL
Signature · 3 lines
"Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."
Quoted 11 lines · Matthew Wilcox
Quoted 4 lines · Dave Hansen
I'd like to have that for other architectures. So, add it for all the architectures that actually use "current" in their
TASK_SIZE. For the others, just add a quick #define insched.hto use plain oldTASK_SIZE.MIPS seems to do things a little differently ... Ralf, what should Dave be doing here?
#define
TASK_SIZE320x7fff8000UL
#defineTASK_SIZE0x10000000000UL
Indeed. Below patch should do the trick.
Ralf
include/asm-mips/processor.h +4 -0
@@ -45,6 +45,8 @@ extern unsigned int vced_count, vcei_count;* space during mmap's. */ #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3)) +#define TASK_SIZE_OF (tsk) \ + (test_thread_flag(TIF_32BIT_ADDR) ? TASK_SIZE32 : TASK_SIZE)#endif #ifdef CONFIG_64BIT
@@ -65,6 +67,8 @@ extern unsigned int vced_count, vcei_count;#define TASK_UNMAPPED_BASE \ (test_thread_flag(TIF_32BIT_ADDR) ? \ PAGE_ALIGN(TASK_SIZE32 / 3) : PAGE_ALIGN(TASK_SIZE / 3)) +#define TASK_SIZE_OF (tsk) \ + (test_thread_flag(TIF_32BIT_ADDR) ? TASK_SIZE32 : TASK_SIZE)#endif #define NUM_FPU_REGS 32
Quoted 8 lines · Ralf Baechle
Quoted 6 lines · Matthew Wilcox
Quoted 4 lines · Dave Hansen
I'd like to have that for other architectures. So, add it for all the architectures that actually use "current" in their
TASK_SIZE. For the others, just add a quick #define insched.hto use plain oldTASK_SIZE.
Quoted 7 lines
Quoted 5 lines
MIPS seems to do things a little differently ... Ralf, what should Dave be doing here?
#define
TASK_SIZE320x7fff8000UL
#defineTASK_SIZE0x10000000000ULIndeed. Below patch should do the trick.
Thanks for the patch. I'll roll it into my larger one.
-- Dave
Quoted 2 lines · Dave Hansen
For the /proc/<pid>/pagemap code[1], we need to able to query how much virtual address space a particular task has.
How does this relate to NOMMU conditions?
David
Quoted 6 lines · David Howells
Quoted 2 lines · Dave Hansen
For the /proc/<pid>/pagemap code[1], we need to able to query how much virtual address space a particular task has.
How does this relate to NOMMU conditions?
It probably doesn't make any sense to use the /proc/<pid>/pagemap feature on NOMMU systems. There are no pagetables to dump, and no shared pages, right?
-- Dave
Quoted 11 lines · Dave Hansen
Quoted 6 lines · David Howells
Quoted 2 lines · Dave Hansen
For the /proc/<pid>/pagemap code[1], we need to able to query how much virtual address space a particular task has.
How does this relate to NOMMU conditions?
It probably doesn't make any sense to use the /proc/<pid>/pagemap feature on NOMMU systems. There are no pagetables to dump, and no shared pages, right?
Nor is there any present/not present to report. VSS == RSS on NOMMU, right?
So we could provide pagemap, but it's not clear it'd be very interesting. kpagemap might be interesting, simply because of the flags though.
Signature · 1 line
Mathematics is the supreme nostalgia of our time.
Quoted 5 lines · David Howells
Quoted 2 lines · Dave Hansen
For the /proc/<pid>/pagemap code[1], we need to able to query how much virtual address space a particular task has.
How does this relate to NOMMU conditions?
Were you asking about /proc/<pid>/pagemap, or about my TASK_SIZE_OF() macro?
/proc/<pid>/pagemap is completely implemented in task_mmu.c, so it shouldn't show up on NOMMU systems.
As far as TASK_SIZE_OF(), it still makes sense on those systems because they (at least m68k) still has TASK_SIZE. Was there a particular problem you're concerned about? I'm not very intimately familiar with the NOMMU code.
-- Dave
Quoted 2 lines · Dave Hansen
Were you asking about /proc/<pid>/pagemap, or about my
TASK_SIZE_OF()macro?
TASK_SIZE_OF().
Quoted 2 lines
As far as
TASK_SIZE_OF(), it still makes sense on those systems because they (at least m68k) still hasTASK_SIZE.
Fair enough.
Quoted 2 lines
Was there a particular problem you're concerned about? I'm not very intimately familiar with the NOMMU code.
Since you were talking about virtual memory, I was wondering as to its applicability for NOMMU.
David