From patchwork Sat Dec 14 03:26:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 22485 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4ACDA23908 for ; Sat, 14 Dec 2013 03:27:22 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id h16sf9937549oag.0 for ; Fri, 13 Dec 2013 19:27:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=tYgdNDF3BjkkyAvv1dRvCDjovqcrjKz8nYyl5CREmV0=; b=ko8CBRdvrOHvJ7jCqVZ/r9zgBf/EnDhSpfxcK+UzhSsPJv9Egad3Z5Y0pVqAITInpL yUZmahT5Fzq3zUD+40MmnCay/88VNLqgfp8EJHg36dL+86/CZP5cnketwET5mQtkllKv Vg0zKvNDd9gGr11Z3Tal7STrVRdfZSv9VPov41kB3nFdfIWgv5s1vlB0JkVLlUh4pn7u s4YRlL4K8jyhGqWqtsUU53CJ9zkSekHTZnZvJKzRM/LUH9HCW7Cxp0G5Fs+Xo1/MtxAR evcA7mK+atED2csHmEiIo/T8/0vKgwZcdToRF/vFP/WOORG8KJi6409K+hv6XrD3Z7Fr xrTg== X-Gm-Message-State: ALoCoQnazU2ocMpcR2z0hCFrdu6SlN+hXlLX/GI7jcJYsuklBx93umf8y3rSnne6QFQYDC3HTp2d X-Received: by 10.182.81.7 with SMTP id v7mr2248152obx.28.1386991641926; Fri, 13 Dec 2013 19:27:21 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.48.82 with SMTP id j18ls1253233qen.49.gmail; Fri, 13 Dec 2013 19:27:21 -0800 (PST) X-Received: by 10.220.200.65 with SMTP id ev1mr2597895vcb.13.1386991641798; Fri, 13 Dec 2013 19:27:21 -0800 (PST) Received: from mail-vb0-f53.google.com (mail-vb0-f53.google.com [209.85.212.53]) by mx.google.com with ESMTPS id a6si1418061vdp.117.2013.12.13.19.27.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Dec 2013 19:27:21 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.53 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.53; Received: by mail-vb0-f53.google.com with SMTP id o19so1862249vbm.12 for ; Fri, 13 Dec 2013 19:27:21 -0800 (PST) X-Received: by 10.221.16.200 with SMTP id pz8mr27780vcb.53.1386991641732; Fri, 13 Dec 2013 19:27:21 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp86977vcz; Fri, 13 Dec 2013 19:27:21 -0800 (PST) X-Received: by 10.67.3.68 with SMTP id bu4mr7212894pad.144.1386991640971; Fri, 13 Dec 2013 19:27:20 -0800 (PST) Received: from mail-pd0-f179.google.com (mail-pd0-f179.google.com [209.85.192.179]) by mx.google.com with ESMTPS id g5si2964929pav.172.2013.12.13.19.27.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Dec 2013 19:27:20 -0800 (PST) Received-SPF: neutral (google.com: 209.85.192.179 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.192.179; Received: by mail-pd0-f179.google.com with SMTP id r10so3235174pdi.24 for ; Fri, 13 Dec 2013 19:27:20 -0800 (PST) X-Received: by 10.68.29.72 with SMTP id i8mr7347594pbh.116.1386991640549; Fri, 13 Dec 2013 19:27:20 -0800 (PST) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id nw11sm11680086pab.13.2013.12.13.19.27.19 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Dec 2013 19:27:19 -0800 (PST) From: John Stultz To: LKML Cc: Greg KH , Android Kernel Team , Sumit Semwal , Jesse Barker , Colin Cross , John Stultz Subject: [PATCH 115/115] ion: Update system heap shrinker to use the new count/scan interface Date: Fri, 13 Dec 2013 19:26:35 -0800 Message-Id: <1386991595-6251-23-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1386991595-6251-1-git-send-email-john.stultz@linaro.org> References: <1386973529-4884-1-git-send-email-john.stultz@linaro.org> <1386991595-6251-1-git-send-email-john.stultz@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.53 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Update the ION system heap shrinker to use the new count/scan interfaces that landed in 3.12 Signed-off-by: John Stultz --- drivers/staging/android/ion/ion_system_heap.c | 40 +++++++++++++++++++-------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c index b5acd6c..144b2272 100644 --- a/drivers/staging/android/ion/ion_system_heap.c +++ b/drivers/staging/android/ion/ion_system_heap.c @@ -232,15 +232,37 @@ static struct ion_heap_ops system_heap_ops = { .map_user = ion_heap_map_user, }; -static int ion_system_heap_shrink(struct shrinker *shrinker, - struct shrink_control *sc) { - +static unsigned long ion_system_heap_shrink_count(struct shrinker *shrinker, + struct shrink_control *sc) +{ struct ion_heap *heap = container_of(shrinker, struct ion_heap, shrinker); struct ion_system_heap *sys_heap = container_of(heap, struct ion_system_heap, heap); int nr_total = 0; + int i; + + /* total number of items is whatever the page pools are holding + plus whatever's in the freelist */ + for (i = 0; i < num_orders; i++) { + struct ion_page_pool *pool = sys_heap->pools[i]; + nr_total += ion_page_pool_shrink(pool, sc->gfp_mask, 0); + } + nr_total += ion_heap_freelist_size(heap) / PAGE_SIZE; + return nr_total; + +} + +static unsigned long ion_system_heap_shrink_scan(struct shrinker *shrinker, + struct shrink_control *sc) +{ + + struct ion_heap *heap = container_of(shrinker, struct ion_heap, + shrinker); + struct ion_system_heap *sys_heap = container_of(heap, + struct ion_system_heap, + heap); int nr_freed = 0; int i; @@ -265,14 +287,7 @@ static int ion_system_heap_shrink(struct shrinker *shrinker, } end: - /* total number of items is whatever the page pools are holding - plus whatever's in the freelist */ - for (i = 0; i < num_orders; i++) { - struct ion_page_pool *pool = sys_heap->pools[i]; - nr_total += ion_page_pool_shrink(pool, sc->gfp_mask, 0); - } - nr_total += ion_heap_freelist_size(heap) / PAGE_SIZE; - return nr_total; + return nr_freed; } @@ -323,7 +338,8 @@ struct ion_heap *ion_system_heap_create(struct ion_platform_heap *unused) heap->pools[i] = pool; } - heap->heap.shrinker.shrink = ion_system_heap_shrink; + heap->heap.shrinker.scan_objects = ion_system_heap_shrink_scan; + heap->heap.shrinker.count_objects = ion_system_heap_shrink_count; heap->heap.shrinker.seeks = DEFAULT_SEEKS; heap->heap.shrinker.batch = 0; register_shrinker(&heap->heap.shrinker);