[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YLUtUV3ZSIqPZbX+@Ryzen-9-3900X.localdomain>
Date: Mon, 31 May 2021 11:39:13 -0700
From: Nathan Chancellor <nathan@...nel.org>
To: Jarmo Tiitto <jarmo.tiitto@...il.com>
Cc: samitolvanen@...gle.com, wcw@...gle.com, ndesaulniers@...gle.com,
linux-kernel@...r.kernel.org, clang-built-linux@...glegroups.com
Subject: Re: [PATCH 2/6] pgo: modules Add definitions in pgo/pgo.h for modules
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@...il.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
Powered by blists - more mailing lists