From: Andrew Morton <akpm@digeo.com>
To: davem@redhat.com, rohit.seth@intel.com, davidm@napali.hpl.hp.com,
anton@samba.org, wli@holomorphy.com, linux-mm@kvack.org
Subject: Re: hugepage patches
Date: Sun, 2 Feb 2003 02:57:20 -0800 [thread overview]
Message-ID: <20030202025720.25bbf46d.akpm@digeo.com> (raw)
In-Reply-To: <20030131151501.7273a9bf.akpm@digeo.com>
12/4
Fix hugetlb_vmtruncate_list()
This function is quite wrong - has an "=" where it should have an "-" and
confuses PAGE_SIZE and HPAGE_SIZE in its address and file offset arithmetic.
hugetlbfs/inode.c | 46 ++++++++++++++++++++++++++++++++--------------
1 files changed, 32 insertions(+), 14 deletions(-)
diff -puN fs/hugetlbfs/inode.c~hugetlb_vmtruncate-fixes fs/hugetlbfs/inode.c
--- 25/fs/hugetlbfs/inode.c~hugetlb_vmtruncate-fixes 2003-02-02 01:17:12.000000000 -0800
+++ 25-akpm/fs/hugetlbfs/inode.c 2003-02-02 02:53:49.000000000 -0800
@@ -240,29 +240,47 @@ static void hugetlbfs_drop_inode(struct
hugetlbfs_forget_inode(inode);
}
-static void hugetlb_vmtruncate_list(struct list_head *list, unsigned long pgoff)
+/*
+ * h_pgoff is in HPAGE_SIZE units.
+ * vma->vm_pgoff is in PAGE_SIZE units.
+ */
+static void
+hugetlb_vmtruncate_list(struct list_head *list, unsigned long h_pgoff)
{
- unsigned long start, end, length, delta;
struct vm_area_struct *vma;
list_for_each_entry(vma, list, shared) {
- start = vma->vm_start;
- end = vma->vm_end;
- length = end - start;
-
- if (vma->vm_pgoff >= pgoff) {
- zap_hugepage_range(vma, start, length);
+ unsigned long h_vm_pgoff;
+ unsigned long v_length;
+ unsigned long h_length;
+ unsigned long v_offset;
+
+ h_vm_pgoff = vma->vm_pgoff << (HPAGE_SHIFT - PAGE_SHIFT);
+ v_length = vma->vm_end - vma->vm_start;
+ h_length = v_length >> HPAGE_SHIFT;
+ v_offset = (h_pgoff - h_vm_pgoff) << HPAGE_SHIFT;
+
+ /*
+ * Is this VMA fully outside the truncation point?
+ */
+ if (h_vm_pgoff >= h_pgoff) {
+ zap_hugepage_range(vma, vma->vm_start, v_length);
continue;
}
- length >>= PAGE_SHIFT;
- delta = pgoff = vma->vm_pgoff;
- if (delta >= length)
+ /*
+ * Is this VMA fully inside the truncaton point?
+ */
+ if (h_vm_pgoff + (v_length >> HPAGE_SHIFT) <= h_pgoff)
continue;
- start += delta << PAGE_SHIFT;
- length = (length - delta) << PAGE_SHIFT;
- zap_hugepage_range(vma, start, length);
+ /*
+ * The VMA straddles the truncation point. v_offset is the
+ * offset (in bytes) into the VMA where the point lies.
+ */
+ zap_hugepage_range(vma,
+ vma->vm_start + v_offset,
+ v_length - v_offset);
}
}
_
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/
next prev parent reply other threads:[~2003-02-02 10:57 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-31 23:15 Andrew Morton
2003-01-31 23:13 ` David S. Miller
2003-01-31 23:36 ` Andrew Morton
2003-01-31 23:23 ` David S. Miller
2003-01-31 23:45 ` Andrew Morton
2003-01-31 23:48 ` David S. Miller
2003-01-31 23:16 ` Andrew Morton
2003-01-31 23:17 ` Andrew Morton
2003-01-31 23:18 ` Andrew Morton
2003-01-31 23:18 ` Andrew Morton
2003-02-01 8:58 ` Ingo Oeser
2003-02-01 9:31 ` Andrew Morton
2003-02-01 10:00 ` William Lee Irwin III
2003-02-01 10:14 ` Andrew Morton
2003-02-02 10:55 ` Andrew Morton
2003-02-02 10:55 ` Andrew Morton
2003-02-02 19:59 ` William Lee Irwin III
2003-02-02 20:49 ` Andrew Morton
2003-02-03 15:09 ` Eric W. Biederman
2003-02-03 21:29 ` Andrew Morton
2003-02-04 5:37 ` Eric W. Biederman
2003-02-04 5:50 ` William Lee Irwin III
2003-02-04 7:06 ` Eric W. Biederman
2003-02-04 7:16 ` Martin J. Bligh
2003-02-04 12:40 ` Eric W. Biederman
2003-02-04 15:55 ` Martin J. Bligh
2003-02-05 12:18 ` Eric W. Biederman
2003-02-04 21:12 ` Andrew Morton
2003-02-05 12:25 ` Eric W. Biederman
2003-02-05 19:57 ` Andrew Morton
2003-02-05 20:00 ` Andrew Morton
2003-02-02 10:55 ` Andrew Morton
2003-02-02 10:56 ` Andrew Morton
2003-02-02 20:06 ` William Lee Irwin III
2003-02-02 10:56 ` Andrew Morton
2003-02-02 10:56 ` Andrew Morton
2003-02-02 10:57 ` Andrew Morton
2003-02-02 10:57 ` Andrew Morton [this message]
2003-02-02 20:17 ` William Lee Irwin III
2003-02-02 10:57 ` Andrew Morton
2003-02-07 21:49 Seth, Rohit
2003-02-07 22:00 ` Andrew Morton
2003-02-07 22:02 Seth, Rohit
2003-02-07 22:24 ` Andrew Morton
2003-02-08 1:47 Seth, Rohit
2003-02-08 2:02 ` Andrew Morton
2003-02-08 3:05 Seth, Rohit
2003-02-08 8:48 ` Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030202025720.25bbf46d.akpm@digeo.com \
--to=akpm@digeo.com \
--cc=anton@samba.org \
--cc=davem@redhat.com \
--cc=davidm@napali.hpl.hp.com \
--cc=linux-mm@kvack.org \
--cc=rohit.seth@intel.com \
--cc=wli@holomorphy.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox