#ifndef __KSM_H #define __KSM_H #include #include #include #include #include /* this should really go to linux/miscdevice.h */ #define KSM_MINOR 233 #define KSM_MAX_SMAS 256 #define SharedPage 1 struct ksm_mem_slot { struct list_head link; struct list_head sma_link; struct mm_struct *mm; unsigned long addr; /* the begining of the virtual address */ unsigned int npages; /* number of pages to share */ }; /* * sma - shared memory area, each process have its own sma that contain the * information about the slots that it own */ struct ksm_sma { struct list_head sma_slots; }; struct ksm { struct list_head slots; struct rw_semaphore slots_lock; int npages_hash; struct hlist_head *page_hash; int nrmaps_hash; struct hlist_head *rmap_hash; struct kmem_cache *page_item_cache; struct kmem_cache *rmap_item_cache; struct address_space address_space; spinlock_t hash_lock; }; struct ksm_scan { struct ksm_mem_slot *slot_index; /* the slot we are scanning now */ int page_index; /* the page inside sma that is now being scanned */ }; struct page_item { struct hlist_node link; struct mm_struct *mm; unsigned long addr; }; struct rmap_item { struct hlist_node link; struct page_item *page_item; unsigned long oldindex; }; #endif