mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Heiko Carstens <heiko.carstens@de.ibm.com>
To: Jeff Garzik <jeff@garzik.org>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>,
	Greg KH <greg@kroah.com>, Andrew Morton <akpm@osdl.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Ashok Raj <ashok.raj@intel.com>,
	Nathan Lynch <nathanl@austin.ibm.com>
Subject: Re: [PATCH] drivers/base: error handling fixes
Date: Thu, 5 Oct 2006 14:48:48 +0200	[thread overview]
Message-ID: <20061005124848.GB6920@osiris.boeblingen.de.ibm.com> (raw)
In-Reply-To: <4524E983.6010208@garzik.org>

> >>> static int __cpuinit topology_cpu_callback(struct notifier_block *nfb,
> >>>@@ -112,17 +110,18 @@ static int __cpuinit topology_cpu_callba
> >>> {
> >>> 	unsigned int cpu = (unsigned long)hcpu;
> >>> 	struct sys_device *sys_dev;
> >>>+	int rc = 0;
> >>>  	sys_dev = get_cpu_sysdev(cpu);
> >>> 	switch (action) {
> >>> 	case CPU_ONLINE:
> >>>-		topology_add_dev(sys_dev);
> >>>+		rc = topology_add_dev(sys_dev);
> >>> 		break;
> >>> 	case CPU_DEAD:
> >>> 		topology_remove_dev(sys_dev);
> >>> 		break;
> >>> 	}
> >>>-	return NOTIFY_OK;
> >>>+	return rc ? NOTIFY_BAD : NOTIFY_OK;
> >>> }
> >>Wouldn't that also require that _cpu_up checked the return code when
> >>doing CPU_ONLINE notification (and clean up on error)?
> >After all code that gets a CPU_ONLINE notification is not supposed to fail.
> >For allocating resources while bringing up a cpu CPU_UP_PREPARE is supposed
> >to be used. That one is allowed to fail.
> 
> It's a bug no matter how you look at it... I just lessen the impact.  :)
> 
> If someone wants to provide a better fix, let's see the patch...

If sysfs_remove_group() would also work for non-created (-existent) groups
then the patch below would work. Unfortunately that is not the case. So one
would have to remember if sysfs_create_group() was done and succeeded before
calling sysfs_remove_group()...
There must be an easier way.

diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index 3ef9d51..d0056c3 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -97,8 +97,7 @@ static struct attribute_group topology_a
 /* Add/Remove cpu_topology interface for CPU device */
 static int __cpuinit topology_add_dev(struct sys_device * sys_dev)
 {
-	sysfs_create_group(&sys_dev->kobj, &topology_attr_group);
-	return 0;
+	return sysfs_create_group(&sys_dev->kobj, &topology_attr_group);
 }
 
 static int __cpuinit topology_remove_dev(struct sys_device * sys_dev)
@@ -112,12 +111,16 @@ static int __cpuinit topology_cpu_callba
 {
 	unsigned int cpu = (unsigned long)hcpu;
 	struct sys_device *sys_dev;
+	int rc;
 
 	sys_dev = get_cpu_sysdev(cpu);
 	switch (action) {
-	case CPU_ONLINE:
-		topology_add_dev(sys_dev);
+	case CPU_UP_PREPARE:
+		rc = topology_add_dev(sys_dev);
+		if (rc)
+			return NOTIFY_BAD;
 		break;
+	case CPU_UP_CANCELED:
 	case CPU_DEAD:
 		topology_remove_dev(sys_dev);
 		break;
@@ -132,11 +135,15 @@ static struct notifier_block __cpuinitda
 
 static int __cpuinit topology_sysfs_init(void)
 {
-	int i;
-
-	for_each_online_cpu(i) {
-		topology_cpu_callback(&topology_cpu_notifier, CPU_ONLINE,
-				(void *)(long)i);
+	struct sys_device *sys_dev;
+	int cpu;
+	int rc;
+
+	for_each_online_cpu(cpu) {
+		sys_dev = get_cpu_sysdev(cpu);
+		rc = topology_add_dev(sys_dev);
+		if (rc)
+			return rc;
 	}
 
 	register_hotcpu_notifier(&topology_cpu_notifier);

  reply	other threads:[~2006-10-05 12:50 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-04 13:05 Jeff Garzik
2006-10-04 14:44 ` Cornelia Huck
2006-10-04 15:24 ` Cornelia Huck
2006-10-05  8:17   ` Heiko Carstens
2006-10-05 11:16     ` Jeff Garzik
2006-10-05 12:48       ` Heiko Carstens [this message]
2006-10-05 12:58         ` Jeff Garzik
2006-10-05 13:16           ` Heiko Carstens
2006-10-09  7:29             ` [patch 1/2] sysfs: allow removal of nonexistent sysfs groups Heiko Carstens
2006-10-09  7:40               ` Andrew Morton
2006-10-09  7:49                 ` Heiko Carstens
2006-10-09  7:30             ` [patch 2/2] cpu topology: various fixes/cleanups Heiko Carstens
2006-10-05 13:15         ` [PATCH] drivers/base: error handling fixes Cornelia Huck
2006-10-05 13:20           ` Heiko Carstens
2006-10-05 13:45             ` Cornelia Huck

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=20061005124848.GB6920@osiris.boeblingen.de.ibm.com \
    --to=heiko.carstens@de.ibm.com \
    --cc=akpm@osdl.org \
    --cc=ashok.raj@intel.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=greg@kroah.com \
    --cc=jeff@garzik.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nathanl@austin.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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

all inboxes | Powered by JetHome®