From patchwork Fri Dec 16 02:51:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 5793 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 5391024055 for ; Fri, 16 Dec 2011 02:51:23 +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 4AF57A18977 for ; Fri, 16 Dec 2011 02:51:23 +0000 (UTC) Received: by mail-ey0-f180.google.com with SMTP id k10so3114749eaa.11 for ; Thu, 15 Dec 2011 18:51:23 -0800 (PST) Received: by 10.205.129.137 with SMTP id hi9mr2589284bkc.90.1324003883100; Thu, 15 Dec 2011 18:51:23 -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 hg2cs59555bkc; Thu, 15 Dec 2011 18:51:23 -0800 (PST) Received: by 10.68.209.10 with SMTP id mi10mr13179950pbc.4.1324003880530; Thu, 15 Dec 2011 18:51:20 -0800 (PST) Received: from e6.ny.us.ibm.com (e6.ny.us.ibm.com. [32.97.182.146]) by mx.google.com with ESMTPS id j1si12454674pbi.152.2011.12.15.18.51.19 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 15 Dec 2011 18:51:20 -0800 (PST) Received-SPF: pass (google.com: domain of jstultz@us.ibm.com designates 32.97.182.146 as permitted sender) client-ip=32.97.182.146; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jstultz@us.ibm.com designates 32.97.182.146 as permitted sender) smtp.mail=jstultz@us.ibm.com Received: from /spool/local by e6.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 15 Dec 2011 21:51:18 -0500 Received: from d01relay04.pok.ibm.com (9.56.227.236) by e6.ny.us.ibm.com (192.168.1.106) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 15 Dec 2011 21:51:17 -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 pBG2pGRq338694; Thu, 15 Dec 2011 21:51:16 -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 pBG2pEFl009585; Fri, 16 Dec 2011 00:51:16 -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 pBG2pEPM009551; Fri, 16 Dec 2011 00:51:14 -0200 Received: by kernel.beaverton.ibm.com (Postfix, from userid 1056) id 684621E7504; Thu, 15 Dec 2011 18:51:12 -0800 (PST) From: John Stultz To: =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= Cc: Colin Cross , Brian Swetland , =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Dima Zavin , Robert Love , Greg KH , John Stultz Subject: [PATCH 08/10] ashmem: Fix arguments to ashmem_shrink Date: Thu, 15 Dec 2011 18:51:02 -0800 Message-Id: <1324003864-26776-9-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.3.2.146.gca209 In-Reply-To: <1324003864-26776-1-git-send-email-john.stultz@linaro.org> References: <1324003864-26776-1-git-send-email-john.stultz@linaro.org> MIME-Version: 1.0 x-cbid: 11121602-1976-0000-0000-0000089DEB29 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; }