Skip to content

Commit

Permalink
lisa._kmod: Make use of kmod VFS to configure features
Browse files Browse the repository at this point in the history
A previous patch adds support for a virtual file system (VFS)
for the lisa module. This VFS allows to configure the module
features at runtime.
Make use of this VFS to configure the desired features. Features
that have parameters can be configured from a notebook with:
"""
features = {
  "lisa__perf_counter": {
    "generic_counters":
      ["cpu_cycles", "l1d_cache", "inst_retired"]
  }
}
ftrace_coll = FtraceCollector(target, ..., kmod_features=features)
"""

Original-author: Beata Michalska <[email protected]>
Signed-off-by: Pierre Gondois <[email protected]>
  • Loading branch information
pierregondois committed Jan 25, 2024
1 parent aeef76d commit 9ee25da
Show file tree
Hide file tree
Showing 8 changed files with 243 additions and 83 deletions.
11 changes: 4 additions & 7 deletions lisa/_assets/kmodules/lisa/configs.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
#include "configs.h"
#include "feature_params.h"

/* List of configs. */
HLIST_HEAD(cfg_list);

void lisa_fs_remove(struct dentry *dentry);

struct lisa_cfg *allocate_lisa_cfg(const char *name)
Expand All @@ -29,12 +26,11 @@ struct lisa_cfg *allocate_lisa_cfg(const char *name)
return NULL;
}

int init_lisa_cfg(struct lisa_cfg *cfg, struct hlist_head *cfg_list,
void init_lisa_cfg(struct lisa_cfg *cfg, struct hlist_head *cfg_list,
struct dentry *dentry)
{
cfg->dentry = dentry;
hlist_add_head(&cfg->node, cfg_list);
return 0;
}

void free_lisa_cfg(struct lisa_cfg *cfg)
Expand All @@ -61,10 +57,11 @@ void drain_lisa_cfg(struct hlist_head *head)
free_lisa_cfg(cfg);
}

struct lisa_cfg *find_lisa_cfg(const char *name)
struct lisa_cfg *find_lisa_cfg(struct hlist_head *cfg_list, const char *name)
{
struct lisa_cfg *cfg;
hlist_for_each_entry(cfg, &cfg_list, node) {

hlist_for_each_entry(cfg, cfg_list, node) {
if (!strcmp(cfg->name, name))
return cfg;
}
Expand Down
6 changes: 2 additions & 4 deletions lisa/_assets/kmodules/lisa/configs.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ struct lisa_cfg {
char *name;
};

extern struct hlist_head cfg_list;

struct lisa_cfg *allocate_lisa_cfg(const char *name);
int init_lisa_cfg(struct lisa_cfg *cfg, struct hlist_head *cfg_list,
void init_lisa_cfg(struct lisa_cfg *cfg, struct hlist_head *cfg_list,
struct dentry *dentry);
void free_lisa_cfg(struct lisa_cfg *cfg);
void drain_lisa_cfg(struct hlist_head *head);
struct lisa_cfg *find_lisa_cfg(const char *name);
struct lisa_cfg *find_lisa_cfg(struct hlist_head *cfg_list, const char *name);
int activate_lisa_cfg(struct lisa_cfg *cfg, bool value);

#endif // _CONFIGS_H
13 changes: 13 additions & 0 deletions lisa/_assets/kmodules/lisa/feature_params.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ void init_feature_param_entry_value_global(struct feature_param_entry_value *val
void free_feature_param_entry_value(struct feature_param_entry_value *val)
{
list_del(&val->node);
val->entry->param->ops->free_value(val);
kfree(val);
}

Expand Down Expand Up @@ -340,6 +341,11 @@ feature_param_set_uint(const char *buf, struct feature_param_entry *entry)
return val;
}

static void feature_param_free_value_uint(struct feature_param_entry_value *val)
{
return;
}

static size_t
feature_param_stringify_uint(const struct feature_param_entry_value *val,
char *buffer)
Expand Down Expand Up @@ -388,6 +394,11 @@ feature_param_set_string(const char *buf, struct feature_param_entry *entry)
return val;
}

static void feature_param_free_value_string(struct feature_param_entry_value *val)
{
kfree(val->data);
}

static size_t
feature_param_stringify_string(const struct feature_param_entry_value *val,
char *buf)
Expand Down Expand Up @@ -415,13 +426,15 @@ feature_param_copy_string(const struct feature_param_entry_value *src_val,

const struct feature_param_ops feature_param_ops_uint = {
.set = feature_param_set_uint,
.free_value = feature_param_free_value_uint,
.stringify = feature_param_stringify_uint,
.is_equal = feature_param_is_equal_uint,
.copy = feature_param_copy_uint,
};

const struct feature_param_ops feature_param_ops_string = {
.set = feature_param_set_string,
.free_value = feature_param_free_value_string,
.stringify = feature_param_stringify_string,
.is_equal = feature_param_is_equal_string,
.copy = feature_param_copy_string,
Expand Down
1 change: 1 addition & 0 deletions lisa/_assets/kmodules/lisa/feature_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ struct feature_param {

struct feature_param_ops {
struct feature_param_entry_value *(*set) (const char *, struct feature_param_entry *);
void (*free_value) (struct feature_param_entry_value *);
size_t (*stringify) (const struct feature_param_entry_value *, char *);
int (*is_equal) (const void *, const struct feature_param_entry_value *);
int (*copy) (const struct feature_param_entry_value *, struct feature_param_entry_value *);
Expand Down
Loading

0 comments on commit 9ee25da

Please sign in to comment.