Skip to content

Commit

Permalink
Don't build kernel modules by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Bechberger committed Aug 17, 2020
1 parent f49b96c commit 743a6ee
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
4 changes: 2 additions & 2 deletions doc/temci_exec.rst
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ Requires root privileges.
disable_cpu_caches
~~~~~~~~~~~~~~~~~~
Disables the L1 and L2 caches on x86 and x86-64 architectures.
It uses a small custom kernel module (be sure to compile it via ``temci setup`` after install the appropriate
It uses a small custom kernel module (be sure to compile it via ``temci setup --build_kernel_modules`` after install the appropriate
``kernel-devel`` package, see `Installation <installation.html>`_).
*Attention*: It will slow down your system by orders of magnitude, giving you essentially a Pentium I like processor.
Expand Down Expand Up @@ -863,7 +863,7 @@ flush_cpu_caches
Write back and flush Internal caches; initiate writing-back and flushing of external caches
(see `WBINVD <https://www.felixcloutier.com/x86/wbinvd>`_).
It uses a small custom kernel module (be sure to compile it via ``temci setup`` after install the appropriate
It uses a small custom kernel module (be sure to compile it via ``temci setup --build_kernel_modules`` after install the appropriate
``kernel-devel`` package, see `Installation <installation.html>`_).
nice
Expand Down
2 changes: 1 addition & 1 deletion temci/run/run_driver_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ def teardown(self):
class DisableCPUCaches(AbstractRunDriverPlugin):
"""
Disable the L1 and L2 caches on x86 and x86-64 architectures.
Uses a small custom kernel module (be sure to compile it via 'temci setup').
Uses a small custom kernel module (be sure to compile it via 'temci setup --build_kernel_modules').
:warning: slows program down significantly and has probably other weird consequences
:warning: this is untested
Expand Down
17 changes: 11 additions & 6 deletions temci/scripts/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ def cli():
run_options["common"])
}
},
"clean": CmdOptionList()
"clean": CmdOptionList(),
"setup": CmdOptionList(CmdOption("build_kernel_modules", type_scheme=Bool() // Default(False)
// Description("Build the rusage helper program and the "
"kernel modules used for disabling "
"the CPU caches (with the --build_kernel_modules option)")))
}
misc_commands_description = {
"completion": {
Expand Down Expand Up @@ -961,14 +965,15 @@ def cli_with_error_catching():


@cli.command(short_help=command_docs["setup"])
def setup():
temci__setup()
@cmd_option(misc_commands["setup"])
def setup(**kwargs):
temci__setup(**kwargs)


@document_func(command_docs["setup"])
def temci__setup():
@document_func(command_docs["setup"], misc_commands["setup"])
def temci__setup(build_kernel_modules: bool):
from temci.setup.setup import make_scripts
make_scripts()
make_scripts(build_kernel_modules)


if sphinx_doc():
Expand Down
6 changes: 5 additions & 1 deletion temci/setup/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,19 @@ def exec(dir: str, cmd: str):
raise ExecError(cmd, str(out), str(err))


def make_scripts():
def make_scripts(build_kernel_modules: bool = False):
"""
Builds the C and C++ code inside the scripts directory.
:param build_kernel_modules: build the kernel modules for disabling the CPU caches too
"""
try:
exec("rusage", "make")
except ExecError as err:
logging.error(err)
exit(1)
if not build_kernel_modules:
return
try:
exec("cpu_cache/disable", "make")
exec("cpu_cache/flush", "make")
Expand Down
2 changes: 1 addition & 1 deletion temci/utils/click_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def callback(context: Context, param: click.Option, val):
self.completion_hints = self.type_scheme.completion_hints
self.is_flag = is_flag is True or (is_flag is None and type(self.type_scheme) in [Bool, BoolOrNone]) # type: bool
""" Is this option flag like? """
if self.is_flag:
if self.is_flag and settings_key is not None:
self.completion_hints = None
self.short = None

Expand Down

0 comments on commit 743a6ee

Please sign in to comment.