From patchwork Fri May 3 18:27:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 16707 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id ED74323905 for ; Fri, 3 May 2013 18:27:52 +0000 (UTC) Received: by mail-wg0-f69.google.com with SMTP id l18sf2872096wgh.0 for ; Fri, 03 May 2013 11:27:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=lqimX997Svw0VRyZvNriATpLpEGxfve4+caJdVLVo0s=; b=JrVo7Se/TEihuigowvCSHz6PbdoPQly+hjJfQyUK6d3Vec+HEjLeTOBxowPrCcojUF LJ7BFXdEXXeM1dzZaQcYbcZRothgL5NCQFEXQMzdciRuitSU6BFnMuGQquojwffLfKZO mnQx+mcCRyHT1+bWfrIfPootQb7wnGvjgwYgwv9x7KmlLbe6aR2h+xYY3vJ64Ksorg0Z sCw6RT1R8kmh10bMdQw08saYPTyCsiQkxmoK+Zi3E1PozMDAjYBmFEMt4dwEeJPFY/Dm 92gEVh5zXOkd838sDruRUaXS0sBYk9+ZjdVCAafx+D11HDvhzD267tHH+6Dou02fCCmk cX+w== X-Received: by 10.180.85.5 with SMTP id d5mr13122564wiz.0.1367605662237; Fri, 03 May 2013 11:27:42 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.180.97.37 with SMTP id dx5ls279625wib.33.canary; Fri, 03 May 2013 11:27:42 -0700 (PDT) X-Received: by 10.180.74.172 with SMTP id u12mr3761532wiv.0.1367605662174; Fri, 03 May 2013 11:27:42 -0700 (PDT) Received: from mail-ve0-x22c.google.com (mail-ve0-x22c.google.com [2607:f8b0:400c:c01::22c]) by mx.google.com with ESMTPS id c8si3988089wjr.189.2013.05.03.11.27.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 03 May 2013 11:27:42 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::22c is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::22c; Received: by mail-ve0-f172.google.com with SMTP id da11so1778060veb.31 for ; Fri, 03 May 2013 11:27:41 -0700 (PDT) X-Received: by 10.221.0.199 with SMTP id nn7mr4061765vcb.14.1367605661015; Fri, 03 May 2013 11:27:41 -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.58.127.98 with SMTP id nf2csp34392veb; Fri, 3 May 2013 11:27:40 -0700 (PDT) X-Received: by 10.66.232.230 with SMTP id tr6mr16378623pac.83.1367605659743; Fri, 03 May 2013 11:27:39 -0700 (PDT) Received: from mail-da0-x22b.google.com (mail-da0-x22b.google.com [2607:f8b0:400e:c00::22b]) by mx.google.com with ESMTPS id wu3si8111670pbc.40.2013.05.03.11.27.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 03 May 2013 11:27:39 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400e:c00::22b is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=2607:f8b0:400e:c00::22b; Received: by mail-da0-f43.google.com with SMTP id u7so926979dae.16 for ; Fri, 03 May 2013 11:27:39 -0700 (PDT) X-Received: by 10.68.242.97 with SMTP id wp1mr2059359pbc.128.1367605659273; Fri, 03 May 2013 11:27:39 -0700 (PDT) Received: from localhost.localdomain (c-24-21-54-107.hsd1.or.comcast.net. [24.21.54.107]) by mx.google.com with ESMTPSA id qh4sm13792406pac.8.2013.05.03.11.27.38 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 03 May 2013 11:27:38 -0700 (PDT) From: John Stultz To: Minchan Kim Cc: John Stultz Subject: [PATCH 12/12] vrange: Add checks in fault handler so we return SIGBUS on purged file pages Date: Fri, 3 May 2013 11:27:16 -0700 Message-Id: <1367605636-18284-13-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1367605636-18284-1-git-send-email-john.stultz@linaro.org> References: <1367605636-18284-1-git-send-email-john.stultz@linaro.org> X-Gm-Message-State: ALoCoQkyO+78CRRLEHbWthEfVvg2vmqMA6auWR+/EzcgbdGELoNYVNZq6qvJjlOc3hJapIC3lpw2 X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::22c 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: , The earlier fvrange() work didn't handle setting the SIGBUS faulting when purged file pages were accessed. This patch remedies that. XXX: Likely need to consolidate anonymous and file page methods here. Using truncate_inode_page_ranges is easier for now then going over all the ptes and marking them w/ mkvrange(). Signed-off-by: John Stultz --- include/linux/vrange.h | 5 ++++- mm/filemap.c | 1 + mm/memory.c | 13 ++++++++++++- mm/vrange.c | 31 ++++++++++++++++++++++++++++--- 4 files changed, 45 insertions(+), 5 deletions(-) diff --git a/include/linux/vrange.h b/include/linux/vrange.h index 761dca0..599b044 100644 --- a/include/linux/vrange.h +++ b/include/linux/vrange.h @@ -57,7 +57,10 @@ int discard_vpage(struct page *page); bool vrange_address(struct mm_struct *mm, unsigned long start, unsigned long end); -extern bool is_purged_vrange(struct mm_struct *mm, unsigned long address); +extern bool is_purged_anon_vrange(struct mm_struct *mm, unsigned long address); +extern bool is_purged_file_vrange(struct address_space *mapping, + unsigned long offset); + unsigned int discard_vrange_pages(struct zone *zone, int nr_to_discard); void lru_move_vrange_to_head(struct mm_struct *mm, unsigned long address); diff --git a/mm/filemap.c b/mm/filemap.c index e1979fd..4ba0ccc 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -33,6 +33,7 @@ #include /* for BUG_ON(!in_atomic()) only */ #include #include +#include #include "internal.h" /* diff --git a/mm/memory.c b/mm/memory.c index b22fa63..e38a1a1 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3481,9 +3481,20 @@ static int do_linear_fault(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long address, pte_t *page_table, pmd_t *pmd, unsigned int flags, pte_t orig_pte) { + struct address_space *mapping = 0; + pgoff_t pgoff = (((address & PAGE_MASK) - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff; + + if (vma->vm_file) + mapping = vma->vm_file->f_mapping; + + if (mapping) + if (is_purged_file_vrange(mapping, (pgoff<vroot; struct interval_tree_node *node; @@ -706,6 +706,31 @@ bool is_purged_vrange(struct mm_struct *mm, unsigned long address) return ret; } + +bool is_purged_file_vrange(struct address_space *mapping, unsigned long offset) +{ + struct vrange_root *vroot = &mapping->vroot; + struct interval_tree_node *node; + struct vrange *range; + bool ret = false; + + + if (!vroot) + return false; + + vrange_lock(vroot); + node = interval_tree_iter_first(&vroot->v_rb, offset, + offset + PAGE_SIZE - 1); + if (node) { + range = container_of(node, struct vrange, node); + if (range->purged) + ret = true; + } + vrange_unlock(vroot); + return ret; +} + + static void vrange_pte_entry(pte_t pteval, unsigned long address, unsigned ptent_size, struct mm_walk *walk) {