Skip to content

Using global variable to control bpf log level#1206

Merged
kmesh-bot merged 7 commits intokmesh-net:mainfrom
hzxuzhonghu:global-var
Feb 20, 2025
Merged

Using global variable to control bpf log level#1206
kmesh-bot merged 7 commits intokmesh-net:mainfrom
hzxuzhonghu:global-var

Conversation

@hzxuzhonghu
Copy link
Copy Markdown
Member

@hzxuzhonghu hzxuzhonghu commented Jan 20, 2025

What type of PR is this?

What this PR does / why we need it:

Using global variable to control bpf log level

Should be after #1205

Global variables provide much nicer user experience and avoid BPF map lookup overhead. Additionally, for constant variables, there values are well-known to BPF verifier and treated as constants during program verification, which allows BPF verifier to verify code more precisely and eliminate dead code branches effectively.

Which issue(s) this PR fixes:
Fixes #

Special notes for you're reviewer:

Does this PR introduce a user-facing change?:


Signed-off-by: Zhonghu Xu <xuzhonghu@huawei.com>
Signed-off-by: Zhonghu Xu <xuzhonghu@huawei.com>
Signed-off-by: Zhonghu Xu <xuzhonghu@huawei.com>
Signed-off-by: Zhonghu Xu <xuzhonghu@huawei.com>
Signed-off-by: Zhonghu Xu <xuzhonghu@huawei.com>
config.BpfLogLevel = uint32(level)
if err := bpf.UpdateKmeshConfigMap(s.kmeshConfigMap, config); err != nil {
http.Error(w, fmt.Sprintf("update log level error: %v", err), http.StatusBadRequest)
if err := s.bpfLogLevel.Set(uint32(level)); err != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So is it now not necessary for KmeshConfigmap to pass the log_level?

Signed-off-by: Zhonghu Xu <xuzhonghu@huawei.com>
Signed-off-by: Zhonghu Xu <xuzhonghu@huawei.com>
@bitcoffeeiux
Copy link
Copy Markdown
Contributor

/lgtm

@hzxuzhonghu
Copy link
Copy Markdown
Member Author

/retest

@kmesh-bot
Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bitcoffeeiux

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kmesh-bot kmesh-bot merged commit 39a4a31 into kmesh-net:main Feb 20, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants