From patchwork Wed Dec 21 00:49:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 5914 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 BD66323E03 for ; Wed, 21 Dec 2011 00:50:52 +0000 (UTC) Received: from mail-ey0-f180.google.com (mail-ey0-f180.google.com [209.85.215.180]) by fiordland.canonical.com (Postfix) with ESMTP id AD38CA182A4 for ; Wed, 21 Dec 2011 00:50:52 +0000 (UTC) Received: by mail-ey0-f180.google.com with SMTP id c11so4023605eaa.11 for ; Tue, 20 Dec 2011 16:50:52 -0800 (PST) Received: by 10.204.156.219 with SMTP id y27mr994888bkw.71.1324428652549; Tue, 20 Dec 2011 16:50: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.82.144 with SMTP id ac16cs26535bkc; Tue, 20 Dec 2011 16:50:52 -0800 (PST) Received: by 10.68.213.6 with SMTP id no6mr7254659pbc.87.1324428650087; Tue, 20 Dec 2011 16:50:50 -0800 (PST) Received: from e7.ny.us.ibm.com (e7.ny.us.ibm.com. [32.97.182.137]) by mx.google.com with ESMTPS id t1si4162630pbi.30.2011.12.20.16.50.49 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 20 Dec 2011 16:50:50 -0800 (PST) Received-SPF: pass (google.com: domain of jstultz@us.ibm.com designates 32.97.182.137 as permitted sender) client-ip=32.97.182.137; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jstultz@us.ibm.com designates 32.97.182.137 as permitted sender) smtp.mail=jstultz@us.ibm.com Received: from /spool/local by e7.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 20 Dec 2011 19:50:48 -0500 Received: from d01relay04.pok.ibm.com (9.56.227.236) by e7.ny.us.ibm.com (192.168.1.107) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 20 Dec 2011 19:50:04 -0500 Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pBL0o30D350772; Tue, 20 Dec 2011 19:50:03 -0500 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pBL0o3Gd020662; Tue, 20 Dec 2011 22:50:03 -0200 Received: from kernel.beaverton.ibm.com (kernel.beaverton.ibm.com [9.47.67.96]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id pBL0o2bF020653; Tue, 20 Dec 2011 22:50:02 -0200 Received: by kernel.beaverton.ibm.com (Postfix, from userid 1056) id 2A00B1E7501; Tue, 20 Dec 2011 16:50:01 -0800 (PST) From: John Stultz To: Greg KH Cc: Colin Cross , Brian Swetland , =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Dima Zavin , Robert Love , Greg KH , John Stultz Subject: [PATCH 6/7] ashmem: Fix arguments to ashmem_shrink Date: Tue, 20 Dec 2011 16:49:53 -0800 Message-Id: <1324428595-9253-7-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.3.2.146.gca209 In-Reply-To: <1324428595-9253-1-git-send-email-john.stultz@linaro.org> References: <1324428595-9253-1-git-send-email-john.stultz@linaro.org> MIME-Version: 1.0 x-cbid: 11122100-5806-0000-0000-000010B64223 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 777e2b2..a78ba21 100644 --- a/drivers/staging/android/ashmem.c +++ b/drivers/staging/android/ashmem.c @@ -355,14 +355,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); @@ -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); @@ -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; }