From: Paul Mundt <lethal@linux-sh.org>
To: Christoph Lameter <clameter@sgi.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Pekka Enberg <penberg@cs.helsinki.fi>,
David Howells <dhowells@redhat.com>,
LKML <linux-kernel@vger.kernel.org>,
cooloney@kernel.org, mpm@selenic.com
Subject: Re: [PATCH] nommu: fix kobjsize() for SLOB and SLUB, v2.
Date: Wed, 11 Jun 2008 16:33:30 +0900 [thread overview]
Message-ID: <20080611073330.GB30983@linux-sh.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0806101027220.17093@schroedinger.engr.sgi.com>
On Tue, Jun 10, 2008 at 10:30:36AM -0700, Christoph Lameter wrote:
> On Mon, 2 Jun 2008, Paul Mundt wrote:
>
> > + page = virt_to_head_page(objp);
> > + if (!page)
> > + return 0;
>
> virt_to_head_page cannot return NULL. virt_to_page also does not return
> NULL. pfn_valid() needs to be used to figure out if a page is valid.
> Otherwise the page struct reference that was returned may have
> PageReserved() set to indicate that it is not a valid page.
>
> > + * The ksize() function is only guaranteed to work for pointers
> > + * returned by kmalloc(). So handle arbitrary pointers, that we expect
> > + * always to be compound pages, here.
> > + */
> > + if (PageCompound(page))
> > + order = compound_order(page);
>
> compund order returns 0 if you use compound_order() on a
> non compound page. No need for the PageCompound test.
>
Thanks for the review. Using virt_addr_valid() we can also get rid of
blackfin's idiotic > memory_end test for its DMA addresses, as the same
logic is encapsulated there. How does this look?
---
mm/nommu.c | 21 +++------------------
1 file changed, 3 insertions(+), 18 deletions(-)
diff --git a/mm/nommu.c b/mm/nommu.c
index 3abd084..4462b6a 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -104,21 +104,15 @@ EXPORT_SYMBOL(vmtruncate);
unsigned int kobjsize(const void *objp)
{
struct page *page;
- int order = 0;
/*
* If the object we have should not have ksize performed on it,
* return size of 0
*/
- if (!objp)
- return 0;
-
- if ((unsigned long)objp >= memory_end)
+ if (!objp || !virt_addr_valid(objp))
return 0;
page = virt_to_head_page(objp);
- if (!page)
- return 0;
/*
* If the allocator sets PageSlab, we know the pointer came from
@@ -129,18 +123,9 @@ unsigned int kobjsize(const void *objp)
/*
* The ksize() function is only guaranteed to work for pointers
- * returned by kmalloc(). So handle arbitrary pointers, that we expect
- * always to be compound pages, here.
- */
- if (PageCompound(page))
- order = compound_order(page);
-
- /*
- * Finally, handle arbitrary pointers that don't set PageSlab.
- * Default to 0-order in the case when we're unable to ksize()
- * the object.
+ * returned by kmalloc(). So handle arbitrary pointers here.
*/
- return PAGE_SIZE << order;
+ return PAGE_SIZE << compound_order(page);
}
/*
next prev parent reply other threads:[~2008-06-11 7:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-02 7:27 [PATCH] nommu: fix kobjsize() for SLOB and SLUB, v2 Paul Mundt
2008-06-05 16:26 ` David Howells
2008-06-10 17:30 ` Christoph Lameter
2008-06-10 18:18 ` Vegard Nossum
2008-06-10 18:30 ` Christoph Lameter
2008-06-11 7:33 ` Paul Mundt [this message]
2008-06-11 23:22 ` Christoph Lameter
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=20080611073330.GB30983@linux-sh.org \
--to=lethal@linux-sh.org \
--cc=akpm@linux-foundation.org \
--cc=clameter@sgi.com \
--cc=cooloney@kernel.org \
--cc=dhowells@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mpm@selenic.com \
--cc=penberg@cs.helsinki.fi \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.