[lc-checkins] CVS: linux/include/linux comp_cache.h,1.42,1.43
Status: Beta
Brought to you by:
nitin_sf
From: Rodrigo S. de C. <rc...@us...> - 2002-01-24 22:05:07
|
Update of /cvsroot/linuxcompressed/linux/include/linux In directory usw-pr-cvs1:/tmp/cvs-serv7824/include/linux Modified Files: comp_cache.h Log Message: This patch include changes regarding the tlb and cache flushing when setting pte. It also fixes a stupid bug in vswap. - comp_cache_release() split into comp_cache_release() and comp_cache_use_address(). - comp_cache_use_address() now searches for the vma for the pte we are going to change. If found, we flush the cache and tlb for this pte before setting it. If not found, we count this reference for the swap count and when this pte faults in or gets freed, we fix the counters. - so we have to handle the cases in lookup_comp_cache() in which the pte gets changed when we sleep to get a new page. In this case, we check to see if the pte has changed. If it has, wow, it's time to return and waits it to fault in again, now with the real address. - to flush, some code was copied from rmap patch by Rik van Riel. He has the same problem and devised a nice way to decrease complexity when looking for the mm struct. - real_entry field was added back to vswap_address struct - fix a _stupid_ bug in vswap. The estimated_pages is a variable that avoids that we assign a huge number of vswaps which are reserved (vswap which is used but does not have a fragment, so we don't know how bit the fragment will be). This variable was supposed to have negative values, _but_ it was declared as unsigned long. :-( - (in this meanwhile I tried to add a referente to the swap count for our compressed fragment, but it turned out to perform not as well as the old code. I intended to remove that find_comp_page() and comp_cache_free() from comp_cache_release(), but that take less time to execute than some general idea, so I reverted the changes). Index: comp_cache.h =================================================================== RCS file: /cvsroot/linuxcompressed/linux/include/linux/comp_cache.h,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -r1.42 -r1.43 *** comp_cache.h 2002/01/16 16:30:11 1.42 --- comp_cache.h 2002/01/24 22:05:03 1.43 *************** *** 2,6 **** * linux/mm/comp_cache.h * ! * Time-stamp: <2002-01-14 16:42:11 rcastro> * * Linux Virtual Memory Compressed Cache --- 2,6 ---- * linux/mm/comp_cache.h * ! * Time-stamp: <2002-01-24 18:59:40 rcastro> * * Linux Virtual Memory Compressed Cache *************** *** 28,32 **** #include <linux/WKcommon.h> ! #define COMP_CACHE_VERSION "0.21pre7" /* maximum compressed size of a page */ --- 28,32 ---- #include <linux/WKcommon.h> ! #define COMP_CACHE_VERSION "0.21" /* maximum compressed size of a page */ *************** *** 87,106 **** /* adaptivity.c */ #ifdef CONFIG_COMP_CACHE - int shrink_comp_cache(comp_cache_t *); inline int grow_comp_cache(zone_t *, int); - #else ! ! static inline int shrink_comp_cache(comp_cache_t * comp_page) ! { ! return 0; ! } ! ! static inline int grow_comp_cache(zone_t * zone, int nr_pages) ! { ! return 0; ! } ! #endif --- 87,95 ---- /* adaptivity.c */ #ifdef CONFIG_COMP_CACHE int shrink_comp_cache(comp_cache_t *); inline int grow_comp_cache(zone_t *, int); #else ! static inline int shrink_comp_cache(comp_cache_t * comp_page) { return 0; } ! static inline int grow_comp_cache(zone_t * zone, int nr_pages) { return 0; } #endif *************** *** 340,347 **** #else extern int swap_writepage(struct page*); ! static inline int compress_page(struct page * page) ! { ! return swap_writepage(page); ! } static inline void comp_cache_init(void) {}; #endif --- 329,333 ---- #else extern int swap_writepage(struct page*); ! static inline int compress_page(struct page * page) { return swap_writepage(page); } static inline void comp_cache_init(void) {}; #endif *************** *** 355,358 **** --- 341,345 ---- comp_cache_fragment_t * fragment; + swp_entry_t real_entry; struct page * swap_cache_page; *************** *** 398,423 **** static inline void comp_cache_swp_duplicate(swp_entry_t entry) {}; ! static inline int comp_cache_swp_free_generic(swp_entry_t entry, int free_fragment) ! { ! return 0; ! } ! static inline int comp_cache_swp_count(swp_entry_t entry) ! { ! return 0; ! } ! static inline int comp_cache_available_space(void) ! { ! return 0; ! } ! static inline swp_entry_t get_virtual_swap_page(struct page * page, unsigned short count) ! { ! return ((swp_entry_t) { 0 }); ! } static inline void add_pte_vswap(pte_t * ptep, swp_entry_t entry) {}; static inline void remove_pte_vswap(pte_t * ptep) {}; static inline void add_swap_cache_page_vswap(struct page * page, swp_entry_t entry) {}; static inline void del_swap_cache_page_vswap(struct page * page) {}; - #endif --- 385,397 ---- static inline void comp_cache_swp_duplicate(swp_entry_t entry) {}; ! static inline int comp_cache_swp_free_generic(swp_entry_t entry, int free_fragment) { return 0; } ! static inline int comp_cache_swp_count(swp_entry_t entry) { return 0; } ! static inline int comp_cache_available_space(void) { return 0; } ! static inline swp_entry_t get_virtual_swap_page(struct page * page, unsigned short count) { return ((swp_entry_t) { 0 }); } static inline void add_pte_vswap(pte_t * ptep, swp_entry_t entry) {}; static inline void remove_pte_vswap(pte_t * ptep) {}; static inline void add_swap_cache_page_vswap(struct page * page, swp_entry_t entry) {}; static inline void del_swap_cache_page_vswap(struct page * page) {}; #endif *************** *** 426,434 **** int comp_cache_free_locked(comp_cache_fragment_t *); - #ifdef CONFIG_COMP_CACHE ! int comp_cache_release(swp_entry_t); #else ! static inline int comp_cache_release(swp_entry_t entry) { return 0; } #endif --- 400,448 ---- int comp_cache_free_locked(comp_cache_fragment_t *); #ifdef CONFIG_COMP_CACHE ! inline void comp_cache_release(swp_entry_t); ! int comp_cache_use_address(swp_entry_t); ! ! /* from Riel's rmap patch */ ! static inline void pgtable_add_rmap(pte_t * ptep, struct mm_struct * mm, unsigned long address) ! { ! struct page * page = virt_to_page(ptep); ! ! page->mapping = (void *)mm; ! page->index = address & ~((PTRS_PER_PTE * PAGE_SIZE) - 1); ! } ! ! static inline void pgtable_remove_rmap(pte_t * ptep) ! { ! struct page * page = virt_to_page(ptep); ! ! page->mapping = NULL; ! page->index = 0; ! } ! ! static inline struct mm_struct * ptep_to_mm(pte_t * ptep) ! { ! struct page * page = virt_to_page(ptep); ! ! return (struct mm_struct *) page->mapping; ! } ! ! static inline unsigned long ptep_to_address(pte_t * ptep) ! { ! struct page * page = virt_to_page(ptep); ! unsigned long low_bits; ! ! low_bits = ((unsigned long)ptep & ~PAGE_MASK) * PTRS_PER_PTE; ! return page->index + low_bits; ! } ! ! #else ! static inline int comp_cache_use_address(swp_entry_t entry) { return 0; } ! static inline void comp_cache_release(swp_entry_t entry) { }; ! static inline void pgtable_add_rmap(pte_t * ptep, struct mm_struct * mm, unsigned long address) { } ! static inline void pgtable_remove_rmap(pte_t * ptep) { } ! static inline struct mm_struct * ptep_to_mm(pte_t * ptep) { return 0; } ! static inline unsigned long ptep_to_address(pte_t * ptep) { return 0; } #endif *************** *** 477,488 **** inline int comp_cache_free_space(void); #else ! ! static inline int comp_cache_free_space(void) ! { ! return 0; ! } ! #endif - /* proc.c */ --- 491,496 ---- inline int comp_cache_free_space(void); #else ! static inline int comp_cache_free_space(void) { return 0; } #endif /* proc.c */ |