Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752708AbaKLJvv (ORCPT ); Wed, 12 Nov 2014 04:51:51 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:30473 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752063AbaKLJvr (ORCPT ); Wed, 12 Nov 2014 04:51:47 -0500 X-AuditID: cbfee61b-f79d76d0000024d6-fb-54632db06886 From: Weijie Yang To: "'Johannes Weiner'" Cc: "'Andrew Morton'" , mgorman@suse.de, "'Rik van Riel'" , "'Weijie Yang'" , "'Linux-MM'" , "'linux-kernel'" Subject: [RFC PATCH] mm: mincore: use PAGE_SIZE instead of PAGE_CACHE_SIZE Date: Wed, 12 Nov 2014 17:50:37 +0800 Message-id: <000001cffe5e$44893f60$cd9bbe20$%yang@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-transfer-encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-index: Ac/+Xhwhj4CcbRi3RbmYb2dqqhbJ1A== Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrLLMWRmVeSWpSXmKPExsVy+t9jQd0NuskhBrOXWVnMWb+GzWL1Jl+L y7vmsFncW/Of1WLyu2eMFn+vrGexeHLiP4sDu8fhN++ZPXbOusvusenTJHaPEzN+s3i833eV zWPz6WqPz5vkAtijuGxSUnMyy1KL9O0SuDKmv+hmK5gqXDHlWTNTA+Mvvi5GTg4JAROJX+3n WCFsMYkL99azdTFycQgJTGeUuPCrhxnC+cMocWr+VEaQKjYBbYm7/RvBOkQEtCTW3z3GCFLE LPCAUeL8x99gCWEBL4lVn3qZuhg5OFgEVCX+r1ACCfMK2EmsvPWQDcIWlPgx+R4LSAmzgLrE lCm5IGFmAXmJzWveMoOEJYDCj/7qQmzSk7jxcTobRIm4xMYjt1gmMArMQjJoFsKgWUgGzULS sYCRZRWjaGpBckFxUnqukV5xYm5xaV66XnJ+7iZGcCQ8k97BuKrB4hCjAAejEg9vxuakECHW xLLiytxDjBIczEoivJ++AoV4UxIrq1KL8uOLSnNSiw8xSnOwKInzHmy1DhQSSE8sSc1OTS1I LYLJMnFwSjUwsp+7tWHz8vyTXDd7nl7fdfpz2qpMJ3GzNMYlb0qbfv1n5JHdXNL3+eA85UMW b5vyPizN9Pj25Hvp8mTvx2Xmv1LVt4h9vsy1JEhgtYNl5lumsir+0ITsstksGgc1lwn8Fe/r OeGwt9HLT1CO+YmS6G4LdoujjknrdnPfNPlnuE1QgHke29YtSizFGYmGWsxFxYkAUw5UkoAC AAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a RFC patch, because current PAGE_SIZE is equal to PAGE_CACHE_SIZE, there isn't any difference and issue when running. However, the current code mixes these two aligned_size inconsistently, and if they are not equal in future mincore_unmapped_range() would check more file pages than wanted. According to man-page, mincore uses PAGE_SIZE as its size unit, so this patch uses PAGE_SIZE instead of PAGE_CACHE_SIZE. Signed-off-by: Weijie Yang --- mm/mincore.c | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-) diff --git a/mm/mincore.c b/mm/mincore.c index 725c809..8c19bce 100644 --- a/mm/mincore.c +++ b/mm/mincore.c @@ -102,11 +102,18 @@ static void mincore_unmapped_range(struct vm_area_struct *vma, int i; if (vma->vm_file) { - pgoff_t pgoff; + pgoff_t pgoff, pgoff_end; + int j, count; + unsigned char res; + count = 1 << (PAGE_CACHE_SHIFT - PAGE_SHIFT); pgoff = linear_page_index(vma, addr); - for (i = 0; i < nr; i++, pgoff++) - vec[i] = mincore_page(vma->vm_file->f_mapping, pgoff); + pgoff_end = linear_page_index(vma, end); + for (i = 0; pgoff < pgoff_end; pgoff++) { + res = mincore_page(vma->vm_file->f_mapping, pgoff); + for (j = 0; j < count; j++) + vec[i++] = res; + } } else { for (i = 0; i < nr; i++) vec[i] = 0; @@ -258,7 +265,7 @@ static long do_mincore(unsigned long addr, unsigned long pages, unsigned char *v * return values: * zero - success * -EFAULT - vec points to an illegal address - * -EINVAL - addr is not a multiple of PAGE_CACHE_SIZE + * -EINVAL - addr is not a multiple of PAGE_SIZE * -ENOMEM - Addresses in the range [addr, addr + len] are * invalid for the address space of this process, or * specify one or more pages which are not currently @@ -273,14 +280,14 @@ SYSCALL_DEFINE3(mincore, unsigned long, start, size_t, len, unsigned char *tmp; /* Check the start address: needs to be page-aligned.. */ - if (start & ~PAGE_CACHE_MASK) + if (start & ~PAGE_MASK) return -EINVAL; /* ..and we need to be passed a valid user-space range */ if (!access_ok(VERIFY_READ, (void __user *) start, len)) return -ENOMEM; - /* This also avoids any overflows on PAGE_CACHE_ALIGN */ + /* This also avoids any overflows on PAGE_ALIGN */ pages = len >> PAGE_SHIFT; pages += (len & ~PAGE_MASK) != 0; -- 1.7.0.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/