Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 286605
b: refs/heads/master
c: 8504657
h: refs/heads/master
i:
  286603: e7a8d63
v: v3
  • Loading branch information
Hugh Dickins authored and Linus Torvalds committed Jan 23, 2012
1 parent f515a40 commit bb20f40
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 24 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: cb78edfdcef5259ac9e9088bd63810d21299928d
refs/heads/master: 85046579bde15e532983438f86b36856e358f417
37 changes: 22 additions & 15 deletions trunk/ipc/shm.c
Original file line number Diff line number Diff line change
Expand Up @@ -870,9 +870,7 @@ SYSCALL_DEFINE3(shmctl, int, shmid, int, cmd, struct shmid_ds __user *, buf)
case SHM_LOCK:
case SHM_UNLOCK:
{
struct file *uninitialized_var(shm_file);

lru_add_drain_all(); /* drain pagevecs to lru lists */
struct file *shm_file;

shp = shm_lock_check(ns, shmid);
if (IS_ERR(shp)) {
Expand All @@ -895,22 +893,31 @@ SYSCALL_DEFINE3(shmctl, int, shmid, int, cmd, struct shmid_ds __user *, buf)
err = security_shm_shmctl(shp, cmd);
if (err)
goto out_unlock;

if(cmd==SHM_LOCK) {

shm_file = shp->shm_file;
if (is_file_hugepages(shm_file))
goto out_unlock;

if (cmd == SHM_LOCK) {
struct user_struct *user = current_user();
if (!is_file_hugepages(shp->shm_file)) {
err = shmem_lock(shp->shm_file, 1, user);
if (!err && !(shp->shm_perm.mode & SHM_LOCKED)){
shp->shm_perm.mode |= SHM_LOCKED;
shp->mlock_user = user;
}
err = shmem_lock(shm_file, 1, user);
if (!err && !(shp->shm_perm.mode & SHM_LOCKED)) {
shp->shm_perm.mode |= SHM_LOCKED;
shp->mlock_user = user;
}
} else if (!is_file_hugepages(shp->shm_file)) {
shmem_lock(shp->shm_file, 0, shp->mlock_user);
shp->shm_perm.mode &= ~SHM_LOCKED;
shp->mlock_user = NULL;
goto out_unlock;
}

/* SHM_UNLOCK */
if (!(shp->shm_perm.mode & SHM_LOCKED))
goto out_unlock;
shmem_lock(shm_file, 0, shp->mlock_user);
shp->shm_perm.mode &= ~SHM_LOCKED;
shp->mlock_user = NULL;
get_file(shm_file);
shm_unlock(shp);
scan_mapping_unevictable_pages(shm_file->f_mapping);
fput(shm_file);
goto out;
}
case IPC_RMID:
Expand Down
7 changes: 0 additions & 7 deletions trunk/mm/shmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -1068,13 +1068,6 @@ int shmem_lock(struct file *file, int lock, struct user_struct *user)
user_shm_unlock(inode->i_size, user);
info->flags &= ~VM_LOCKED;
mapping_clear_unevictable(file->f_mapping);
/*
* Ensure that a racing putback_lru_page() can see
* the pages of this mapping are evictable when we
* skip them due to !PageLRU during the scan.
*/
smp_mb__after_clear_bit();
scan_mapping_unevictable_pages(file->f_mapping);
}
retval = 0;

Expand Down
12 changes: 11 additions & 1 deletion trunk/mm/vmscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -3499,6 +3499,7 @@ int page_evictable(struct page *page, struct vm_area_struct *vma)
return 1;
}

#ifdef CONFIG_SHMEM
/**
* check_move_unevictable_page - check page for evictability and move to appropriate zone lru list
* @page: page to check evictability and move to appropriate lru list
Expand All @@ -3509,6 +3510,8 @@ int page_evictable(struct page *page, struct vm_area_struct *vma)
*
* Restrictions: zone->lru_lock must be held, page must be on LRU and must
* have PageUnevictable set.
*
* This function is only used for SysV IPC SHM_UNLOCK.
*/
static void check_move_unevictable_page(struct page *page, struct zone *zone)
{
Expand Down Expand Up @@ -3545,6 +3548,8 @@ static void check_move_unevictable_page(struct page *page, struct zone *zone)
*
* Scan all pages in mapping. Check unevictable pages for
* evictability and move them to the appropriate zone lru list.
*
* This function is only used for SysV IPC SHM_UNLOCK.
*/
void scan_mapping_unevictable_pages(struct address_space *mapping)
{
Expand Down Expand Up @@ -3590,9 +3595,14 @@ void scan_mapping_unevictable_pages(struct address_space *mapping)
pagevec_release(&pvec);

count_vm_events(UNEVICTABLE_PGSCANNED, pg_scanned);
cond_resched();
}

}
#else
void scan_mapping_unevictable_pages(struct address_space *mapping)
{
}
#endif /* CONFIG_SHMEM */

static void warn_scan_unevictable_pages(void)
{
Expand Down

0 comments on commit bb20f40

Please sign in to comment.