Re: [PATCH] dma-debug: Fix the overlap() function to be correctand readable

From: Ingo Molnar
Date: Fri Jul 10 2009 - 16:34:31 EST



* Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:

>
>
> On Fri, 10 Jul 2009, Ingo Molnar wrote:
> >
> > How about the patch below? Lightly tested.
> >
> > if (!PageHighMem(page)) {
> > - void *addr = ((char *)page_address(page)) + offset;
> > + void *addr = (void *)page_address(page) + offset;
> > +
>
> Why is that 'void *' cast there? page_address() is already a void *.
>
> Other than that it obviously looks good to me. But I never see my
> own bugs.

hm, indeed. I distinctly remember page_address() having been
unsigned long ten years ago.

And yes, i still have a "highmem-2.2.21-A0" patch proving it:

--- linux/include/linux/pagemap.h.orig Thu Oct 7 14:54:24 1999
+++ linux/include/linux/pagemap.h Wed Oct 13 02:44:03 1999
@@ -11,12 +11,24 @@

#include <linux/mm.h>
#include <linux/fs.h>
+#include <linux/list.h>

-static inline unsigned long page_address(struct page * page)
+extern inline unsigned long FIXME_page_address(struct page * page)
{
+ if (PageHIGHMEM(page))
+ BUG();
return PAGE_OFFSET + ((page - mem_map) << PAGE_SHIFT);

Which, beyond being a rather embarrasing hunk (whose author i wont
name voluntarily - i'll rather take the 5th), also shows that
page_address() started out as an unsigned long.

Which got cleaned up for good once we added page->address, instead
of the above direct calculation.

( Note to self: consider checking the types of core MM facilities
somewhat more frequently than every 10 years. )

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/