Skip to content

Commit

Permalink
kernel/gcov: checkout to 4.19-q
Browse files Browse the repository at this point in the history
* Samsung got this from 4.19-stable, but for us it'll cause conflicts as we're merging 4.19-stable over 4.19-q. So reset it.

Signed-off-by: ExtremeXT <75576145+ExtremeXT@users.noreply.github.com>
  • Loading branch information
ExtremeXT committed Feb 16, 2025
1 parent e4ea375 commit 5e7ed9a
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 56 deletions.
17 changes: 5 additions & 12 deletions kernel/gcov/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,16 @@ config GCOV_PROFILE_ALL
choice
prompt "Specify GCOV format"
depends on GCOV_KERNEL
default GCOV_FORMAT_AUTODETECT
---help---
The gcov format is usually determined by the GCC version, but there are
The gcov format is usually determined by the GCC version, and the
default is chosen according to your GCC version. However, there are
exceptions where format changes are integrated in lower-version GCCs.
In such a case use this option to adjust the format used in the kernel
accordingly.

If unsure, choose "Autodetect".

config GCOV_FORMAT_AUTODETECT
bool "Autodetect"
---help---
Select this option to use the format that corresponds to your GCC
version.
In such a case, change this option to adjust the format used in the
kernel accordingly.

config GCOV_FORMAT_3_4
bool "GCC 3.4 format"
depends on CC_IS_GCC && GCC_VERSION < 40700
---help---
Select this option to use the format defined by GCC 3.4.

Expand Down
10 changes: 2 additions & 8 deletions kernel/gcov/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
ccflags-y := -DSRCTREE='"$(srctree)"' -DOBJTREE='"$(objtree)"'

ifeq ($(cc-name),clang)
obj-y := base.o fs.o clang.o
else
obj-y := base.o fs.o
obj-$(CONFIG_GCOV_FORMAT_3_4) += gcc_base.o gcc_3_4.o
obj-$(CONFIG_GCOV_FORMAT_4_7) += gcc_base.o gcc_4_7.o
obj-$(CONFIG_GCOV_FORMAT_AUTODETECT) += $(call cc-ifversion, -lt, 0407, \
gcc_base.o gcc_3_4.o, gcc_base.o gcc_4_7.o)
endif
obj-$(CONFIG_GCOV_FORMAT_3_4) += gcc_3_4.o
obj-$(CONFIG_GCOV_FORMAT_4_7) += gcc_4_7.o
86 changes: 83 additions & 3 deletions kernel/gcov/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,88 @@
#include <linux/sched.h>
#include "gcov.h"

int gcov_events_enabled;
DEFINE_MUTEX(gcov_lock);
static int gcov_events_enabled;
static DEFINE_MUTEX(gcov_lock);

/*
* __gcov_init is called by gcc-generated constructor code for each object
* file compiled with -fprofile-arcs.
*/
void __gcov_init(struct gcov_info *info)
{
static unsigned int gcov_version;

mutex_lock(&gcov_lock);
if (gcov_version == 0) {
gcov_version = gcov_info_version(info);
/*
* Printing gcc's version magic may prove useful for debugging
* incompatibility reports.
*/
pr_info("version magic: 0x%x\n", gcov_version);
}
/*
* Add new profiling data structure to list and inform event
* listener.
*/
gcov_info_link(info);
if (gcov_events_enabled)
gcov_event(GCOV_ADD, info);
mutex_unlock(&gcov_lock);
}
EXPORT_SYMBOL(__gcov_init);

/*
* These functions may be referenced by gcc-generated profiling code but serve
* no function for kernel profiling.
*/
void __gcov_flush(void)
{
/* Unused. */
}
EXPORT_SYMBOL(__gcov_flush);

void __gcov_merge_add(gcov_type *counters, unsigned int n_counters)
{
/* Unused. */
}
EXPORT_SYMBOL(__gcov_merge_add);

void __gcov_merge_single(gcov_type *counters, unsigned int n_counters)
{
/* Unused. */
}
EXPORT_SYMBOL(__gcov_merge_single);

void __gcov_merge_delta(gcov_type *counters, unsigned int n_counters)
{
/* Unused. */
}
EXPORT_SYMBOL(__gcov_merge_delta);

void __gcov_merge_ior(gcov_type *counters, unsigned int n_counters)
{
/* Unused. */
}
EXPORT_SYMBOL(__gcov_merge_ior);

void __gcov_merge_time_profile(gcov_type *counters, unsigned int n_counters)
{
/* Unused. */
}
EXPORT_SYMBOL(__gcov_merge_time_profile);

void __gcov_merge_icall_topn(gcov_type *counters, unsigned int n_counters)
{
/* Unused. */
}
EXPORT_SYMBOL(__gcov_merge_icall_topn);

void __gcov_exit(void)
{
/* Unused. */
}
EXPORT_SYMBOL(__gcov_exit);

