Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix load time #769

Merged
merged 1 commit into from
Sep 22, 2023
Merged

fix load time #769

merged 1 commit into from
Sep 22, 2023

Conversation

astoycos
Copy link
Member

time since boot is defined as the UNIX_EPOCH plus the duration since boot. which is realtime - boottime NOT boottime - realtime.

@netlify
Copy link

netlify bot commented Aug 28, 2023

Deploy Preview for aya-rs-docs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit dffff1c
🔍 Latest deploy log https://app.netlify.com/sites/aya-rs-docs/deploys/650dbff3935a7f0008f1c91b
😎 Deploy Preview https://deploy-preview-769--aya-rs-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mergify mergify bot added the aya This is about aya (userspace) label Aug 28, 2023
@astoycos
Copy link
Member Author

Broken:

[astoycos@nfvsdn-02-oot bpfd]$ sudo ./target/debug/bpfctl list --all
 Kernel ID  Bpfd UUID  Name             Type           Load Time                
 45                    restrict_filesy  lsm            1916-06-05T23:06:29-0500 
 132                   sd_devices       cgroup_device  1916-06-30T00:16:58-0500 

Fixed:

[astoycos@nfvsdn-02-oot bpfd]$ sudo ./target/debug/bpfctl list --all
 Kernel ID  Bpfd UUID  Name             Type           Load Time                
 45                    restrict_filesy  lsm            2023-07-28T15:53:50-0400 

Bpftool output as verification:

[astoycos@nfvsdn-02-oot bpfd]$ sudo bpftool prog 
45: lsm  name restrict_filesystems  tag aae89fa01fe7ee91  gpl
        loaded_at 2023-07-28T15:53:50-0400  uid 0
        xlated 560B  jited 297B  memlock 4096B  map_ids 22
        btf_id 49
        pids systemd(1)

Copy link
Member

@tamird tamird left a comment

Choose a reason for hiding this comment

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

Needs a test.

@mergify mergify bot added the test A PR that improves test cases or CI label Sep 22, 2023

let loaded_at = prog.info().unwrap().loaded_at();

// make sure loaded_at() api is correct with a millisecond tolerance.
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it be more robust to:

  • get current time t1
  • load
  • get current time t2
  • assert load is been t1 and t2
    ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep good call, done


let loaded_at = prog.info().unwrap().loaded_at();

assert!(t1 < loaded_at && t2 > loaded_at);
Copy link
Member

Choose a reason for hiding this comment

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

this assertion doesn't emit information on failure, which seems bad. how about

let range = t1..t2;
assert!(range.contains(loaded_at), "{range}.contains({loaded_at})");

or something like that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Time since boot is defined as the UNIX_EPOCH plus the duration
since boot. which is realtime - boottime NOT boottime - realtime.

Add a integration test to ensure this doesn't happen again.

Signed-off-by: astoycos <astoycos@redhat.com>
@astoycos astoycos merged commit c130500 into aya-rs:main Sep 22, 2023
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aya This is about aya (userspace) test A PR that improves test cases or CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants