From: Zou Cao <zoucao@linux.alibaba.com>
To: viro@zeniv.linux.org.uk
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH 2/2] fs:regfs: add panic notifier callback for saving regs
Date: Tue, 20 Oct 2020 14:30:08 +0800 [thread overview]
Message-ID: <1603175408-96164-2-git-send-email-zoucao@linux.alibaba.com> (raw)
In-Reply-To: <1603175408-96164-1-git-send-email-zoucao@linux.alibaba.com>
register panic notifier callback for saveing regs, add a module
param regfs_panic to enable the show reg info when panic.
Signed-off-by: Zou Cao <zoucao@linux.alibaba.com>
---
fs/regfs/inode.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/fs/regfs/inode.c b/fs/regfs/inode.c
index 1643fcd..6c79f73 100644
--- a/fs/regfs/inode.c
+++ b/fs/regfs/inode.c
@@ -46,10 +46,41 @@
static LIST_HEAD(regfs_head);
static const struct inode_operations regfs_dir_inode_operations;
-int regfs_debug;
+int regfs_debug = 1;
module_param(regfs_debug, int, S_IRUGO);
MODULE_PARM_DESC(regfs_debug, "enable regfs debug mode");
+static int regfs_panic = 1;
+module_param(regfs_panic, int, S_IRUGO);
+MODULE_PARM_DESC(regfs_debug, "printk the register when panic");
+
+//save all register val when panic
+static int regfs_panic_event(struct notifier_block *self,
+ unsigned long val, void *data)
+{
+ struct regfs_fs_info *fsi;
+ struct inode *inode, *next;
+
+
+ list_for_each_entry(fsi, ®fs_head, regfs_head) {
+ list_for_each_entry_safe(inode, next, &fsi->sb->s_inodes, i_sb_list) {
+ struct regfs_inode_info *info = REGFS_I(inode);;
+ //save the regs val
+ if (info->type == RES_TYPE_ITEM) {
+ info->val = readl_relaxed(info->base + info->offset);
+ if (regfs_panic)
+ printk("%llx:%llx\n", (u64)(info->base + info->offset), info->val);
+ }
+ }
+ }
+
+ return NOTIFY_DONE;
+}
+
+static struct notifier_block regfs_panic_event_nb = {
+ .notifier_call = regfs_panic_event,
+};
+
struct inode *regfs_get_inode(struct super_block *sb, const struct inode *dir, umode_t mode, dev_t dev)
{
struct inode *inode = new_inode(sb);
@@ -328,6 +359,7 @@ static void init_once(void *foo)
static int __init init_regfs_fs(void)
{
+ int ret;
regfs_inode_cachep = kmem_cache_create_usercopy("regfs_inode_cache",
sizeof(struct regfs_inode_info), 0,
@@ -337,11 +369,16 @@ static int __init init_regfs_fs(void)
if (!regfs_inode_cachep)
return -ENOMEM;
+ ret = atomic_notifier_chain_register(&panic_notifier_list, ®fs_panic_event_nb);
+ if (ret)
+ pr_warn("regfs regiter panic notifier failed\n");
+
return register_filesystem(®fs_fs_type);
}
static void __exit exit_regfs_fs(void)
{
+ atomic_notifier_chain_unregister(&panic_notifier_list, ®fs_panic_event_nb);
unregister_filesystem(®fs_fs_type);
rcu_barrier();
kmem_cache_destroy(regfs_inode_cachep);
--
1.8.3.1
next prev parent reply other threads:[~2020-10-20 6:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-20 6:30 [PATCH 1/2] fs:regfs: add register easy filesystem Zou Cao
2020-10-20 6:30 ` Zou Cao [this message]
2020-10-23 2:57 ` zc
2020-10-27 9:16 ` zc
[not found] ` <fe9f0382-da87-77ab-75ab-5a4bec0a9a21@linux.alibaba.com>
2020-10-29 2:44 ` Al Viro
2020-10-29 7:55 ` zc
2020-10-29 2:42 ` Al Viro
2020-10-29 8:14 ` zc
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=1603175408-96164-2-git-send-email-zoucao@linux.alibaba.com \
--to=zoucao@linux.alibaba.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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).