Re: [patch 1/5]thp: improve the error code path

From: David Rientjes
Date: Wed Nov 09 2011 - 21:44:03 EST


On Thu, 10 Nov 2011, Shaohua Li wrote:

> > hugepage_attr_group is defined even if CONFIG_SYSFS is not set and I
> > just made a build with CONFIG_SYSFS=n and it builds just fine without
> > any change.
>
> > $ grep CONFIG_SYSFS .config
> > # CONFIG_SYSFS is not set
> >
> > So we can drop 1/5 above.
> this isn't the case in the code. And the code uses hugepage_attr_group
> is already within CONFIG_SYSFS, so your build success.
>

You're right, but I agree that the #ifdef's just make the function error
handling much too complex. Would you mind adding sysfs_*_out labels at
the end of the function to handle these errors instead? And I think we
should be doing khugepaged_slab_init() and mm_slots_hash_init() before
initializing sysfs.

Something like

out:
khugepaged_slab_free();
mm_slots_hash_free(); <-- after you remove it from #if 0
return err;

#ifdef CONFIG_SYSFS
sysfs_khugepaged_out:
sysfs_remove_group(hugepage_kobj, &khugepaged_attr_group);
sysfs_hugepage_out:
sysfs_remove_group(hugepage_kobj, &hugepage_attr_group);
...
goto out;
#endif
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/