compile my kernel module with kernel sources

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=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 :slight_smile:
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;

#define MAX_NR_ZONES N

Where N is the number you want set.

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!

Hi gonezapcars2club,

is that from you, too? 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, 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 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

So how can someone compile this code ?

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

Hi gonezapcars2club,

[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