* [PATCH 2/6] pgo: modules Add definitions in pgo/pgo.h for modules
@ 2021-05-28 20:04 Jarmo Tiitto
2021-05-31 18:39 ` Nathan Chancellor
0 siblings, 1 reply; 2+ messages in thread
From: Jarmo Tiitto @ 2021-05-28 20:04 UTC (permalink / raw)
To: samitolvanen; +Cc: wcw, nathan, ndesaulniers, linux-kernel, Jarmo Tiitto
Add new function and struct definitions to pgo/pgo.h
Few functions are shared by the new machinery so mark them as extern.
Signed-off-by: Jarmo Tiitto <jarmo.tiitto@gmail.com>
---
kernel/pgo/fs.c | 13 ++++++++-----
kernel/pgo/pgo.h | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 5 deletions(-)
diff --git a/kernel/pgo/fs.c b/kernel/pgo/fs.c
index 1678df3b7d64..575142735273 100644
--- a/kernel/pgo/fs.c
+++ b/kernel/pgo/fs.c
@@ -26,7 +26,7 @@
#include <linux/vmalloc.h>
#include "pgo.h"
-static struct dentry *directory;
+struct dentry *directory;
struct prf_private_data {
void *buffer;
@@ -82,7 +82,7 @@ static void prf_copy_to_buffer(void **buffer, void *src, unsigned long size)
*buffer += size;
}
-static u32 __prf_get_value_size(struct llvm_prf_data *p, u32 *value_kinds)
+u32 __prf_get_value_size(struct llvm_prf_data *p, u32 *value_kinds)
{
struct llvm_prf_value_node **nodes =
(struct llvm_prf_value_node **)p->values;
@@ -140,7 +140,7 @@ static u32 prf_get_value_size(void)
}
/* Serialize the profiling's value. */
-static void prf_serialize_value(struct llvm_prf_data *p, void **buffer)
+void prf_serialize_value(struct llvm_prf_data *p, void **buffer)
{
struct llvm_prf_value_data header;
struct llvm_prf_value_node **nodes =
@@ -254,7 +254,10 @@ static int prf_serialize(struct prf_private_data *p)
return err;
}
-/* open() implementation for PGO. Creates a copy of the profiling data set. */
+/*
+ * open() implementation for PGO.
+ * Creates a copy of the profiling data set.
+ */
static int prf_open(struct inode *inode, struct file *file)
{
struct prf_private_data *data;
@@ -292,7 +295,7 @@ static ssize_t prf_read(struct file *file, char __user *buf, size_t count,
BUG_ON(!data);
return simple_read_from_buffer(buf, count, ppos, data->buffer,
- data->size);
+ data->size);
}
/* release() implementation for PGO. Release resources allocated by open(). */
diff --git a/kernel/pgo/pgo.h b/kernel/pgo/pgo.h
index ddc8d3002fe5..a9ff51abbfd5 100644
--- a/kernel/pgo/pgo.h
+++ b/kernel/pgo/pgo.h
@@ -19,6 +19,11 @@
#ifndef _PGO_H
#define _PGO_H
+#include <linux/kernel.h>
+#include <linux/debugfs.h>
+#include <linux/fs.h>
+#include <linux/module.h>
+
/*
* Note: These internal LLVM definitions must match the compiler version.
* See llvm/include/llvm/ProfileData/InstrProfData.inc in LLVM's source code.
@@ -200,4 +205,38 @@ __DEFINE_PRF_SIZE(vnds);
#undef __DEFINE_PRF_SIZE
+/* debugfs directory */
+extern struct dentry *directory;
+
+struct prf_mod_private_data {
+ struct list_head link;
+ struct rcu_head rcu;
+
+ void *buffer;
+ unsigned long size;
+
+ char mod_name[MODULE_NAME_LEN];
+ struct module *mod;
+ struct dentry *file;
+
+ int current_node;
+};
+
+/* Mutex protecting the prf_mod_list and entries */
+extern struct mutex prf_mod_lock;
+
+/* List of modules profiled */
+extern struct list_head prf_mod_list;
+
+extern void prf_modules_init(void);
+extern void prf_modules_exit(void);
+
+/* Update each modules snapshot of the profiling data. */
+extern int prf_modules_snapshot(void);
+
+/* below funcs are required by prf_modules_snapshot() */
+extern u32 __prf_get_value_size(struct llvm_prf_data *p, u32 *value_kinds);
+
+extern void prf_serialize_value(struct llvm_prf_data *p, void **buffer);
+
#endif /* _PGO_H */
--
2.31.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 2/6] pgo: modules Add definitions in pgo/pgo.h for modules
2021-05-28 20:04 [PATCH 2/6] pgo: modules Add definitions in pgo/pgo.h for modules Jarmo Tiitto
@ 2021-05-31 18:39 ` Nathan Chancellor
0 siblings, 0 replies; 2+ messages in thread
From: Nathan Chancellor @ 2021-05-31 18:39 UTC (permalink / raw)
To: Jarmo Tiitto
Cc: samitolvanen, wcw, ndesaulniers, linux-kernel, clang-built-linux
On Fri, May 28, 2021 at 11:04:32PM +0300, Jarmo Tiitto wrote:
> Add new function and struct definitions to pgo/pgo.h
> Few functions are shared by the new machinery so mark them as extern.
This patch probably belongs in 3/6 since these changes are only needed
because of that and this patch is self contained to 'kernel/pgo'.
> Signed-off-by: Jarmo Tiitto <jarmo.tiitto@gmail.com>
> ---
> kernel/pgo/fs.c | 13 ++++++++-----
> kernel/pgo/pgo.h | 39 +++++++++++++++++++++++++++++++++++++++
> 2 files changed, 47 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/pgo/fs.c b/kernel/pgo/fs.c
> index 1678df3b7d64..575142735273 100644
> --- a/kernel/pgo/fs.c
> +++ b/kernel/pgo/fs.c
> @@ -26,7 +26,7 @@
> #include <linux/vmalloc.h>
> #include "pgo.h"
>
> -static struct dentry *directory;
> +struct dentry *directory;
>
> struct prf_private_data {
> void *buffer;
> @@ -82,7 +82,7 @@ static void prf_copy_to_buffer(void **buffer, void *src, unsigned long size)
> *buffer += size;
> }
>
> -static u32 __prf_get_value_size(struct llvm_prf_data *p, u32 *value_kinds)
> +u32 __prf_get_value_size(struct llvm_prf_data *p, u32 *value_kinds)
> {
> struct llvm_prf_value_node **nodes =
> (struct llvm_prf_value_node **)p->values;
> @@ -140,7 +140,7 @@ static u32 prf_get_value_size(void)
> }
>
> /* Serialize the profiling's value. */
> -static void prf_serialize_value(struct llvm_prf_data *p, void **buffer)
> +void prf_serialize_value(struct llvm_prf_data *p, void **buffer)
> {
> struct llvm_prf_value_data header;
> struct llvm_prf_value_node **nodes =
> @@ -254,7 +254,10 @@ static int prf_serialize(struct prf_private_data *p)
> return err;
> }
>
> -/* open() implementation for PGO. Creates a copy of the profiling data set. */
> +/*
> + * open() implementation for PGO.
> + * Creates a copy of the profiling data set.
> + */
> static int prf_open(struct inode *inode, struct file *file)
> {
> struct prf_private_data *data;
> @@ -292,7 +295,7 @@ static ssize_t prf_read(struct file *file, char __user *buf, size_t count,
> BUG_ON(!data);
>
> return simple_read_from_buffer(buf, count, ppos, data->buffer,
> - data->size);
> + data->size);
> }
>
> /* release() implementation for PGO. Release resources allocated by open(). */
> diff --git a/kernel/pgo/pgo.h b/kernel/pgo/pgo.h
> index ddc8d3002fe5..a9ff51abbfd5 100644
> --- a/kernel/pgo/pgo.h
> +++ b/kernel/pgo/pgo.h
> @@ -19,6 +19,11 @@
> #ifndef _PGO_H
> #define _PGO_H
>
> +#include <linux/kernel.h>
> +#include <linux/debugfs.h>
> +#include <linux/fs.h>
> +#include <linux/module.h>
> +
> /*
> * Note: These internal LLVM definitions must match the compiler version.
> * See llvm/include/llvm/ProfileData/InstrProfData.inc in LLVM's source code.
> @@ -200,4 +205,38 @@ __DEFINE_PRF_SIZE(vnds);
>
> #undef __DEFINE_PRF_SIZE
>
> +/* debugfs directory */
> +extern struct dentry *directory;
> +
> +struct prf_mod_private_data {
> + struct list_head link;
> + struct rcu_head rcu;
> +
> + void *buffer;
> + unsigned long size;
> +
> + char mod_name[MODULE_NAME_LEN];
> + struct module *mod;
> + struct dentry *file;
> +
> + int current_node;
> +};
> +
> +/* Mutex protecting the prf_mod_list and entries */
> +extern struct mutex prf_mod_lock;
> +
> +/* List of modules profiled */
> +extern struct list_head prf_mod_list;
> +
> +extern void prf_modules_init(void);
> +extern void prf_modules_exit(void);
> +
> +/* Update each modules snapshot of the profiling data. */
> +extern int prf_modules_snapshot(void);
> +
> +/* below funcs are required by prf_modules_snapshot() */
> +extern u32 __prf_get_value_size(struct llvm_prf_data *p, u32 *value_kinds);
> +
> +extern void prf_serialize_value(struct llvm_prf_data *p, void **buffer);
> +
> #endif /* _PGO_H */
> --
> 2.31.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-05-31 18:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-28 20:04 [PATCH 2/6] pgo: modules Add definitions in pgo/pgo.h for modules Jarmo Tiitto
2021-05-31 18:39 ` Nathan Chancellor
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.