Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 356567
b: refs/heads/master
c: ec8acf2
h: refs/heads/master
i:
  356565: 785f0f6
  356563: c3e752c
  356559: 4a0f780
v: v3
  • Loading branch information
Shaohua Li authored and Linus Torvalds committed Feb 24, 2013
1 parent 58036c8 commit 8fc864f
Show file tree
Hide file tree
Showing 9 changed files with 146 additions and 61 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 33806f06da654092182410d974b6d3c5396ea3eb
refs/heads/master: ec8acf20afb8534ed511f6613dd2226b9e301010
2 changes: 1 addition & 1 deletion trunk/arch/sparc/mm/init_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void show_mem(unsigned int filter)
printk("Mem-info:\n");
show_free_areas(filter);
printk("Free swap: %6ldkB\n",
nr_swap_pages << (PAGE_SHIFT-10));
get_nr_swap_pages() << (PAGE_SHIFT-10));
printk("%ld pages of RAM\n", totalram_pages);
printk("%ld free pages\n", nr_free_pages());
}
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/tile/mm/pgtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void show_mem(unsigned int filter)
global_page_state(NR_PAGETABLE),
global_page_state(NR_BOUNCE),
global_page_state(NR_FILE_PAGES),
nr_swap_pages);
get_nr_swap_pages());

for_each_zone(zone) {
unsigned long flags, order, total = 0, largest_order = -1;
Expand Down
32 changes: 27 additions & 5 deletions trunk/include/linux/swap.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,25 @@ struct swap_info_struct {
unsigned long *frontswap_map; /* frontswap in-use, one bit per page */
atomic_t frontswap_pages; /* frontswap pages in-use counter */
#endif
spinlock_t lock; /*
* protect map scan related fields like
* swap_map, lowest_bit, highest_bit,
* inuse_pages, cluster_next,
* cluster_nr, lowest_alloc and
* highest_alloc. other fields are only
* changed at swapon/swapoff, so are
* protected by swap_lock. changing
* flags need hold this lock and
* swap_lock. If both locks need hold,
* hold swap_lock first.
*/
};

struct swap_list_t {
int head; /* head of priority-ordered swapfile list */
int next; /* swapfile to be used next */
};

/* Swap 50% full? Release swapcache more aggressively.. */
#define vm_swap_full() (nr_swap_pages*2 < total_swap_pages)

/* linux/mm/page_alloc.c */
extern unsigned long totalram_pages;
extern unsigned long totalreserve_pages;
Expand Down Expand Up @@ -347,8 +356,20 @@ extern struct page *swapin_readahead(swp_entry_t, gfp_t,
struct vm_area_struct *vma, unsigned long addr);

/* linux/mm/swapfile.c */
extern long nr_swap_pages;
extern atomic_long_t nr_swap_pages;
extern long total_swap_pages;

/* Swap 50% full? Release swapcache more aggressively.. */
static inline bool vm_swap_full(void)
{
return atomic_long_read(&nr_swap_pages) * 2 < total_swap_pages;
}

static inline long get_nr_swap_pages(void)
{
return atomic_long_read(&nr_swap_pages);
}

extern void si_swapinfo(struct sysinfo *);
extern swp_entry_t get_swap_page(void);
extern swp_entry_t get_swap_page_of_type(int);
Expand Down Expand Up @@ -381,9 +402,10 @@ mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout)

#else /* CONFIG_SWAP */

#define nr_swap_pages 0L
#define get_nr_swap_pages() 0L
#define total_swap_pages 0L
#define total_swapcache_pages() 0UL
#define vm_swap_full() 0

#define si_swapinfo(val) \
do { (val)->freeswap = (val)->totalswap = 0; } while (0)
Expand Down
2 changes: 1 addition & 1 deletion trunk/mm/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin)
*/
free -= global_page_state(NR_SHMEM);

free += nr_swap_pages;
free += get_nr_swap_pages();

/*
* Any slabs which are created with the
Expand Down
2 changes: 1 addition & 1 deletion trunk/mm/nommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1907,7 +1907,7 @@ int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin)
*/
free -= global_page_state(NR_SHMEM);

free += nr_swap_pages;
free += get_nr_swap_pages();

/*
* Any slabs which are created with the
Expand Down
3 changes: 2 additions & 1 deletion trunk/mm/swap_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ void show_swap_cache_info(void)
printk("Swap cache stats: add %lu, delete %lu, find %lu/%lu\n",
swap_cache_info.add_total, swap_cache_info.del_total,
swap_cache_info.find_success, swap_cache_info.find_total);
printk("Free swap = %ldkB\n", nr_swap_pages << (PAGE_SHIFT - 10));
printk("Free swap = %ldkB\n",
get_nr_swap_pages() << (PAGE_SHIFT - 10));
printk("Total swap = %lukB\n", total_swap_pages << (PAGE_SHIFT - 10));
}

Expand Down
Loading

0 comments on commit 8fc864f

Please sign in to comment.