Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 281406
b: refs/heads/master
c: 33e8fc4
h: refs/heads/master
v: v3
  • Loading branch information
Colin Cross authored and Greg Kroah-Hartman committed Dec 21, 2011
1 parent f7b5578 commit 94d4de5
Show file tree
Hide file tree
Showing 2 changed files with 13 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: 5154b93b8eceb57bdab4e77030bf21ead15b42e4
refs/heads/master: 33e8fc463eeec29227282e4bd2082f5928d629a5
19 changes: 12 additions & 7 deletions trunk/drivers/staging/android/ashmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,14 +355,14 @@ static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)
* chunks of ashmem regions LRU-wise one-at-a-time until we hit 'nr_to_scan'
* pages freed.
*/
static int ashmem_shrink(struct shrinker *s, int nr_to_scan, gfp_t gfp_mask)
static int ashmem_shrink(struct shrinker *s, struct shrink_control *sc)
{
struct ashmem_range *range, *next;

/* We might recurse into filesystem code, so bail out if necessary */
if (nr_to_scan && !(gfp_mask & __GFP_FS))
if (sc->nr_to_scan && !(sc->gfp_mask & __GFP_FS))
return -1;
if (!nr_to_scan)
if (!sc->nr_to_scan)
return lru_count;

mutex_lock(&ashmem_mutex);
Expand All @@ -375,8 +375,8 @@ static int ashmem_shrink(struct shrinker *s, int nr_to_scan, gfp_t gfp_mask)
range->purged = ASHMEM_WAS_PURGED;
lru_del(range);

nr_to_scan -= range_size(range);
if (nr_to_scan <= 0)
sc->nr_to_scan -= range_size(range);
if (sc->nr_to_scan <= 0)
break;
}
mutex_unlock(&ashmem_mutex);
Expand Down Expand Up @@ -670,8 +670,13 @@ static long ashmem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
case ASHMEM_PURGE_ALL_CACHES:
ret = -EPERM;
if (capable(CAP_SYS_ADMIN)) {
ret = ashmem_shrink(&ashmem_shrinker, 0, GFP_KERNEL);
ashmem_shrink(&ashmem_shrinker, ret, GFP_KERNEL);
struct shrink_control sc = {
.gfp_mask = GFP_KERNEL,
.nr_to_scan = 0,
};
ret = ashmem_shrink(&ashmem_shrinker, &sc);
sc.nr_to_scan = ret;
ashmem_shrink(&ashmem_shrinker, &sc);
}
break;
}
Expand Down

0 comments on commit 94d4de5

Please sign in to comment.