Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 176259
b: refs/heads/master
c: 8d69aae
h: refs/heads/master
i:
  176257: 06a9227
  176255: 5babe88
v: v3
  • Loading branch information
Hugh Dickins authored and Linus Torvalds committed Dec 15, 2009
1 parent 1c2b400 commit edc5721
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 22 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: 253d553ba75ab26b3e9e2f70cbf6fbf0813f7e86
refs/heads/master: 8d69aaee80c123b460918816cbfa2e83224c3646
8 changes: 4 additions & 4 deletions trunk/include/linux/swap.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ enum {

#define SWAP_CLUSTER_MAX 32

#define SWAP_MAP_MAX 0x7ffe
#define SWAP_MAP_BAD 0x7fff
#define SWAP_HAS_CACHE 0x8000 /* There is a swap cache of entry. */
#define SWAP_MAP_MAX 0x7e
#define SWAP_MAP_BAD 0x7f
#define SWAP_HAS_CACHE 0x80 /* There is a swap cache of entry. */

/*
* The in-memory structure used to track swap areas.
Expand All @@ -167,7 +167,7 @@ struct swap_info_struct {
struct block_device *bdev;
struct swap_extent first_swap_extent;
struct swap_extent *curr_swap_extent;
unsigned short *swap_map;
unsigned char *swap_map;
unsigned int lowest_bit;
unsigned int highest_bit;
unsigned int lowest_alloc; /* while preparing discard cluster */
Expand Down
40 changes: 23 additions & 17 deletions trunk/mm/swapfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static struct swap_info_struct *swap_info[MAX_SWAPFILES];

static DEFINE_MUTEX(swapon_mutex);

static inline int swap_count(unsigned short ent)
static inline unsigned char swap_count(unsigned char ent)
{
return ent & ~SWAP_HAS_CACHE;
}
Expand Down Expand Up @@ -203,7 +203,7 @@ static int wait_for_discard(void *word)
#define LATENCY_LIMIT 256

static inline unsigned long scan_swap_map(struct swap_info_struct *si,
unsigned short usage)
unsigned char usage)
{
unsigned long offset;
unsigned long scan_base;
Expand Down Expand Up @@ -531,12 +531,12 @@ static struct swap_info_struct *swap_info_get(swp_entry_t entry)
return NULL;
}

static unsigned short swap_entry_free(struct swap_info_struct *p,
swp_entry_t entry, unsigned short usage)
static unsigned char swap_entry_free(struct swap_info_struct *p,
swp_entry_t entry, unsigned char usage)
{
unsigned long offset = swp_offset(entry);
unsigned short count;
unsigned short has_cache;
unsigned char count;
unsigned char has_cache;

count = p->swap_map[offset];
has_cache = count & SWAP_HAS_CACHE;
Expand Down Expand Up @@ -591,7 +591,7 @@ void swap_free(swp_entry_t entry)
void swapcache_free(swp_entry_t entry, struct page *page)
{
struct swap_info_struct *p;
unsigned short count;
unsigned char count;

p = swap_info_get(entry);
if (p) {
Expand Down Expand Up @@ -975,7 +975,7 @@ static unsigned int find_next_to_unuse(struct swap_info_struct *si,
{
unsigned int max = si->max;
unsigned int i = prev;
int count;
unsigned char count;

/*
* No need for swap_lock here: we're just looking
Expand Down Expand Up @@ -1013,8 +1013,8 @@ static int try_to_unuse(unsigned int type)
{
struct swap_info_struct *si = swap_info[type];
struct mm_struct *start_mm;
unsigned short *swap_map;
unsigned short swcount;
unsigned char *swap_map;
unsigned char swcount;
struct page *page;
swp_entry_t entry;
unsigned int i = 0;
Expand Down Expand Up @@ -1174,6 +1174,12 @@ static int try_to_unuse(unsigned int type)
* If that's wrong, then we should worry more about
* exit_mmap() and do_munmap() cases described above:
* we might be resetting SWAP_MAP_MAX too early here.
*
* Yes, that's wrong: though very unlikely, swap count 0x7ffe
* could surely occur if pid_max raised from PID_MAX_DEFAULT;
* and we are now lowering SWAP_MAP_MAX to 0x7e, making it
* much easier to reach. But the next patch will fix that.
*
* We know "Undead"s can happen, they're okay, so don't
* report them; but do report if we reset SWAP_MAP_MAX.
*/
Expand Down Expand Up @@ -1492,7 +1498,7 @@ static int setup_swap_extents(struct swap_info_struct *sis, sector_t *span)
SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
{
struct swap_info_struct *p = NULL;
unsigned short *swap_map;
unsigned char *swap_map;
struct file *swap_file, *victim;
struct address_space *mapping;
struct inode *inode;
Expand Down Expand Up @@ -1762,7 +1768,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
sector_t span;
unsigned long maxpages = 1;
unsigned long swapfilepages;
unsigned short *swap_map = NULL;
unsigned char *swap_map = NULL;
struct page *page = NULL;
struct inode *inode = NULL;
int did_down = 0;
Expand Down Expand Up @@ -1938,13 +1944,13 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
goto bad_swap;

/* OK, set up the swap map and apply the bad block list */
swap_map = vmalloc(maxpages * sizeof(short));
swap_map = vmalloc(maxpages);
if (!swap_map) {
error = -ENOMEM;
goto bad_swap;
}

memset(swap_map, 0, maxpages * sizeof(short));
memset(swap_map, 0, maxpages);
for (i = 0; i < swap_header->info.nr_badpages; i++) {
int page_nr = swap_header->info.badpages[i];
if (page_nr <= 0 || page_nr >= swap_header->info.last_page) {
Expand Down Expand Up @@ -2082,12 +2088,12 @@ void si_swapinfo(struct sysinfo *val)
* - swap-cache reference is requested but there is already one. -> EEXIST
* - swap-cache reference is requested but the entry is not used. -> ENOENT
*/
static int __swap_duplicate(swp_entry_t entry, unsigned short usage)
static int __swap_duplicate(swp_entry_t entry, unsigned char usage)
{
struct swap_info_struct *p;
unsigned long offset, type;
unsigned short count;
unsigned short has_cache;
unsigned char count;
unsigned char has_cache;
int err = -EINVAL;

if (non_swap_entry(entry))
Expand Down

0 comments on commit edc5721

Please sign in to comment.