From: Andrew Morton <akpm@osdl.org>
To: Badari Pulavarty <pbadari@us.ibm.com>
Cc: andrea@suse.de, linux-kernel@vger.kernel.org, hugh@veritas.com,
dvhltc@us.ibm.com, linux-mm@kvack.org, blaisorblade@yahoo.it,
jdike@addtoit.com
Subject: Re: [PATCH] 2.6.14 patch for supporting madvise(MADV_REMOVE)
Date: Fri, 11 Nov 2005 16:25:11 -0800 [thread overview]
Message-ID: <20051111162511.57ee1af3.akpm@osdl.org> (raw)
In-Reply-To: <1130947957.24503.70.camel@localhost.localdomain>
Badari Pulavarty <pbadari@us.ibm.com> wrote:
>
> +/*
> + * Application wants to free up the pages and associated backing store.
> + * This is effectively punching a hole into the middle of a file.
> + *
> + * NOTE: Currently, only shmfs/tmpfs is supported for this operation.
> + * Other filesystems return -ENOSYS.
> + */
> +static long madvise_remove(struct vm_area_struct * vma,
> + unsigned long start, unsigned long end)
> +{
> + struct address_space *mapping;
> + loff_t offset, endoff;
> +
> + if (vma->vm_flags & (VM_LOCKED|VM_NONLINEAR|VM_HUGETLB))
> + return -EINVAL;
> +
> + if (!vma->vm_file || !vma->vm_file->f_mapping
> + || !vma->vm_file->f_mapping->host) {
> + return -EINVAL;
> + }
> +
> + mapping = vma->vm_file->f_mapping;
> + if (mapping == &swapper_space) {
> + return -EINVAL;
> + }
> +
> + offset = (loff_t)(start - vma->vm_start)
> + + (vma->vm_pgoff << PAGE_SHIFT);
> + endoff = (loff_t)(end - vma->vm_start - 1)
> + + (vma->vm_pgoff << PAGE_SHIFT);
> + return vmtruncate_range(mapping->host, offset, endoff);
> +}
> +
I'm suspecting you tested this on a 64-bit machine, yes? On 32-bit that
vm_pgoff shift is going to overflow.
Fixes-thus-far below. Please rerun all tests on x86?
Why does madvise_remove() have an explicit check for swapper_space?
In your testing, how are you determining that the code is successfully
removing the correct number of pages, from the correct file offset?
diff -puN mm/madvise.c~madvise-remove-remove-pages-from-tmpfs-shm-backing-store-tidy mm/madvise.c
--- devel/mm/madvise.c~madvise-remove-remove-pages-from-tmpfs-shm-backing-store-tidy 2005-11-11 16:12:43.000000000 -0800
+++ devel-akpm/mm/madvise.c 2005-11-11 16:16:50.000000000 -0800
@@ -147,8 +147,8 @@ static long madvise_dontneed(struct vm_a
* NOTE: Currently, only shmfs/tmpfs is supported for this operation.
* Other filesystems return -ENOSYS.
*/
-static long madvise_remove(struct vm_area_struct * vma,
- unsigned long start, unsigned long end)
+static long madvise_remove(struct vm_area_struct *vma,
+ unsigned long start, unsigned long end)
{
struct address_space *mapping;
loff_t offset, endoff;
@@ -162,14 +162,13 @@ static long madvise_remove(struct vm_are
}
mapping = vma->vm_file->f_mapping;
- if (mapping == &swapper_space) {
+ if (mapping == &swapper_space)
return -EINVAL;
- }
offset = (loff_t)(start - vma->vm_start)
- + (vma->vm_pgoff << PAGE_SHIFT);
+ + ((loff_t)vma->vm_pgoff << PAGE_SHIFT);
endoff = (loff_t)(end - vma->vm_start - 1)
- + (vma->vm_pgoff << PAGE_SHIFT);
+ + ((loff_t)vma->vm_pgoff << PAGE_SHIFT);
return vmtruncate_range(mapping->host, offset, endoff);
}
diff -puN mm/memory.c~madvise-remove-remove-pages-from-tmpfs-shm-backing-store-tidy mm/memory.c
--- devel/mm/memory.c~madvise-remove-remove-pages-from-tmpfs-shm-backing-store-tidy 2005-11-11 16:16:54.000000000 -0800
+++ devel-akpm/mm/memory.c 2005-11-11 16:17:59.000000000 -0800
@@ -1608,10 +1608,9 @@ out_big:
out_busy:
return -ETXTBSY;
}
-
EXPORT_SYMBOL(vmtruncate);
-int vmtruncate_range(struct inode * inode, loff_t offset, loff_t end)
+int vmtruncate_range(struct inode *inode, loff_t offset, loff_t end)
{
struct address_space *mapping = inode->i_mapping;
@@ -1634,7 +1633,6 @@ int vmtruncate_range(struct inode * inod
return 0;
}
-
EXPORT_SYMBOL(vmtruncate_range);
/*
_
next prev parent reply other threads:[~2005-11-12 0:26 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1130366995.23729.38.camel@localhost.localdomain>
[not found] ` <20051028034616.GA14511@ccure.user-mode-linux.org>
[not found] ` <43624F82.6080003@us.ibm.com>
[not found] ` <20051028184235.GC8514@ccure.user-mode-linux.org>
[not found] ` <1130544201.23729.167.camel@localhost.localdomain>
[not found] ` <20051029025119.GA14998@ccure.user-mode-linux.org>
[not found] ` <1130788176.24503.19.camel@localhost.localdomain>
[not found] ` <20051101000509.GA11847@ccure.user-mode-linux.org>
2005-11-02 1:15 ` [PATCH] 2.6.14 patch for supporting madvise(MADV_FREE) Badari Pulavarty
2005-11-02 1:43 ` Andrea Arcangeli
2005-11-02 15:49 ` Badari Pulavarty
2005-11-02 16:12 ` [PATCH] 2.6.14 patch for supporting madvise(MADV_REMOVE) Badari Pulavarty
2005-11-02 19:54 ` New bug in patch and existing Linux code - race with install_page() (was: Re: [PATCH] 2.6.14 patch for supporting madvise(MADV_REMOVE)) Blaisorblade
2005-11-02 20:12 ` Hugh Dickins
2005-11-02 20:45 ` Hugh Dickins
2005-11-02 21:36 ` Badari Pulavarty
2005-11-02 21:55 ` Hugh Dickins
2005-11-02 22:02 ` Badari Pulavarty
2005-11-12 0:25 ` Andrew Morton [this message]
2005-11-12 0:34 ` [PATCH] 2.6.14 patch for supporting madvise(MADV_REMOVE) Badari Pulavarty
2005-11-12 1:43 ` Andrew Morton
2005-11-12 4:41 ` Badari Pulavarty
2006-01-16 13:06 ` differences between MADV_FREE and MADV_DONTNEED Andrea Arcangeli
2006-01-16 16:02 ` Suleiman Souhlal
2006-01-16 16:28 ` Andrea Arcangeli
2006-01-16 17:03 ` Suleiman Souhlal
2006-01-16 17:24 ` Andrea Arcangeli
2006-01-16 21:43 ` Eric W. Biederman
2006-01-17 0:24 ` Suleiman Souhlal
2006-01-17 1:04 ` Nicholas Miell
2006-01-17 12:43 ` Christoph Hellwig
2006-01-17 18:23 ` Eric W. Biederman
2006-01-17 22:55 ` Nicholas Miell
2007-03-01 18:11 ` Samuel Thibault
2006-01-17 19:06 ` Badari Pulavarty
2006-01-17 1:06 ` Blaisorblade
2006-01-17 1:33 ` Andrea Arcangeli
2005-11-12 0:34 ` [PATCH] 2.6.14 patch for supporting madvise(MADV_REMOVE) 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=20051111162511.57ee1af3.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=andrea@suse.de \
--cc=blaisorblade@yahoo.it \
--cc=dvhltc@us.ibm.com \
--cc=hugh@veritas.com \
--cc=jdike@addtoit.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pbadari@us.ibm.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
Powered by JetHome