diff --git a/agent/src/config/config.rs b/agent/src/config/config.rs
index c7b5d9fcc49..809378b196b 100644
--- a/agent/src/config/config.rs
+++ b/agent/src/config/config.rs
@@ -1214,6 +1214,7 @@ pub struct EbpfProfileLanguages {
pub python_disabled: bool,
pub php_disabled: bool,
pub nodejs_disabled: bool,
+ pub lua_disabled: bool,
}
impl Default for EbpfProfileLanguages {
@@ -1222,6 +1223,7 @@ impl Default for EbpfProfileLanguages {
python_disabled: false,
php_disabled: false,
nodejs_disabled: false,
+ lua_disabled: false,
}
}
}
diff --git a/agent/src/ebpf/mod.rs b/agent/src/ebpf/mod.rs
index aa0b078bb95..53285e1e003 100644
--- a/agent/src/ebpf/mod.rs
+++ b/agent/src/ebpf/mod.rs
@@ -132,6 +132,8 @@ pub const FEATURE_PROFILE_PYTHON: c_int = 9;
pub const FEATURE_PROFILE_PHP: c_int = 10;
#[allow(dead_code)]
pub const FEATURE_PROFILE_V8: c_int = 11;
+#[allow(dead_code)]
+pub const FEATURE_PROFILE_LUA: c_int = 12;
//追踪器当前状态
#[allow(dead_code)]
diff --git a/agent/src/ebpf/user/config.h b/agent/src/ebpf/user/config.h
index 5d3207a493b..baff309fbfe 100644
--- a/agent/src/ebpf/user/config.h
+++ b/agent/src/ebpf/user/config.h
@@ -89,7 +89,7 @@
#define PROG_ONCPU_OUTPUT_FOR_PE "df_PE_oncpu_output"
// lua related maps
-#define MAP_LUA_LANG_FLAGS_NAME "__lang_flags_map"
+#define MAP_LUA_LANG_FLAGS_NAME "__lua_lang_flags_map"
#define MAP_LUA_UNWIND_INFO_NAME "__lua_unwind_info_map"
#define MAP_LUA_OFFSETS_NAME "__lua_offsets_map"
#define MAP_LUAJIT_OFFSETS_NAME "__luajit_offsets_map"
@@ -181,6 +181,7 @@ enum cfg_feature_idx {
FEATURE_PROFILE_PYTHON,
FEATURE_PROFILE_PHP,
FEATURE_PROFILE_V8,
+ FEATURE_PROFILE_LUA,
FEATURE_CPU_BALANCER,
FEATURE_MAX,
};
@@ -196,6 +197,7 @@ enum cfg_feature_idx {
#define FEATURE_FLAG_PROFILE_PYTHON (1 << FEATURE_PROFILE_PYTHON)
#define FEATURE_FLAG_PROFILE_PHP (1 << FEATURE_PROFILE_PHP)
#define FEATURE_FLAG_PROFILE_V8 (1 << FEATURE_PROFILE_V8)
+#define FEATURE_FLAG_PROFILE_LUA (1 << FEATURE_PROFILE_LUA)
#define FEATURE_FLAG_CPU_BALANCER (1 << FEATURE_CPU_BALANCER)
#define FEATURE_FLAG_PROFILE (FEATURE_FLAG_PROFILE_ONCPU | FEATURE_FLAG_PROFILE_OFFCPU | FEATURE_FLAG_PROFILE_MEMORY)
diff --git a/agent/src/ebpf/user/load.c b/agent/src/ebpf/user/load.c
index 2600b209b54..05bcf36889f 100644
--- a/agent/src/ebpf/user/load.c
+++ b/agent/src/ebpf/user/load.c
@@ -1338,6 +1338,9 @@ int ebpf_obj_load(struct ebpf_object *obj)
if (!python_profiler_enabled()) {
enabled_feats &= ~FEATURE_FLAG_PROFILE_PYTHON;
}
+ if (!lua_profiler_enabled()) {
+ enabled_feats &= ~FEATURE_FLAG_PROFILE_LUA;
+ }
enabled_feats &= ~extended_feature_flags(map);
if (enabled_feats == 0 &&
map->def.type != BPF_MAP_TYPE_PROG_ARRAY &&
@@ -1359,7 +1362,8 @@ int ebpf_obj_load(struct ebpf_object *obj)
}
// Log language profiler map creation with max_entries for verification
if (strstr(map->name, "php_") || strstr(map->name, "v8_") ||
- strstr(map->name, "python_")) {
+ strstr(map->name, "python_") || strstr(map->name, "lua_") ||
+ strstr(map->name, "luajit_")) {
ebpf_info
("Language profiler map created: name=%s, max_entries=%d (1 means disabled)\n",
map->name, map->def.max_entries);
diff --git a/agent/src/ebpf/user/tracer.c b/agent/src/ebpf/user/tracer.c
index 2781d84848b..a949cfdfe9c 100644
--- a/agent/src/ebpf/user/tracer.c
+++ b/agent/src/ebpf/user/tracer.c
@@ -2055,6 +2055,11 @@ bool python_profiler_enabled(void)
return is_feature_regex_set(FEATURE_PROFILE_PYTHON);
}
+bool lua_profiler_enabled(void)
+{
+ return is_feature_regex_set(FEATURE_PROFILE_LUA);
+}
+
static void init_thread_ids(void)
{
thread_ids.entries = NULL;
diff --git a/agent/src/ebpf/user/tracer.h b/agent/src/ebpf/user/tracer.h
index 8126afc9e0f..056d1173bdc 100644
--- a/agent/src/ebpf/user/tracer.h
+++ b/agent/src/ebpf/user/tracer.h
@@ -629,6 +629,7 @@ bool is_feature_regex_set(int feature);
bool php_profiler_enabled(void);
bool v8_profiler_enabled(void);
bool python_profiler_enabled(void);
+bool lua_profiler_enabled(void);
int bpf_tracer_init(const char *log_file, bool is_stdout);
int set_kick_kern_nice(int32_t nice);
int tracer_bpf_load(struct bpf_tracer *tracer);
diff --git a/agent/src/ebpf_dispatcher.rs b/agent/src/ebpf_dispatcher.rs
index 8487256e1dd..87553e49da2 100644
--- a/agent/src/ebpf_dispatcher.rs
+++ b/agent/src/ebpf_dispatcher.rs
@@ -1143,6 +1143,12 @@ impl EbpfCollector {
CString::new(".*").unwrap().as_c_str().as_ptr(),
);
}
+ if !languages.lua_disabled {
+ ebpf::set_feature_regex(
+ ebpf::FEATURE_PROFILE_LUA,
+ CString::new(".*").unwrap().as_c_str().as_ptr(),
+ );
+ }
#[cfg(feature = "extended_observability")]
{
diff --git a/server/agent_config/README-CH.md b/server/agent_config/README-CH.md
index d1bad450428..a2ce293664c 100644
--- a/server/agent_config/README-CH.md
+++ b/server/agent_config/README-CH.md
@@ -5172,6 +5172,35 @@ inputs:
禁用 Node.js(V8)解释器剖析。禁用后将不采集 Node.js 进程的函数调用栈,
可节省约 6.4 MB 内核内存(v8_unwind_info_map)。
+##### 禁用 Lua 剖析 {#inputs.ebpf.profile.languages.lua_disabled}
+
+**标签**:
+
+agent_restart
+
+**FQCN**:
+
+`inputs.ebpf.profile.languages.lua_disabled`
+
+**默认值**:
+```yaml
+inputs:
+ ebpf:
+ profile:
+ languages:
+ lua_disabled: false
+```
+
+**模式**:
+| Key | Value |
+| ---- | ---------------------------- |
+| Type | bool |
+
+**详细描述**:
+
+禁用 Lua 解释器剖析。禁用后将不采集 Lua 进程的函数调用栈,
+可节省约 13 MB 内核内存(lua_tstate_map、lua_lang_flags_map、lua_unwind_info_map、lua_offsets_map、luajit_offsets_map)。
+
### 网络 {#inputs.ebpf.network}
#### NIC optimization Enabled {#inputs.ebpf.network.nic_opt_enabled}
diff --git a/server/agent_config/README.md b/server/agent_config/README.md
index b44bdf0d0f9..22c0cb784bf 100644
--- a/server/agent_config/README.md
+++ b/server/agent_config/README.md
@@ -5312,6 +5312,35 @@ inputs:
Disable Node.js (V8) interpreter profiling. When disabled, Node.js process stack traces will not be collected,
saving approximately 6.4 MB of kernel memory (v8_unwind_info_map).
+##### Lua profiling disabled {#inputs.ebpf.profile.languages.lua_disabled}
+
+**Tags**:
+
+agent_restart
+
+**FQCN**:
+
+`inputs.ebpf.profile.languages.lua_disabled`
+
+**Default value**:
+```yaml
+inputs:
+ ebpf:
+ profile:
+ languages:
+ lua_disabled: false
+```
+
+**Schema**:
+| Key | Value |
+| ---- | ---------------------------- |
+| Type | bool |
+
+**Description**:
+
+Disable Lua interpreter profiling. When disabled, Lua process stack traces will not be collected,
+saving approximately 13 MB of kernel memory (lua_tstate_map, lua_lang_flags_map, lua_unwind_info_map, lua_offsets_map, luajit_offsets_map).
+
### Network {#inputs.ebpf.network}
#### NIC optimization Enabled {#inputs.ebpf.network.nic_opt_enabled}
diff --git a/server/agent_config/template.yaml b/server/agent_config/template.yaml
index 0e707557e9e..9bef7769b9e 100644
--- a/server/agent_config/template.yaml
+++ b/server/agent_config/template.yaml
@@ -3874,6 +3874,32 @@ inputs:
# 禁用 Node.js(V8)解释器剖析。禁用后将不采集 Node.js 进程的函数调用栈,
# 可节省约 6.4 MB 内核内存(v8_unwind_info_map)。
nodejs_disabled: false
+ # type: bool
+ # name:
+ # en: Lua profiling disabled
+ # ch: 禁用 Lua 剖析
+ # unit:
+ # range: []
+ # enum_options: []
+ # modification: agent_restart
+ # ee_feature: false
+ # description:
+ # en: |-
+ # Disable Lua interpreter profiling. When disabled, Lua process stack traces will not be collected,
+ # saving approximately 13 MB of kernel memory.
+ # This controls the following eBPF maps:
+ # - lua_tstate_map: Per-thread lua_State cache (~7 MB)
+ # - lua_lang_flags_map: Per-process Lua/LuaJIT type flags (~2.5 MB)
+ # - lua_unwind_info_map: Per-process unwinding metadata (~3 MB)
+ # - lua_offsets_map, luajit_offsets_map: Lua/LuaJIT struct offset tables (< 2 KB total)
+ # ch: |-
+ # 禁用 Lua 解释器剖析功能。禁用后将不会采集 Lua 进程的函数调用栈,可节省约 13 MB 的内核内存。
+ # 此配置项控制以下 eBPF maps 的创建:
+ # - lua_tstate_map:缓存每线程 lua_State 栈(按线程,容量较大,约 7 MB)
+ # - lua_lang_flags_map:记录进程 Lua/LuaJIT 类型标记(约 2.5 MB)
+ # - lua_unwind_info_map:存储进程级 unwinding 元信息(约 3 MB)
+ # - lua_offsets_map、luajit_offsets_map:存储 Lua/LuaJIT 结构偏移表(总计 < 2 KB)
+ lua_disabled: false
# type: section
# name:
# en: Network