Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 83047
b: refs/heads/master
c: c4cc6d0
h: refs/heads/master
i:
  83045: 2eb1200
  83043: d2b05e4
  83039: ffea3e8
v: v3
  • Loading branch information
Hugh Dickins authored and Linus Torvalds committed Feb 5, 2008
1 parent effe7c3 commit be435b4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 65 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: 75897d60a54ccee94253312107f941a83b5077cb
refs/heads/master: c4cc6d07b2f465fbf5efd99bbe772a49c515f3f2
47 changes: 14 additions & 33 deletions trunk/mm/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -1998,45 +1998,26 @@ int vmtruncate_range(struct inode *inode, loff_t offset, loff_t end)
*/
void swapin_readahead(swp_entry_t entry, unsigned long addr,struct vm_area_struct *vma)
{
#ifdef CONFIG_NUMA
struct vm_area_struct *next_vma = vma ? vma->vm_next : NULL;
#endif
int i, num;
struct page *new_page;
int nr_pages;
struct page *page;
unsigned long offset;
unsigned long end_offset;

/*
* Get the number of handles we should do readahead io to.
* Get starting offset for readaround, and number of pages to read.
* Adjust starting address by readbehind (for NUMA interleave case)?
* No, it's very unlikely that swap layout would follow vma layout,
* more likely that neighbouring swap pages came from the same node:
* so use the same "addr" to choose the same node for each swap read.
*/
num = valid_swaphandles(entry, &offset);
for (i = 0; i < num; offset++, i++) {
nr_pages = valid_swaphandles(entry, &offset);
for (end_offset = offset + nr_pages; offset < end_offset; offset++) {
/* Ok, do the async read-ahead now */
new_page = read_swap_cache_async(swp_entry(swp_type(entry),
offset), vma, addr);
if (!new_page)
page = read_swap_cache_async(swp_entry(swp_type(entry), offset),
vma, addr);
if (!page)
break;
page_cache_release(new_page);
#ifdef CONFIG_NUMA
/*
* Find the next applicable VMA for the NUMA policy.
*/
addr += PAGE_SIZE;
if (addr == 0)
vma = NULL;
if (vma) {
if (addr >= vma->vm_end) {
vma = next_vma;
next_vma = vma ? vma->vm_next : NULL;
}
if (vma && addr < vma->vm_start)
vma = NULL;
} else {
if (next_vma && addr >= next_vma->vm_start) {
vma = next_vma;
next_vma = vma->vm_next;
}
}
#endif
page_cache_release(page);
}
lru_add_drain(); /* Push any new pages onto the LRU now */
}
Expand Down
43 changes: 12 additions & 31 deletions trunk/mm/shmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -1025,53 +1025,34 @@ static inline int shmem_parse_mpol(char *value, int *policy, nodemask_t *policy_
return err;
}

static struct page *shmem_swapin_async(struct shared_policy *p,
static struct page *shmem_swapin(struct shmem_inode_info *info,
swp_entry_t entry, unsigned long idx)
{
struct page *page;
struct vm_area_struct pvma;
struct page *page;

/* Create a pseudo vma that just contains the policy */
memset(&pvma, 0, sizeof(struct vm_area_struct));
pvma.vm_end = PAGE_SIZE;
pvma.vm_start = 0;
pvma.vm_pgoff = idx;
pvma.vm_policy = mpol_shared_policy_lookup(p, idx);
pvma.vm_ops = NULL;
pvma.vm_policy = mpol_shared_policy_lookup(&info->policy, idx);
swapin_readahead(entry, 0, &pvma);
page = read_swap_cache_async(entry, &pvma, 0);
mpol_free(pvma.vm_policy);
return page;
}

static struct page *shmem_swapin(struct shmem_inode_info *info,
swp_entry_t entry, unsigned long idx)
{
struct shared_policy *p = &info->policy;
int i, num;
struct page *page;
unsigned long offset;

num = valid_swaphandles(entry, &offset);
for (i = 0; i < num; offset++, i++) {
page = shmem_swapin_async(p,
swp_entry(swp_type(entry), offset), idx);
if (!page)
break;
page_cache_release(page);
}
lru_add_drain(); /* Push any new pages onto the LRU now */
return shmem_swapin_async(p, entry, idx);
}

static struct page *
shmem_alloc_page(gfp_t gfp, struct shmem_inode_info *info,
unsigned long idx)
static struct page *shmem_alloc_page(gfp_t gfp, struct shmem_inode_info *info,
unsigned long idx)
{
struct vm_area_struct pvma;
struct page *page;

memset(&pvma, 0, sizeof(struct vm_area_struct));
pvma.vm_policy = mpol_shared_policy_lookup(&info->policy, idx);
/* Create a pseudo vma that just contains the policy */
pvma.vm_start = 0;
pvma.vm_pgoff = idx;
pvma.vm_end = PAGE_SIZE;
pvma.vm_ops = NULL;
pvma.vm_policy = mpol_shared_policy_lookup(&info->policy, idx);
page = alloc_page_vma(gfp, &pvma, 0);
mpol_free(pvma.vm_policy);
return page;
Expand Down

0 comments on commit be435b4

Please sign in to comment.