Skip to content

[herd] Improvements for vmsa+ifetch - #1940

Draft
artkhyzha wants to merge 2 commits into
herd:masterfrom
artkhyzha:artem-vmsa-for-ifetch
Draft

[herd] Improvements for vmsa+ifetch#1940
artkhyzha wants to merge 2 commits into
herd:masterfrom
artkhyzha:artem-vmsa-for-ifetch

Conversation

@artkhyzha

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread herd/mem.ml
Comment on lines +436 to +453
Label.Map.fold (fun _ addr acc -> addr::acc) prog []
|> List.filter (fun addr ->
(addr mod Pseudo.page_size = 0)
&& (is_on_exported_page (addr2va addr) || is_on_relevant_page (addr2va addr))
)
in
let page_size pa =
let (_,code) = IntMap.find pa code_segment in
List.fold_left (fun acc (a,_) ->
acc + (if pa <= a && a < pa + Pseudo.page_size then 1 else 0)
) 0 code
in
let check =
match page_addrs with
| [] -> () (* no checks to perform *)
| pa::page_addrs -> begin
let eta = page_size pa in
List.iter (fun a ->

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.

Would you be interested in taking some functions in the list and map libraries that make the intention clearer in the code?

In particular:

  • extracting values from the map: a15b8c5
  • counting elements that satisfy a function: 4052e67

These can be adapted into this code like so:

Suggested change
Label.Map.fold (fun _ addr acc -> addr::acc) prog []
|> List.filter (fun addr ->
(addr mod Pseudo.page_size = 0)
&& (is_on_exported_page (addr2va addr) || is_on_relevant_page (addr2va addr))
)
in
let page_size pa =
let (_,code) = IntMap.find pa code_segment in
List.fold_left (fun acc (a,_) ->
acc + (if pa <= a && a < pa + Pseudo.page_size then 1 else 0)
) 0 code
in
let check =
match page_addrs with
| [] -> () (* no checks to perform *)
| pa::page_addrs -> begin
let eta = page_size pa in
List.iter (fun a ->
Label.Map.values prog
|> Seq.filter (fun addr ->
(addr mod Pseudo.page_size = 0)
&& (is_on_exported_page (addr2va addr) || is_on_relevant_page (addr2va addr))
)
in
let page_size pa =
let (_,code) = IntMap.find pa code_segment in
Misc.List.count (fun (a, _) -> pa <= a && a < pa + Pseudo.page_size) code
in
let check =
match Seq.uncons page_addrs with
| None -> () (* no checks to perform *)
| Some (pa, page_addrs) -> begin
let eta = page_size pa in
Seq.iter (fun a ->

@psafont

psafont commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Is the first commit only fixing a bug, or are there also enhancements? It would be good to explain in the commit message which bug is being fixed, and if there are unrelated enhancements, separate them from the bugfix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants