* [PATCH] kobject: WARN as tip when call kobject_get() to a kobject not initialized
@ 2015-03-12 4:04 Ethan Zhao
2015-03-12 7:45 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Ethan Zhao @ 2015-03-12 4:04 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, ethan.kernel, Ethan Zhao
call kobject_get() to kojbect that is not initalized or released will only
leave following like call trace to us:
-----------[ cut here ]------------
[ 54.545816] WARNING: CPU: 0 PID: 213 at include/linux/kref.h:47
kobject_get+0x41/0x50()
[ 54.642595] Modules linked in: i2c_i801(+) mfd_core shpchp(+)
acpi_cpufreq(+) edac_core ioatdma(+) xfs libcrc32c ast syscopyarea ixgbe
sysfillrect sysimgblt sr_mod sd_mod drm_kms_helper igb mdio cdrom e1000e ahci
dca ttm libahci uas drm i2c_algo_bit ptp megaraid_sas libata usb_storage
i2c_core pps_core dm_mirror dm_region_hash dm_log dm_mod
[ 55.007264] CPU: 0 PID: 213 Comm: kworker/0:2 Not tainted
3.18.5
[ 55.099970] Hardware name: Oracle Corporation SUN FIRE X4170 M2 SERVER
/ASSY,MOTHERBOARD,X4170, BIOS 08120104 05/08/2012
[ 55.239736] Workqueue: kacpi_notify acpi_os_execute_deferred
[ 55.308598] 0000000000000000 00000000bd730b61 ffff88046742baf8
ffffffff816b7edb
[ 55.398305] 0000000000000000 0000000000000000 ffff88046742bb38
ffffffff81078ae1
[ 55.488040] ffff88046742bbd8 ffff8806706b3000 0000000000000292
0000000000000000
[ 55.577776] Call Trace:
[ 55.608228] [<ffffffff816b7edb>] dump_stack+0x46/0x58
[ 55.670895] [<ffffffff81078ae1>] warn_slowpath_common+0x81/0xa0
[ 55.743952] [<ffffffff81078bfa>] warn_slowpath_null+0x1a/0x20
[ 55.814929] [<ffffffff8130d0d1>] kobject_get+0x41/0x50
[ 55.878654] [<ffffffff8153e955>] cpufreq_cpu_get+0x75/0xc0
[ 55.946528] [<ffffffff8153f37e>] cpufreq_update_policy+0x2e/0x1f0
The above issue was casued by a race condition, if there is a WARN in
kobject_get() of the kobject is not initialized, that would save us much
time to debug it.
Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
---
lib/kobject.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lib/kobject.c b/lib/kobject.c
index 03d4ab3..3b841b9 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -576,8 +576,13 @@ void kobject_del(struct kobject *kobj)
*/
struct kobject *kobject_get(struct kobject *kobj)
{
- if (kobj)
+ if (kobj) {
+ if (!kobj->state_initialized)
+ WARN(1, KERN_WARNING "kobject: '%s' (%p): is not "
+ "initialized, yet kobject_get() is being "
+ "called.\n", kobject_name(kobj), kobj);
kref_get(&kobj->kref);
+ }
return kobj;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] kobject: WARN as tip when call kobject_get() to a kobject not initialized
2015-03-12 4:04 [PATCH] kobject: WARN as tip when call kobject_get() to a kobject not initialized Ethan Zhao
@ 2015-03-12 7:45 ` Greg KH
2015-03-12 9:27 ` Ethan Zhao
0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2015-03-12 7:45 UTC (permalink / raw)
To: Ethan Zhao; +Cc: linux-kernel, ethan.kernel
On Thu, Mar 12, 2015 at 01:04:16PM +0900, Ethan Zhao wrote:
> call kobject_get() to kojbect that is not initalized or released will only
> leave following like call trace to us:
>
> -----------[ cut here ]------------
> [ 54.545816] WARNING: CPU: 0 PID: 213 at include/linux/kref.h:47
> kobject_get+0x41/0x50()
> [ 54.642595] Modules linked in: i2c_i801(+) mfd_core shpchp(+)
> acpi_cpufreq(+) edac_core ioatdma(+) xfs libcrc32c ast syscopyarea ixgbe
> sysfillrect sysimgblt sr_mod sd_mod drm_kms_helper igb mdio cdrom e1000e ahci
> dca ttm libahci uas drm i2c_algo_bit ptp megaraid_sas libata usb_storage
> i2c_core pps_core dm_mirror dm_region_hash dm_log dm_mod
> [ 55.007264] CPU: 0 PID: 213 Comm: kworker/0:2 Not tainted
> 3.18.5
> [ 55.099970] Hardware name: Oracle Corporation SUN FIRE X4170 M2 SERVER
> /ASSY,MOTHERBOARD,X4170, BIOS 08120104 05/08/2012
> [ 55.239736] Workqueue: kacpi_notify acpi_os_execute_deferred
> [ 55.308598] 0000000000000000 00000000bd730b61 ffff88046742baf8
> ffffffff816b7edb
> [ 55.398305] 0000000000000000 0000000000000000 ffff88046742bb38
> ffffffff81078ae1
> [ 55.488040] ffff88046742bbd8 ffff8806706b3000 0000000000000292
> 0000000000000000
> [ 55.577776] Call Trace:
> [ 55.608228] [<ffffffff816b7edb>] dump_stack+0x46/0x58
> [ 55.670895] [<ffffffff81078ae1>] warn_slowpath_common+0x81/0xa0
> [ 55.743952] [<ffffffff81078bfa>] warn_slowpath_null+0x1a/0x20
> [ 55.814929] [<ffffffff8130d0d1>] kobject_get+0x41/0x50
> [ 55.878654] [<ffffffff8153e955>] cpufreq_cpu_get+0x75/0xc0
> [ 55.946528] [<ffffffff8153f37e>] cpufreq_update_policy+0x2e/0x1f0
>
> The above issue was casued by a race condition, if there is a WARN in
> kobject_get() of the kobject is not initialized, that would save us much
> time to debug it.
>
> Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
> ---
> lib/kobject.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/lib/kobject.c b/lib/kobject.c
> index 03d4ab3..3b841b9 100644
> --- a/lib/kobject.c
> +++ b/lib/kobject.c
> @@ -576,8 +576,13 @@ void kobject_del(struct kobject *kobj)
> */
> struct kobject *kobject_get(struct kobject *kobj)
> {
> - if (kobj)
> + if (kobj) {
> + if (!kobj->state_initialized)
> + WARN(1, KERN_WARNING "kobject: '%s' (%p): is not "
> + "initialized, yet kobject_get() is being "
> + "called.\n", kobject_name(kobj), kobj);
> kref_get(&kobj->kref);
> + }
> return kobj;
> }
>
Have you tried running a system with this patch to see if there are a
lot of messages at boot time? I'm a bit worried that the initial
kobject init sequence would trigger this, but haven't looked at the full
codepath just yet given that I haven't had my morning coffee...
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] kobject: WARN as tip when call kobject_get() to a kobject not initialized
2015-03-12 7:45 ` Greg KH
@ 2015-03-12 9:27 ` Ethan Zhao
0 siblings, 0 replies; 3+ messages in thread
From: Ethan Zhao @ 2015-03-12 9:27 UTC (permalink / raw)
To: Greg KH; +Cc: Ethan Zhao, LKML
On Thu, Mar 12, 2015 at 3:45 PM, Greg KH <gregkh@linuxfoundation.org> wrote:
> On Thu, Mar 12, 2015 at 01:04:16PM +0900, Ethan Zhao wrote:
>> call kobject_get() to kojbect that is not initalized or released will only
>> leave following like call trace to us:
>>
>> -----------[ cut here ]------------
>> [ 54.545816] WARNING: CPU: 0 PID: 213 at include/linux/kref.h:47
>> kobject_get+0x41/0x50()
>> [ 54.642595] Modules linked in: i2c_i801(+) mfd_core shpchp(+)
>> acpi_cpufreq(+) edac_core ioatdma(+) xfs libcrc32c ast syscopyarea ixgbe
>> sysfillrect sysimgblt sr_mod sd_mod drm_kms_helper igb mdio cdrom e1000e ahci
>> dca ttm libahci uas drm i2c_algo_bit ptp megaraid_sas libata usb_storage
>> i2c_core pps_core dm_mirror dm_region_hash dm_log dm_mod
>> [ 55.007264] CPU: 0 PID: 213 Comm: kworker/0:2 Not tainted
>> 3.18.5
>> [ 55.099970] Hardware name: Oracle Corporation SUN FIRE X4170 M2 SERVER
>> /ASSY,MOTHERBOARD,X4170, BIOS 08120104 05/08/2012
>> [ 55.239736] Workqueue: kacpi_notify acpi_os_execute_deferred
>> [ 55.308598] 0000000000000000 00000000bd730b61 ffff88046742baf8
>> ffffffff816b7edb
>> [ 55.398305] 0000000000000000 0000000000000000 ffff88046742bb38
>> ffffffff81078ae1
>> [ 55.488040] ffff88046742bbd8 ffff8806706b3000 0000000000000292
>> 0000000000000000
>> [ 55.577776] Call Trace:
>> [ 55.608228] [<ffffffff816b7edb>] dump_stack+0x46/0x58
>> [ 55.670895] [<ffffffff81078ae1>] warn_slowpath_common+0x81/0xa0
>> [ 55.743952] [<ffffffff81078bfa>] warn_slowpath_null+0x1a/0x20
>> [ 55.814929] [<ffffffff8130d0d1>] kobject_get+0x41/0x50
>> [ 55.878654] [<ffffffff8153e955>] cpufreq_cpu_get+0x75/0xc0
>> [ 55.946528] [<ffffffff8153f37e>] cpufreq_update_policy+0x2e/0x1f0
>>
>> The above issue was casued by a race condition, if there is a WARN in
>> kobject_get() of the kobject is not initialized, that would save us much
>> time to debug it.
>>
>> Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
>> ---
>> lib/kobject.c | 7 ++++++-
>> 1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/lib/kobject.c b/lib/kobject.c
>> index 03d4ab3..3b841b9 100644
>> --- a/lib/kobject.c
>> +++ b/lib/kobject.c
>> @@ -576,8 +576,13 @@ void kobject_del(struct kobject *kobj)
>> */
>> struct kobject *kobject_get(struct kobject *kobj)
>> {
>> - if (kobj)
>> + if (kobj) {
>> + if (!kobj->state_initialized)
>> + WARN(1, KERN_WARNING "kobject: '%s' (%p): is not "
>> + "initialized, yet kobject_get() is being "
>> + "called.\n", kobject_name(kobj), kobj);
>> kref_get(&kobj->kref);
>> + }
>> return kobj;
>> }
>>
>
> Have you tried running a system with this patch to see if there are a
> lot of messages at boot time? I'm a bit worried that the initial
Don't worry about that, no warning appear if no bug hit, I have tried
booting the kernel with this patch hundreds of times (To verify another
issue at the same time ).
> kobject init sequence would trigger this, but haven't looked at the full
> codepath just yet given that I haven't had my morning coffee...
Enjoy your coffee.
Thanks,
Ethan
>
> thanks,
>
> greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-03-12 9:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-12 4:04 [PATCH] kobject: WARN as tip when call kobject_get() to a kobject not initialized Ethan Zhao
2015-03-12 7:45 ` Greg KH
2015-03-12 9:27 ` Ethan Zhao
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.