From patchwork Tue Jun 11 02:11: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: 17772 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-fa0-f71.google.com (mail-fa0-f71.google.com [209.85.161.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6881B2397B for ; Tue, 11 Jun 2013 02:13:24 +0000 (UTC) Received: by mail-fa0-f71.google.com with SMTP id v1sf1722115fav.10 for ; Mon, 10 Jun 2013 19:13:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to: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=oHibg4IpgIqKbzAyAnM/ghjCiI5vxcyAjmaw9c+VfGo=; b=Zt7z3dnIuknPrU/24k8LM2+5MDx2tn7FdEfc3mTEjVdxOI2mjlzA38PoPZA5PzGFuh 5b3HD3iMV8a6KuHcVgvtX8UPS6uwikXbuVaemg/xIvUm1snHcxZ26cDuw0eB9xAz5Ck9 R0qOI6nU7hAWaKPJermaeusoA34Vycb7i8lI5dE2lg4I0bFNJjrgu3Yqj/czia69+5tZ gJRgEorwxwSG9d1KsDLtZziiKSwHgUXWxoRCmDgBJUUACy7nXzveI9L5SHQuMwysBwdh 00eBukFrNT/TiMxzEpc7qDIakk9KfUZ0NSGT1s+xWQzzVLpZOO5e9HpRoejXJON9UERL EOdQ== X-Received: by 10.180.37.229 with SMTP id b5mr42491wik.4.1370916803108; Mon, 10 Jun 2013 19:13:23 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.180.19.67 with SMTP id c3ls1029948wie.28.canary; Mon, 10 Jun 2013 19:13:22 -0700 (PDT) X-Received: by 10.194.249.129 with SMTP id yu1mr7288305wjc.10.1370916802916; Mon, 10 Jun 2013 19:13:22 -0700 (PDT) Received: from mail-ve0-x22b.google.com (mail-ve0-x22b.google.com [2607:f8b0:400c:c01::22b]) by mx.google.com with ESMTPS id ct9si4507593wjb.166.2013.06.10.19.13.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Jun 2013 19:13:22 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::22b 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::22b; Received: by mail-ve0-f171.google.com with SMTP id b10so5335630vea.2 for ; Mon, 10 Jun 2013 19:13:21 -0700 (PDT) X-Received: by 10.220.19.74 with SMTP id z10mr7333220vca.45.1370916801512; Mon, 10 Jun 2013 19:13:21 -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.221.10.206 with SMTP id pb14csp90932vcb; Mon, 10 Jun 2013 19:13:20 -0700 (PDT) X-Received: by 10.66.159.234 with SMTP id xf10mr16496985pab.203.1370916800374; Mon, 10 Jun 2013 19:13:20 -0700 (PDT) Received: from mail-pb0-x230.google.com (mail-pb0-x230.google.com [2607:f8b0:400e:c01::230]) by mx.google.com with ESMTPS id lb5si5908992pbc.210.2013.06.10.19.13.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Jun 2013 19:13:20 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400e:c01::230 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=2607:f8b0:400e:c01::230; Received: by mail-pb0-f48.google.com with SMTP id ma3so2442324pbc.7 for ; Mon, 10 Jun 2013 19:13:19 -0700 (PDT) X-Received: by 10.66.27.114 with SMTP id s18mr16292728pag.98.1370916799822; Mon, 10 Jun 2013 19:13:19 -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 nt2sm12427175pbc.17.2013.06.10.19.13.18 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Jun 2013 19:13:19 -0700 (PDT) From: John Stultz To: minchan.kim@lge.com Cc: John Stultz Subject: [PATCH 13/13] vrange: Add checks in fault handler so we return SIGBUS on purged file pages Date: Mon, 10 Jun 2013 19:11:32 -0700 Message-Id: <1370916692-9576-14-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1370916692-9576-1-git-send-email-john.stultz@linaro.org> References: <1370916692-9576-1-git-send-email-john.stultz@linaro.org> X-Gm-Message-State: ALoCoQnOeEu1AZpE5bueBVknr79qM/d4g421hPcOWuSFBEjjm5lTXQSLbDcHHirQgbPTJ/UKS+Ii X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::22b 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 bd36d67..ac60f76 100644 --- a/include/linux/vrange.h +++ b/include/linux/vrange.h @@ -58,7 +58,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 7905fe7..06c7997 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" #define CREATE_TRACE_POINTS diff --git a/mm/memory.c b/mm/memory.c index 341c794..1783327 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3486,9 +3486,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; @@ -680,6 +680,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) {