Skip to contentSkip to conversation

slub: correct return errno on slab_sysfs_init failure

PATCH Superseded Jeff Liu 3 participants 9 messages Jun 12, 2014 – Jun 16, 2014

Subsystems (2)
lore
Share & tools
lore

Jeff Liu

author
#0 lore raw

PATCH 1/1 slub: correct return errno on slab_sysfs_init failure

From: Jie Liu <[email protected]>

Return ENOMEM instead of ENOSYS if slab_sysfs_init() failed

---
 mm/slub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/slub.c +1 -1
index 2b1ce69..75ca109 100644
@@ -5304,7 +5304,7 @@ static int __init slab_sysfs_init(void)
 	if (!slab_kset) {
 		mutex_unlock(&slab_mutex);
 		printk(KERN_ERR "Cannot register slab subsystem.\n");
-		return -ENOSYS;
+		return -ENOMEM;
 	}
 
 	slab_state = FULL;
Signature · 7 lines
1.8.3.2

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw
Quoted 14 lines · Jeff Liu

From: Jie Liu <[email protected]>

Return ENOMEM instead of ENOSYS if slab_sysfs_init() failed

---
 mm/slub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/slub.c +0 -0
index 2b1ce69..75ca109 100644

mm/slub.c static int __init slab_sysfs_init(void) · line 5307

Quoted 5 lines
mm/slub.c +1 -1
@@ -5304,7 +5304,7 @@ static int __init slab_sysfs_init(void)
        if (!slab_kset) {
                mutex_unlock(&slab_mutex);
                printk(KERN_ERR "Cannot register slab subsystem.\n");
-               return -ENOSYS;
+               return -ENOMEM;

What is the motivation for this change? AFAICT, kset_create_and_add() can fail for other reasons than ENOMEM, no?

mm/slub.c static int __init slab_sysfs_init(void) · line 5310

Quoted 3 lines
mm/slub.c +0 -0
        }
 
        slab_state = FULL;

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#2 lore raw
Quoted 10 lines · Pekka Enberg
Quoted 9 lines · Jeff Liu

From: Jie Liu <[email protected]>

Return ENOMEM instead of ENOSYS if slab_sysfs_init() failed

---
 mm/slub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines

mm/slub.c static int __init slab_sysfs_init(void) · line 5307

Quoted 10 lines
mm/slub.c +1 -1
index 2b1ce69..75ca109 100644
@@ -5304,7 +5304,7 @@ static int __init slab_sysfs_init(void)
        if (!slab_kset) {
                mutex_unlock(&slab_mutex);
                printk(KERN_ERR "Cannot register slab subsystem.\n");
-               return -ENOSYS;
+               return -ENOMEM;

What is the motivation for this change? AFAICT, kset_create_and_add() can fail for other reasons than ENOMEM, no?

Originally I'd like to make it consistent to most other subsystems which are return ENOMEM in case of sysfs init failed, but yes, kset_register() can fail due to different reaons...

Cheers,
-Jeff

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#3 lore raw
In reply to Jeff Liu
Quoted 3 lines · Jeff Liu

From: Jie Liu <[email protected]>

Return ENOMEM instead of ENOSYS if slab_sysfs_init() failed

The reason that I used ENOSYS there is that the whole sysfs portion of the slab allocator will be disabled. Could be due to a number of issues since kset_create_and_add() returns NULL for any error.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#4 lore raw
Quoted 10 lines · Christoph Lameter
Quoted 3 lines · Jeff Liu

From: Jie Liu <[email protected]>

Return ENOMEM instead of ENOSYS if slab_sysfs_init() failed

The reason that I used ENOSYS there is that the whole sysfs portion of the slab allocator will be disabled. Could be due to a number of issues since kset_create_and_add() returns NULL for any error.

Thanks for your clarification and sorry for the noise.

Cheers,
-Jeff

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#5 lore raw
Quoted 1 line · Jeff Liu

Thanks for your clarification and sorry for the noise.

Dont be worried. I am not sure anymore that this was such a wise move. Maybe get kset_create_and_add to return an error code instead and return that instead of -ENOSYS?

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#6 lore raw
Quoted 7 lines · Christoph Lameter
Quoted 1 line · Jeff Liu

Thanks for your clarification and sorry for the noise.

Dont be worried. I am not sure anymore that this was such a wise move. Maybe get kset_create_and_add to return an error code instead and return that instead of -ENOSYS?

Personally, I prefer to get kset_create_and_add() to return an error which can reflect the actual cause of the failure given that kset_register() can failed due to different reasons. If so, however, looks we have to make a certain amount of change for the existing modules which are support sysfs since they all return -ENOMEM if kset_create_and_add() return NULL, maybe this is inherited from samples/kobject/kset-example.c...

Cheers,
-Jeff

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#7 lore raw
Quoted 11 lines · Jeff Liu
Quoted 4 lines

Dont be worried. I am not sure anymore that this was such a wise move. Maybe get kset_create_and_add to return an error code instead and return that instead of -ENOSYS?

Personally, I prefer to get kset_create_and_add() to return an error which can reflect the actual cause of the failure given that kset_register() can failed due to different reasons. If so, however, looks we have to make a certain amount of change for the existing modules which are support sysfs since they all return -ENOMEM if kset_create_and_add() return NULL, maybe this is inherited from samples/kobject/kset-example.c...

Probably. Could you come up with patchset to clean this up? ERR_PTR() can be used to return an error code in a pointer value.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#8 lore raw
Quoted 14 lines · Christoph Lameter
Quoted 11 lines · Jeff Liu
Quoted 4 lines

Dont be worried. I am not sure anymore that this was such a wise move. Maybe get kset_create_and_add to return an error code instead and return that instead of -ENOSYS?

Personally, I prefer to get kset_create_and_add() to return an error which can reflect the actual cause of the failure given that kset_register() can failed due to different reasons. If so, however, looks we have to make a certain amount of change for the existing modules which are support sysfs since they all return -ENOMEM if kset_create_and_add() return NULL, maybe this is inherited from samples/kobject/kset-example.c...

Quoted 2 lines

Probably. Could you come up with patchset to clean this up? ERR_PTR() can be used to return an error code in a pointer value.

Sure, I'll work it out ASAP.

Cheers,
-Jeff

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>