diff for duplicates of <53BE9713.8090700@arm.com> diff --git a/a/1.txt b/N1/1.txt index dde947d..bbb5c61 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -109,7 +109,7 @@ is_visible callback. >> +{ >> + struct device *dev = get_cpu_device(cpu); >> + ->> + if (per_cpu_cacheinfo(cpu) = NULL) +>> + if (per_cpu_cacheinfo(cpu) == NULL) >> + return -ENOENT; >> + >> + per_cpu_cache_dev(cpu) = device_create(dev->class, dev, cpu, @@ -120,7 +120,7 @@ is_visible callback. >> + /* Allocate all required memory */ >> + per_cpu_index_dev(cpu) = kzalloc(sizeof(struct device *) * >> + cache_leaves(cpu), GFP_KERNEL); ->> + if (unlikely(per_cpu_index_dev(cpu) = NULL)) +>> + if (unlikely(per_cpu_index_dev(cpu) == NULL)) >> + goto err_out; >> + >> + return 0; diff --git a/a/content_digest b/N1/content_digest index 2e1a2f9..0f0869b 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -3,7 +3,7 @@ "ref\020140710000905.GA18025@kroah.com\0" "From\0Sudeep Holla <sudeep.holla@arm.com>\0" "Subject\0Re: [PATCH 2/9] drivers: base: support cpu cache information interface to userspace via sysfs\0" - "Date\0Thu, 10 Jul 2014 13:37:23 +0000\0" + "Date\0Thu, 10 Jul 2014 14:37:23 +0100\0" "To\0Greg Kroah-Hartman <gregkh@linuxfoundation.org>\0" "Cc\0Sudeep Holla <sudeep.holla@arm.com>" linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org> @@ -130,7 +130,7 @@ ">> +{\n" ">> +\tstruct device *dev = get_cpu_device(cpu);\n" ">> +\n" - ">> +\tif (per_cpu_cacheinfo(cpu) = NULL)\n" + ">> +\tif (per_cpu_cacheinfo(cpu) == NULL)\n" ">> +\t\treturn -ENOENT;\n" ">> +\n" ">> +\tper_cpu_cache_dev(cpu) = device_create(dev->class, dev, cpu,\n" @@ -141,7 +141,7 @@ ">> +\t/* Allocate all required memory */\n" ">> +\tper_cpu_index_dev(cpu) = kzalloc(sizeof(struct device *) *\n" ">> +\t\t\t\t\t cache_leaves(cpu), GFP_KERNEL);\n" - ">> +\tif (unlikely(per_cpu_index_dev(cpu) = NULL))\n" + ">> +\tif (unlikely(per_cpu_index_dev(cpu) == NULL))\n" ">> +\t\tgoto err_out;\n" ">> +\n" ">> +\treturn 0;\n" @@ -200,4 +200,4 @@ "Regards,\n" Sudeep -6a28551fda741ef2ab138c989e4f0ebb29aed5fdf2d58b6cffba35404202ee77 +3a99fb2920ca05b360d82bb4a47f06dd8765964f2555a5d43f85982300b42c96
diff --git a/a/1.txt b/N2/1.txt index dde947d..f4a6878 100644 --- a/a/1.txt +++ b/N2/1.txt @@ -4,47 +4,47 @@ Thanks for reviewing this. On 10/07/14 01:09, Greg Kroah-Hartman wrote: > On Wed, Jun 25, 2014 at 06:30:37PM +0100, Sudeep Holla wrote: ->> +static const struct device_attribute *cache_optional_attrs[] = { ->> + &dev_attr_coherency_line_size, ->> + &dev_attr_ways_of_associativity, ->> + &dev_attr_number_of_sets, ->> + &dev_attr_size, ->> + &dev_attr_attributes, ->> + &dev_attr_physical_line_partition, ->> + NULL +>> +static const struct device_attribute *cache_optional_attrs[] =3D { +>> +=09&dev_attr_coherency_line_size, +>> +=09&dev_attr_ways_of_associativity, +>> +=09&dev_attr_number_of_sets, +>> +=09&dev_attr_size, +>> +=09&dev_attr_attributes, +>> +=09&dev_attr_physical_line_partition, +>> +=09NULL >> +}; >> + >> +static int device_add_attrs(struct device *dev, ->> + const struct device_attribute **dev_attrs) +>> +=09=09=09 const struct device_attribute **dev_attrs) >> +{ ->> + int i, error = 0; ->> + struct device_attribute *dev_attr; ->> + char *buf; ->> + ->> + if (!dev_attrs) ->> + return 0; ->> + ->> + buf = kmalloc(PAGE_SIZE, GFP_KERNEL); ->> + if (!buf) ->> + return -ENOMEM; ->> + ->> + for (i = 0; dev_attrs[i]; i++) { ->> + dev_attr = (struct device_attribute *)dev_attrs[i]; ->> + ->> + /* create attributes that provides meaningful value */ ->> + if (dev_attr->show(dev, dev_attr, buf) < 0) ->> + continue; ->> + ->> + error = device_create_file(dev, dev_attrs[i]); ->> + if (error) { ->> + while (--i >= 0) ->> + device_remove_file(dev, dev_attrs[i]); ->> + break; ->> + } ->> + } ->> + ->> + kfree(buf); ->> + return error; +>> +=09int i, error =3D 0; +>> +=09struct device_attribute *dev_attr; +>> +=09char *buf; +>> + +>> +=09if (!dev_attrs) +>> +=09=09return 0; +>> + +>> +=09buf =3D kmalloc(PAGE_SIZE, GFP_KERNEL); +>> +=09if (!buf) +>> +=09=09return -ENOMEM; +>> + +>> +=09for (i =3D 0; dev_attrs[i]; i++) { +>> +=09=09dev_attr =3D (struct device_attribute *)dev_attrs[i]; +>> + +>> +=09=09/* create attributes that provides meaningful value */ +>> +=09=09if (dev_attr->show(dev, dev_attr, buf) < 0) +>> +=09=09=09continue; +>> + +>> +=09=09error =3D device_create_file(dev, dev_attrs[i]); +>> +=09=09if (error) { +>> +=09=09=09while (--i >=3D 0) +>> +=09=09=09=09device_remove_file(dev, dev_attrs[i]); +>> +=09=09=09break; +>> +=09=09} +>> +=09} +>> + +>> +=09kfree(buf); +>> +=09return error; >> +} > > Ick, why create your own function for this when the driver core has this @@ -52,20 +52,22 @@ On 10/07/14 01:09, Greg Kroah-Hartman wrote: > it is use for an attribute group please. > -I agree even I added this function hesitantly as didn't realize that I can use -is_visible for this purpose. Thanks for pointing that out I will have a look +I agree even I added this function hesitantly as didn't realize that I can = +use +is_visible for this purpose. Thanks for pointing that out I will have a loo= +k at it. >> +static void device_remove_attrs(struct device *dev, ->> + const struct device_attribute **dev_attrs) +>> +=09=09=09=09const struct device_attribute **dev_attrs) >> +{ ->> + int i; +>> +=09int i; >> + ->> + if (!dev_attrs) ->> + return; +>> +=09if (!dev_attrs) +>> +=09=09return; >> + ->> + for (i = 0; dev_attrs[i]; dev_attrs++, i++) ->> + device_remove_file(dev, dev_attrs[i]); +>> +=09for (i =3D 0; dev_attrs[i]; dev_attrs++, i++) +>> +=09=09device_remove_file(dev, dev_attrs[i]); >> +} > > You should just remove a whole group at once, not individually. @@ -78,93 +80,93 @@ is_visible callback. >> +const struct device_attribute ** >> +__weak cache_get_priv_attr(struct device *cache_idx_dev) >> +{ ->> + return NULL; +>> +=09return NULL; >> +} >> + >> +/* Add/Remove cache interface for CPU device */ >> +static void cpu_cache_sysfs_exit(unsigned int cpu) >> +{ ->> + int i; ->> + struct device *tmp_dev; ->> + const struct device_attribute **ci_priv_attr; ->> + ->> + if (per_cpu_index_dev(cpu)) { ->> + for (i = 0; i < cache_leaves(cpu); i++) { ->> + tmp_dev = per_cache_index_dev(cpu, i); ->> + if (!tmp_dev) ->> + continue; ->> + ci_priv_attr = cache_get_priv_attr(tmp_dev); ->> + device_remove_attrs(tmp_dev, ci_priv_attr); ->> + device_remove_attrs(tmp_dev, cache_optional_attrs); ->> + device_unregister(tmp_dev); ->> + } ->> + kfree(per_cpu_index_dev(cpu)); ->> + per_cpu_index_dev(cpu) = NULL; ->> + } ->> + device_unregister(per_cpu_cache_dev(cpu)); ->> + per_cpu_cache_dev(cpu) = NULL; +>> +=09int i; +>> +=09struct device *tmp_dev; +>> +=09const struct device_attribute **ci_priv_attr; +>> + +>> +=09if (per_cpu_index_dev(cpu)) { +>> +=09=09for (i =3D 0; i < cache_leaves(cpu); i++) { +>> +=09=09=09tmp_dev =3D per_cache_index_dev(cpu, i); +>> +=09=09=09if (!tmp_dev) +>> +=09=09=09=09continue; +>> +=09=09=09ci_priv_attr =3D cache_get_priv_attr(tmp_dev); +>> +=09=09=09device_remove_attrs(tmp_dev, ci_priv_attr); +>> +=09=09=09device_remove_attrs(tmp_dev, cache_optional_attrs); +>> +=09=09=09device_unregister(tmp_dev); +>> +=09=09} +>> +=09=09kfree(per_cpu_index_dev(cpu)); +>> +=09=09per_cpu_index_dev(cpu) =3D NULL; +>> +=09} +>> +=09device_unregister(per_cpu_cache_dev(cpu)); +>> +=09per_cpu_cache_dev(cpu) =3D NULL; >> +} >> + >> +static int cpu_cache_sysfs_init(unsigned int cpu) >> +{ ->> + struct device *dev = get_cpu_device(cpu); +>> +=09struct device *dev =3D get_cpu_device(cpu); >> + ->> + if (per_cpu_cacheinfo(cpu) = NULL) ->> + return -ENOENT; +>> +=09if (per_cpu_cacheinfo(cpu) =3D=3D NULL) +>> +=09=09return -ENOENT; >> + ->> + per_cpu_cache_dev(cpu) = device_create(dev->class, dev, cpu, ->> + NULL, "cache"); ->> + if (IS_ERR_OR_NULL(per_cpu_cache_dev(cpu))) ->> + return PTR_ERR(per_cpu_cache_dev(cpu)); +>> +=09per_cpu_cache_dev(cpu) =3D device_create(dev->class, dev, cpu, +>> +=09=09=09=09=09 NULL, "cache"); +>> +=09if (IS_ERR_OR_NULL(per_cpu_cache_dev(cpu))) +>> +=09=09return PTR_ERR(per_cpu_cache_dev(cpu)); >> + ->> + /* Allocate all required memory */ ->> + per_cpu_index_dev(cpu) = kzalloc(sizeof(struct device *) * ->> + cache_leaves(cpu), GFP_KERNEL); ->> + if (unlikely(per_cpu_index_dev(cpu) = NULL)) ->> + goto err_out; +>> +=09/* Allocate all required memory */ +>> +=09per_cpu_index_dev(cpu) =3D kzalloc(sizeof(struct device *) * +>> +=09=09=09=09=09 cache_leaves(cpu), GFP_KERNEL); +>> +=09if (unlikely(per_cpu_index_dev(cpu) =3D=3D NULL)) +>> +=09=09goto err_out; >> + ->> + return 0; +>> +=09return 0; >> + >> +err_out: ->> + cpu_cache_sysfs_exit(cpu); ->> + return -ENOMEM; +>> +=09cpu_cache_sysfs_exit(cpu); +>> +=09return -ENOMEM; >> +} >> + >> +static int cache_add_dev(unsigned int cpu) >> +{ ->> + unsigned short i; ->> + int rc; ->> + struct device *tmp_dev, *parent; ->> + struct cacheinfo *this_leaf; ->> + const struct device_attribute **ci_priv_attr; ->> + struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu); ->> + ->> + rc = cpu_cache_sysfs_init(cpu); ->> + if (unlikely(rc < 0)) ->> + return rc; ->> + ->> + parent = per_cpu_cache_dev(cpu); ->> + for (i = 0; i < cache_leaves(cpu); i++) { ->> + this_leaf = this_cpu_ci->info_list + i; ->> + if (this_leaf->disable_sysfs) ->> + continue; ->> + tmp_dev = device_create_with_groups(parent->class, parent, i, ->> + this_leaf, ->> + cache_default_groups, ->> + "index%1u", i); ->> + if (IS_ERR_OR_NULL(tmp_dev)) { ->> + rc = PTR_ERR(tmp_dev); ->> + goto err; ->> + } ->> + ->> + rc = device_add_attrs(tmp_dev, cache_optional_attrs); ->> + if (unlikely(rc)) ->> + goto err; ->> + ->> + ci_priv_attr = cache_get_priv_attr(tmp_dev); ->> + rc = device_add_attrs(tmp_dev, ci_priv_attr); ->> + if (unlikely(rc)) ->> + goto err; +>> +=09unsigned short i; +>> +=09int rc; +>> +=09struct device *tmp_dev, *parent; +>> +=09struct cacheinfo *this_leaf; +>> +=09const struct device_attribute **ci_priv_attr; +>> +=09struct cpu_cacheinfo *this_cpu_ci =3D get_cpu_cacheinfo(cpu); +>> + +>> +=09rc =3D cpu_cache_sysfs_init(cpu); +>> +=09if (unlikely(rc < 0)) +>> +=09=09return rc; +>> + +>> +=09parent =3D per_cpu_cache_dev(cpu); +>> +=09for (i =3D 0; i < cache_leaves(cpu); i++) { +>> +=09=09this_leaf =3D this_cpu_ci->info_list + i; +>> +=09=09if (this_leaf->disable_sysfs) +>> +=09=09=09continue; +>> +=09=09tmp_dev =3D device_create_with_groups(parent->class, parent, i, +>> +=09=09=09=09=09=09 this_leaf, +>> +=09=09=09=09=09=09 cache_default_groups, +>> +=09=09=09=09=09=09 "index%1u", i); +>> +=09=09if (IS_ERR_OR_NULL(tmp_dev)) { +>> +=09=09=09rc =3D PTR_ERR(tmp_dev); +>> +=09=09=09goto err; +>> +=09=09} +>> + +>> +=09=09rc =3D device_add_attrs(tmp_dev, cache_optional_attrs); +>> +=09=09if (unlikely(rc)) +>> +=09=09=09goto err; +>> + +>> +=09=09ci_priv_attr =3D cache_get_priv_attr(tmp_dev); +>> +=09=09rc =3D device_add_attrs(tmp_dev, ci_priv_attr); +>> +=09=09if (unlikely(rc)) +>> +=09=09=09goto err; > > You just raced with userspace here, creating these files _after_ the > device was announced to userspace, causing problems with anyone wanting diff --git a/a/content_digest b/N2/content_digest index 2e1a2f9..5b8d3bb 100644 --- a/a/content_digest +++ b/N2/content_digest @@ -3,18 +3,18 @@ "ref\020140710000905.GA18025@kroah.com\0" "From\0Sudeep Holla <sudeep.holla@arm.com>\0" "Subject\0Re: [PATCH 2/9] drivers: base: support cpu cache information interface to userspace via sysfs\0" - "Date\0Thu, 10 Jul 2014 13:37:23 +0000\0" + "Date\0Thu, 10 Jul 2014 14:37:23 +0100\0" "To\0Greg Kroah-Hartman <gregkh@linuxfoundation.org>\0" - "Cc\0Sudeep Holla <sudeep.holla@arm.com>" - linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org> - Heiko Carstens <heiko.carstens@de.ibm.com> + "Cc\0Rob Herring <robh@kernel.org>" Lorenzo Pieralisi <Lorenzo.Pieralisi@arm.com> - Rob Herring <robh@kernel.org> - linux-doc@vger.kernel.org <linux-doc@vger.kernel.org> linux-ia64@vger.kernel.org <linux-ia64@vger.kernel.org> - linux390@de.ibm.com <linux390@de.ibm.com> + linux-doc@vger.kernel.org <linux-doc@vger.kernel.org> linux-s390@vger.kernel.org <linux-s390@vger.kernel.org> x86@kernel.org <x86@kernel.org> + Heiko Carstens <heiko.carstens@de.ibm.com> + linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org> + Sudeep Holla <sudeep.holla@arm.com> + linux390@de.ibm.com <linux390@de.ibm.com> linuxppc-dev@lists.ozlabs.org <linuxppc-dev@lists.ozlabs.org> " linux-arm-kernel@lists.infradead.org <linux-arm-kernel@lists.infradead.org>\0" "\00:1\0" @@ -25,47 +25,47 @@ "\n" "On 10/07/14 01:09, Greg Kroah-Hartman wrote:\n" "> On Wed, Jun 25, 2014 at 06:30:37PM +0100, Sudeep Holla wrote:\n" - ">> +static const struct device_attribute *cache_optional_attrs[] = {\n" - ">> +\t&dev_attr_coherency_line_size,\n" - ">> +\t&dev_attr_ways_of_associativity,\n" - ">> +\t&dev_attr_number_of_sets,\n" - ">> +\t&dev_attr_size,\n" - ">> +\t&dev_attr_attributes,\n" - ">> +\t&dev_attr_physical_line_partition,\n" - ">> +\tNULL\n" + ">> +static const struct device_attribute *cache_optional_attrs[] =3D {\n" + ">> +=09&dev_attr_coherency_line_size,\n" + ">> +=09&dev_attr_ways_of_associativity,\n" + ">> +=09&dev_attr_number_of_sets,\n" + ">> +=09&dev_attr_size,\n" + ">> +=09&dev_attr_attributes,\n" + ">> +=09&dev_attr_physical_line_partition,\n" + ">> +=09NULL\n" ">> +};\n" ">> +\n" ">> +static int device_add_attrs(struct device *dev,\n" - ">> +\t\t\t const struct device_attribute **dev_attrs)\n" + ">> +=09=09=09 const struct device_attribute **dev_attrs)\n" ">> +{\n" - ">> +\tint i, error = 0;\n" - ">> +\tstruct device_attribute *dev_attr;\n" - ">> +\tchar *buf;\n" - ">> +\n" - ">> +\tif (!dev_attrs)\n" - ">> +\t\treturn 0;\n" - ">> +\n" - ">> +\tbuf = kmalloc(PAGE_SIZE, GFP_KERNEL);\n" - ">> +\tif (!buf)\n" - ">> +\t\treturn -ENOMEM;\n" - ">> +\n" - ">> +\tfor (i = 0; dev_attrs[i]; i++) {\n" - ">> +\t\tdev_attr = (struct device_attribute *)dev_attrs[i];\n" - ">> +\n" - ">> +\t\t/* create attributes that provides meaningful value */\n" - ">> +\t\tif (dev_attr->show(dev, dev_attr, buf) < 0)\n" - ">> +\t\t\tcontinue;\n" - ">> +\n" - ">> +\t\terror = device_create_file(dev, dev_attrs[i]);\n" - ">> +\t\tif (error) {\n" - ">> +\t\t\twhile (--i >= 0)\n" - ">> +\t\t\t\tdevice_remove_file(dev, dev_attrs[i]);\n" - ">> +\t\t\tbreak;\n" - ">> +\t\t}\n" - ">> +\t}\n" - ">> +\n" - ">> +\tkfree(buf);\n" - ">> +\treturn error;\n" + ">> +=09int i, error =3D 0;\n" + ">> +=09struct device_attribute *dev_attr;\n" + ">> +=09char *buf;\n" + ">> +\n" + ">> +=09if (!dev_attrs)\n" + ">> +=09=09return 0;\n" + ">> +\n" + ">> +=09buf =3D kmalloc(PAGE_SIZE, GFP_KERNEL);\n" + ">> +=09if (!buf)\n" + ">> +=09=09return -ENOMEM;\n" + ">> +\n" + ">> +=09for (i =3D 0; dev_attrs[i]; i++) {\n" + ">> +=09=09dev_attr =3D (struct device_attribute *)dev_attrs[i];\n" + ">> +\n" + ">> +=09=09/* create attributes that provides meaningful value */\n" + ">> +=09=09if (dev_attr->show(dev, dev_attr, buf) < 0)\n" + ">> +=09=09=09continue;\n" + ">> +\n" + ">> +=09=09error =3D device_create_file(dev, dev_attrs[i]);\n" + ">> +=09=09if (error) {\n" + ">> +=09=09=09while (--i >=3D 0)\n" + ">> +=09=09=09=09device_remove_file(dev, dev_attrs[i]);\n" + ">> +=09=09=09break;\n" + ">> +=09=09}\n" + ">> +=09}\n" + ">> +\n" + ">> +=09kfree(buf);\n" + ">> +=09return error;\n" ">> +}\n" ">\n" "> Ick, why create your own function for this when the driver core has this\n" @@ -73,20 +73,22 @@ "> it is use for an attribute group please.\n" ">\n" "\n" - "I agree even I added this function hesitantly as didn't realize that I can use\n" - "is_visible for this purpose. Thanks for pointing that out I will have a look\n" + "I agree even I added this function hesitantly as didn't realize that I can =\n" + "use\n" + "is_visible for this purpose. Thanks for pointing that out I will have a loo=\n" + "k\n" "at it.\n" "\n" ">> +static void device_remove_attrs(struct device *dev,\n" - ">> +\t\t\t\tconst struct device_attribute **dev_attrs)\n" + ">> +=09=09=09=09const struct device_attribute **dev_attrs)\n" ">> +{\n" - ">> +\tint i;\n" + ">> +=09int i;\n" ">> +\n" - ">> +\tif (!dev_attrs)\n" - ">> +\t\treturn;\n" + ">> +=09if (!dev_attrs)\n" + ">> +=09=09return;\n" ">> +\n" - ">> +\tfor (i = 0; dev_attrs[i]; dev_attrs++, i++)\n" - ">> +\t\tdevice_remove_file(dev, dev_attrs[i]);\n" + ">> +=09for (i =3D 0; dev_attrs[i]; dev_attrs++, i++)\n" + ">> +=09=09device_remove_file(dev, dev_attrs[i]);\n" ">> +}\n" ">\n" "> You should just remove a whole group at once, not individually.\n" @@ -99,93 +101,93 @@ ">> +const struct device_attribute **\n" ">> +__weak cache_get_priv_attr(struct device *cache_idx_dev)\n" ">> +{\n" - ">> +\treturn NULL;\n" + ">> +=09return NULL;\n" ">> +}\n" ">> +\n" ">> +/* Add/Remove cache interface for CPU device */\n" ">> +static void cpu_cache_sysfs_exit(unsigned int cpu)\n" ">> +{\n" - ">> +\tint i;\n" - ">> +\tstruct device *tmp_dev;\n" - ">> +\tconst struct device_attribute **ci_priv_attr;\n" - ">> +\n" - ">> +\tif (per_cpu_index_dev(cpu)) {\n" - ">> +\t\tfor (i = 0; i < cache_leaves(cpu); i++) {\n" - ">> +\t\t\ttmp_dev = per_cache_index_dev(cpu, i);\n" - ">> +\t\t\tif (!tmp_dev)\n" - ">> +\t\t\t\tcontinue;\n" - ">> +\t\t\tci_priv_attr = cache_get_priv_attr(tmp_dev);\n" - ">> +\t\t\tdevice_remove_attrs(tmp_dev, ci_priv_attr);\n" - ">> +\t\t\tdevice_remove_attrs(tmp_dev, cache_optional_attrs);\n" - ">> +\t\t\tdevice_unregister(tmp_dev);\n" - ">> +\t\t}\n" - ">> +\t\tkfree(per_cpu_index_dev(cpu));\n" - ">> +\t\tper_cpu_index_dev(cpu) = NULL;\n" - ">> +\t}\n" - ">> +\tdevice_unregister(per_cpu_cache_dev(cpu));\n" - ">> +\tper_cpu_cache_dev(cpu) = NULL;\n" + ">> +=09int i;\n" + ">> +=09struct device *tmp_dev;\n" + ">> +=09const struct device_attribute **ci_priv_attr;\n" + ">> +\n" + ">> +=09if (per_cpu_index_dev(cpu)) {\n" + ">> +=09=09for (i =3D 0; i < cache_leaves(cpu); i++) {\n" + ">> +=09=09=09tmp_dev =3D per_cache_index_dev(cpu, i);\n" + ">> +=09=09=09if (!tmp_dev)\n" + ">> +=09=09=09=09continue;\n" + ">> +=09=09=09ci_priv_attr =3D cache_get_priv_attr(tmp_dev);\n" + ">> +=09=09=09device_remove_attrs(tmp_dev, ci_priv_attr);\n" + ">> +=09=09=09device_remove_attrs(tmp_dev, cache_optional_attrs);\n" + ">> +=09=09=09device_unregister(tmp_dev);\n" + ">> +=09=09}\n" + ">> +=09=09kfree(per_cpu_index_dev(cpu));\n" + ">> +=09=09per_cpu_index_dev(cpu) =3D NULL;\n" + ">> +=09}\n" + ">> +=09device_unregister(per_cpu_cache_dev(cpu));\n" + ">> +=09per_cpu_cache_dev(cpu) =3D NULL;\n" ">> +}\n" ">> +\n" ">> +static int cpu_cache_sysfs_init(unsigned int cpu)\n" ">> +{\n" - ">> +\tstruct device *dev = get_cpu_device(cpu);\n" + ">> +=09struct device *dev =3D get_cpu_device(cpu);\n" ">> +\n" - ">> +\tif (per_cpu_cacheinfo(cpu) = NULL)\n" - ">> +\t\treturn -ENOENT;\n" + ">> +=09if (per_cpu_cacheinfo(cpu) =3D=3D NULL)\n" + ">> +=09=09return -ENOENT;\n" ">> +\n" - ">> +\tper_cpu_cache_dev(cpu) = device_create(dev->class, dev, cpu,\n" - ">> +\t\t\t\t\t NULL, \"cache\");\n" - ">> +\tif (IS_ERR_OR_NULL(per_cpu_cache_dev(cpu)))\n" - ">> +\t\treturn PTR_ERR(per_cpu_cache_dev(cpu));\n" + ">> +=09per_cpu_cache_dev(cpu) =3D device_create(dev->class, dev, cpu,\n" + ">> +=09=09=09=09=09 NULL, \"cache\");\n" + ">> +=09if (IS_ERR_OR_NULL(per_cpu_cache_dev(cpu)))\n" + ">> +=09=09return PTR_ERR(per_cpu_cache_dev(cpu));\n" ">> +\n" - ">> +\t/* Allocate all required memory */\n" - ">> +\tper_cpu_index_dev(cpu) = kzalloc(sizeof(struct device *) *\n" - ">> +\t\t\t\t\t cache_leaves(cpu), GFP_KERNEL);\n" - ">> +\tif (unlikely(per_cpu_index_dev(cpu) = NULL))\n" - ">> +\t\tgoto err_out;\n" + ">> +=09/* Allocate all required memory */\n" + ">> +=09per_cpu_index_dev(cpu) =3D kzalloc(sizeof(struct device *) *\n" + ">> +=09=09=09=09=09 cache_leaves(cpu), GFP_KERNEL);\n" + ">> +=09if (unlikely(per_cpu_index_dev(cpu) =3D=3D NULL))\n" + ">> +=09=09goto err_out;\n" ">> +\n" - ">> +\treturn 0;\n" + ">> +=09return 0;\n" ">> +\n" ">> +err_out:\n" - ">> +\tcpu_cache_sysfs_exit(cpu);\n" - ">> +\treturn -ENOMEM;\n" + ">> +=09cpu_cache_sysfs_exit(cpu);\n" + ">> +=09return -ENOMEM;\n" ">> +}\n" ">> +\n" ">> +static int cache_add_dev(unsigned int cpu)\n" ">> +{\n" - ">> +\tunsigned short i;\n" - ">> +\tint rc;\n" - ">> +\tstruct device *tmp_dev, *parent;\n" - ">> +\tstruct cacheinfo *this_leaf;\n" - ">> +\tconst struct device_attribute **ci_priv_attr;\n" - ">> +\tstruct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);\n" - ">> +\n" - ">> +\trc = cpu_cache_sysfs_init(cpu);\n" - ">> +\tif (unlikely(rc < 0))\n" - ">> +\t\treturn rc;\n" - ">> +\n" - ">> +\tparent = per_cpu_cache_dev(cpu);\n" - ">> +\tfor (i = 0; i < cache_leaves(cpu); i++) {\n" - ">> +\t\tthis_leaf = this_cpu_ci->info_list + i;\n" - ">> +\t\tif (this_leaf->disable_sysfs)\n" - ">> +\t\t\tcontinue;\n" - ">> +\t\ttmp_dev = device_create_with_groups(parent->class, parent, i,\n" - ">> +\t\t\t\t\t\t this_leaf,\n" - ">> +\t\t\t\t\t\t cache_default_groups,\n" - ">> +\t\t\t\t\t\t \"index%1u\", i);\n" - ">> +\t\tif (IS_ERR_OR_NULL(tmp_dev)) {\n" - ">> +\t\t\trc = PTR_ERR(tmp_dev);\n" - ">> +\t\t\tgoto err;\n" - ">> +\t\t}\n" - ">> +\n" - ">> +\t\trc = device_add_attrs(tmp_dev, cache_optional_attrs);\n" - ">> +\t\tif (unlikely(rc))\n" - ">> +\t\t\tgoto err;\n" - ">> +\n" - ">> +\t\tci_priv_attr = cache_get_priv_attr(tmp_dev);\n" - ">> +\t\trc = device_add_attrs(tmp_dev, ci_priv_attr);\n" - ">> +\t\tif (unlikely(rc))\n" - ">> +\t\t\tgoto err;\n" + ">> +=09unsigned short i;\n" + ">> +=09int rc;\n" + ">> +=09struct device *tmp_dev, *parent;\n" + ">> +=09struct cacheinfo *this_leaf;\n" + ">> +=09const struct device_attribute **ci_priv_attr;\n" + ">> +=09struct cpu_cacheinfo *this_cpu_ci =3D get_cpu_cacheinfo(cpu);\n" + ">> +\n" + ">> +=09rc =3D cpu_cache_sysfs_init(cpu);\n" + ">> +=09if (unlikely(rc < 0))\n" + ">> +=09=09return rc;\n" + ">> +\n" + ">> +=09parent =3D per_cpu_cache_dev(cpu);\n" + ">> +=09for (i =3D 0; i < cache_leaves(cpu); i++) {\n" + ">> +=09=09this_leaf =3D this_cpu_ci->info_list + i;\n" + ">> +=09=09if (this_leaf->disable_sysfs)\n" + ">> +=09=09=09continue;\n" + ">> +=09=09tmp_dev =3D device_create_with_groups(parent->class, parent, i,\n" + ">> +=09=09=09=09=09=09 this_leaf,\n" + ">> +=09=09=09=09=09=09 cache_default_groups,\n" + ">> +=09=09=09=09=09=09 \"index%1u\", i);\n" + ">> +=09=09if (IS_ERR_OR_NULL(tmp_dev)) {\n" + ">> +=09=09=09rc =3D PTR_ERR(tmp_dev);\n" + ">> +=09=09=09goto err;\n" + ">> +=09=09}\n" + ">> +\n" + ">> +=09=09rc =3D device_add_attrs(tmp_dev, cache_optional_attrs);\n" + ">> +=09=09if (unlikely(rc))\n" + ">> +=09=09=09goto err;\n" + ">> +\n" + ">> +=09=09ci_priv_attr =3D cache_get_priv_attr(tmp_dev);\n" + ">> +=09=09rc =3D device_add_attrs(tmp_dev, ci_priv_attr);\n" + ">> +=09=09if (unlikely(rc))\n" + ">> +=09=09=09goto err;\n" ">\n" "> You just raced with userspace here, creating these files _after_ the\n" "> device was announced to userspace, causing problems with anyone wanting\n" @@ -200,4 +202,4 @@ "Regards,\n" Sudeep -6a28551fda741ef2ab138c989e4f0ebb29aed5fdf2d58b6cffba35404202ee77 +635b47b2673d9efc516400fc98c2a5f1c287142af155a3322d78d3ec4b8423d7
diff --git a/a/1.txt b/N3/1.txt index dde947d..bbb5c61 100644 --- a/a/1.txt +++ b/N3/1.txt @@ -109,7 +109,7 @@ is_visible callback. >> +{ >> + struct device *dev = get_cpu_device(cpu); >> + ->> + if (per_cpu_cacheinfo(cpu) = NULL) +>> + if (per_cpu_cacheinfo(cpu) == NULL) >> + return -ENOENT; >> + >> + per_cpu_cache_dev(cpu) = device_create(dev->class, dev, cpu, @@ -120,7 +120,7 @@ is_visible callback. >> + /* Allocate all required memory */ >> + per_cpu_index_dev(cpu) = kzalloc(sizeof(struct device *) * >> + cache_leaves(cpu), GFP_KERNEL); ->> + if (unlikely(per_cpu_index_dev(cpu) = NULL)) +>> + if (unlikely(per_cpu_index_dev(cpu) == NULL)) >> + goto err_out; >> + >> + return 0; diff --git a/a/content_digest b/N3/content_digest index 2e1a2f9..b1933e2 100644 --- a/a/content_digest +++ b/N3/content_digest @@ -1,22 +1,10 @@ "ref\01403717444-23559-1-git-send-email-sudeep.holla@arm.com\0" "ref\01403717444-23559-3-git-send-email-sudeep.holla@arm.com\0" "ref\020140710000905.GA18025@kroah.com\0" - "From\0Sudeep Holla <sudeep.holla@arm.com>\0" - "Subject\0Re: [PATCH 2/9] drivers: base: support cpu cache information interface to userspace via sysfs\0" - "Date\0Thu, 10 Jul 2014 13:37:23 +0000\0" - "To\0Greg Kroah-Hartman <gregkh@linuxfoundation.org>\0" - "Cc\0Sudeep Holla <sudeep.holla@arm.com>" - linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org> - Heiko Carstens <heiko.carstens@de.ibm.com> - Lorenzo Pieralisi <Lorenzo.Pieralisi@arm.com> - Rob Herring <robh@kernel.org> - linux-doc@vger.kernel.org <linux-doc@vger.kernel.org> - linux-ia64@vger.kernel.org <linux-ia64@vger.kernel.org> - linux390@de.ibm.com <linux390@de.ibm.com> - linux-s390@vger.kernel.org <linux-s390@vger.kernel.org> - x86@kernel.org <x86@kernel.org> - linuxppc-dev@lists.ozlabs.org <linuxppc-dev@lists.ozlabs.org> - " linux-arm-kernel@lists.infradead.org <linux-arm-kernel@lists.infradead.org>\0" + "From\0sudeep.holla@arm.com (Sudeep Holla)\0" + "Subject\0[PATCH 2/9] drivers: base: support cpu cache information interface to userspace via sysfs\0" + "Date\0Thu, 10 Jul 2014 14:37:23 +0100\0" + "To\0linux-arm-kernel@lists.infradead.org\0" "\00:1\0" "b\0" "Hi Greg,\n" @@ -130,7 +118,7 @@ ">> +{\n" ">> +\tstruct device *dev = get_cpu_device(cpu);\n" ">> +\n" - ">> +\tif (per_cpu_cacheinfo(cpu) = NULL)\n" + ">> +\tif (per_cpu_cacheinfo(cpu) == NULL)\n" ">> +\t\treturn -ENOENT;\n" ">> +\n" ">> +\tper_cpu_cache_dev(cpu) = device_create(dev->class, dev, cpu,\n" @@ -141,7 +129,7 @@ ">> +\t/* Allocate all required memory */\n" ">> +\tper_cpu_index_dev(cpu) = kzalloc(sizeof(struct device *) *\n" ">> +\t\t\t\t\t cache_leaves(cpu), GFP_KERNEL);\n" - ">> +\tif (unlikely(per_cpu_index_dev(cpu) = NULL))\n" + ">> +\tif (unlikely(per_cpu_index_dev(cpu) == NULL))\n" ">> +\t\tgoto err_out;\n" ">> +\n" ">> +\treturn 0;\n" @@ -200,4 +188,4 @@ "Regards,\n" Sudeep -6a28551fda741ef2ab138c989e4f0ebb29aed5fdf2d58b6cffba35404202ee77 +3207f2cb5ccef72b27e8b80d0c1e055352e4609930ea0dae79b42b2f38845337
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.