From patchwork Thu Oct 3 00:51:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 20753 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f197.google.com (mail-qc0-f197.google.com [209.85.216.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B2893238F9 for ; Thu, 3 Oct 2013 00:52:07 +0000 (UTC) Received: by mail-qc0-f197.google.com with SMTP id r5sf3266547qcx.0 for ; Wed, 02 Oct 2013 17:52:07 -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=Kow7vCtmvXticYUg0XbTFIhlwD0Gu+woHjP6SxtpuPU=; b=SxHzU4gFd5n80048o9HotvMcQRAG5lf79UU9KivyhibM52ynvq9q/3u4PEaJmreFJc tSUB+d3+GnrDalPOGXAcIl233pElHtSpEctgFaR61cSoxNKox/r0eMCiWaPDiUEBQUAh sFgIltI/J2unNMZTNe7lYIQ8/qSEnvEAIXW44RzHTFOQqZ201YeEwqo/DCAJZkANRJ2F mgNotrBBbnkOak2faAQ+f7CgVJSwg5pb9L99LcQSdm2W0WxSRLovMvWV/D6ZUIZvxy0b DdAGittIseY5Bvo4UZc2QZed335kXPdr/L8QIDsmLynzdxF80gSxRVsUviOn6PmnUVqE DOWw== X-Received: by 10.236.135.211 with SMTP id u59mr4570409yhi.43.1380761527577; Wed, 02 Oct 2013 17:52:07 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.76.100 with SMTP id j4ls798375qew.29.gmail; Wed, 02 Oct 2013 17:52:07 -0700 (PDT) X-Received: by 10.220.74.69 with SMTP id t5mr4715912vcj.18.1380761527403; Wed, 02 Oct 2013 17:52:07 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id bl10si1050758vcb.9.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 02 Oct 2013 17:52:07 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id hz10so578316vcb.26 for ; Wed, 02 Oct 2013 17:52:07 -0700 (PDT) X-Gm-Message-State: ALoCoQnygAfyAri911tI5hrixhJnMV79C91Ik6zyAKiZ+oBBCNxnSQItaqj8ipjmK5SEOmYFTzm1 X-Received: by 10.220.143.80 with SMTP id t16mr4702964vcu.10.1380761527292; Wed, 02 Oct 2013 17:52:07 -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 u4csp137509vcz; Wed, 2 Oct 2013 17:52:06 -0700 (PDT) X-Received: by 10.68.11.41 with SMTP id n9mr5440054pbb.164.1380761526378; Wed, 02 Oct 2013 17:52:06 -0700 (PDT) Received: from mail-pb0-f49.google.com (mail-pb0-f49.google.com [209.85.160.49]) by mx.google.com with ESMTPS id hb3si3883339pac.326.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 02 Oct 2013 17:52:06 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.49 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.160.49; Received: by mail-pb0-f49.google.com with SMTP id xb4so1657210pbc.8 for ; Wed, 02 Oct 2013 17:52:06 -0700 (PDT) X-Received: by 10.66.119.172 with SMTP id kv12mr6110542pab.34.1380761525948; Wed, 02 Oct 2013 17:52:05 -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:04 -0700 (PDT) From: John Stultz To: LKML Cc: John Stultz , 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 , Minchan Kim , "linux-mm@kvack.org" Subject: [PATCH 03/14] vrange: Clear volatility on new mmaps Date: Wed, 2 Oct 2013 17:51:32 -0700 Message-Id: <1380761503-14509-4-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.220.181 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: , At lsf-mm, the issue was brought up that there is a precedence with interfaces like mlock, such that new mappings in a pre-existing range do no inherit the mlock state. This is mostly because mlock only modifies the existing vmas, and so any new mmaps create new vmas, which won't be mlocked. Since volatility is not stored in the vma (for good cause, specifically as we'd have to have manage file volatility differently from anonymous and we're likely to manage volatility on small chunks of memory, which would cause lots of vma splitting and churn), this patch clears volitility on new mappings, to ensure that we don't inherit volatility if memory in an existing volatile range is unmapped and then re-mapped with something else. Thus, this patch forces any volatility to be cleared on mmap. XXX: We expect this patch to be not well loved by mm folks, and are open to alternative methods here. Its more of a place holder to address the issue from lsf-mm and hopefully will spur some further discussion. Minchan does have an alternative solution, but I'm not a big fan of it yet, so this simpler approach is a placeholder for now. 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: John Stultz --- include/linux/vrange.h | 2 ++ mm/mmap.c | 5 +++++ mm/vrange.c | 8 ++++++++ 3 files changed, 15 insertions(+) diff --git a/include/linux/vrange.h b/include/linux/vrange.h index 2b96ee1..ef153c8 100644 --- a/include/linux/vrange.h +++ b/include/linux/vrange.h @@ -36,6 +36,8 @@ static inline int vrange_type(struct vrange *vrange) return vrange->owner->type; } +extern int vrange_clear(struct vrange_root *vroot, + unsigned long start, unsigned long end); extern void vrange_root_cleanup(struct vrange_root *vroot); extern int vrange_fork(struct mm_struct *new, struct mm_struct *old); diff --git a/mm/mmap.c b/mm/mmap.c index f9c97d1..ed7056f 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -1502,6 +1503,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr, /* Clear old maps */ error = -ENOMEM; munmap_back: + + /* zap any volatile ranges */ + vrange_clear(&mm->vroot, addr, addr + len); + if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) { if (do_munmap(mm, addr, len)) return -ENOMEM; diff --git a/mm/vrange.c b/mm/vrange.c index 4ddcc3e9..f2d1588 100644 --- a/mm/vrange.c +++ b/mm/vrange.c @@ -166,6 +166,14 @@ static int vrange_remove(struct vrange_root *vroot, return 0; } +int vrange_clear(struct vrange_root *vroot, + unsigned long start, unsigned long end) +{ + int purged; + + return vrange_remove(vroot, start, end - 1, &purged); +} + void vrange_root_cleanup(struct vrange_root *vroot) { struct vrange *range;