mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jarmo Tiitto <jarmo.tiitto@gmail.com>
To: samitolvanen@google.com
Cc: wcw@google.com, nathan@kernel.org, ndesaulniers@google.com,
	linux-kernel@vger.kernel.org,
	Jarmo Tiitto <jarmo.tiitto@gmail.com>
Subject: [PATCH 2/6] pgo: modules Add definitions in pgo/pgo.h for modules
Date: Fri, 28 May 2021 23:04:32 +0300	[thread overview]
Message-ID: <20210528200432.459120-1-jarmo.tiitto@gmail.com> (raw)

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


             reply	other threads:[~2021-05-28 20:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-28 20:04 Jarmo Tiitto [this message]
2021-05-31 18:39 ` Nathan Chancellor

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=20210528200432.459120-1-jarmo.tiitto@gmail.com \
    --to=jarmo.tiitto@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=samitolvanen@google.com \
    --cc=wcw@google.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®