* Out-of-tree Kernel Modules
@ 2024-10-30 12:58 Yishai Jaffe
2024-10-30 13:25 ` [yocto] " Quentin Schulz
0 siblings, 1 reply; 6+ messages in thread
From: Yishai Jaffe @ 2024-10-30 12:58 UTC (permalink / raw)
To: yocto
[-- Attachment #1: Type: text/plain, Size: 1583 bytes --]
Hi,
I'm having a problem compiling my out of tree kernel module.
I've managed to reproduce my problem with the meta-skeleton hello-mod
recipe.
I'm working with poky on branch scarthgap.
Here are the necessary changes:
diff --git a/meta-skeleton/recipes-kernel/hello-mod/files/hello.c
b/meta-skeleton/recipes-kernel/hello-mod/files/hello.c
index 4f73455d20..221b5da97c 100644
--- a/meta-skeleton/recipes-kernel/hello-mod/files/hello.c
+++ b/meta-skeleton/recipes-kernel/hello-mod/files/hello.c
@@ -7,9 +7,13 @@
*****************************************************************************/
#include <linux/module.h>
+#include <linux/sched/types.h>
static int __init hello_init(void)
{
+ struct sched_param a = {
+ .sched_priority = 1,
+ };
pr_info("Hello World!\n");
return 0;
}
As you can see I'm trying to use the sched_param struct but when compiling
I get the following error:
|
/home/user/dev/yishai/yocto/build/tmp/work/qemux86_64-poky-linux/hello-mod/0.1/hello.c:
In function 'hello_init':
|
/home/user/dev/yishai/yocto/build/tmp/work/qemux86_64-poky-linux/hello-mod/0.1/hello.c:14:16:
error: variable 'a' has initializer but incomplete type
| 14 | struct sched_param a = {
This looks as if the struct isn't defined anywhere but if I look
at tmp/work/qemux86_64-poky-linux/hello-mod/0.1/recipe-sysroot/usr/include/linux/sched/types.h
which should be the header that I included - I can see that it is defined.
Therefore, it seems like that is not the actual header being included.
Would love to get some help on this!
Thanks in advance,
Yishai Jaffe
[-- Attachment #2: Type: text/html, Size: 2032 bytes --]
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [yocto] Out-of-tree Kernel Modules
2024-10-30 12:58 Out-of-tree Kernel Modules Yishai Jaffe
@ 2024-10-30 13:25 ` Quentin Schulz
2024-10-30 14:54 ` Yishai Jaffe
0 siblings, 1 reply; 6+ messages in thread
From: Quentin Schulz @ 2024-10-30 13:25 UTC (permalink / raw)
To: yocto, yishai1999
Hi Yishai,
On 10/30/24 1:58 PM, Yishai Jaffe via lists.yoctoproject.org wrote:
> You don't often get email from yishai1999=gmail.com@lists.yoctoproject.org. Learn why this is important<https://aka.ms/LearnAboutSenderIdentification>
> Hi,
> I'm having a problem compiling my out of tree kernel module.
> I've managed to reproduce my problem with the meta-skeleton hello-mod recipe.
> I'm working with poky on branch scarthgap.
> Here are the necessary changes:
>
> diff --git a/meta-skeleton/recipes-kernel/hello-mod/files/hello.c b/meta-skeleton/recipes-kernel/hello-mod/files/hello.c
> index 4f73455d20..221b5da97c 100644
> --- a/meta-skeleton/recipes-kernel/hello-mod/files/hello.c
> +++ b/meta-skeleton/recipes-kernel/hello-mod/files/hello.c
> @@ -7,9 +7,13 @@
> *****************************************************************************/
>
> #include <linux/module.h>
> +#include <linux/sched/types.h>
>
> static int __init hello_init(void)
> {
> + struct sched_param a = {
> + .sched_priority = 1,
> + };
> pr_info("Hello World!\n");
> return 0;
> }
>
> As you can see I'm trying to use the sched_param struct but when compiling I get the following error:
>
> | /home/user/dev/yishai/yocto/build/tmp/work/qemux86_64-poky-linux/hello-mod/0.1/hello.c: In function 'hello_init':
> | /home/user/dev/yishai/yocto/build/tmp/work/qemux86_64-poky-linux/hello-mod/0.1/hello.c:14:16: error: variable 'a' has initializer but incomplete type
> | 14 | struct sched_param a = {
>
> This looks as if the struct isn't defined anywhere but if I look at tmp/work/qemux86_64-poky-linux/hello-mod/0.1/recipe-sysroot/usr/include/linux/sched/types.h which should be the header that I included - I can see that it is defined.
> Therefore, it seems like that is not the actual header being included.
>
> Would love to get some help on this!
>
Just giving hints at where to look at next, not sure this is really
valuable information but here it is.
6.6 had the structure defined in include/uapi/linux/sched/types.h but
6.7+ has it in include/linux/sched.h, c.f.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d844fe65f0957024c3e1b0bf2a0615246184d9bc
If I am not mistaken, the kernel headers are coming from
linux-libc-headers which would be 6.6 on Scarthgap, and not your kernel
recipe (because it is **REALLY** bad to use non-upstream kernel headers,
feel free to read the big comment in
meta/recipes-kernel/linux-libc-headers/linux-libc-headers.inc :)
If that is the case, then you probably need to include
uapi/linux/sched/types.h instead?
You probably need a different include for 6.7+ which would simply be
include/sched.h?
Hope this helps.
Cheers,
Quentin
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [yocto] Out-of-tree Kernel Modules
2024-10-30 13:25 ` [yocto] " Quentin Schulz
@ 2024-10-30 14:54 ` Yishai Jaffe
2024-10-30 15:01 ` Quentin Schulz
0 siblings, 1 reply; 6+ messages in thread
From: Yishai Jaffe @ 2024-10-30 14:54 UTC (permalink / raw)
To: Quentin Schulz, yocto
[-- Attachment #1: Type: text/plain, Size: 211 bytes --]
Thanks Quentin,
Changing the include to uapi/linux/sched/types.h solved the issue.
But just so I'm clear on this - Can you explain when I should use uapi headers vs when to use the regular linux/xxx headers?
[-- Attachment #2: Type: text/html, Size: 1624 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [yocto] Out-of-tree Kernel Modules
2024-10-30 14:54 ` Yishai Jaffe
@ 2024-10-30 15:01 ` Quentin Schulz
2024-10-30 19:01 ` Yishai Jaffe
0 siblings, 1 reply; 6+ messages in thread
From: Quentin Schulz @ 2024-10-30 15:01 UTC (permalink / raw)
To: yishai1999, yocto
Hi Yishai,
On 10/30/24 3:54 PM, Yishai Jaffe via Lists.Yoctoproject.Org wrote:
> You don't often get email from yishai1999=gmail.com@lists.yoctoproject.org. Learn why this is important<https://aka.ms/LearnAboutSenderIdentification>
> Thanks Quentin,
> Changing the include to uapi/linux/sched/types.h solved the issue.
> But just so I'm clear on this - Can you explain when I should use uapi headers vs when to use the regular linux/xxx headers?
>
You should include the header where the structure is defined.
The "issue" in Yocto is that the headers aren't coming from your kernel
sources but from a generic linux kernel header recipe, and this is made
on purpose. The generic linux kernel header recipe is at 6.6 in
Scarthgap. Styhead has 6.10. The structure is defined in a different
header in 6.6 and in 6.7+ (including 6.10), so your out-of-tree module
needs the path from 6.6 in order to compile in Scarthgap, but will need
another path from 6.7+ in order to compile in Styhead.
You can handle that via #if in your code, if you need the exact same
source code to build on different Yocto/kernel versions. That is the
cross to bear when one develops out of tree kernel modules sadly.
Cheers,
Quentin
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [yocto] Out-of-tree Kernel Modules
2024-10-30 15:01 ` Quentin Schulz
@ 2024-10-30 19:01 ` Yishai Jaffe
2024-10-31 7:33 ` Yoann Congal
0 siblings, 1 reply; 6+ messages in thread
From: Yishai Jaffe @ 2024-10-30 19:01 UTC (permalink / raw)
To: Quentin Schulz; +Cc: yocto
[-- Attachment #1: Type: text/plain, Size: 1602 bytes --]
Hi Quentin,
On Wed, Oct 30, 2024 at 5:01 PM Quentin Schulz <quentin.schulz@cherry.de>
wrote:
> Hi Yishai,
>
> On 10/30/24 3:54 PM, Yishai Jaffe via Lists.Yoctoproject.Org wrote:
> > You don't often get email from yishai1999=
> gmail.com@lists.yoctoproject.org. Learn why this is important<
> https://aka.ms/LearnAboutSenderIdentification>
> > Thanks Quentin,
> > Changing the include to uapi/linux/sched/types.h solved the issue.
> > But just so I'm clear on this - Can you explain when I should use uapi
> headers vs when to use the regular linux/xxx headers?
> >
>
> You should include the header where the structure is defined.
>
> The "issue" in Yocto is that the headers aren't coming from your kernel
> sources but from a generic linux kernel header recipe, and this is made
> on purpose. The generic linux kernel header recipe is at 6.6 in
> Scarthgap. Styhead has 6.10. The structure is defined in a different
> header in 6.6 and in 6.7+ (including 6.10), so your out-of-tree module
> needs the path from 6.6 in order to compile in Scarthgap, but will need
> another path from 6.7+ in order to compile in Styhead.
>
>
I think my question wasn't clear enough.
I meant to ask about the general usage of uapi header files.
When are definitions put in the uapi headers and when are they in the
regular linux headers?
> You can handle that via #if in your code, if you need the exact same
> source code to build on different Yocto/kernel versions. That is the
> cross to bear when one develops out of tree kernel modules sadly.
>
> Cheers,
> Quentin
>
[-- Attachment #2: Type: text/html, Size: 2470 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [yocto] Out-of-tree Kernel Modules
2024-10-30 19:01 ` Yishai Jaffe
@ 2024-10-31 7:33 ` Yoann Congal
0 siblings, 0 replies; 6+ messages in thread
From: Yoann Congal @ 2024-10-31 7:33 UTC (permalink / raw)
To: Yocto Mailing list, yishai1999; +Cc: Quentin Schulz
[-- Attachment #1: Type: text/plain, Size: 2382 bytes --]
Le mer. 30 oct. 2024 à 20:01, Yishai Jaffe via lists.yoctoproject.org
<yishai1999=gmail.com@lists.yoctoproject.org> a écrit :
> Hi Quentin,
>
> On Wed, Oct 30, 2024 at 5:01 PM Quentin Schulz <quentin.schulz@cherry.de>
> wrote:
>
>> Hi Yishai,
>>
>> On 10/30/24 3:54 PM, Yishai Jaffe via Lists.Yoctoproject.Org wrote:
>> > You don't often get email from yishai1999=
>> gmail.com@lists.yoctoproject.org. Learn why this is important<
>> https://aka.ms/LearnAboutSenderIdentification>
>> > Thanks Quentin,
>> > Changing the include to uapi/linux/sched/types.h solved the issue.
>> > But just so I'm clear on this - Can you explain when I should use uapi
>> headers vs when to use the regular linux/xxx headers?
>> >
>>
>> You should include the header where the structure is defined.
>>
>> The "issue" in Yocto is that the headers aren't coming from your kernel
>> sources but from a generic linux kernel header recipe, and this is made
>> on purpose. The generic linux kernel header recipe is at 6.6 in
>> Scarthgap. Styhead has 6.10. The structure is defined in a different
>> header in 6.6 and in 6.7+ (including 6.10), so your out-of-tree module
>> needs the path from 6.6 in order to compile in Scarthgap, but will need
>> another path from 6.7+ in order to compile in Styhead.
>>
>>
> I think my question wasn't clear enough.
> I meant to ask about the general usage of uapi header files.
> When are definitions put in the uapi headers and when are they in the
> regular linux headers?
>
The best explanation I could find when I hit this issue a few weeks ago is
a stack overflow answer:
https://stackoverflow.com/a/18858544 (+links inside)
Does that help?
>
>> You can handle that via #if in your code, if you need the exact same
>> source code to build on different Yocto/kernel versions. That is the
>> cross to bear when one develops out of tree kernel modules sadly.
>>
>> Cheers,
>> Quentin
>>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#64189):
> https://lists.yoctoproject.org/g/yocto/message/64189
> Mute This Topic: https://lists.yoctoproject.org/mt/109295266/4316185
> Group Owner: yocto+owner@lists.yoctoproject.org
> Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [
> yoann.congal@smile.fr]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
[-- Attachment #2: Type: text/html, Size: 4552 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-10-31 7:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-30 12:58 Out-of-tree Kernel Modules Yishai Jaffe
2024-10-30 13:25 ` [yocto] " Quentin Schulz
2024-10-30 14:54 ` Yishai Jaffe
2024-10-30 15:01 ` Quentin Schulz
2024-10-30 19:01 ` Yishai Jaffe
2024-10-31 7:33 ` Yoann Congal
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.