Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 83064
b: refs/heads/master
c: b409f9f
h: refs/heads/master
v: v3
  • Loading branch information
Hugh Dickins authored and Linus Torvalds committed Feb 5, 2008
1 parent 7913e91 commit 10ea818
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 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: 2e0e26c76a35de8f8bec6b2b917518cfeb52888a
refs/heads/master: b409f9fcf04692c0f603d28c73d2e3dfed27bf54
25 changes: 18 additions & 7 deletions trunk/mm/shmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -901,12 +901,16 @@ static int shmem_unuse_inode(struct shmem_inode_info *info, swp_entry_t entry, s
error = 1;
if (!inode)
goto out;
error = radix_tree_preload(GFP_KERNEL);
if (error)
goto out;
error = 1;

spin_lock(&info->lock);
ptr = shmem_swp_entry(info, idx, NULL);
if (ptr && ptr->val == entry.val)
error = add_to_page_cache(page, inode->i_mapping,
idx, GFP_ATOMIC);
idx, GFP_NOWAIT);
if (error == -EEXIST) {
struct page *filepage = find_get_page(inode->i_mapping, idx);
error = 1;
Expand All @@ -931,6 +935,7 @@ static int shmem_unuse_inode(struct shmem_inode_info *info, swp_entry_t entry, s
if (ptr)
shmem_swp_unmap(ptr);
spin_unlock(&info->lock);
radix_tree_preload_end();
out:
unlock_page(page);
page_cache_release(page);
Expand Down Expand Up @@ -1185,6 +1190,16 @@ static int shmem_getpage(struct inode *inode, unsigned long idx,
goto done;
error = 0;
gfp = mapping_gfp_mask(mapping);
if (!filepage) {
/*
* Try to preload while we can wait, to not make a habit of
* draining atomic reserves; but don't latch on to this cpu.
*/
error = radix_tree_preload(gfp & ~__GFP_HIGHMEM);
if (error)
goto failed;
radix_tree_preload_end();
}

spin_lock(&info->lock);
shmem_recalc_inode(inode);
Expand Down Expand Up @@ -1266,7 +1281,7 @@ static int shmem_getpage(struct inode *inode, unsigned long idx,
set_page_dirty(filepage);
swap_free(swap);
} else if (!(error = add_to_page_cache(
swappage, mapping, idx, GFP_ATOMIC))) {
swappage, mapping, idx, GFP_NOWAIT))) {
info->flags |= SHMEM_PAGEIN;
shmem_swp_set(info, entry, 0);
shmem_swp_unmap(entry);
Expand All @@ -1280,10 +1295,6 @@ static int shmem_getpage(struct inode *inode, unsigned long idx,
spin_unlock(&info->lock);
unlock_page(swappage);
page_cache_release(swappage);
if (error == -ENOMEM) {
/* let kswapd refresh zone for GFP_ATOMICs */
congestion_wait(WRITE, HZ/50);
}
goto repeat;
}
} else if (sgp == SGP_READ && !filepage) {
Expand Down Expand Up @@ -1338,7 +1349,7 @@ static int shmem_getpage(struct inode *inode, unsigned long idx,
shmem_swp_unmap(entry);
}
if (error || swap.val || 0 != add_to_page_cache_lru(
filepage, mapping, idx, GFP_ATOMIC)) {
filepage, mapping, idx, GFP_NOWAIT)) {
spin_unlock(&info->lock);
page_cache_release(filepage);
shmem_unacct_blocks(info->flags, 1);
Expand Down

0 comments on commit 10ea818

Please sign in to comment.