From patchwork Thu Oct 3 00:51:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 20762 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ye0-f198.google.com (mail-ye0-f198.google.com [209.85.213.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0103A238F9 for ; Thu, 3 Oct 2013 00:52:28 +0000 (UTC) Received: by mail-ye0-f198.google.com with SMTP id m11sf2712541yen.9 for ; Wed, 02 Oct 2013 17:52:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state: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=7Q8NY133kHINCIRouPrg4g+LX58D0jp/mSmENLzmulo=; b=mWvGCj7ocw2ef4KKGtGqmHlYMk+kUPQn0gyYuN55Vmc4WkmstLGdBSVLwN8jAskaMP 97o/28NmVf6yyOVSrQr8GqVEVZ0WISG8RNWdIfrtKYTPMeFUklu7VM8LHBCZFKY5zo9i Y5EuyLISkhYEhWYoNeomAqBoTqjKvntRH9IdZrGE1FAYM42K/LLZTQG64WxhUXvj7Y4A 87CbOdIYAU+Kr3m5RmS9kUPILJ3wb/sP4G9NCETRE4RgYJpWctRumL1PEXMPG9/epolp 5HUlRehPkdvZREk8d4zulTHLSnv6sMRhsI5K6MIcCrux4Jop5/GV+yDIziDhoAHv4x16 iN/A== X-Received: by 10.236.17.161 with SMTP id j21mr5096551yhj.55.1380761548808; Wed, 02 Oct 2013 17:52:28 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.64.68 with SMTP id m4ls720617qes.5.gmail; Wed, 02 Oct 2013 17:52:28 -0700 (PDT) X-Received: by 10.220.199.5 with SMTP id eq5mr4687950vcb.16.1380761548708; Wed, 02 Oct 2013 17:52:28 -0700 (PDT) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by mx.google.com with ESMTPS id cl2si1037620vdc.101.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 02 Oct 2013 17:52:28 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.179; Received: by mail-ve0-f179.google.com with SMTP id c14so1256787vea.38 for ; Wed, 02 Oct 2013 17:52:28 -0700 (PDT) X-Gm-Message-State: ALoCoQl3a9dPIKjqkGFH7MwtlL755PLx4k/tYZ9mXPYVl3uVdGioRdAqNAEXOTJ+/hQ+A+3EafJV X-Received: by 10.52.33.44 with SMTP id o12mr3933135vdi.7.1380761548595; Wed, 02 Oct 2013 17:52:28 -0700 (PDT) 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 u4csp137541vcz; Wed, 2 Oct 2013 17:52:28 -0700 (PDT) X-Received: by 10.67.11.103 with SMTP id eh7mr6140905pad.153.1380761547728; Wed, 02 Oct 2013 17:52:27 -0700 (PDT) Received: from mail-pd0-f171.google.com (mail-pd0-f171.google.com [209.85.192.171]) by mx.google.com with ESMTPS id to1si3945731pab.109.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 02 Oct 2013 17:52:27 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.171 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.192.171; Received: by mail-pd0-f171.google.com with SMTP id g10so1711054pdj.16 for ; Wed, 02 Oct 2013 17:52:27 -0700 (PDT) X-Received: by 10.68.255.229 with SMTP id at5mr5497138pbd.130.1380761547314; Wed, 02 Oct 2013 17:52:27 -0700 (PDT) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id gh2sm4507018pbc.40.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 02 Oct 2013 17:52:26 -0700 (PDT) From: John Stultz To: LKML Cc: Minchan Kim , Andrew Morton , Android Kernel Team , Robert Love , Mel Gorman , Hugh Dickins , Dave Hansen , Rik van Riel , Dmitry Adamushko , Dave Chinner , Neil Brown , Andrea Righi , Andrea Arcangeli , "Aneesh Kumar K.V" , Mike Hommey , Taras Glek , Dhaval Giani , Jan Kara , KOSAKI Motohiro , Michel Lespinasse , Rob Clark , "linux-mm@kvack.org" , John Stultz Subject: [PATCH 12/14] vrange: Support background purging for vrange-file Date: Wed, 2 Oct 2013 17:51:41 -0700 Message-Id: <1380761503-14509-13-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1380761503-14509-1-git-send-email-john.stultz@linaro.org> References: <1380761503-14509-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.128.179 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: , From: Minchan Kim Add support to purge vrange file pages via the shrinker interface. This is useful, since some filesystems like shmem/tmpfs use anonymous pages, which won't be aged off the page LRU if swap is disabled. Cc: Andrew Morton Cc: Android Kernel Team Cc: Robert Love Cc: Mel Gorman Cc: Hugh Dickins Cc: Dave Hansen Cc: Rik van Riel Cc: Dmitry Adamushko Cc: Dave Chinner Cc: Neil Brown Cc: Andrea Righi Cc: Andrea Arcangeli Cc: Aneesh Kumar K.V Cc: Mike Hommey Cc: Taras Glek Cc: Dhaval Giani Cc: Jan Kara Cc: KOSAKI Motohiro Cc: Michel Lespinasse Cc: Rob Clark Cc: Minchan Kim Cc: linux-mm@kvack.org Signed-off-by: Minchan Kim [jstultz: Commit message tweaks] Signed-off-by: John Stultz --- mm/vrange.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 7 deletions(-) diff --git a/mm/vrange.c b/mm/vrange.c index c6bc32f..3f21dc9 100644 --- a/mm/vrange.c +++ b/mm/vrange.c @@ -13,6 +13,7 @@ #include #include #include +#include static struct kmem_cache *vrange_cachep; @@ -854,21 +855,62 @@ out: return ret; } +static int __discard_vrange_file(struct address_space *mapping, + struct vrange *vrange, unsigned int *ret_discard) +{ + struct pagevec pvec; + pgoff_t index; + int i; + unsigned int nr_discard = 0; + unsigned long start_idx = vrange->node.start; + unsigned long end_idx = vrange->node.last; + const pgoff_t start = start_idx >> PAGE_CACHE_SHIFT; + pgoff_t end = end_idx >> PAGE_CACHE_SHIFT; + LIST_HEAD(pagelist); + + pagevec_init(&pvec, 0); + index = start; + while (index <= end && pagevec_lookup(&pvec, mapping, index, + min(end - index, (pgoff_t)PAGEVEC_SIZE - 1) + 1)) { + for (i = 0; i < pagevec_count(&pvec); i++) { + struct page *page = pvec.pages[i]; + index = page->index; + if (index > end) + break; + if (isolate_lru_page(page)) + continue; + list_add(&page->lru, &pagelist); + inc_zone_page_state(page, NR_ISOLATED_ANON); + } + pagevec_release(&pvec); + cond_resched(); + index++; + } + + if (!list_empty(&pagelist)) + nr_discard = discard_vrange_pagelist(&pagelist); + + *ret_discard = nr_discard; + putback_lru_pages(&pagelist); + + return 0; +} + static int discard_vrange(struct vrange *vrange) { int ret = 0; - struct mm_struct *mm; struct vrange_root *vroot; unsigned int nr_discard = 0; vroot = vrange->owner; - /* TODO : handle VRANGE_FILE */ - if (vroot->type != VRANGE_MM) - goto out; + if (vroot->type == VRANGE_MM) { + struct mm_struct *mm = vroot->object; + ret = __discard_vrange_anon(mm, vrange, &nr_discard); + } else if (vroot->type == VRANGE_FILE) { + struct address_space *mapping = vroot->object; + ret = __discard_vrange_file(mapping, vrange, &nr_discard); + } - mm = vroot->object; - ret = __discard_vrange_anon(mm, vrange, &nr_discard); -out: return nr_discard; }