From: Hui Zhu <zhuhui@xiaomi.com>
To: <linux-kernel@vger.kernel.org>
Cc: <teawater@gmail.com>, Hui Zhu <zhuhui@xiaomi.com>
Subject: [RFC 3/4] module: add /proc/modules_update_version
Date: Fri, 13 Oct 2017 16:56:04 +0800 [thread overview]
Message-ID: <1507884965-31476-4-git-send-email-zhuhui@xiaomi.com> (raw)
In-Reply-To: <1507884965-31476-1-git-send-email-zhuhui@xiaomi.com>
With "BloodTest: perf", we can get the address of kernel from "cpu0/page"
without symbol.
The application that call BloodTest need translate the address to symbol
with itself. For normal address, just vmlinux is OK to get the right
symbol. But for the address of kernel module, it also need the address
of modules from /proc/modules.
Add /proc/modules_update_version will help the application to get if the
kernel modules address is changed or not.
Signed-off-by: Hui Zhu <zhuhui@xiaomi.com>
---
kernel/module.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/kernel/module.c b/kernel/module.c
index de66ec8..ed6f370 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -317,6 +317,8 @@ struct load_info {
} index;
};
+static atomic_t modules_update_version = ATOMIC_INIT(0);
+
/*
* We require a truly strong try_module_get(): 0 means success.
* Otherwise an error is returned due to ongoing or failed
@@ -1020,6 +1022,9 @@ int module_refcount(struct module *mod)
strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module));
free_module(mod);
+
+ atomic_inc(&modules_update_version);
+
return 0;
out:
mutex_unlock(&module_mutex);
@@ -3183,6 +3188,8 @@ static int move_module(struct module *mod, struct load_info *info)
(long)shdr->sh_addr, info->secstrings + shdr->sh_name);
}
+ atomic_inc(&modules_update_version);
+
return 0;
}
@@ -4196,9 +4203,21 @@ static int modules_open(struct inode *inode, struct file *file)
.release = seq_release,
};
+static int modules_update_version_get(void *data, u64 *val)
+{
+ *val = (u64)atomic_read(&modules_update_version);
+
+ return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(proc_modules_update_version_operations,
+ modules_update_version_get, NULL, "%llu\n");
+
static int __init proc_modules_init(void)
{
proc_create("modules", 0, NULL, &proc_modules_operations);
+ proc_create("modules_update_version", 0, NULL,
+ &proc_modules_update_version_operations);
return 0;
}
module_init(proc_modules_init);
--
1.9.1
next prev parent reply other threads:[~2017-10-13 8:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-13 8:56 [RFC 0/4] BloodTest: kernel status Hui Zhu
2017-10-13 8:56 ` [RFC 1/4] " Hui Zhu
2017-10-13 8:56 ` [RFC 2/4] BloodTest: perf Hui Zhu
2017-10-13 8:56 ` Hui Zhu [this message]
2017-10-13 8:56 ` [RFC 4/4] BloodTest: task Hui Zhu
2017-10-23 9:30 ` [RFC 0/4] BloodTest: kernel status Pavel Machek
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=1507884965-31476-4-git-send-email-zhuhui@xiaomi.com \
--to=zhuhui@xiaomi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=teawater@gmail.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®