From patchwork Fri Dec 9 04:45:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 5547 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id CDF8D23E03 for ; Fri, 9 Dec 2011 04:45:52 +0000 (UTC) Received: from mail-bw0-f52.google.com (mail-bw0-f52.google.com [209.85.214.52]) by fiordland.canonical.com (Postfix) with ESMTP id BE084A1801B for ; Fri, 9 Dec 2011 04:45:52 +0000 (UTC) Received: by mail-bw0-f52.google.com with SMTP id 17so3421035bke.11 for ; Thu, 08 Dec 2011 20:45:52 -0800 (PST) Received: by 10.205.127.12 with SMTP id gy12mr2908327bkc.108.1323405952553; Thu, 08 Dec 2011 20:45:52 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.205.129.2 with SMTP id hg2cs106999bkc; Thu, 8 Dec 2011 20:45:52 -0800 (PST) Received: by 10.68.197.232 with SMTP id ix8mr2662222pbc.74.1323405950085; Thu, 08 Dec 2011 20:45:50 -0800 (PST) Received: from e9.ny.us.ibm.com (e9.ny.us.ibm.com. [32.97.182.139]) by mx.google.com with ESMTPS id e10si10464468pbv.240.2011.12.08.20.45.49 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 08 Dec 2011 20:45:50 -0800 (PST) Received-SPF: pass (google.com: domain of jstultz@us.ibm.com designates 32.97.182.139 as permitted sender) client-ip=32.97.182.139; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jstultz@us.ibm.com designates 32.97.182.139 as permitted sender) smtp.mail=jstultz@us.ibm.com Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 8 Dec 2011 23:45:48 -0500 Received: from d01relay04.pok.ibm.com (9.56.227.236) by e9.ny.us.ibm.com (192.168.1.109) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 8 Dec 2011 23:45:45 -0500 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pB94ji6o272146; Thu, 8 Dec 2011 23:45:44 -0500 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pB94jhuT026824; Thu, 8 Dec 2011 21:45:43 -0700 Received: from kernel.beaverton.ibm.com (kernel.beaverton.ibm.com [9.47.67.96]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id pB94jhpK026805; Thu, 8 Dec 2011 21:45:43 -0700 Received: by kernel.beaverton.ibm.com (Postfix, from userid 1056) id 7DCC01E7504; Thu, 8 Dec 2011 20:45:41 -0800 (PST) From: John Stultz To: Brian Swetland Cc: Colin Cross , Brian Swetland , =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Dima Zavin , Robert Love , Greg KH , John Stultz Subject: [PATCH 8/9] ashmem: Fix arguments to ashmem_shrink Date: Thu, 8 Dec 2011 20:45:07 -0800 Message-Id: <1323405908-26046-9-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.3.2.146.gca209 In-Reply-To: <1323405908-26046-1-git-send-email-john.stultz@linaro.org> References: <1323405908-26046-1-git-send-email-john.stultz@linaro.org> MIME-Version: 1.0 x-cbid: 11120904-7182-0000-0000-0000005D4FB1 From: Colin Cross The arguments to shrink functions have changed, update ashmem_shrink to match. Change-Id: Id279d22d761a2a7c4965c957960eef804d06cc07 Signed-off-by: Colin Cross [jstultz: tweaked commit subject] CC: Brian Swetland CC: Colin Cross CC: Arve Hjønnevåg CC: Dima Zavin CC: Robert Love CC: Greg KH Signed-off-by: John Stultz --- drivers/staging/android/ashmem.c | 19 ++++++++++++------- 1 files changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c index bbb61b7..33c6495 100644 --- a/drivers/staging/android/ashmem.c +++ b/drivers/staging/android/ashmem.c @@ -350,14 +350,14 @@ out: * 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); @@ -370,8 +370,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); @@ -665,8 +665,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; }