summaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2009-01-08 12:04:48 +0000
committerDavid Howells <dhowells@redhat.com>2009-01-08 12:04:48 +0000
commitab2e83ead4eca9e045daac4cbf66eb1e7a244bb2 (patch)
tree0e42c62476d09a5b7389ba02eb093448af36c58b /mm
parent0f3e442a403a344a5d0a49af9ecd7632b7e7343a (diff)
downloadop-kernel-dev-ab2e83ead4eca9e045daac4cbf66eb1e7a244bb2.zip
op-kernel-dev-ab2e83ead4eca9e045daac4cbf66eb1e7a244bb2.tar.gz
NOMMU: Teach kobjsize() about VMA regions.
Now that we no longer use compound pages for all large allocations, kobjsize() actively breaks things like binfmt_flat by always handing back PAGE_SIZE for mmap'ed regions. Fix this up by looking up the VMA region for non-compounds. Ideally binfmt_flat wants to get rid of kobjsize() completely, but this is an incremental step. Signed-off-by: Paul Mundt <lethal@linux-sh.org> Signed-off-by: David Howells <dhowells@redhat.com> Tested-by: Mike Frysinger <vapier.adi@gmail.com>
Diffstat (limited to 'mm')
-rw-r--r--mm/nommu.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/mm/nommu.c b/mm/nommu.c
index a6e8ccf..60ed837 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -149,6 +149,20 @@ unsigned int kobjsize(const void *objp)
return ksize(objp);
/*
+ * If it's not a compound page, see if we have a matching VMA
+ * region. This test is intentionally done in reverse order,
+ * so if there's no VMA, we still fall through and hand back
+ * PAGE_SIZE for 0-order pages.
+ */
+ if (!PageCompound(page)) {
+ struct vm_area_struct *vma;
+
+ vma = find_vma(current->mm, (unsigned long)objp);
+ if (vma)
+ return vma->vm_end - vma->vm_start;
+ }
+
+ /*
* The ksize() function is only guaranteed to work for pointers
* returned by kmalloc(). So handle arbitrary pointers here.
*/
OpenPOWER on IntegriCloud