git: 19d26be3f3b3 - stable/13 - loader: tslog: Add more log for module loading
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 27 Jan 2022 10:07:06 UTC
The branch stable/13 has been updated by manu:
URL: https://cgit.FreeBSD.org/src/commit/?id=19d26be3f3b3b52487c085f8f02927e8eef5c52b
commit 19d26be3f3b3b52487c085f8f02927e8eef5c52b
Author: Emmanuel Vadot <manu@FreeBSD.org>
AuthorDate: 2021-12-30 14:49:24 +0000
Commit: Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2022-01-27 10:06:43 +0000
loader: tslog: Add more log for module loading
This helps mesuring what's happening when we load the kernel/modules/mfsroot.
This also adds TSENTER2 which uses the third argument of TSRAW, same
as in the kernel.
MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D33699
(cherry picked from commit 01cad731921bb60b4f6e04c1cac987eea7af9d08)
---
stand/common/module.c | 22 ++++++++++++++++++++++
stand/libsa/stand.h | 1 +
2 files changed, 23 insertions(+)
diff --git a/stand/common/module.c b/stand/common/module.c
index f28771396af0..fdc65541b1a5 100644
--- a/stand/common/module.c
+++ b/stand/common/module.c
@@ -552,6 +552,7 @@ file_load(char *filename, vm_offset_t dest, struct preloaded_file **result)
int error;
int i;
+ TSENTER2(filename);
if (archsw.arch_loadaddr != NULL)
dest = archsw.arch_loadaddr(LOAD_RAW, filename, dest);
@@ -578,6 +579,7 @@ file_load(char *filename, vm_offset_t dest, struct preloaded_file **result)
break;
}
}
+ TSEXIT();
return (error);
}
@@ -739,9 +741,11 @@ file_loadraw(const char *fname, char *type, int insert)
int verror;
#endif
+ TSENTER2(fname);
/* We can't load first */
if ((file_findfile(NULL, NULL)) == NULL) {
command_errmsg = "can't load file before kernel";
+ TSEXIT();
return(NULL);
}
@@ -750,6 +754,7 @@ file_loadraw(const char *fname, char *type, int insert)
if (name == NULL) {
snprintf(command_errbuf, sizeof(command_errbuf),
"can't find '%s'", fname);
+ TSEXIT();
return(NULL);
}
@@ -757,6 +762,7 @@ file_loadraw(const char *fname, char *type, int insert)
snprintf(command_errbuf, sizeof(command_errbuf),
"can't open '%s': %s", name, strerror(errno));
free(name);
+ TSEXIT();
return(NULL);
}
@@ -768,6 +774,7 @@ file_loadraw(const char *fname, char *type, int insert)
free(name);
free(vctx);
close(fd);
+ TSEXIT();
return(NULL);
}
#else
@@ -777,6 +784,7 @@ file_loadraw(const char *fname, char *type, int insert)
name, ve_error_get());
free(name);
close(fd);
+ TSEXIT();
return(NULL);
}
#endif
@@ -801,6 +809,7 @@ file_loadraw(const char *fname, char *type, int insert)
#ifdef LOADER_VERIEXEC_VECTX
free(vctx);
#endif
+ TSEXIT();
return(NULL);
}
laddr += got;
@@ -813,6 +822,7 @@ file_loadraw(const char *fname, char *type, int insert)
free(name);
close(fd);
free(vctx);
+ TSEXIT();
return(NULL);
}
#endif
@@ -824,6 +834,7 @@ file_loadraw(const char *fname, char *type, int insert)
"no memory to load %s", name);
free(name);
close(fd);
+ TSEXIT();
return (NULL);
}
fp->f_name = name;
@@ -839,6 +850,7 @@ file_loadraw(const char *fname, char *type, int insert)
"no memory to load %s", name);
free(name);
close(fd);
+ TSEXIT();
return (NULL);
}
/* recognise space consumption */
@@ -848,6 +860,7 @@ file_loadraw(const char *fname, char *type, int insert)
if (insert != 0)
file_insert_tail(fp);
close(fd);
+ TSEXIT();
return(fp);
}
@@ -863,8 +876,10 @@ mod_load(char *modname, struct mod_depend *verinfo, int argc, char *argv[])
int err;
char *filename;
+ TSENTER2(modname);
if (file_havepath(modname)) {
printf("Warning: mod_load() called instead of mod_loadkld() for module '%s'\n", modname);
+ TSEXIT();
return (mod_loadkld(modname, argc, argv));
}
/* see if module is already loaded */
@@ -876,6 +891,7 @@ mod_load(char *modname, struct mod_depend *verinfo, int argc, char *argv[])
#endif
snprintf(command_errbuf, sizeof(command_errbuf),
"warning: module '%s' already loaded", mp->m_name);
+ TSEXIT();
return (0);
}
/* locate file with the module on the search path */
@@ -883,10 +899,12 @@ mod_load(char *modname, struct mod_depend *verinfo, int argc, char *argv[])
if (filename == NULL) {
snprintf(command_errbuf, sizeof(command_errbuf),
"can't find '%s'", modname);
+ TSEXIT();
return (ENOENT);
}
err = mod_loadkld(filename, argc, argv);
free(filename);
+ TSEXIT();
return (err);
}
@@ -902,6 +920,7 @@ mod_loadkld(const char *kldname, int argc, char *argv[])
char *filename;
vm_offset_t loadaddr_saved;
+ TSENTER2(kldname);
/*
* Get fully qualified KLD name
*/
@@ -909,6 +928,7 @@ mod_loadkld(const char *kldname, int argc, char *argv[])
if (filename == NULL) {
snprintf(command_errbuf, sizeof(command_errbuf),
"can't find '%s'", kldname);
+ TSEXIT();
return (ENOENT);
}
/*
@@ -919,6 +939,7 @@ mod_loadkld(const char *kldname, int argc, char *argv[])
snprintf(command_errbuf, sizeof(command_errbuf),
"warning: KLD '%s' already loaded", filename);
free(filename);
+ TSEXIT();
return (0);
}
@@ -945,6 +966,7 @@ mod_loadkld(const char *kldname, int argc, char *argv[])
if (err)
file_discard(fp);
free(filename);
+ TSEXIT();
return (err);
}
diff --git a/stand/libsa/stand.h b/stand/libsa/stand.h
index 172b54c33b30..99b55e2282e4 100644
--- a/stand/libsa/stand.h
+++ b/stand/libsa/stand.h
@@ -486,6 +486,7 @@ void hexdump(caddr_t region, size_t len);
/* tslog.c */
#define TSRAW(a, b, c) tslog(a, b, c)
#define TSENTER() TSRAW("ENTER", __func__, NULL)
+#define TSENTER2(x) TSRAW("ENTER", __func__, x)
#define TSEXIT() TSRAW("EXIT", __func__, NULL)
#define TSLINE() TSRAW("EVENT", __FILE__, __XSTRING(__LINE__))
void tslog(const char *, const char *, const char *);