* [PATCH] kobject: add the missing export for kobject_create()
@ 2021-08-31 6:50 Qu Wenruo
2021-08-31 6:57 ` Greg KH
2021-08-31 7:32 ` Nikolay Borisov
0 siblings, 2 replies; 6+ messages in thread
From: Qu Wenruo @ 2021-08-31 6:50 UTC (permalink / raw)
To: gregkh, rafael; +Cc: linux-btrfs
[BUG]
For any module utilizing kobject_create(), it will lead to link error:
$ make M=fs/btrfs -j12
CC [M] fs/btrfs/sysfs.o
LD [M] fs/btrfs/btrfs.o
MODPOST fs/btrfs/Module.symvers
ERROR: modpost: "kobject_create" [fs/btrfs/btrfs.ko] undefined!
make[1]: *** [scripts/Makefile.modpost:150: fs/btrfs/Module.symvers] Error 1
make[1]: *** Deleting file 'fs/btrfs/Module.symvers'
make: *** [Makefile:1766: modules] Error 2
[CAUSE]
It's pretty straight forward, kobject_create() doesn't have
EXPORT_SYMBOL_GPL().
[FIX]
Fix it by adding the missing EXPORT_SYMBOL_GPL().
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
A little surprised by the fact that no know even is calling
kobject_create() now.
Or should we just call kmalloc() manually then kobject_init_and_add()?
---
lib/kobject.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/kobject.c b/lib/kobject.c
index ea53b30cf483..af308cf7dba2 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -788,6 +788,7 @@ struct kobject *kobject_create(void)
kobject_init(kobj, &dynamic_kobj_ktype);
return kobj;
}
+EXPORT_SYMBOL_GPL(kobject_create);
/**
* kobject_create_and_add() - Create a struct kobject dynamically and
--
2.33.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] kobject: add the missing export for kobject_create()
2021-08-31 6:50 [PATCH] kobject: add the missing export for kobject_create() Qu Wenruo
@ 2021-08-31 6:57 ` Greg KH
2021-08-31 7:53 ` Qu Wenruo
2021-08-31 7:32 ` Nikolay Borisov
1 sibling, 1 reply; 6+ messages in thread
From: Greg KH @ 2021-08-31 6:57 UTC (permalink / raw)
To: Qu Wenruo; +Cc: rafael, linux-btrfs
On Tue, Aug 31, 2021 at 02:50:09PM +0800, Qu Wenruo wrote:
> [BUG]
> For any module utilizing kobject_create(), it will lead to link error:
>
> $ make M=fs/btrfs -j12
> CC [M] fs/btrfs/sysfs.o
> LD [M] fs/btrfs/btrfs.o
> MODPOST fs/btrfs/Module.symvers
> ERROR: modpost: "kobject_create" [fs/btrfs/btrfs.ko] undefined!
> make[1]: *** [scripts/Makefile.modpost:150: fs/btrfs/Module.symvers] Error 1
> make[1]: *** Deleting file 'fs/btrfs/Module.symvers'
> make: *** [Makefile:1766: modules] Error 2
>
> [CAUSE]
> It's pretty straight forward, kobject_create() doesn't have
> EXPORT_SYMBOL_GPL().
>
> [FIX]
> Fix it by adding the missing EXPORT_SYMBOL_GPL().
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
> A little surprised by the fact that no know even is calling
> kobject_create() now.
>
> Or should we just call kmalloc() manually then kobject_init_and_add()?
> ---
> lib/kobject.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/lib/kobject.c b/lib/kobject.c
> index ea53b30cf483..af308cf7dba2 100644
> --- a/lib/kobject.c
> +++ b/lib/kobject.c
> @@ -788,6 +788,7 @@ struct kobject *kobject_create(void)
> kobject_init(kobj, &dynamic_kobj_ktype);
> return kobj;
> }
> +EXPORT_SYMBOL_GPL(kobject_create);
>
> /**
> * kobject_create_and_add() - Create a struct kobject dynamically and
> --
> 2.33.0
>
What in-kernel module needs to call this function? No driver should be
messing with calls to kobjects like this.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] kobject: add the missing export for kobject_create()
2021-08-31 6:50 [PATCH] kobject: add the missing export for kobject_create() Qu Wenruo
2021-08-31 6:57 ` Greg KH
@ 2021-08-31 7:32 ` Nikolay Borisov
1 sibling, 0 replies; 6+ messages in thread
From: Nikolay Borisov @ 2021-08-31 7:32 UTC (permalink / raw)
To: Qu Wenruo, gregkh, rafael; +Cc: linux-btrfs
On 31.08.21 г. 9:50, Qu Wenruo wrote:
> [BUG]
> For any module utilizing kobject_create(), it will lead to link error:
>
> $ make M=fs/btrfs -j12
> CC [M] fs/btrfs/sysfs.o
> LD [M] fs/btrfs/btrfs.o
> MODPOST fs/btrfs/Module.symvers
> ERROR: modpost: "kobject_create" [fs/btrfs/btrfs.ko] undefined!
> make[1]: *** [scripts/Makefile.modpost:150: fs/btrfs/Module.symvers] Error 1
> make[1]: *** Deleting file 'fs/btrfs/Module.symvers'
> make: *** [Makefile:1766: modules] Error 2
>
> [CAUSE]
> It's pretty straight forward, kobject_create() doesn't have
> EXPORT_SYMBOL_GPL().
>
> [FIX]
> Fix it by adding the missing EXPORT_SYMBOL_GPL().
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
> A little surprised by the fact that no know even is calling
> kobject_create() now.
>
> Or should we just call kmalloc() manually then kobject_init_and_add()?
There is kobject_create_and_add which seems to be the preferred public API.
> ---
> lib/kobject.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/lib/kobject.c b/lib/kobject.c
> index ea53b30cf483..af308cf7dba2 100644
> --- a/lib/kobject.c
> +++ b/lib/kobject.c
> @@ -788,6 +788,7 @@ struct kobject *kobject_create(void)
> kobject_init(kobj, &dynamic_kobj_ktype);
> return kobj;
> }
> +EXPORT_SYMBOL_GPL(kobject_create);
>
> /**
> * kobject_create_and_add() - Create a struct kobject dynamically and
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] kobject: add the missing export for kobject_create()
2021-08-31 6:57 ` Greg KH
@ 2021-08-31 7:53 ` Qu Wenruo
2021-08-31 20:04 ` Greg KH
0 siblings, 1 reply; 6+ messages in thread
From: Qu Wenruo @ 2021-08-31 7:53 UTC (permalink / raw)
To: Greg KH; +Cc: rafael, linux-btrfs
On 2021/8/31 下午2:57, Greg KH wrote:
> On Tue, Aug 31, 2021 at 02:50:09PM +0800, Qu Wenruo wrote:
>> [BUG]
>> For any module utilizing kobject_create(), it will lead to link error:
>>
>> $ make M=fs/btrfs -j12
>> CC [M] fs/btrfs/sysfs.o
>> LD [M] fs/btrfs/btrfs.o
>> MODPOST fs/btrfs/Module.symvers
>> ERROR: modpost: "kobject_create" [fs/btrfs/btrfs.ko] undefined!
>> make[1]: *** [scripts/Makefile.modpost:150: fs/btrfs/Module.symvers] Error 1
>> make[1]: *** Deleting file 'fs/btrfs/Module.symvers'
>> make: *** [Makefile:1766: modules] Error 2
>>
>> [CAUSE]
>> It's pretty straight forward, kobject_create() doesn't have
>> EXPORT_SYMBOL_GPL().
>>
>> [FIX]
>> Fix it by adding the missing EXPORT_SYMBOL_GPL().
>>
>> Signed-off-by: Qu Wenruo <wqu@suse.com>
>> ---
>> A little surprised by the fact that no know even is calling
>> kobject_create() now.
>>
>> Or should we just call kmalloc() manually then kobject_init_and_add()?
>> ---
>> lib/kobject.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/lib/kobject.c b/lib/kobject.c
>> index ea53b30cf483..af308cf7dba2 100644
>> --- a/lib/kobject.c
>> +++ b/lib/kobject.c
>> @@ -788,6 +788,7 @@ struct kobject *kobject_create(void)
>> kobject_init(kobj, &dynamic_kobj_ktype);
>> return kobj;
>> }
>> +EXPORT_SYMBOL_GPL(kobject_create);
>>
>> /**
>> * kobject_create_and_add() - Create a struct kobject dynamically and
>> --
>> 2.33.0
>>
>
> What in-kernel module needs to call this function? No driver should be
> messing with calls to kobjects like this.
But kobject_create_and_add() can't specify ktype if we want extra
attributes to the new kobject.
Or is the following way the preferred call style?
local_kobj = kmalloc();
ret = kobject_init_and_add();
Then I guess we should not export kobject_create() at all even in its
header.
Thanks,
Qu
>
> thanks,
>
> greg k-h
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] kobject: add the missing export for kobject_create()
2021-08-31 7:53 ` Qu Wenruo
@ 2021-08-31 20:04 ` Greg KH
2021-08-31 22:58 ` Qu Wenruo
0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2021-08-31 20:04 UTC (permalink / raw)
To: Qu Wenruo; +Cc: rafael, linux-btrfs
On Tue, Aug 31, 2021 at 03:53:02PM +0800, Qu Wenruo wrote:
>
>
> On 2021/8/31 下午2:57, Greg KH wrote:
> > On Tue, Aug 31, 2021 at 02:50:09PM +0800, Qu Wenruo wrote:
> > > [BUG]
> > > For any module utilizing kobject_create(), it will lead to link error:
> > >
> > > $ make M=fs/btrfs -j12
> > > CC [M] fs/btrfs/sysfs.o
> > > LD [M] fs/btrfs/btrfs.o
> > > MODPOST fs/btrfs/Module.symvers
> > > ERROR: modpost: "kobject_create" [fs/btrfs/btrfs.ko] undefined!
> > > make[1]: *** [scripts/Makefile.modpost:150: fs/btrfs/Module.symvers] Error 1
> > > make[1]: *** Deleting file 'fs/btrfs/Module.symvers'
> > > make: *** [Makefile:1766: modules] Error 2
> > >
> > > [CAUSE]
> > > It's pretty straight forward, kobject_create() doesn't have
> > > EXPORT_SYMBOL_GPL().
> > >
> > > [FIX]
> > > Fix it by adding the missing EXPORT_SYMBOL_GPL().
> > >
> > > Signed-off-by: Qu Wenruo <wqu@suse.com>
> > > ---
> > > A little surprised by the fact that no know even is calling
> > > kobject_create() now.
> > >
> > > Or should we just call kmalloc() manually then kobject_init_and_add()?
> > > ---
> > > lib/kobject.c | 1 +
> > > 1 file changed, 1 insertion(+)
> > >
> > > diff --git a/lib/kobject.c b/lib/kobject.c
> > > index ea53b30cf483..af308cf7dba2 100644
> > > --- a/lib/kobject.c
> > > +++ b/lib/kobject.c
> > > @@ -788,6 +788,7 @@ struct kobject *kobject_create(void)
> > > kobject_init(kobj, &dynamic_kobj_ktype);
> > > return kobj;
> > > }
> > > +EXPORT_SYMBOL_GPL(kobject_create);
> > > /**
> > > * kobject_create_and_add() - Create a struct kobject dynamically and
> > > --
> > > 2.33.0
> > >
> >
> > What in-kernel module needs to call this function? No driver should be
> > messing with calls to kobjects like this.
>
> But kobject_create_and_add() can't specify ktype if we want extra attributes
> to the new kobject.
You didn't answer this question, what in-kernel driver needs this? We
do not export things that are not needed to be exported.
> Or is the following way the preferred call style?
>
> local_kobj = kmalloc();
> ret = kobject_init_and_add();
Depends on your need.
Why do you need to call this function from a module?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] kobject: add the missing export for kobject_create()
2021-08-31 20:04 ` Greg KH
@ 2021-08-31 22:58 ` Qu Wenruo
0 siblings, 0 replies; 6+ messages in thread
From: Qu Wenruo @ 2021-08-31 22:58 UTC (permalink / raw)
To: Greg KH, Qu Wenruo; +Cc: rafael, linux-btrfs
On 2021/9/1 上午4:04, Greg KH wrote:
> On Tue, Aug 31, 2021 at 03:53:02PM +0800, Qu Wenruo wrote:
>>
>>
>> On 2021/8/31 下午2:57, Greg KH wrote:
>>> On Tue, Aug 31, 2021 at 02:50:09PM +0800, Qu Wenruo wrote:
>>>> [BUG]
>>>> For any module utilizing kobject_create(), it will lead to link error:
>>>>
>>>> $ make M=fs/btrfs -j12
>>>> CC [M] fs/btrfs/sysfs.o
>>>> LD [M] fs/btrfs/btrfs.o
>>>> MODPOST fs/btrfs/Module.symvers
>>>> ERROR: modpost: "kobject_create" [fs/btrfs/btrfs.ko] undefined!
>>>> make[1]: *** [scripts/Makefile.modpost:150: fs/btrfs/Module.symvers] Error 1
>>>> make[1]: *** Deleting file 'fs/btrfs/Module.symvers'
>>>> make: *** [Makefile:1766: modules] Error 2
>>>>
>>>> [CAUSE]
>>>> It's pretty straight forward, kobject_create() doesn't have
>>>> EXPORT_SYMBOL_GPL().
>>>>
>>>> [FIX]
>>>> Fix it by adding the missing EXPORT_SYMBOL_GPL().
>>>>
>>>> Signed-off-by: Qu Wenruo <wqu@suse.com>
>>>> ---
>>>> A little surprised by the fact that no know even is calling
>>>> kobject_create() now.
>>>>
>>>> Or should we just call kmalloc() manually then kobject_init_and_add()?
>>>> ---
>>>> lib/kobject.c | 1 +
>>>> 1 file changed, 1 insertion(+)
>>>>
>>>> diff --git a/lib/kobject.c b/lib/kobject.c
>>>> index ea53b30cf483..af308cf7dba2 100644
>>>> --- a/lib/kobject.c
>>>> +++ b/lib/kobject.c
>>>> @@ -788,6 +788,7 @@ struct kobject *kobject_create(void)
>>>> kobject_init(kobj, &dynamic_kobj_ktype);
>>>> return kobj;
>>>> }
>>>> +EXPORT_SYMBOL_GPL(kobject_create);
>>>> /**
>>>> * kobject_create_and_add() - Create a struct kobject dynamically and
>>>> --
>>>> 2.33.0
>>>>
>>>
>>> What in-kernel module needs to call this function? No driver should be
>>> messing with calls to kobjects like this.
>>
>> But kobject_create_and_add() can't specify ktype if we want extra attributes
>> to the new kobject.
>
> You didn't answer this question, what in-kernel driver needs this? We
> do not export things that are not needed to be exported.
Then the function should not be declared in kobject.h either.
Originally I just want a dynamically allocated kobject with extra
attributes.
Thus I look into the callers of kobject_create_and_add(), and lsp points
to the header where just one line before kobject_create_and_add(), there
comes kobject_create().
But after more reading into kobject.c, kobject_create() creates kobject
with dynamic ktype, thus in theory we shouldn't change its type halfway.
>
>> Or is the following way the preferred call style?
>>
>> local_kobj = kmalloc();
>> ret = kobject_init_and_add();
>
> Depends on your need.
>
> Why do you need to call this function from a module?
As explained, a want a dynamically allocated kobject while has extra
attributes.
As kobject_create_and_add() can't have extra attributes, while
kobject_init_and_add() needs an existing kobject.
But now I understand why it's not that possible, as kobject_create()
will initialize its dynamic ktype, thus with its .release function fixed.
Currently I go the kmalloc() then kobject_init_and_add() way instead,
and the .release is just the same as the dynamic ktype to kfree() the
kobject.
Thus I send a new patch to unexport kobject_create() from kobject.h.
Thanks,
Qu
>
> thanks,
>
> greg k-h
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-08-31 22:59 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-31 6:50 [PATCH] kobject: add the missing export for kobject_create() Qu Wenruo
2021-08-31 6:57 ` Greg KH
2021-08-31 7:53 ` Qu Wenruo
2021-08-31 20:04 ` Greg KH
2021-08-31 22:58 ` Qu Wenruo
2021-08-31 7:32 ` Nikolay Borisov
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.