Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
make strategy evaluation return "long double"
this allows us to compute more complex strategy evaluations
  • Loading branch information
alan-maguire committed Aug 22, 2023
commit ce23d20dc282b6d496ccde07d29fcc95de8f6fbd
2 changes: 1 addition & 1 deletion include/bpftune/bpftune.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ struct bpftuner_strategy {
const char *name;
const char *description;
/* return a number to compare with other strategies */
int (*evaluate)(struct bpftuner *tuner, struct bpftuner_strategy *strategy);
long double (*evaluate)(struct bpftuner *tuner, struct bpftuner_strategy *strategy);
unsigned long timeout; /* time in seconds until evaluation */
const char **bpf_progs; /* programs to load in BPF skeleton for this
* strategy; if NULL, all */
Expand Down
2 changes: 1 addition & 1 deletion src/libbpftune.c
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,7 @@ int bpftune_module_unload(const char *name)
static void bpftuner_strategy_update(struct bpftuner *tuner)
{
struct bpftuner_strategy *strategy, *max_strategy = NULL;
int curr, max = 0;
long double curr, max = 0;

if (!tuner->strategies)
return;
Expand Down
12 changes: 6 additions & 6 deletions test/strategy/strategy_tuner.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
#include "strategy_tuner.skel.legacy.h"
#include "strategy_tuner.skel.nobtf.h"

static int evaluate_A(struct bpftuner *tuner, struct bpftuner_strategy *strategy)
static long double evaluate_A(struct bpftuner *tuner, struct bpftuner_strategy *strategy)
{
if (tuner->strategy == strategy)
return 0;
return (long double)0;
else
return 1;
return (long double)1;
}

const char *progs_A[] = { "entry__proc_dostring_coredump", NULL };
Expand All @@ -41,12 +41,12 @@ struct bpftuner_strategy strategy_A = {
.bpf_progs = progs_A,
};

static int evaluate_B(struct bpftuner *tuner, struct bpftuner_strategy *strategy)
static long double evaluate_B(struct bpftuner *tuner, struct bpftuner_strategy *strategy)
{
if (tuner->strategy == strategy)
return 0;
return (long double)0;
else
return 1;
return (long double)1;
}

const char *progs_B[] = { "entry__proc_dostring", NULL };
Expand Down