kshmem implementation, configuration and makefile
Subsystems (4)
PATCH 2/3 kshmem implementation, configuration and makefile
Signed-off-by Wink Saville <wink-hKg/[email protected]>
--- include/asm-x86_64/kshmem.h | 17 +++ include/linux/kshmem.h | 47 +++++++ include/linux/mm.h | 1 + include/linux/vmalloc.h | 3 + mm/Kconfig | 8 + mm/Makefile | 1 + mm/kshmem.c | 296 +++++++++++++++++++++++++++++++++++++++++++ mm/vmalloc.c | 37 +++++- 8 files changed, 406 insertions(+), 4 deletions(-)
create mode 100644 include/asm-x86_64/kshmem.h
create mode 100644 include/linux/kshmem.h
create mode 100644 mm/kshmem.c
include/asm-x86_64/kshmem.h new file +17 -0
@@ -0,0 +1,17 @@ +/** * Copyright (C) 2007 Saville Software, Inc. +* +* This code may be used for any purpose whatsoever, but +* no warranty of any kind is provided. +*/ + +#ifndef _ASM_KSHMEM_H +#define _ASM_KSHMEM_H + +#define KSHMEM_AREA_ADDR 0x6f8000000000 +#define KSHMEM_AREA_SIZE 0x008000000000 +#define KSHMEM_AREA_MASK (~(KSHMEM_AREA_SIZE-1)) + +#define KSHMEM_USER_DISABLE (x) __pgd(pgd_val(x) & ~_PAGE_USER) +#define KSHMEM_USER_ENABLE (x) __pgd(pgd_val(x) | _PAGE_USER) + +#endif
include/linux/kshmem.h new file +47 -0
47 lines not on this page · raw message
include/linux/mm.h +1 -0
@@ -169,6 +169,7 @@#define VM_MAPPED_COPY 0x01000000/* T if mapped copy of data (nommu mmap) */ #define VM_INSERTPAGE 0x02000000/* The vma has had "vm_insert_page()" done on it */ #define VM_ALWAYSDUMP 0x04000000/* Always include in core dumps */ +#define VM_KSHMEM 0x08000000/* Kernel shared memory */ #ifndef VM_STACK_DEFAULT_FLAGS /* arch can override this */ #define VM_STACK_DEFAULT_FLAGS VM_DATA_DEFAULT_FLAGS
include/linux/vmalloc.h +3 -0
@@ -42,6 +42,9 @@extern void *vmalloc_exec (unsigned long size);extern void *vmalloc_32 (unsigned long size);extern void *vmalloc_32_user (unsigned long size); +extern void *__vmalloc_at (unsigned long size,unsigned long flags, +unsigned long start,unsigned long end, +gfp_t gfp_mask,pgprot_t prot);extern void *__vmalloc (unsigned long size,gfp_t gfp_mask,pgprot_t prot);extern void *__vmalloc_area (struct vm_struct *area,gfp_t gfp_mask,pgprot_t prot);
mm/Kconfig +8 -0
@@ -163,3 +163,11 @@ default "0" if !ZONE_DMA default "1" +config KSHMEM + bool "Kernel shared memory" + def_bool n + help + Allows an area of memory to be shared between the kernel and + user space programs. For instance interrupt service routines + and user space programs may share the same memory. +
mm/Makefile +1 -0
@@ -29,3 +29,4 @@ obj-$(CONFIG_FS_XIP) += filemap_xip.o obj-$(CONFIG_MIGRATION) += migrate.o obj-$(CONFIG_SMP) += allocpercpu.o +obj-$(CONFIG_KSHMEM) += kshmem.o
mm/kshmem.c new file +296 -0
296 lines not on this page · raw message
mm/vmalloc.c +33 -4
@@ -469,8 +469,11 @@ }/** -* __vmalloc_node - allocate virtually contiguous memory +* __vmalloc_node_at - allocate virtually contiguous memory * @size: allocation size +* @flags: flags for vm area +* @start: desired starting location +* @end: desired ending location * @gfp_mask: flags for the page level allocator * @prot: protection mask for the allocated pages * @node: node to use for allocation or -1
@@ -479,8 +482,9 @@* allocator with @gfp_mask flags. Map them into contiguous * kernel virtual space, using a pagetable protection of @prot. */ -static void *__vmalloc_node (unsigned long size,gfp_t gfp_mask,pgprot_t prot, -int node) +static void *__vmalloc_node_at (unsigned long size,unsigned long flags, +unsigned long start,unsigned long end, +gfp_t gfp_mask,pgprot_t prot,int node) {struct vm_struct *area;
@@ -488,13 +492,38 @@if (!size || (size >>PAGE_SHIFT ) > num_physpages)return NULL ; - area =get_vm_area_node (size,VM_ALLOC , node, gfp_mask); + area =__get_vm_area_node (size, flags, start, end, node, gfp_mask);if (!area)return NULL ;return __vmalloc_area_node (area, gfp_mask, prot, node); } +void *__vmalloc_at (unsigned long size,unsigned long flags, +unsigned long start,unsigned long end, +gfp_t gfp_mask,pgprot_t prot) +{ +return __vmalloc_node_at (size, flags, start, end, gfp_mask, prot,-1 ); +} +EXPORT_SYMBOL (__vmalloc_at); + +/** +* __vmalloc_node - allocate virtually contiguous memory +* @size: allocation size +* @gfp_mask: flags for the page level allocator +* @prot: protection mask for the allocated pages +* @node: node to use for allocation or -1 +* +* Allocate enough pages to cover @size from the page level +* allocator with @gfp_mask flags. Map them into contiguous +* kernel virtual space, using a pagetable protection of @prot. +*/ +static void *__vmalloc_node (unsigned long size,gfp_t gfp_mask,pgprot_t prot, +int node) +{ +return __vmalloc_node_at (size,VM_ALLOC ,VMALLOC_START ,VMALLOC_END , gfp_mask, prot, node); +} +void *__vmalloc (unsigned long size,gfp_t gfp_mask,pgprot_t prot) {return __vmalloc_node (size, gfp_mask, prot,-1 );
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/