From: Joel Becker <Joel.Becker@oracle.com>
To: Satyam Sharma <ssatyam@cse.iitk.ac.in>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Keiichi Kii <k-keiichi@bx.jp.nec.com>,
Netdev <netdev@vger.kernel.org>, Matt Mackall <mpm@selenic.com>,
Andrew Morton <akpm@linux-foundation.org>,
David Miller <davem@davemloft.net>
Subject: Re: [PATCH -mm 9/9] netconsole: Support dynamic reconfiguration using configfs
Date: Fri, 6 Jul 2007 23:01:15 -0700 [thread overview]
Message-ID: <20070707060114.GB1011@tasint.org> (raw)
In-Reply-To: <20070704110824.28520.11661.sendpatchset@cselinux1.cse.iitk.ac.in>
On Wed, Jul 04, 2007 at 04:38:24PM +0530, Satyam Sharma wrote:
> struct netconsole_target {
> struct list_head list;
> + struct config_item item;
> + int id;
> + int enabled;
> int dev_status;
> struct netpoll np;
> };
If you're trying to be good with your CONFIG_NETCONSOLE_DYNAMIC
ifdefs, you probably want to ifdef the item. You'll save space when
NETCONSOLE_DYNAMIC is off.
> +#ifdef CONFIG_NETCONSOLE_DYNAMIC
> +
> +/*
> + * Targets that were created by parsing the boot/module option string
> + * do not exist in the configfs hierarchy and will never go away (and
> + * have zeroed-out config_item members). So make these a no-op for them.
> + */
> +static void netconsole_target_get(struct netconsole_target *nt)
> +{
> + static struct config_item empty_item; /* Zeroed-out config_item */
> +
> + if (memcmp(&nt->item, &empty_item, sizeof(struct config_item)))
> + config_item_get(&nt->item);
> +}
I was going to point out that you could merely check
config_item_name(&nt->item) != NULL, because a valid configfs object has
a name and your zeroed object does not. But your followup email
suggests you'll be removing this code anyway.
I don't, off the top of my head, see a problem with removing the
_get/_put cycle, because you do have them under the spinlock. Things
should behave correctly. However, the _get/_put pair is "cleaner", in
that it expresses the relationship and doesn't add a special case of "I
happen to know this is safe".
> + * Our subsystem hierarchy is:
> + *
> + * /config/netconsole/
> + * |
> + * <target>/
> + * | id
> + * | enabled
Your configfs bits seem to be pretty straightforward.
> + /*
> + * Skip netpoll_parse_options() -- all the attributes are
> + * already configured in nt->np through configfs. But at
> + * least let's print the useful stuff it used to output :-)
> + */
> + printk(KERN_INFO "%s: local port %d\n",
> + np->name, np->local_port);
> + printk(KERN_INFO "%s: local IP %d.%d.%d.%d\n",
> + np->name, HIPQUAD(np->local_ip));
> + printk(KERN_INFO "%s: interface %s\n",
> + np->name, np->dev_name);
> + printk(KERN_INFO "%s: remote port %d\n",
> + np->name, np->remote_port);
> + printk(KERN_INFO "%s: remote IP %d.%d.%d.%d\n",
> + np->name, HIPQUAD(np->remote_ip));
> + printk(KERN_INFO "%s: remote ethernet address "
> + "%02x:%02x:%02x:%02x:%02x:%02x\n",
> + np->name,
> + np->remote_mac[0], np->remote_mac[1],
> + np->remote_mac[2], np->remote_mac[3],
> + np->remote_mac[4], np->remote_mac[5]);
Shouldn't you break this out into a function so that both places
can use it?
> +#define NETCONSOLE_TARGET_ATTR_RO(_name) \
> +static struct netconsole_target_attr netconsole_target_##_name = \
> +__CONFIGFS_ATTR(_name, S_IRUGO, show_##_name, NULL)
> +
> +#define NETCONSOLE_TARGET_ATTR_RW(_name) \
> +static struct netconsole_target_attr netconsole_target_##_name = \
> +__CONFIGFS_ATTR(_name, S_IRUGO | S_IWUSR, show_##_name, store_##_name)
Perhaps an indent would be clearer, but that's a tiny nitpick.
> /*
> - * Neither the netdev notifier, nor the console have been
> - * registered so far. Nobody's racing us, so skip the lock.
> + * Neither the netdev notifier, not the configfs subsystem and
> + * nor the console have been registered so far. Nobody's racing us,
> + * so skip the lock.
Once again, while you know you can skip the lock, it's unclear
without the comment. Perhaps using the lock makes it explicitly
"correct"? Food for thought.
> @@ -251,6 +796,17 @@ static int __init init_netconsole(void)
> if (err)
> goto fail;
>
> +#ifdef CONFIG_NETCONSOLE_DYNAMIC
> + config_group_init(&netconsole_subsys.su_group);
> + mutex_init(&netconsole_subsys.su_mtx);
> +
> + err = configfs_register_subsystem(&netconsole_subsys);
> + if (err) {
> + unregister_netdevice_notifier(&netconsole_netdev_notifier);
> + goto fail;
> + }
> +#endif /* CONFIG_NETCONSOLE_DYNAMIC */
I'd abstract this to a dynamic_init() function.
> +
> +#ifdef CONFIG_NETCONSOLE_DYNAMIC
> + configfs_unregister_subsystem(&netconsole_subsys);
> +#endif /* CONFIG_NETCONSOLE_DYNAMIC */
> +
and this to an dynamic_fini() function. Basically, do what you
did with _get()/_put(). This keeps the ifdef up above and out of the
functions themselves.
#ifdef CONFIG_NETCONSOLE_DYNAMIC
static int __init dynamic_netconsole_init(void)
{
config_group_init(&netconsole_subsys.su_group);
mutex_init(&netconsole_subsys.su_mtx);
return configfs_register_subsystem(&netconsole_subsys);
}
#else
static int __init dynamic_netconsole_init(void)
{
return 0;
}
#endif
Joel
--
Life's Little Instruction Book #3
"Watch a sunrise at least once a year."
Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker@oracle.com
Phone: (650) 506-8127
next prev parent reply other threads:[~2007-07-07 6:01 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-04 11:07 [RFC][PATCH -mm 0/9] netconsole: Multiple targets and dynamic reconfigurability Satyam Sharma
2007-07-04 11:07 ` [PATCH -mm 1/9] netconsole: Cleanups, codingstyle, prettyfication Satyam Sharma
2007-07-04 11:07 ` [PATCH -mm 2/9] netconsole: Code simplification Satyam Sharma
2007-07-04 13:46 ` Matt Mackall
2007-07-04 17:43 ` Satyam Sharma
2007-07-04 11:07 ` [PATCH -mm 3/9] netconsole: Introduce netconsole_target Satyam Sharma
2007-07-04 11:07 ` [PATCH -mm 4/9] netconsole: Introduce netconsole_netdev_notifier Satyam Sharma
2007-07-04 13:59 ` Matt Mackall
2007-07-04 18:02 ` Satyam Sharma
2007-07-07 18:33 ` KII Keiichi
2007-07-07 20:28 ` Satyam Sharma
2007-07-07 20:49 ` Satyam Sharma
2007-07-04 11:08 ` [PATCH -mm 5/9] netconsole: Introduce dev_status member Satyam Sharma
2007-07-04 13:56 ` Matt Mackall
2007-07-04 16:33 ` Satyam Sharma
2007-07-05 15:17 ` Stephen Hemminger
2007-07-07 8:08 ` Satyam Sharma
2007-07-05 6:39 ` Joel Becker
2007-07-05 9:36 ` Satyam Sharma
2007-07-04 11:08 ` [PATCH -mm 6/9] netconsole: Update documentation for multiple target support Satyam Sharma
2007-07-04 14:01 ` Matt Mackall
2007-07-04 18:11 ` Satyam Sharma
2007-07-04 11:08 ` [PATCH -mm 7/9] netconsole: Support multiple logging targets Satyam Sharma
2007-07-07 18:33 ` KII Keiichi
2007-07-07 19:46 ` Satyam Sharma
2007-07-04 11:08 ` [PATCH -mm 8/9] netconsole: Update documentation for dynamic reconfigurability Satyam Sharma
2007-07-05 6:52 ` Joel Becker
2007-07-05 9:38 ` Satyam Sharma
2007-07-05 12:58 ` Keiichi KII
2007-07-05 13:55 ` Satyam Sharma
2007-07-05 14:03 ` Satyam Sharma
2007-07-07 18:33 ` KII Keiichi
2007-07-07 20:35 ` Satyam Sharma
2007-07-04 11:08 ` [PATCH -mm 9/9] netconsole: Support dynamic reconfiguration using configfs Satyam Sharma
2007-07-04 13:21 ` Satyam Sharma
2007-07-07 6:01 ` Joel Becker [this message]
2007-07-07 7:48 ` Satyam Sharma
2007-07-07 8:18 ` Joel Becker
2007-07-07 18:33 ` KII Keiichi
2007-07-07 19:38 ` Satyam Sharma
2007-07-04 11:49 ` [RFC][PATCH -mm 0/9] netconsole: Multiple targets and dynamic reconfigurability Keiichi KII
2007-07-04 12:25 ` Satyam Sharma
2007-07-05 7:04 ` Joel Becker
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=20070707060114.GB1011@tasint.org \
--to=joel.becker@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=k-keiichi@bx.jp.nec.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mpm@selenic.com \
--cc=netdev@vger.kernel.org \
--cc=ssatyam@cse.iitk.ac.in \
/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;
as well as URLs for NNTP newsgroup(s).