> For the complete documentation index, see [llms.txt](https://huataihuang.gitbook.io/cloud-atlas-draft/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://huataihuang.gitbook.io/cloud-atlas-draft/os/linux/kernel/module/kernel_module_parameters.md).

# 内核模块参数

## 使用脚本检查内核模块参数

内核模块参数位于 `/sys/module/<module_name>/parameters` 中，可以通过这个参数入口动态调整内核模块的特性。

如何打印出内核模块的参数值设置呢？参考

```bash
cat /proc/modules | cut -f 1 -d " " | while read module; do \
 echo "Module: $module"; \
 if [ -d "/sys/module/$module/parameters" ]; then \
  ls /sys/module/$module/parameters/ | while read parameter; do \
   echo -n "Parameter: $parameter --> "; \
   cat /sys/module/$module/parameters/$parameter; \
  done; \
 fi; \
 echo; \
done
```

上述脚本很好展示了内核模块参数当前值：

```
Module: tun

Module: ipt_MASQUERADE

Module: nf_nat_masquerade_ipv4
...
Module: nf_conntrack_ipv4
Parameter: hashsize --> 187500
...

Module: kvm_intel
Parameter: emulate_invalid_guest_state --> Y
Parameter: enable_apicv --> Y
Parameter: enable_shadow_vmcs --> Y
Parameter: ept --> Y
Parameter: eptad --> Y
Parameter: fasteoi --> Y
Parameter: flexpriority --> Y
Parameter: nested --> N
Parameter: ple_gap --> 128
Parameter: ple_window --> 4096
Parameter: ple_window_grow --> 2
Parameter: ple_window_max --> 1073741823
Parameter: ple_window_shrink --> 0
Parameter: pml --> Y
Parameter: unrestricted_guest --> Y
Parameter: vmm_exclusive --> Y
Parameter: vpid --> Y
```

## 使用`sysfsutils`软件包提供的工具`systool`

首先安装`sysfsutils`工具包

```
sudo yum install sysfsutils
```

然后执行`systool -vm <Module name>`来检查模块参数，例如检查`kvm_intel`模块

```bash
systool -vm kvm_intel
```

显示输出：

```bash
Module = "kvm_intel"

  Attributes:
    coresize            = "162153"
    initsize            = "0"
    initstate           = "live"
    refcnt              = "6"
    rhelversion         = "7.2"
    srcversion          = "A7365FEDDA6A1937D82B32F"
    taint               = ""
    uevent              = <store method only>

  Parameters:
    emulate_invalid_guest_state= "Y"
    enable_apicv        = "Y"
    enable_shadow_vmcs  = "Y"
    ept                 = "Y"
    eptad               = "Y"
    fasteoi             = "Y"
    flexpriority        = "Y"
    nested              = "N"
    ple_gap             = "128"
    ple_window_grow     = "2"
    ple_window_max      = "1073741823"
    ple_window_shrink   = "0"
    ple_window          = "4096"
    pml                 = "Y"
    unrestricted_guest  = "Y"
    vmm_exclusive       = "Y"
    vpid                = "Y"

  Sections:
    .bss                = "0xffffffffa041aa40"
    .data               = "0xffffffffa041a000"
    .data..read_mostly  = "0xffffffffa041a7e2"
    .data.unlikely      = "0xffffffffa041a7e0"
    .exit.text          = "0xffffffffa0408ca4"
    .fixup              = "0xffffffffa0406308"
    .gnu.linkonce.this_module= "0xffffffffa041a800"
    .init.text          = "0xffffffffa0255000"
    .note.gnu.build-id  = "0xffffffffa0409000"
    .parainstructions   = "0xffffffffa0417908"
    .rodata             = "0xffffffffa0409040"
    .rodata.str1.1      = "0xffffffffa0417ca4"
    .rodata.str1.8      = "0xffffffffa0417ee8"
    .smp_locks          = "0xffffffffa04188bc"
    .strtab             = "0xffffffffa02596a8"
    .symtab             = "0xffffffffa0256000"
    .text               = "0xffffffffa03f9000"
    .text.unlikely      = "0xffffffffa04081f5"
    __bug_table         = "0xffffffffa0418928"
    __ex_table          = "0xffffffffa0416fc0"
    __jump_table        = "0xffffffffa041a600"
    __mcount_loc        = "0xffffffffa0418b60"
    __param             = "0xffffffffa0418940"
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://huataihuang.gitbook.io/cloud-atlas-draft/os/linux/kernel/module/kernel_module_parameters.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