/**
* gcov_enable_events - enable event reporting through gcov_event()
Expand Down Expand Up @@ -64,7 +144,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,

/* Remove entries located in module from linked list. */
while ((info = gcov_info_next(info))) {
if (gcov_info_within_module(info, mod)) {
if (within_module((unsigned long)info, mod)) {
gcov_info_unlink(prev, info);
if (gcov_events_enabled)
gcov_event(GCOV_REMOVE, info);
Expand Down
24 changes: 22 additions & 2 deletions kernel/gcov/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ struct gcov_node {
static const char objtree[] = OBJTREE;
static const char srctree[] = SRCTREE;
static struct gcov_node root_node;
static struct dentry *reset_dentry;
static LIST_HEAD(all_head);
static DEFINE_MUTEX(node_lock);

Expand Down Expand Up @@ -386,6 +387,8 @@ static void add_links(struct gcov_node *node, struct dentry *parent)
goto out_err;
node->links[i] = debugfs_create_symlink(deskew(basename),
parent, target);
if (!node->links[i])
goto out_err;
kfree(target);
}

Expand Down Expand Up @@ -447,6 +450,11 @@ static struct gcov_node *new_node(struct gcov_node *parent,
parent->dentry, node, &gcov_data_fops);
} else
node->dentry = debugfs_create_dir(node->name, parent->dentry);
if (!node->dentry) {
pr_warn("could not create file\n");
kfree(node);
return NULL;
}
if (info)
add_links(node, parent->dentry);
list_add(&node->list, &parent->children);
Expand Down Expand Up @@ -753,20 +761,32 @@ void gcov_event(enum gcov_action action, struct gcov_info *info)
/* Create debugfs entries. */
static __init int gcov_fs_init(void)
{
int rc = -EIO;

init_node(&root_node, NULL, NULL, NULL);
/*
* /sys/kernel/debug/gcov will be parent for the reset control file
* and all profiling files.
*/
root_node.dentry = debugfs_create_dir("gcov", NULL);
if (!root_node.dentry)
goto err_remove;
/*
* Create reset file which resets all profiling counts when written
* to.
*/
debugfs_create_file("reset", 0600, root_node.dentry, NULL,
&gcov_reset_fops);
reset_dentry = debugfs_create_file("reset", 0600, root_node.dentry,
NULL, &gcov_reset_fops);
if (!reset_dentry)
goto err_remove;
/* Replay previous events to get our fs hierarchy up-to-date. */
gcov_enable_events();
return 0;

err_remove:
pr_err("init failed\n");
debugfs_remove(root_node.dentry);

return rc;
}
device_initcall(gcov_fs_init);
18 changes: 4 additions & 14 deletions kernel/gcov/gcc_3_4.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,6 @@ void gcov_info_unlink(struct gcov_info *prev, struct gcov_info *info)
gcov_info_head = info->next;
}

/**
* gcov_info_within_module - check if a profiling data set belongs to a module
* @info: profiling data set
* @mod: module
*
* Returns true if profiling data belongs module, false otherwise.
*/
bool gcov_info_within_module(struct gcov_info *info, struct module *mod)
{
return within_module((unsigned long)info, mod);
}

/* Symbolic links to be created for each profiling data file. */
const struct gcov_link gcov_link[] = {
{ OBJ_TREE, "gcno" }, /* Link to .gcno file in $(objtree). */
Expand Down Expand Up @@ -257,7 +245,8 @@ struct gcov_info *gcov_info_dup(struct gcov_info *info)

/* Duplicate gcov_info. */
active = num_counter_active(info);
dup = kzalloc(struct_size(dup, counts, active), GFP_KERNEL);
dup = kzalloc(sizeof(struct gcov_info) +
sizeof(struct gcov_ctr_info) * active, GFP_KERNEL);
if (!dup)
return NULL;
dup->version = info->version;
Expand Down Expand Up @@ -375,7 +364,8 @@ struct gcov_iterator *gcov_iter_new(struct gcov_info *info)
{
struct gcov_iterator *iter;

iter = kzalloc(struct_size(iter, type_info, num_counter_active(info)),
iter = kzalloc(sizeof(struct gcov_iterator) +
num_counter_active(info) * sizeof(struct type_info),
GFP_KERNEL);
if (iter)
iter->info = info;
Expand Down
12 changes: 0 additions & 12 deletions kernel/gcov/gcc_4_7.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,6 @@ void gcov_info_unlink(struct gcov_info *prev, struct gcov_info *info)
gcov_info_head = info->next;
}

/**
* gcov_info_within_module - check if a profiling data set belongs to a module
* @info: profiling data set
* @mod: module
*
* Returns true if profiling data belongs module, false otherwise.
*/
bool gcov_info_within_module(struct gcov_info *info, struct module *mod)
{
return within_module((unsigned long)info, mod);
}

/* Symbolic links to be created for each profiling data file. */
const struct gcov_link gcov_link[] = {
{ OBJ_TREE, "gcno" }, /* Link to .gcno file in $(objtree). */
Expand Down
5 changes: 0 additions & 5 deletions kernel/gcov/gcov.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#ifndef GCOV_H
#define GCOV_H GCOV_H

#include <linux/module.h>
#include <linux/types.h>

/*
Expand Down Expand Up @@ -47,7 +46,6 @@ unsigned int gcov_info_version(struct gcov_info *info);
struct gcov_info *gcov_info_next(struct gcov_info *info);
void gcov_info_link(struct gcov_info *info);
void gcov_info_unlink(struct gcov_info *prev, struct gcov_info *info);
bool gcov_info_within_module(struct gcov_info *info, struct module *mod);

/* Base interface. */
enum gcov_action {
Expand Down Expand Up @@ -85,7 +83,4 @@ struct gcov_link {
};
extern const struct gcov_link gcov_link[];

extern int gcov_events_enabled;
extern struct mutex gcov_lock;

#endif /* GCOV_H */

0 comments on commit 5e7ed9a

Please sign in to comment.