# compile my kernel module with kernel sources

**URL:** <https://forums.suse.com/t/compile-my-kernel-module-with-kernel-sources/32957>\
**Category:** SLES Configure-Administer\
**Created:** [September 24, 2018, 9:36am UTC](https://forums.suse.com/t/compile-my-kernel-module-with-kernel-sources/32957 "2018-09-24T09:36:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![gonezapcars2club](https://avatars.discourse-cdn.com/v4/letter/g/ebca7d/32.png) [@gonezapcars2club](https://forums.suse.com/u/gonezapcars2club)\
**Post date:** [September 24, 2018, 9:36am UTC](https://forums.suse.com/t/compile-my-kernel-module-with-kernel-sources/32957/1 "2018-09-24T09:36:14Z")

</div>

Hi,  
When I compile my kernel module, as I did for suse 12.2, i get the following:  
#error ZONES\_SHIFT – too many zones configured adjust calculation

from looking at the sources, it seems that MAX\_NR\_ZONES is undefined.  
Where is it suppose to be ? and what does ZONES\_SHIFT means ? and what the value suppose to be ?

---

<div class="post-metadata">

**Author:** ![malcolmlewis](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/malcolmlewis/32/11375_2.png) [@malcolmlewis](https://forums.suse.com/u/malcolmlewis)\
**Post date:** [September 24, 2018, 2:58pm UTC](https://forums.suse.com/t/compile-my-kernel-module-with-kernel-sources/32957/2 "2018-09-24T14:58:59Z")

</div>

[QUOTE=gonezapcars2club;54531]Hi,  
When I compile my kernel module, as I did for suse 12.2, i get the following:  
#error ZONES\_SHIFT – too many zones configured adjust calculation

from looking at the sources, it seems that MAX\_NR\_ZONES is undefined.  
Where is it suppose to be ? and what does ZONES\_SHIFT means ? and what the value suppose to be ?[/QUOTE]  
Hi and welcome to the Forum 🙂  
So what is the kernel module your trying to compile?

You would need to check the module Makefile/Kconfig for this setting. I imagine a header file with;

```auto
#define MAX_NR_ZONES N
```

Where N is the number you want set.

---

<div class="post-metadata">

**Author:** ![gonezapcars2club](https://avatars.discourse-cdn.com/v4/letter/g/ebca7d/32.png) [@gonezapcars2club](https://forums.suse.com/u/gonezapcars2club)\
**Post date:** [September 25, 2018, 3:53pm UTC](https://forums.suse.com/t/compile-my-kernel-module-with-kernel-sources/32957/3 "2018-09-25T15:53:33Z")

</div>

What is N ? i am not suppose to set it.

SUSE-SLES123 4.4.131-94.29-default

---

<div class="post-metadata">

**Author:** ![malcolmlewis](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/malcolmlewis/32/11375_2.png) [@malcolmlewis](https://forums.suse.com/u/malcolmlewis)\
**Post date:** [September 25, 2018, 4:18pm UTC](https://forums.suse.com/t/compile-my-kernel-module-with-kernel-sources/32957/4 "2018-09-25T16:18:14Z")

</div>

> [@](#):
>
> On Tue 25 Sep 2018 12:54:02 PM CDT, gonezapcars2club wrote:
> 
> What is N ? i am not suppose to set it.
> 
> SUSE-SLES123 4.4.131-94.29-default

Hi  
It’s something in the module code, not the kernel… it could be a yes  
or no and not a number… that’s why I asked for information on the  
module. Or post the whole output of the gcc command and error…

–  
Cheers Malcolm Â°Â¿Â° SUSE Knowledge Partner (Linux Counter #276890)  
SLES 15 | GNOME Shell 3.26.2 | 4.12.14-25.16-default  
If you find this post helpful and are logged into the web interface,  
please show your appreciation and click on the star below… Thanks!

---

<div class="post-metadata">

**Author:** ![Jens-U](https://avatars.discourse-cdn.com/v4/letter/j/d78d45/32.png) [@Jens-U](https://forums.suse.com/u/Jens-U)\
**Post date:** [September 25, 2018, 5:54pm UTC](https://forums.suse.com/t/compile-my-kernel-module-with-kernel-sources/32957/5 "2018-09-25T17:54:58Z")

</div>

Hi gonezapcars2club,

is that from you, too? [https://www.linuxquestions.org/questions/showthread.php?p=5907575#post5907575](https://www.linuxquestions.org/questions/showthread.php?p=5907575#post5907575)

[QUOTE]When compiling I get the following exception:  
/usr/src/linux-4.4.131-94.29/include/linux/page-flags-layout.h:21:2:  
error: #error ZONES\_SHIFT – too many zones configured adjust  
calculation  
#error ZONES\_SHIFT – too many zones configured adjust calculation

I assume MAX\_NR\_ZONES is not defined.  
How could that be ?

The code for page-flags-layout.h line 21 is:  
#if MAX\_NR\_ZONES \< 2  
#define ZONES\_SHIFT 0  
#elif MAX\_NR\_ZONES \<= 2  
#define ZONES\_SHIFT 1  
#elif MAX\_NR\_ZONES \<= 4  
#define ZONES\_SHIFT 2  
#else  
#error ZONES\_SHIFT – too many zones configured adjust calculation  
#endif[/QUOTE]

looking at [https://elixir.bootlin.com/linux/v4.4.131/source/kernel/bounds.c#L19](https://elixir.bootlin.com/linux/v4.4.131/source/kernel/bounds.c#L19), MAX\_NR\_ZONES is derived from \_\_MAX\_NR\_ZONES. Which in turn is auto-generated in [https://elixir.bootlin.com/linux/v4.4.131/source/include/linux/mmzone.h#L326](https://elixir.bootlin.com/linux/v4.4.131/source/include/linux/mmzone.h#L326) to “6”, if I counted right. So it’s not unset, but set to a value larger than 4, resulting in the #error in the #else case. Do you agree?

Regards,  
J

---

<div class="post-metadata">

**Author:** ![gonezapcars2club](https://avatars.discourse-cdn.com/v4/letter/g/ebca7d/32.png) [@gonezapcars2club](https://forums.suse.com/u/gonezapcars2club)\
**Post date:** [September 25, 2018, 10:36pm UTC](https://forums.suse.com/t/compile-my-kernel-module-with-kernel-sources/32957/6 "2018-09-25T22:36:00Z")

</div>

So how can someone compile this code ?

---

<div class="post-metadata">

**Author:** ![gonezapcars2club](https://avatars.discourse-cdn.com/v4/letter/g/ebca7d/32.png) [@gonezapcars2club](https://forums.suse.com/u/gonezapcars2club)\
**Post date:** [September 25, 2018, 10:40pm UTC](https://forums.suse.com/t/compile-my-kernel-module-with-kernel-sources/32957/7 "2018-09-25T22:40:11Z")

</div>

My kernel module is company-internal VFS layer driver.  
So what additional output can be helpful for solving this issue ?  
Thanks !

---

<div class="post-metadata">

**Author:** ![Jens-U](https://avatars.discourse-cdn.com/v4/letter/j/d78d45/32.png) [@Jens-U](https://forums.suse.com/u/Jens-U)\
**Post date:** [September 26, 2018, 6:05pm UTC](https://forums.suse.com/t/compile-my-kernel-module-with-kernel-sources/32957/8 "2018-09-26T18:05:45Z")

</div>

Hi gonezapcars2club,

> [@gonezapcars2club;54587](#):
>
> So how can someone compile this code ?

[QUOTE]In suse 12.3 (4.4.131-94.29-default), I downloaded the source package  
(kernel-source-4.4.131-94.29.1.src.rpm), extract linux-4.4.tar.xz out  
of it, copy to /usr/src/4.4.131-94.29 and update symbolic link from  
/lib/modules/4.4.131-94.29-default/source to source →   
/usr/src/linux-4.4.131-94.29[/QUOTE]

Maybe the answer is in the other files, some patch that’s included with the distro source RPM. Or maybe that failing code branch hasn’t been ported and is only used in an isolated way? I haven’t had a closer look so far.

Have you checked the upstream kernel sources, to see if it compiles cleanly and then checking if your module compiles against it cleanly? Once you did, you can take it from there to the distro-specific things. If it already fails with the upstream code, the Linux kernel ML may be helpful to find out what needs to be adjusted.

Regards,  
J
