kobject: Add support for default attribute groups to kobj_type
Subsystems (11)
PATCH 1/1 kobject: Add support for default attribute groups to kobj_type
kobj_type currently uses a list of individual attributes to store default attributes. Attribute groups are more flexible than a list of attributes because groups provide support for attribute visibility. So, add support for default attribute groups to kobj_type.
In future patches, the existing uses of kobj_type’s attribute list will be converted to attribute groups. When that is complete, kobj_type’s attribute list, “default_attrs”, will be removed.
--- include/linux/kobject.h | 3 ++- lib/kobject.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-)
include/linux/kobject.h +2 -1
@@ -139,7 +139,8 @@ static inline bool kobject_has_children(struct kobject *kobj)struct kobj_type {void (*release)(struct kobject *kobj);const struct sysfs_ops *sysfs_ops; -struct attribute **default_attrs; +struct attribute **default_attrs;/* use default_groups instead */ +const struct attribute_group **default_groups;const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);const void *(*namespace)(struct kobject *kobj);void (*get_ownership)(struct kobject *kobj,kuid_t *uid,kgid_t *gid);
lib/kobject.c +14 -0
@@ -82,6 +82,7 @@ static int populate_dir(struct kobject *kobj)static int create_dir (struct kobject *kobj) { +const struct kobj_type *ktype =get_ktype (kobj);const struct kobj_ns_type_operations *ops;int error;
@@ -95,6 +96,14 @@ static int create_dir(struct kobject *kobj)return error; } +if (ktype) { + error =sysfs_create_groups (kobj, ktype->default_groups); +if (error) { +sysfs_remove_dir (kobj); +return error; + } + } +/* * @kobj->sd may be deleted by an ancestor going away. Hold an * extra reference so that it stays until @kobj is gone.
@@ -584,11 +593,16 @@ EXPORT_SYMBOL_GPL(kobject_move);void kobject_del (struct kobject *kobj) {struct kernfs_node *sd; +const struct kobj_type *ktype =get_ktype (kobj);if (!kobj)return ; sd = kobj->sd; + +if (ktype) +sysfs_remove_groups (kobj, ktype->default_groups); +sysfs_remove_dir (kobj);sysfs_put (sd);
Signature · 1 line
2.17.1
Greg Kroah-Hartman
maintainerQuoted 9 lines · Kimberly Brown
kobj_typecurrently uses a list of individual attributes to store default attributes. Attribute groups are more flexible than a list of attributes because groups provide support for attribute visibility. So, add support for default attribute groups tokobj_type.In future patches, the existing uses of kobj_type’s attribute list will be converted to attribute groups. When that is complete, kobj_type’s attribute list, “default_attrs”, will be removed.
Quoted 5 lines
Signed-off-by Kimberly Brown <[email protected]>--- include/linux/kobject.h | 3 ++- lib/kobject.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-)
Yes! Thanks for doing this.
But how did you test it? Did you convert any kobj_type structures to the attribute group and see that all was the same? Ideally I'd like to take this patch with at least one subsystem that uses the change, otherwise this looks like unused code in the kernel.
thanks,
greg k-h
Quoted 16 lines · Greg Kroah-Hartman
Quoted 9 lines · Kimberly Brown
kobj_typecurrently uses a list of individual attributes to store default attributes. Attribute groups are more flexible than a list of attributes because groups provide support for attribute visibility. So, add support for default attribute groups tokobj_type.In future patches, the existing uses of kobj_type’s attribute list will be converted to attribute groups. When that is complete, kobj_type’s attribute list, “default_attrs”, will be removed.
Quoted 5 lines
Signed-off-by Kimberly Brown <[email protected]>--- include/linux/kobject.h | 3 ++- lib/kobject.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-)
Quoted 6 lines
Yes! Thanks for doing this.
But how did you test it? Did you convert any
kobj_typestructures to the attribute group and see that all was the same? Ideally I'd like to take this patch with at least one subsystem that uses the change, otherwise this looks like unused code in the kernel.
Yes, I tested it by converting a couple of kobj_type structures, including one that I recently added an is_visible() function to (vmbus_chan_ktype in the hv_vmbus driver).
I'll put together a patchset with this patch and at least one subsystem's changes.
Thanks,
Kim
Quoted 4 lines
thanks,
greg k-h
Greg Kroah-Hartman
maintainerQuoted 24 lines · Kimberly Brown
Quoted 16 lines · Greg Kroah-Hartman
Quoted 9 lines · Kimberly Brown
kobj_typecurrently uses a list of individual attributes to store default attributes. Attribute groups are more flexible than a list of attributes because groups provide support for attribute visibility. So, add support for default attribute groups tokobj_type.In future patches, the existing uses of kobj_type’s attribute list will be converted to attribute groups. When that is complete, kobj_type’s attribute list, “default_attrs”, will be removed.
Quoted 5 lines
Signed-off-by Kimberly Brown <[email protected]>--- include/linux/kobject.h | 3 ++- lib/kobject.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-)Quoted 6 lines
Yes! Thanks for doing this.
But how did you test it? Did you convert any
kobj_typestructures to the attribute group and see that all was the same? Ideally I'd like to take this patch with at least one subsystem that uses the change, otherwise this looks like unused code in the kernel.
Quoted 6 lines
Yes, I tested it by converting a couple of
kobj_typestructures, including one that I recently added anis_visible()function to (vmbus_chan_ktypein thehv_vmbusdriver).I'll put together a patchset with this patch and at least one subsystem's changes.
Wonderful, I'll wait to take this when you send that series.
thanks,
greg k-h
v2 cover kobject: Add default group support to kobj_type and replace subsystem uses
In reply to Kimberly BrownThis patchset adds support for default attribute groups to kobj_type. Also, the uses of kobj_type's default_attrs field are replaced with default_groups in the following subsystems:
- samples
- block
- net
- irq
- padata
- cpufreq
- livepatch
The subsystem maintainers and lists will be copied on the subsystem patches.
The uses of kobj_type's default_attrs field in the other subsystems will be replaced in future patchsets.
Changes in v2:
- Patch 1 is not changed.
- Patches 2-8 are new.
Kimberly Brown (8):
kobject: Add support for default attribute groups to kobj_type samples/kobject: Replace foo_ktype's default_attrs field with groups
block: Replace all ktype default_attrs with groups
net-sysfs: Replace ktype default_attrs field with groups
irqdesc: Replace irq_kobj_type's default_attrs field with groups
padata: Replace padata_attr_type default_attrs field with groups
cpufreq: schedutil: Replace default_attrs field with groups
livepatch: Replace klp_ktype_patch's default_attrs with groups
block/blk-integrity.c | 3 ++- block/blk-mq-sysfs.c | 8 ++------ block/blk-sysfs.c | 3 ++- include/linux/kobject.h | 3 ++- kernel/irq/irqdesc.c | 3 ++- kernel/livepatch/core.c | 3 ++- kernel/padata.c | 3 ++- kernel/sched/cpufreq_schedutil.c | 5 +++-- lib/kobject.c | 14 ++++++++++++++ net/core/net-sysfs.c | 6 ++++-- samples/kobject/kset-example.c | 3 ++- 11 files changed, 37 insertions(+), 17 deletions(-)
Signature · 1 line
2.17.1
PATCH v2 1/8 kobject: Add support for default attribute groups to kobj_type
kobj_type currently uses a list of individual attributes to store default attributes. Attribute groups are more flexible than a list of attributes because groups provide support for attribute visibility. So, add support for default attribute groups to kobj_type.
In future patches, the existing uses of kobj_type’s attribute list will be converted to attribute groups. When that is complete, kobj_type’s attribute list, “default_attrs”, will be removed.
--- include/linux/kobject.h | 3 ++- lib/kobject.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-)
include/linux/kobject.h +2 -1
@@ -139,7 +139,8 @@ static inline bool kobject_has_children(struct kobject *kobj)struct kobj_type {void (*release)(struct kobject *kobj);const struct sysfs_ops *sysfs_ops; -struct attribute **default_attrs; +struct attribute **default_attrs;/* use default_groups instead */ +const struct attribute_group **default_groups;const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);const void *(*namespace)(struct kobject *kobj);void (*get_ownership)(struct kobject *kobj,kuid_t *uid,kgid_t *gid);
lib/kobject.c +14 -0
@@ -82,6 +82,7 @@ static int populate_dir(struct kobject *kobj)static int create_dir (struct kobject *kobj) { +const struct kobj_type *ktype =get_ktype (kobj);const struct kobj_ns_type_operations *ops;int error;
@@ -95,6 +96,14 @@ static int create_dir(struct kobject *kobj)return error; } +if (ktype) { + error =sysfs_create_groups (kobj, ktype->default_groups); +if (error) { +sysfs_remove_dir (kobj); +return error; + } + } +/* * @kobj->sd may be deleted by an ancestor going away. Hold an * extra reference so that it stays until @kobj is gone.
@@ -584,11 +593,16 @@ EXPORT_SYMBOL_GPL(kobject_move);void kobject_del (struct kobject *kobj) {struct kernfs_node *sd; +const struct kobj_type *ktype =get_ktype (kobj);if (!kobj)return ; sd = kobj->sd; + +if (ktype) +sysfs_remove_groups (kobj, ktype->default_groups); +sysfs_remove_dir (kobj);sysfs_put (sd);
Signature · 1 line
2.17.1
PATCH v2 2/8 samples/kobject: Replace foo_ktype's default_attrs field with groups
In reply to Kimberly BrownThe kobj_type default_attrs field is being replaced by the default_groups field. Replace foo_ktype's default_attrs field with default_groups and use the ATTRIBUTE_GROUPS macro to create foo_default_groups.
This patch was tested by loading the kset-example module and verifying that the sysfs files for the attributes in the default group were created.
--- samples/kobject/kset-example.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
samples/kobject/kset-example.c +2 -1
@@ -178,6 +178,7 @@ static struct attribute *foo_default_attrs[] = { &bar_attribute.attr,NULL ,/* need to NULL terminate the list of attributes */ }; +ATTRIBUTE_GROUPS (foo_default);/* * Our own ktype for our kobjects. Here we specify our sysfs ops, the
@@ -187,7 +188,7 @@ static struct attribute *foo_default_attrs[] = {static struct kobj_type foo_ktype = { .sysfs_ops = &foo_sysfs_ops, .release = foo_release, - .default_attrs = foo_default_attrs, + .default_groups = foo_default_groups, };static struct kset *example_kset;
Signature · 1 line
2.17.1
PATCH v2 3/8 block: Replace all ktype default_attrs with groups
In reply to Kimberly BrownThe kobj_type default_attrs field is being replaced by the default_groups field. Replace all of the ktype default_attrs fields in the block subsystem with default_groups and use the ATTRIBUTE_GROUPS macro to create the default groups.
Remove default_ctx_attrs[] because it doesn't contain any attributes.
This patch was tested by verifying that the sysfs files for the attributes in the default groups were created.
--- block/blk-integrity.c | 3 ++- block/blk-mq-sysfs.c | 8 ++------ block/blk-sysfs.c | 3 ++- 3 files changed, 6 insertions(+), 8 deletions(-)
block/blk-integrity.c +2 -1
@@ -365,6 +365,7 @@ static struct attribute *integrity_attrs[] = { &integrity_device_entry.attr,NULL , }; +ATTRIBUTE_GROUPS (integrity);static const struct sysfs_ops integrity_ops = { .show = &integrity_attr_show,
@@ -372,7 +373,7 @@ static const struct sysfs_ops integrity_ops = { };static struct kobj_type integrity_ktype = { - .default_attrs = integrity_attrs, + .default_groups = integrity_groups, .sysfs_ops = &integrity_ops, };
block/blk-mq-sysfs.c +2 -6
@@ -173,10 +173,6 @@ static ssize_t blk_mq_hw_sysfs_cpus_show(struct blk_mq_hw_ctx *hctx, char *page)return ret; } -static struct attribute *default_ctx_attrs[] = { -NULL , -}; -static struct blk_mq_hw_ctx_sysfs_entry blk_mq_hw_sysfs_nr_tags = { .attr = {.name ="nr_tags" , .mode =0444 }, .show = blk_mq_hw_sysfs_nr_tags_show,
@@ -196,6 +192,7 @@ static struct attribute *default_hw_ctx_attrs[] = { &blk_mq_hw_sysfs_cpus.attr,NULL , }; +ATTRIBUTE_GROUPS (default_hw_ctx);static const struct sysfs_ops blk_mq_sysfs_ops = { .show = blk_mq_sysfs_show,
@@ -214,13 +211,12 @@ static struct kobj_type blk_mq_ktype = {static struct kobj_type blk_mq_ctx_ktype = { .sysfs_ops = &blk_mq_sysfs_ops, - .default_attrs = default_ctx_attrs, .release = blk_mq_ctx_sysfs_release, };static struct kobj_type blk_mq_hw_ktype = { .sysfs_ops = &blk_mq_hw_sysfs_ops, - .default_attrs = default_hw_ctx_attrs, + .default_groups = default_hw_ctx_groups, .release = blk_mq_hw_sysfs_release, };
block/blk-sysfs.c +2 -1
@@ -769,6 +769,7 @@ static struct attribute *default_attrs[] = {#endif NULL, }; +ATTRIBUTE_GROUPS (default);#define to_queue (atr) container_of((atr), struct queue_sysfs_entry, attr)
@@ -890,7 +891,7 @@ static const struct sysfs_ops queue_sysfs_ops = {struct kobj_type blk_queue_ktype = { .sysfs_ops = &queue_sysfs_ops, - .default_attrs = default_attrs, + .default_groups = default_groups, .release = blk_release_queue, };
Signature · 1 line
2.17.1
Re: [PATCH v2 3/8] block: Replace all ktype default_attrs with groups
Quoted 66 lines · Kimberly Brown
The
kobj_typedefault_attrsfield is being replaced by thedefault_groupsfield. Replace all of the ktypedefault_attrsfields in the block subsystem withdefault_groupsand use theATTRIBUTE_GROUPSmacro to create the default groups.Remove default_ctx_attrs[]because it doesn't contain any attributes.
This patch was tested by verifying that the sysfs files for the attributes in the default groups were created.
Signed-off-by Kimberly Brown <[email protected]>>---block/blk-integrity.c |3 +-+-- block/blk-mq-sysfs.c |8 +-+------- block/blk-sysfs.c |3 +-+-- 3 files changed, 6 insertions(+-), 8 deletions(-)block/blk-integrity.c +1
-1--- a/block/blk-integrity.c +-+-+- b/block/blk-integrity.c@@-365,6 +-365,7 @@static struct attribute *integrity_attrs[]={> &integrity_device_entry.attr,
NULL,
};>+-ATTRIBUTE_GROUPS(integrity);>
static const structsysfs_opsintegrity_ops={> .show =&integrity_attr_show,
@@-372,7 +-373,7 @@static const structsysfs_opsintegrity_ops={> };>
static structkobj_typeintegrity_ktype={>- .default_attrs =integrity_attrs,
+- .default_groups =integrity_groups,.sysfs_ops =&integrity_ops, };>block/blk-mq-sysfs.c +1
-1--- a/block/blk-mq-sysfs.c +-+-+- b/block/blk-mq-sysfs.c@@-173,10 +-173,6 @@static
ssize_tblk_mq_hw_sysfs_cpus_show(struct blk_mq_hw_ctx *hctx, char *page)return ret;> }>block/blk-mq-sysfs.c +0
-2-static struct attribute *default_ctx_attrs[]={>- NULL, -};>-static struct
blk_mq_hw_ctx_sysfs_entryblk_mq_hw_sysfs_nr_tags={> .attr ={name ="nr_tags" .mode =0444 }
.show =blk_mq_hw_sysfs_nr_tags_show,
@@-196,6 +-192,7 @@static struct attribute *default_hw_ctx_attrs[]={> &blk_mq_hw_sysfs_cpus.attr,
NULL,
};>+-ATTRIBUTE_GROUPS(default_hw_ctx);>
static const structsysfs_opsblk_mq_sysfs_ops={> .show =blk_mq_sysfs_show,
@@-214,13 +-211,12 @@static structkobj_typeblk_mq_ktype={>
static structkobj_typeblk_mq_ctx_ktype={> .sysfs_ops =&blk_mq_sysfs_ops,block/blk-mq-sysfs.c +0
-1- .default_attrs =default_ctx_attrs,.release =blk_mq_ctx_sysfs_release,
};>
static structkobj_typeblk_mq_hw_ktype={> .sysfs_ops =&blk_mq_hw_sysfs_ops,block/blk-mq-sysfs.c +1
-1- .default_attrs =default_hw_ctx_attrs, +- .default_groups =default_hw_ctx_groups,.release =blk_mq_hw_sysfs_release,
};>block/blk-sysfs.c +1
-1--- a/block/blk-sysfs.c +-+-+- b/block/blk-sysfs.c@@-769,6 +-769,7 @@static struct attribute *default_attrs[]={> #endif
NULL,
};>+-ATTRIBUTE_GROUPS(default);>
#defineto_queue(atr)container_of((atr), struct queue_sysfs_entry, attr)@@-890,7 +-891,7 @@static const struct
sysfs_opsqueue_sysfs_ops={>
structkobj_typeblk_queue_ktype={> .sysfs_ops =&queue_sysfs_ops,block/blk-sysfs.c +1
-1- .default_attrs =default_attrs, +- .default_groups =default_groups,
Quoted 2 lines
.release =blk_release_queue,
};
I think this should have been four patches instead of one.
Anyway:
Greg Kroah-Hartman
maintainerRe: [PATCH v2 3/8] block: Replace all ktype default_attrs with groups
Quoted 91 lines · Bart Van Assche
Quoted 90 lines · Kimberly Brown
The
kobj_typedefault_attrsfield is being replaced by thedefault_groupsfield. Replace all of the ktypedefault_attrsfields in the block subsystem withdefault_groupsand use theATTRIBUTE_GROUPSmacro to create the default groups.Remove default_ctx_attrs[] because it doesn't contain any attributes.
This patch was tested by verifying that the sysfs files for the attributes in the default groups were created.
Signed-off-by Kimberly Brown <[email protected]>--- block/blk-integrity.c | 3 ++- block/blk-mq-sysfs.c | 8 ++------ block/blk-sysfs.c | 3 ++- 3 files changed, 6 insertions(+), 8 deletions(-)block/blk-integrity.c +2
-1@@ -365,6 +365,7 @@ static struct attribute *integrity_attrs[] = { &integrity_device_entry.attr,NULL , }; +ATTRIBUTE_GROUPS (integrity);static const struct sysfs_ops integrity_ops = { .show = &integrity_attr_show,@@ -372,7 +373,7 @@ static const struct sysfs_ops integrity_ops = { };static struct kobj_type integrity_ktype = { - .default_attrs = integrity_attrs, + .default_groups = integrity_groups, .sysfs_ops = &integrity_ops, };block/blk-mq-sysfs.c +2
-6@@ -173,10 +173,6 @@ static ssize_t blk_mq_hw_sysfs_cpus_show(struct blk_mq_hw_ctx *hctx, char *page)return ret; } -static struct attribute *default_ctx_attrs[] = { -NULL , -}; -static struct blk_mq_hw_ctx_sysfs_entry blk_mq_hw_sysfs_nr_tags = { .attr = {.name ="nr_tags" , .mode =0444 }, .show = blk_mq_hw_sysfs_nr_tags_show,@@ -196,6 +192,7 @@ static struct attribute *default_hw_ctx_attrs[] = { &blk_mq_hw_sysfs_cpus.attr,NULL , }; +ATTRIBUTE_GROUPS (default_hw_ctx);static const struct sysfs_ops blk_mq_sysfs_ops = { .show = blk_mq_sysfs_show,@@ -214,13 +211,12 @@ static struct kobj_type blk_mq_ktype = {static struct kobj_type blk_mq_ctx_ktype = { .sysfs_ops = &blk_mq_sysfs_ops, - .default_attrs = default_ctx_attrs, .release = blk_mq_ctx_sysfs_release, };static struct kobj_type blk_mq_hw_ktype = { .sysfs_ops = &blk_mq_hw_sysfs_ops, - .default_attrs = default_hw_ctx_attrs, + .default_groups = default_hw_ctx_groups, .release = blk_mq_hw_sysfs_release, };block/blk-sysfs.c +1
-0@@ -769,6 +769,7 @@ static struct attribute *default_attrs[] = {#endif NULL, }; +ATTRIBUTE_GROUPS (default);#define to_queue (atr) container_of((atr), struct queue_sysfs_entry, attr)@@ -890,7 +891,7 @@ static const struct sysfs_ops queue_sysfs_ops = {
Quoted 8 lines
block/blk-sysfs.c static const struct sysfs_ops queue_sysfs_ops = { · line 896
Quoted 6 lines
block/blk-sysfs.c +1
-1struct kobj_type blk_queue_ktype = { .sysfs_ops = &queue_sysfs_ops, - .default_attrs = default_attrs, + .default_groups = default_groups, .release = blk_release_queue, };I think this should have been four patches instead of one.
4? I could maybe see 3, how would you make 4 patches out of this?
Quoted 3 lines
Anyway:
Reviewed-by Bart Van Assche <[email protected]>
Thanks for the review, I'll queue this up in a few days.
greg k-h
Re: [PATCH v2 3/8] block: Replace all ktype default_attrs with groups
Quoted 72 lines · Greg Kroah-Hartman
Quoted 63 lines · Bart Van Assche
Quoted 62 lines · Kimberly Brown
The
kobj_typedefault_attrsfield is being replaced by thedefault_groupsfield. Replace all of the ktypedefault_attrsfields in the block subsystem withdefault_groupsand use theATTRIBUTE_GROUPSmacro to create the default groups.Remove default_ctx_attrs[]because it doesn't contain any attributes.
This patch was tested by verifying that the sysfs files for the attributes in the default groups were created.
Signed-off-by Kimberly Brown <[email protected]>>>>---block/blk-integrity.c |3 +-+-- block/blk-mq-sysfs.c |8 +-+------- block/blk-sysfs.c |3 +-+-- 3 files changed, 6 insertions(+-), 8 deletions(-)block/blk-integrity.c +1
-1--- a/block/blk-integrity.c +-+-+- b/block/blk-integrity.c@@-365,6 +-365,7 @@static struct attribute *integrity_attrs[]={>>> &integrity_device_entry.attr,
NULL,
};>>>+-ATTRIBUTE_GROUPS(integrity);>>>
static const structsysfs_opsintegrity_ops={>>> .show =&integrity_attr_show,
@@-372,7 +-373,7 @@static const structsysfs_opsintegrity_ops={>>> };>>>
static structkobj_typeintegrity_ktype={>>>- .default_attrs =integrity_attrs,
+- .default_groups =integrity_groups,.sysfs_ops =&integrity_ops, };>>>block/blk-mq-sysfs.c +1
-1--- a/block/blk-mq-sysfs.c +-+-+- b/block/blk-mq-sysfs.c@@-173,10 +-173,6 @@static
ssize_tblk_mq_hw_sysfs_cpus_show(struct blk_mq_hw_ctx *hctx, char *page)return ret;>>> }>>>block/blk-mq-sysfs.c +0
-2-static struct attribute *default_ctx_attrs[]={>>>- NULL, -};>>>-static struct
blk_mq_hw_ctx_sysfs_entryblk_mq_hw_sysfs_nr_tags={>>> .attr ={name ="nr_tags" .mode =0444 }
.show =blk_mq_hw_sysfs_nr_tags_show,
@@-196,6 +-192,7 @@static struct attribute *default_hw_ctx_attrs[]={>>> &blk_mq_hw_sysfs_cpus.attr,
NULL,
};>>>+-ATTRIBUTE_GROUPS(default_hw_ctx);>>>
static const structsysfs_opsblk_mq_sysfs_ops={>>> .show =blk_mq_sysfs_show,
@@-214,13 +-211,12 @@static structkobj_typeblk_mq_ktype={>>>
static structkobj_typeblk_mq_ctx_ktype={>>> .sysfs_ops =&blk_mq_sysfs_ops,block/blk-mq-sysfs.c +0
-1- .default_attrs =default_ctx_attrs,.release =blk_mq_ctx_sysfs_release,
};>>>
static structkobj_typeblk_mq_hw_ktype={>>> .sysfs_ops =&blk_mq_hw_sysfs_ops,block/blk-mq-sysfs.c +1
-1- .default_attrs =default_hw_ctx_attrs, +- .default_groups =default_hw_ctx_groups,.release =blk_mq_hw_sysfs_release,
};>>>block/blk-sysfs.c +1
-1--- a/block/blk-sysfs.c +-+-+- b/block/blk-sysfs.c@@-769,6 +-769,7 @@static struct attribute *default_attrs[]={>>> #endif
NULL,
};>>>+-ATTRIBUTE_GROUPS(default);>>>
#defineto_queue(atr)container_of((atr), struct queue_sysfs_entry, attr)Quoted 7 lines
Quoted 6 lines
@@-890,7 +-891,7 @@static const struct
sysfs_opsqueue_sysfs_ops={>>>
structkobj_typeblk_queue_ktype={>>> .sysfs_ops =&queue_sysfs_ops,block/blk-sysfs.c +1
-1- .default_attrs =default_attrs, +- .default_groups =default_groups,.release =blk_release_queue,
};>>I think this should have been four patches instead of one.
Quoted 1 line
4? I could maybe see 3, how would you make 4 patches out of this?
Hi Greg,
Not that it matters, but I see four changes in this patch: three conversions from default_attrs into default_groups and also the removal of default_ctx_attrs.
Thanks,
Bart.
PATCH v2 4/8 net-sysfs: Replace ktype default_attrs field with groups
In reply to Kimberly BrownThe kobj_type default_attrs field is being replaced by the default_groups field. Replace the default_attrs fields in rx_queue_ktype and netdev_queue_ktype with default_groups. Use the ATTRIBUTE_GROUPS macro to create rx_queue_default_groups and netdev_queue_default_groups.
This patch was tested by verifying that the sysfs files for the attributes in the default groups were created.
--- net/core/net-sysfs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/core/net-sysfs.c +4 -2
@@ -863,6 +863,7 @@ static struct attribute *rx_queue_default_attrs[] __ro_after_init = {#endif NULL }; +ATTRIBUTE_GROUPS (rx_queue_default);static void rx_queue_release (struct kobject *kobj) {
@@ -911,7 +912,7 @@ static void rx_queue_get_ownership(struct kobject *kobj,static struct kobj_type rx_queue_ktype__ro_after_init = { .sysfs_ops = &rx_queue_sysfs_ops, .release = rx_queue_release, - .default_attrs = rx_queue_default_attrs, + .default_groups = rx_queue_default_groups, .namespace = rx_queue_namespace, .get_ownership = rx_queue_get_ownership, };
@@ -1416,6 +1417,7 @@ static struct attribute *netdev_queue_default_attrs[] __ro_after_init = {#endif NULL }; +ATTRIBUTE_GROUPS (netdev_queue_default);static void netdev_queue_release (struct kobject *kobj) {
@@ -1448,7 +1450,7 @@ static void netdev_queue_get_ownership(struct kobject *kobj,static struct kobj_type netdev_queue_ktype__ro_after_init = { .sysfs_ops = &netdev_queue_sysfs_ops, .release = netdev_queue_release, - .default_attrs = netdev_queue_default_attrs, + .default_groups = netdev_queue_default_groups, .namespace = netdev_queue_namespace, .get_ownership = netdev_queue_get_ownership, };
Signature · 1 line
2.17.1
PATCH v2 5/8 irqdesc: Replace irq_kobj_type's default_attrs field with groups
In reply to Kimberly BrownThe kobj_type default_attrs field is being replaced by the default_groups field. Replace irq_kobj_type's default_attrs field with default_groups and use the ATTRIBUTE_GROUPS macro to create irq_groups.
This patch was tested by verifying that the sysfs files for the attributes in the default groups were created.
--- kernel/irq/irqdesc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/irq/irqdesc.c +2 -1
@@ -275,11 +275,12 @@ static struct attribute *irq_attrs[] = { &actions_attr.attr, NULL }; +ATTRIBUTE_GROUPS (irq);static struct kobj_type irq_kobj_type = { .release = irq_kobj_release, .sysfs_ops = &kobj_sysfs_ops, - .default_attrs = irq_attrs, + .default_groups = irq_groups, };static void irq_sysfs_add (int irq,struct irq_desc *desc)
Signature · 1 line
2.17.1
Re: [PATCH v2 5/8] irqdesc: Replace irq_kobj_type's default_attrs field with groups
Quoted 8 lines · Kimberly Brown
The
kobj_typedefault_attrsfield is being replaced by thedefault_groupsfield. Replace irq_kobj_type'sdefault_attrsfield withdefault_groupsand use theATTRIBUTE_GROUPSmacro to createirq_groups.This patch was tested by verifying that the sysfs files for the attributes in the default groups were created.
Signed-off-by Kimberly Brown <[email protected]>
Feel free to route it with the patch it depends on.
PATCH v2 6/8 padata: Replace padata_attr_type default_attrs field with groups
In reply to Kimberly BrownThe kobj_type default_attrs field is being replaced by the default_groups field. Replace padata_attr_type's default_attrs field with default_groups and use the ATTRIBUTE_GROUPS macro to create padata_default_groups.
This patch was tested by loading the pcrypt module and verifying that the sysfs files for the attributes in the default groups were created.
--- kernel/padata.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/padata.c +2 -1
@@ -957,6 +957,7 @@ static struct attribute *padata_default_attrs[] = { ¶llel_cpumask_attr.attr,NULL , }; +ATTRIBUTE_GROUPS (padata_default);static ssize_t padata_sysfs_show (struct kobject *kobj,struct attribute *attr,char *buf)
@@ -995,7 +996,7 @@ static const struct sysfs_ops padata_sysfs_ops = {static struct kobj_type padata_attr_type = { .sysfs_ops = &padata_sysfs_ops, - .default_attrs = padata_default_attrs, + .default_groups = padata_default_groups, .release = padata_sysfs_release, };
Signature · 1 line
2.17.1
PATCH v2 7/8 cpufreq: schedutil: Replace default_attrs field with groups
In reply to Kimberly BrownThe kobj_type default_attrs field is being replaced by the default_groups field. Replace sugov_tunables_ktype's default_attrs field with default groups. Change "sugov_attributes" to "sugov_attrs" and use the ATTRIBUTE_GROUPS macro to create sugov_groups.
This patch was tested by setting the scaling governor to schedutil and verifying that the sysfs files for the attributes in the default groups were created.
--- kernel/sched/cpufreq_schedutil.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/sched/cpufreq_schedutil.c +3 -2
@@ -598,13 +598,14 @@ rate_limit_us_store(struct gov_attr_set *attr_set, const char *buf, size_t countstatic struct governor_attr rate_limit_us =__ATTR_RW (rate_limit_us); -static struct attribute *sugov_attributes[] = { +static struct attribute *sugov_attrs[] = { &rate_limit_us.attr,NULL }; +ATTRIBUTE_GROUPS (sugov);static struct kobj_type sugov_tunables_ktype = { - .default_attrs = sugov_attributes, + .default_groups = sugov_groups, .sysfs_ops = &governor_sysfs_ops, };
Signature · 1 line
2.17.1
Rafael J. Wysocki
maintainerRe: [PATCH v2 7/8] cpufreq: schedutil: Replace default_attrs field with groups
Quoted 11 lines · Kimberly Brown
The
kobj_typedefault_attrsfield is being replaced by thedefault_groupsfield. Replace sugov_tunables_ktype'sdefault_attrsfield with default groups. Change "sugov_attributes" to "sugov_attrs" and use theATTRIBUTE_GROUPSmacro to createsugov_groups.This patch was tested by setting the scaling governor to schedutil and verifying that the sysfs files for the attributes in the default groups were created.
Signed-off-by Kimberly Brown <[email protected]>
Quoted 28 lines
--- kernel/sched/cpufreq_schedutil.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)kernel/sched/cpufreq_schedutil.c +3
-3@@ -598,13 +598,14 @@ rate_limit_us_store(struct gov_attr_set *attr_set, const char *buf, size_t countstatic struct governor_attr rate_limit_us =__ATTR_RW (rate_limit_us); -static struct attribute *sugov_attributes[] = { +static struct attribute *sugov_attrs[] = { &rate_limit_us.attr,NULL }; +ATTRIBUTE_GROUPS (sugov);static struct kobj_type sugov_tunables_ktype = { - .default_attrs = sugov_attributes, + .default_groups = sugov_groups, .sysfs_ops = &governor_sysfs_ops, }; --2.17.1
Re: [PATCH v2 7/8] cpufreq: schedutil: Replace default_attrs field with groups
In reply to Kimberly BrownQuoted 10 lines · Kimberly Brown
The
kobj_typedefault_attrsfield is being replaced by thedefault_groupsfield. Replace sugov_tunables_ktype'sdefault_attrsfield with default groups. Change "sugov_attributes" to "sugov_attrs" and use theATTRIBUTE_GROUPSmacro to createsugov_groups.This patch was tested by setting the scaling governor to schedutil and verifying that the sysfs files for the attributes in the default groups were created.
Signed-off-by Kimberly Brown <[email protected]>
Please route the patch as is most convenient.
Quoted 28 lines
--- kernel/sched/cpufreq_schedutil.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)kernel/sched/cpufreq_schedutil.c +3
-2@@ -598,13 +598,14 @@ rate_limit_us_store(struct gov_attr_set *attr_set, const char *buf, size_t countstatic struct governor_attr rate_limit_us =__ATTR_RW (rate_limit_us); -static struct attribute *sugov_attributes[] = { +static struct attribute *sugov_attrs[] = { &rate_limit_us.attr,NULL }; +ATTRIBUTE_GROUPS (sugov);static struct kobj_type sugov_tunables_ktype = { - .default_attrs = sugov_attributes, + .default_groups = sugov_groups, .sysfs_ops = &governor_sysfs_ops, };Signature · 1 line
2.17.1
PATCH v2 8/8 livepatch: Replace klp_ktype_patch's default_attrs with groups
In reply to Kimberly BrownThe kobj_type default_attrs field is being replaced by the default_groups field. Replace klp_ktype_patch's default_attrs field with default_groups and use the ATTRIBUTE_GROUPS macro to create klp_patch_groups.
This patch was tested by loading the livepatch-sample module and verifying that the sysfs files for the attributes in the default groups were created.
--- kernel/livepatch/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/livepatch/core.c +2 -1
@@ -419,6 +419,7 @@ static struct attribute *klp_patch_attrs[] = { &force_kobj_attr.attr, NULL }; +ATTRIBUTE_GROUPS (klp_patch);static void klp_free_object_dynamic (struct klp_object *obj) {
@@ -546,7 +547,7 @@ static void klp_kobj_release_patch(struct kobject *kobj)static struct kobj_type klp_ktype_patch = { .release = klp_kobj_release_patch, .sysfs_ops = &kobj_sysfs_ops, - .default_attrs = klp_patch_attrs, + .default_groups = klp_patch_groups, };static void klp_kobj_release_object (struct kobject *kobj)
Signature · 1 line
2.17.1
Re: [PATCH v2 8/8] livepatch: Replace klp_ktype_patch's default_attrs with groups
Quoted 10 lines · Kimberly Brown
The
kobj_typedefault_attrsfield is being replaced by thedefault_groupsfield. Replace klp_ktype_patch'sdefault_attrsfield withdefault_groupsand use theATTRIBUTE_GROUPSmacro to createklp_patch_groups.This patch was tested by loading the livepatch-sample module and verifying that the sysfs files for the attributes in the default groups were created.
Signed-off-by Kimberly Brown <[email protected]>
Greg, feel free to route this one through your tree.
Signature · 2 lines
Jiri Kosina SUSE Labs
Re: [PATCH v2 8/8] livepatch: Replace klp_ktype_patch's default_attrs with groups
In reply to Kimberly BrownQuoted 10 lines · Kimberly Brown
The
kobj_typedefault_attrsfield is being replaced by thedefault_groupsfield. Replace klp_ktype_patch'sdefault_attrsfield withdefault_groupsand use theATTRIBUTE_GROUPSmacro to createklp_patch_groups.This patch was tested by loading the livepatch-sample module and verifying that the sysfs files for the attributes in the default groups were created.
Signed-off-by Kimberly Brown <[email protected]>
M
Re: [PATCH v2 8/8] livepatch: Replace klp_ktype_patch's default_attrs with groups
In reply to Kimberly BrownQuoted 10 lines · Kimberly Brown
The
kobj_typedefault_attrsfield is being replaced by thedefault_groupsfield. Replace klp_ktype_patch'sdefault_attrsfield withdefault_groupsand use theATTRIBUTE_GROUPSmacro to createklp_patch_groups.This patch was tested by loading the livepatch-sample module and verifying that the sysfs files for the attributes in the default groups were created.
Signed-off-by Kimberly Brown <[email protected]>
Best Regards,
Petr
Greg Kroah-Hartman
maintainerRe: [PATCH v2 0/8] kobject: Add default group support to kobj_type and replace subsystem uses
In reply to Kimberly BrownQuoted 14 lines · Kimberly Brown
This patchset adds support for default attribute groups to
kobj_type. Also, the uses of kobj_type'sdefault_attrsfield are replaced withdefault_groupsin the following subsystems:
- samples
- block
- net
- irq
- padata
- cpufreq
- livepatchThe subsystem maintainers and lists will be copied on the subsystem patches.
Quoted 6 lines
The uses of kobj_type's
default_attrsfield in the other subsystems will be replaced in future patchsets.Changes in v2:
- Patch 1 is not changed.
- Patches 2-8 are new.
Thanks so much for doing this.
As all of the different subsystems depend on the first patch, I'll be glad to merge them all through my driver-core tree, or apply the first one and wait a release cycle so that the others can go through the individual subsystem's tree, depending on what the subsystem maintainer is comfortable with.
thanks,
greg k-h
Greg Kroah-Hartman
maintainerRe: [PATCH v2 0/8] kobject: Add default group support to kobj_type and replace subsystem uses
In reply to Kimberly BrownQuoted 11 lines · Kimberly Brown
This patchset adds support for default attribute groups to
kobj_type. Also, the uses of kobj_type'sdefault_attrsfield are replaced withdefault_groupsin the following subsystems:
- samples
- block
- net
- irq
- padata
- cpufreq
- livepatch
Quoted 5 lines
The subsystem maintainers and lists will be copied on the subsystem patches.
The uses of kobj_type's
default_attrsfield in the other subsystems will be replaced in future patchsets.
Thanks for all of these, now queued up. Patches to fix up the other subsystems are always welcome :)
greg k-h
Re: [PATCH v2 0/8] kobject: Add default group support to kobj_type and replace subsystem uses
Quoted 15 lines · Greg Kroah-Hartman
Quoted 14 lines · Kimberly Brown
This patchset adds support for default attribute groups to
kobj_type. Also, the uses of kobj_type'sdefault_attrsfield are replaced withdefault_groupsin the following subsystems:
- samples
- block
- net
- irq
- padata
- cpufreq
- livepatchThe subsystem maintainers and lists will be copied on the subsystem patches.
Quoted 7 lines
Quoted 2 lines
The uses of kobj_type's
default_attrsfield in the other subsystems will be replaced in future patchsets.Thanks for all of these, now queued up. Patches to fix up the other subsystems are always welcome :)
greg k-h
Thanks, Greg! I'll start preparing more patches.
I know that patches should be in linux-next for some time before the merge window opens. How long do they typically need to be in linux-next? I'm trying to figure out if the next patches I work on could be included in the next merge window, in which case I'll let the maintainers know that the patch will either need to go through the driver-core tree or wait for the next release cycle.
Thanks,
Kim
Greg Kroah-Hartman
maintainerRe: [PATCH v2 0/8] kobject: Add default group support to kobj_type and replace subsystem uses
Quoted 22 lines · Kimberly Brown
Quoted 21 lines · Greg Kroah-Hartman
Quoted 11 lines · Kimberly Brown
This patchset adds support for default attribute groups to
kobj_type. Also, the uses of kobj_type'sdefault_attrsfield are replaced withdefault_groupsin the following subsystems:
- samples
- block
- net
- irq
- padata
- cpufreq
- livepatchQuoted 5 lines
The subsystem maintainers and lists will be copied on the subsystem patches.
The uses of kobj_type's
default_attrsfield in the other subsystems will be replaced in future patchsets.Thanks for all of these, now queued up. Patches to fix up the other subsystems are always welcome :)
Quoted 6 lines
Quoted 1 line
greg k-h
Thanks, Greg! I'll start preparing more patches.
I know that patches should be in linux-next for some time before the merge window opens. How long do they typically need to be in linux-next?
It depends on the maintainer, what they feel like. I like to have a week or so, but some like more, and others less.
Sorry there's not a single answer.
Quoted 4 lines
I'm trying to figure out if the next patches I work on could be included in the next merge window, in which case I'll let the maintainers know that the patch will either need to go through the driver-core tree or wait for the next release cycle.
Mention that I can take them all through my tree now, as that's usually the easiest thing for api changes like this.
thanks,
greg k-h