Add a new function
compound_nth_page(page, n)
and
vmalloc_nth_page(page, n)
to find the nth page of a compound page. For real compound pages
his simply reduces to page + n. For virtual compound pages we need to consult
the page tables to figure out the nth page from the one specified.
Update all the references to page[1] to use compound_nth instead.
---
include/linux/mm.h | 17 +++++++++++++----
mm/page_alloc.c | 16 +++++++++++-----
mm/vmalloc.c | 10 ++++++++++
3 files changed, 34 insertions(+), 9 deletions(-)
Index: linux-2.6/include/linux/mm.h
===================================================================
--- linux-2.6.orig/include/linux/mm.h 2007-10-03 19:31:45.000000000 -0700
+++ linux-2.6/include/linux/mm.h 2007-10-03 19:31:51.000000000 -0700
@@ -295,6 +295,8 @@ static inline int get_page_unless_zero(s
}
void *vmalloc_address(struct page *);
+struct page *vmalloc_to_page(void *addr);
+struct page *vmalloc_nth_page(struct page *page, int n);
static inline struct page *compound_head(struct page *page)
{
@@ -338,27 +340,34 @@ void split_page(struct page *page, unsig
*/
typedef void compound_page_dtor(struct page *);
+static inline struct page *compound_nth_page(struct page *page, int n)
+{
+ if (likely(!PageVcompound(page)))
+ return page + n;
+ return vmalloc_nth_page(page, n);
+}
+
static inline void set_compound_page_dtor(struct page *page,
compound_page_dtor *dtor)
{
- page[1].lru.next = (void *)dtor;
+ compound_nth_page(page, 1)->lru.next = (void *)dtor;
}
static inline compound_page_dtor *get_compound_page_dtor(struct page *page)
{
- return (compound_page_dtor *)page[1].lru.next;
+ return (compound_page_dtor *)compound_nth_page(page, 1)->lru.next;
}
static inline int compound_order(struct page *page)
{
if (!PageHead(page))
return 0;
- return (unsigned long)page[1].lru.prev;
+ return (unsigned long)compound_nth_page(page, 1)->lru.prev;
}
static inline void set_compound_order(struct page *page, unsigned long order)
{
- page[1].lru.prev = (void *)order;
+ compound_nth_page(page, 1)->lru.prev = (void *)order;
}
/*
Index: linux-2.6/mm/vmalloc.c
===================================================================
--- linux-2.6.orig/mm/vmalloc.c 2007-10-03 19:31:45.000000000 -0700
+++ linux-2.6/mm/vmalloc.c 2007-10-03 19:31:51.000000000 -0700
@@ -541,6 +541,16 @@ void *vmalloc(unsigned long size)
}
EXPORT_SYMBOL(vmalloc);
+/*
+ * Given a pointer to the first page struct:
+ * Determine a pointer to the nth page.
+ */
+struct page *vmalloc_nth_page(struct page *page, int n)
+{
+ return vmalloc_to_page(page_address(page) + n * PAGE_SIZE);
+}
+EXPORT_SYMBOL(vmalloc_nth_page);
+
/**
* vmalloc_user - allocate zeroed virtually contiguous memory for userspace
* @size: allocation size
Index: linux-2.6/mm/page_alloc.c
===================================================================
--- linux-2.6.orig/mm/page_alloc.c 2007-10-03 19:31:51.000000000 -0700
+++ linux-2.6/mm/page_alloc.c 2007-10-03 19:32:45.000000000 -0700
@@ -274,7 +274,7 @@ static void prep_compound_page(struct pa
set_compound_order(page, order);
__SetPageHead(page);
for (i = 1; i < nr_pages; i++) {
- struct page *p = page + i;
+ struct page *p = compound_nth_page(page, i);
__SetPageTail(p);
p->first_page = page;
@@ -289,17 +289,23 @@ static void destroy_compound_page(struct
if (unlikely(compound_order(page) != order))
bad_page(page);
- if (unlikely(!PageHead(page)))
- bad_page(page);
- __ClearPageHead(page);
for (i = 1; i < nr_pages; i++) {
- struct page *p = page + i;
+ struct page *p = compound_nth_page(page, i);
if (unlikely(!PageTail(p) |
(p->first_page != page)))
bad_page(page);
__ClearPageTail(p);
}
+
+ /*
+ * The PageHead is important since it determines how operations on
+ * a compound page have to be performed. We can only tear the head
+ * down after all the tail pages are done.
+ */
+ if (unlikely(!PageHead(page)))
+ bad_page(page);
+ __ClearPageHead(page);
}
static inline void prep_zero_page(struct page *page, int order, gfp_t gfp_flags)
--
Hi,
I am a kernel newbie, so need some help trying to compile it.
I have fedora 7 installed.
While compiling it, I get errors as follows.....
HOSTCC scripts/basic/fixdep
scripts/basic/fixdep.c:107:23: error: sys/types.h: No such file or
directory
scripts/basic/fixdep.c:108:22: error: sys/stat.h: No such file or
directory
scripts/basic/fixdep.c:109:22: error: sys/mman.h: No such file or
directory
scripts/basic/fixdep.c:110:20: error: unistd.h: No such file or
directory
scripts/basic/fixdep.c:111:19: error: fcntl.h: No such file or directory
scripts/basic/fixdep.c:112:20: error: string.h: No such file or
directory
scripts/basic/fixdep.c:113:20: error: stdlib.h: No such file or
directory
scripts/basic/fixdep.c:114:19: error: stdio.h: No such file or directory
In file included
from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/include/syslimits.h:7,
from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/include/limits.h:11,
from scripts/basic/fixdep.c:115:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/include/limits.h:122:61: error:
limits.h: No such file or directory
scripts/basic/fixdep.c:116:19: error: ctype.h: No such file or directory
scripts/basic/fixdep.c:117:23: error: arpa/inet.h: No such file or
directory
scripts/basic/fixdep.c: In function ‘usage’:
scripts/basic/fixdep.c:131: warning: implicit declaration of function
‘fprintf’
scripts/basic/fixdep.c:131: warning: incompatible implicit declaration
of built-in function ‘fprintf’
scripts/basic/fixdep.c:131: error: ‘stderr’ undeclared (first use in
this function)
scripts/basic/fixdep.c:131: error: (Each undeclared identifier is
reported only once
scripts/basic/fixdep.c:131: error: for each function it appears in.)
scripts/basic/fixdep.c:132: warning: implicit declaration of function
‘exit’
scripts/basic/fixdep.c:132: warning: incompatible implicit declaration
of built-in function ‘exit’
scripts/basic/fixdep.c: In function ‘print_cmdline’:
scripts/basic/fixdep.c:140: warning: implicit declaration of function
‘printf’
scripts/basic/fixdep.c:140: warning: incompatible implicit declaration
of built-in function ‘printf’
scripts/basic/fixdep.c: At top level:
scripts/basic/fixdep.c:143: error: ‘NULL’ undeclared here (not in a
function)
scripts/basic/fixdep.c: In function ‘grow_config’:
scripts/basic/fixdep.c:156: warning: implicit declaration of function
‘realloc’
scripts/basic/fixdep.c:156: warning: assignment makes pointer from
integer without a cast
scripts/basic/fixdep.c:158: warning: implicit declaration of function
‘perror’
scripts/basic/fixdep.c:158: warning: incompatible implicit declaration
of built-in function ‘exit’
scripts/basic/fixdep.c: In function ‘is_defined_config’:
scripts/basic/fixdep.c:174: warning: implicit declaration of function
‘memcmp’
scripts/basic/fixdep.c: In function ‘define_config’:
scripts/basic/fixdep.c:187: warning: implicit declaration of function
‘memcpy’
scripts/basic/fixdep.c:187: warning: incompatible implicit declaration
of built-in function ‘memcpy’
scripts/basic/fixdep.c: In function ‘use_config’:
scripts/basic/fixdep.c:206: error: ‘PATH_MAX’ undeclared (first use in
this function)
scripts/basic/fixdep.c:214: warning: incompatible implicit declaration
of built-in function ‘memcpy’
scripts/basic/fixdep.c:220: warning: implicit declaration of function
‘tolower’
scripts/basic/fixdep.c:222: warning: incompatible implicit declaration
of built-in function ‘printf’
scripts/basic/fixdep.c:206: warning: unused variable ‘s’
scripts/basic/fixdep.c: At top level:
scripts/basic/fixdep.c:225: error: expected declaration specifiers or
‘...’ before ‘size_t’
scripts/basic/fixdep.c: In function ‘parse_config_file’:
scripts/basic/fixdep.c:227: error: ‘len’ undeclared (first use in this
function)
scripts/basic/fixdep.c:233: warning: implicit declaration of function
‘ntohl’
scripts/basic/fixdep.c:244: warning: implicit declaration of function
‘isalnum’
scripts/basic/fixdep.c: In function ‘strrcmp’:
scripts/basic/fixdep.c:261: warning: implicit declaration of function
‘strlen’
scripts/basic/fixdep.c:261: warning: incompatible implicit declaration
of built-in function ‘strlen’
scripts/basic/fixdep.c: In function ‘do_config_file’:
scripts/basic/fixdep.c:272: error: storage size of ‘st’ isn’t known
scripts/basic/fixdep.c:276: warning: implicit declaration of function
‘open’
scripts/basic/fixdep.c:276: error: ‘O_RDONLY’ undeclared (first use in
this function)
scripts/basic/fixdep.c:278: warning: incompatible implicit declaration
of built-in function ‘fprintf’
scripts/basic/fixdep.c:278: error: ‘stderr’ undeclared (first use in
this function)
On many forums it said I need to have 2.4 kernel headers. I can't
understand why is it so? Am I missing something?
I used git for getting the latest kernel.
git-clone
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Is there something similar for getting kernel headers? Please help.
Thanks,
Animesh Saxena
Greetings,
This is not the proper forum for compilation help (if nothing is broken of course). You would probably get good help asking on fedora forum (or simply do a search there). Looking at your log it seems to more reflect headers missing than anything wrong with the kernel in it self.
If you fail to find anything useful, I can help you but please send me mail directly so we don't put additional weight on
this mailinglist.
Best wishes
Kristoffer Ericson
On Sat, 13 Oct 2007 22:16:08 +0530
animesh saxena <[email protected]> wrote:
> Hi,
> I am a kernel newbie, so need some help trying to compile it.
> I have fedora 7 installed.
>
> While compiling it, I get errors as follows.....
>
> HOSTCC scripts/basic/fixdep
> scripts/basic/fixdep.c:107:23: error: sys/types.h: No such file or
> directory
> scripts/basic/fixdep.c:108:22: error: sys/stat.h: No such file or
> directory
> scripts/basic/fixdep.c:109:22: error: sys/mman.h: No such file or
> directory
> scripts/basic/fixdep.c:110:20: error: unistd.h: No such file or
> directory
> scripts/basic/fixdep.c:111:19: error: fcntl.h: No such file or directory
> scripts/basic/fixdep.c:112:20: error: string.h: No such file or
> directory
> scripts/basic/fixdep.c:113:20: error: stdlib.h: No such file or
> directory
> scripts/basic/fixdep.c:114:19: error: stdio.h: No such file or directory
> In file included
> from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/include/syslimits.h:7,
>
> from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/include/limits.h:11,
> from scripts/basic/fixdep.c:115:
> /usr/lib/gcc/x86_64-redhat-linux/4.1.2/include/limits.h:122:61: error:
> limits.h: No such file or directory
> scripts/basic/fixdep.c:116:19: error: ctype.h: No such file or directory
> scripts/basic/fixdep.c:117:23: error: arpa/inet.h: No such file or
> directory
> scripts/basic/fixdep.c: In function ‘usage’:
> scripts/basic/fixdep.c:131: warning: implicit declaration of function
> ‘fprintf’
> scripts/basic/fixdep.c:131: warning: incompatible implicit declaration
> of built-in function ‘fprintf’
> scripts/basic/fixdep.c:131: error: ‘stderr’ undeclared (first use in
> this function)
> scripts/basic/fixdep.c:131: error: (Each undeclared identifier is
> reported only once
> scripts/basic/fixdep.c:131: error: for each function it appears in.)
> scripts/basic/fixdep.c:132: warning: implicit declaration of function
> ‘exit’
> scripts/basic/fixdep.c:132: warning: incompatible implicit declaration
> of built-in function ‘exit’
> scripts/basic/fixdep.c: In function ‘print_cmdline’:
> scripts/basic/fixdep.c:140: warning: implicit declaration of function
> ‘printf’
> scripts/basic/fixdep.c:140: warning: incompatible implicit declaration
> of built-in function ‘printf’
> scripts/basic/fixdep.c: At top level:
> scripts/basic/fixdep.c:143: error: ‘NULL’ undeclared here (not in a
> function)
> scripts/basic/fixdep.c: In function ‘grow_config’:
> scripts/basic/fixdep.c:156: warning: implicit declaration of function
> ‘realloc’
> scripts/basic/fixdep.c:156: warning: assignment makes pointer from
> integer without a cast
> scripts/basic/fixdep.c:158: warning: implicit declaration of function
> ‘perror’
> scripts/basic/fixdep.c:158: warning: incompatible implicit declaration
> of built-in function ‘exit’
> scripts/basic/fixdep.c: In function ‘is_defined_config’:
> scripts/basic/fixdep.c:174: warning: implicit declaration of function
> ‘memcmp’
> scripts/basic/fixdep.c: In function ‘define_config’:
> scripts/basic/fixdep.c:187: warning: implicit declaration of function
> ‘memcpy’
> scripts/basic/fixdep.c:187: warning: incompatible implicit declaration
> of built-in function ‘memcpy’
> scripts/basic/fixdep.c: In function ‘use_config’:
> scripts/basic/fixdep.c:206: error: ‘PATH_MAX’ undeclared (first use in
> this function)
> scripts/basic/fixdep.c:214: warning: incompatible implicit declaration
> of built-in function ‘memcpy’
> scripts/basic/fixdep.c:220: warning: implicit declaration of function
> ‘tolower’
> scripts/basic/fixdep.c:222: warning: incompatible implicit declaration
> of built-in function ‘printf’
> scripts/basic/fixdep.c:206: warning: unused variable ‘s’
> scripts/basic/fixdep.c: At top level:
> scripts/basic/fixdep.c:225: error: expected declaration specifiers or
> ‘...’ before ‘size_t’
> scripts/basic/fixdep.c: In function ‘parse_config_file’:
> scripts/basic/fixdep.c:227: error: ‘len’ undeclared (first use in this
> function)
> scripts/basic/fixdep.c:233: warning: implicit declaration of function
> ‘ntohl’
> scripts/basic/fixdep.c:244: warning: implicit declaration of function
> ‘isalnum’
> scripts/basic/fixdep.c: In function ‘strrcmp’:
> scripts/basic/fixdep.c:261: warning: implicit declaration of function
> ‘strlen’
> scripts/basic/fixdep.c:261: warning: incompatible implicit declaration
> of built-in function ‘strlen’
> scripts/basic/fixdep.c: In function ‘do_config_file’:
> scripts/basic/fixdep.c:272: error: storage size of ‘st’ isn’t known
> scripts/basic/fixdep.c:276: warning: implicit declaration of function
> ‘open’
> scripts/basic/fixdep.c:276: error: ‘O_RDONLY’ undeclared (first use in
> this function)
> scripts/basic/fixdep.c:278: warning: incompatible implicit declaration
> of built-in function ‘fprintf’
> scripts/basic/fixdep.c:278: error: ‘stderr’ undeclared (first use in
> this function)
>
> On many forums it said I need to have 2.4 kernel headers. I can't
> understand why is it so? Am I missing something?
>
> I used git for getting the latest kernel.
>
> git-clone
> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
>
> Is there something similar for getting kernel headers? Please help.
>
> Thanks,
> Animesh Saxena
>
>
>
>
>
>
>
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
Kristoffer Ericson <[email protected]>
On Sat, Oct 13, 2007 at 10:16:08PM +0530, animesh saxena wrote:
> Hi,
> I am a kernel newbie, so need some help trying to compile it.
> I have fedora 7 installed.
>
> While compiling it, I get errors as follows.....
>
> HOSTCC scripts/basic/fixdep
> scripts/basic/fixdep.c:107:23: error: sys/types.h: No such file or
> directory
> scripts/basic/fixdep.c:108:22: error: sys/stat.h: No such file or
> directory
> scripts/basic/fixdep.c:109:22: error: sys/mman.h: No such file or
> directory
> scripts/basic/fixdep.c:110:20: error: unistd.h: No such file or
> directory
> scripts/basic/fixdep.c:111:19: error: fcntl.h: No such file or directory
> scripts/basic/fixdep.c:112:20: error: string.h: No such file or
> directory
> scripts/basic/fixdep.c:113:20: error: stdlib.h: No such file or
> directory
> scripts/basic/fixdep.c:114:19: error: stdio.h: No such file or directory
It seems to me that you do not have glibc-devel or any other name it
can have on your distro. It's very likely that after that you will be
missing a few other development packages, but you'll quickly find them
one at a time.
(...)
> On many forums it said I need to have 2.4 kernel headers. I can't
> understand why is it so? Am I missing something?
Possibly that you will also need some random kernel-header-xxxx package,
I don't know how it's packaged. Install the libc headers first to see.
> I used git for getting the latest kernel.
>
> git-clone
> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
If you're a newbie, you're not encouraged to try building GIT kernels.
They are *very* likely to break during build with nasty errors. You'd
better get the official releases in tar.bz2 form which are know to build
and work for most people.
> Is there something similar for getting kernel headers? Please help.
not to my knowledge.
Regards,
Willy