From: Nathan Fontenot <nfont@austin•ibm.com>
To: linuxppc-dev@ozlabs•org, linux-kernel@vger•kernel.org
Subject: Re: [PATCH 5/5] kernel handling of CPU DLPAR
Date: Mon, 14 Sep 2009 13:20:04 -0500 [thread overview]
Message-ID: <4AAE8954.1090709@austin.ibm.com> (raw)
In-Reply-To: <20090914064127.GC13139@centrinvest.ru>
Andrey Panin wrote:
> On 254, 09 11, 2009 at 04:15:33PM -0500, Nathan Fontenot wrote:
>> This adds the capability to DLPAR add and remove CPUs from the kernel. The
>> creates two new files /sys/devices/system/cpu/probe and
>> /sys/devices/system/cpu/release to handle the DLPAR addition and
>> removal of
>> CPUs respectively.
>>
>> CPU DLPAR add is accomplished by writing the drc-index of the CPU to the
>> probe file, and removal is done by writing the device-tree path of the cpu
>> to the release file.
>>
>> Signed-off-by: Nathan Fontenot <nfont@austin•ibm.com>
>
>> +static ssize_t cpu_probe_store(struct class *class, const char *buf,
>> + size_t count)
>> +{
>> + struct device_node *dn;
>> + u32 drc_index;
>> + char *cpu_name;
>> + int rc;
>> +
>> + drc_index = simple_strtoull(buf, NULL, 0);
>> + if (!drc_index)
>> + return -EINVAL;
>> +
>> + rc = acquire_drc(drc_index);
>> + if (rc)
>> + return rc;
>> +
>> + dn = configure_connector(drc_index);
>> + if (!dn) {
>> + release_drc(drc_index);
>> + return rc;
>> + }
>> +
>> + /* fixup dn name */
>> + cpu_name = kzalloc(strlen(dn->full_name) + strlen("/cpus/") + 1,
>> + GFP_KERNEL);
>
> Unchecked memory allocation with immediate crash in case of failure.
Yep, thats a bad thing. I'll fix this in an updated patch. thanks.
-Nathan
>
>> + sprintf(cpu_name, "/cpus/%s", dn->full_name);
>> + kfree(dn->full_name);
>> + dn->full_name = cpu_name;
>> +
>> + rc = add_device_tree_nodes(dn);
>> + if (rc)
>> + release_drc(drc_index);
>> +
>> + return rc ? rc : count;
>> +}
>> +
>> +static ssize_t cpu_release_store(struct class *class, const char *buf,
>> + size_t count)
>> +{
>> + struct device_node *dn;
>> + u32 *drc_index;
>> + int rc;
>> +
>> + dn = of_find_node_by_path(buf);
>> + if (!dn)
>> + return -EINVAL;
>> +
>> + drc_index = (u32 *)of_get_property(dn, "ibm,my-drc-index", NULL);
>> + if (!drc_index) {
>> + of_node_put(dn);
>> + return -EINVAL;
>> + }
>> +
>> + rc = release_drc(*drc_index);
>> + if (rc) {
>> + of_node_put(dn);
>> + return rc;
>> + }
>> +
>> + rc = remove_device_tree_nodes(dn);
>> + if (rc)
>> + acquire_drc(*drc_index);
>> +
>> + of_node_put(dn);
>> + return rc? rc : count;
>> +}
>> +
>> static struct class_attribute class_attr_mem_release =
>> __ATTR(release, S_IWUSR, NULL, memory_release_store);
>> +static struct class_attribute class_attr_cpu_probe =
>> + __ATTR(probe, S_IWUSR, NULL, cpu_probe_store);
>> +static struct class_attribute class_attr_cpu_release =
>> + __ATTR(release, S_IWUSR, NULL, cpu_release_store);
>>
>> static int pseries_dlpar_init(void)
>> {
>> @@ -576,6 +648,18 @@
>> printk(KERN_INFO "DLPAR: Could not create sysfs memory "
>> "release file\n");
>>
>> + rc = sysfs_create_file(&cpu_sysdev_class.kset.kobj,
>> + &class_attr_cpu_probe.attr);
>> + if (rc)
>> + printk(KERN_INFO "DLPAR: Could not create sysfs cpu "
>> + "probe file\n");
>> +
>> + rc = sysfs_create_file(&cpu_sysdev_class.kset.kobj,
>> + &class_attr_cpu_release.attr);
>> + if (rc)
>> + printk(KERN_INFO "DLPAR: Could not create sysfs cpu "
>> + "release file\n");
>> +
>> return 0;
>> }
>> __initcall(pseries_dlpar_init);
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger•kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at http://www.tux.org/lkml/
>>
next prev parent reply other threads:[~2009-09-14 18:20 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-11 21:08 [PATCH 0/5] kernel handling of dynamic logical partitioning Nathan Fontenot
2009-09-11 21:10 ` [PATCH 1/5] dynamic logical partitioning infrastructure Nathan Fontenot
2009-09-14 18:30 ` Brian King
2009-09-15 14:15 ` Nathan Fontenot
2009-09-16 1:33 ` Michael Ellerman
2009-09-17 14:45 ` Nathan Fontenot
2009-09-11 21:12 ` [PATCH 2/5] move of_drconf_cell definition to prom.h Nathan Fontenot
2009-09-15 14:38 ` Brian King
2009-09-11 21:13 ` [PATCH 3/5] Export memory_sysdev_class Nathan Fontenot
2009-09-11 21:14 ` [PATCH 4/5] kernel handling of memory DLPAR Nathan Fontenot
2009-09-14 6:39 ` Andrey Panin
2009-09-14 18:18 ` Nathan Fontenot
2009-09-11 21:15 ` [PATCH 5/5] kernel handling of CPU DLPAR Nathan Fontenot
2009-09-14 6:41 ` Andrey Panin
2009-09-14 18:20 ` Nathan Fontenot [this message]
2009-09-15 14:48 ` Brian King
2009-09-11 21:23 ` [PATCH 0/5] kernel handling of dynamic logical partitioning Daniel Walker
2009-09-14 18:22 ` Nathan Fontenot
2009-09-14 18:24 ` Daniel Walker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4AAE8954.1090709@austin.ibm.com \
--to=nfont@austin$(echo .)ibm.com \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linuxppc-dev@ozlabs$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox