From: Eric Sandeen <sandeen@sandeen.net>
To: xfs@oss.sgi.com
Subject: Re: [PATCH 5/7] xfs: incorporate sysfs/kobject in xfsstats: handlers take kobjects.
Date: Mon, 28 Sep 2015 10:40:39 -0500 [thread overview]
Message-ID: <56095F77.7030403@sandeen.net> (raw)
In-Reply-To: <1443223380-18870-6-git-send-email-billodo@redhat.com>
On 9/25/15 6:22 PM, Bill O'Donnell wrote:
> This patch is the next step toward per-fs xfs stats. Allocate &
> deallocate per-fs stats structures and set up the sysfs entries for them.
>
> Instead of a single global xfsstats structure, add kobject and a pointer
> to a per-cpu struct xfsstats. Modify the macros that manipulate the stats
> accordingly: XFS_STATS_INC, XFS_STATS_DEC, and XFS_STATS_ADD now access
> xfsstats->xs_stats.
>
> The sysfs functions need to get from the kobject back to the xfsstats
> structure which contains it, and pass the pointer to the ->xs_stats
> percpu structure into the show & clear routines.
>
>
> Signed-off-by: Bill O'Donnell <billodo@redhat.com>
<snip>
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index 0dfc53b..23e5681 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -61,7 +61,6 @@ static kmem_zone_t *xfs_ioend_zone;
> mempool_t *xfs_ioend_pool;
>
> static struct kset *xfs_kset; /* top-level xfs sysfs dir */
> -static struct xfs_kobj xfs_stats_kobj; /* global stats sysfs attrs */
> #ifdef DEBUG
> static struct xfs_kobj xfs_dbg_kobj; /* global debug sysfs attrs */
> #endif
> @@ -1802,6 +1801,7 @@ xfs_destroy_workqueues(void)
> destroy_workqueue(xfs_alloc_wq);
> }
>
> +
> STATIC int __init
> init_xfs_fs(void)
> {
> @@ -1842,8 +1842,9 @@ init_xfs_fs(void)
> goto out_sysctl_unregister;
> }
>
> - xfs_stats_kobj.kobject.kset = xfs_kset;
> - error = xfs_sysfs_init(&xfs_stats_kobj, &xfs_stats_ktype, NULL,
> + xfsstats.xs_stats = alloc_percpu(struct xfsstats);
alloc_percpu can fail, so:
if (!xfsstats.xs_stats) {
error = -ENOMEM;
goto out_kset_unregister ...
}
> + xfsstats.xs_kobj.kobject.kset = xfs_kset;
> + error = xfs_sysfs_init(&xfsstats.xs_kobj, &xfs_stats_ktype, NULL,
> "stats");
> if (error)
> goto out_kset_unregister;
If this fails, you need to free the percpu allocation, so this would
be "goto out_free_stats" I think
> @@ -1852,7 +1853,7 @@ init_xfs_fs(void)
> xfs_dbg_kobj.kobject.kset = xfs_kset;
> error = xfs_sysfs_init(&xfs_dbg_kobj, &xfs_dbg_ktype, NULL, "debug");
> if (error)
> - goto out_remove_stats_kobj;
> + goto out_remove_stats;
And this remains as out_remove_stats_kobj, I think.
> #endif
>
> error = xfs_qm_init();
> @@ -1869,9 +1870,9 @@ init_xfs_fs(void)
> out_remove_dbg_kobj:
> #ifdef DEBUG
> xfs_sysfs_del(&xfs_dbg_kobj);
> - out_remove_stats_kobj:
> + out_remove_stats:
> #endif
> - xfs_sysfs_del(&xfs_stats_kobj);
> + free_percpu(xfsstats.xs_stats);
hm, now nothing deletes the stats kobject?
xfs_sysfs_del(&xfsstats.xs_kobj);
but there should be another goto target ...
there's one more thing to unwind (the percpu allocation) so you should
end up with more unwind goto target (i.e. out_free_stats), but you still
need the unwind target for the stats kobject sysfs deletion.
something like:
out_remove_dbg_kobj:
#ifdef DEBUG
xfs_sysfs_del(&xfs_dbg_kobj);
out_remove_stats_kobj:
#endif
xfs_sysfs_del(&xfs_stats_kobj);
out_free_stats:
free_percpu(xfsstats.xs_stats);
out_kset_unregister:
kset_unregister(xfs_kset);
out_sysctl_unregister:
but double-check me ;)
> out_kset_unregister:
> kset_unregister(xfs_kset);
> out_sysctl_unregister:
> @@ -1898,7 +1899,7 @@ exit_xfs_fs(void)
> #ifdef DEBUG
> xfs_sysfs_del(&xfs_dbg_kobj);
> #endif
> - xfs_sysfs_del(&xfs_stats_kobj);
> + free_percpu(xfsstats.xs_stats);
here as well, you still need to delete the stats kobject:
xfs_sysfs_del(&xfsstats.xs_kobj);
> kset_unregister(xfs_kset);
> xfs_sysctl_unregister();
> xfs_cleanup_procfs();
-Eric
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2015-09-28 15:40 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-25 23:22 [PATCH 0/7 v8] xfs: stats in sysfs Bill O'Donnell
2015-09-25 23:22 ` [PATCH 1/7] xfs: create global stats and stats_clear " Bill O'Donnell
2015-09-25 23:22 ` [PATCH 2/7] xfs: create symlink proc/fs/xfs/stat to sys/fs/xfs/stats Bill O'Donnell
2015-09-25 23:22 ` [PATCH 3/7] xfs: remove unused procfs code Bill O'Donnell
2015-09-25 23:22 ` [PATCH 4/7] xfs: consolidate sysfs ops (dbg, stats, log) Bill O'Donnell
2015-09-25 23:22 ` [PATCH 5/7] xfs: incorporate sysfs/kobject in xfsstats: handlers take kobjects Bill O'Donnell
2015-09-28 15:40 ` Eric Sandeen [this message]
2015-09-25 23:22 ` [PATCH 6/7] xfs: per-filesystem stats in sysfs Bill O'Donnell
2015-09-28 15:37 ` Eric Sandeen
2015-09-25 23:23 ` [PATCH 7/7] xfs: per-filesystem stats counter implementation Bill O'Donnell
2015-09-28 15:30 ` Eric Sandeen
2015-09-28 15:00 ` [PATCH 0/7 v8] xfs: stats in sysfs Eric Sandeen
2015-09-28 15:01 ` Eric Sandeen
2015-09-28 15:06 ` Bill O'Donnell
-- strict thread matches above, loose matches on Subject: below --
2015-09-28 21:33 [PATCH 0/7 v9] " Bill O'Donnell
2015-09-28 21:33 ` [PATCH 5/7] xfs: incorporate sysfs/kobject in xfsstats: handlers take kobjects Bill O'Donnell
2015-10-02 16:22 [PATCH 0/7 v10] xfs: per-fs stats in sysfs Bill O'Donnell
2015-10-02 16:22 ` [PATCH 5/7] xfs: incorporate sysfs/kobject in xfsstats: handlers take kobjects Bill O'Donnell
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=56095F77.7030403@sandeen.net \
--to=sandeen@sandeen.net \
--cc=xfs@oss.sgi.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