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

Refactor makesyscalls.lua #1362

Closed
wants to merge 1 commit into from
Closed

Conversation

agge3
Copy link
Contributor

@agge3 agge3 commented Aug 5, 2024

Refactor of makesyscalls.lua to be a library
Drop-in replacement to makesyscalls.lua

Google Summer of Code 2024 Final Work Product
Project description: Refactor Syscall Creation Script
Mentors: Warner Losh (bsdimp), Kyle Evans (kevans)

Sponsored by: Google (GSoC 2024)

@bsdimp bsdimp requested review from brooksdavis and kevans91 August 5, 2024 15:33
@bsdimp
Copy link
Member

bsdimp commented Aug 5, 2024

Adding @jrtc27 and @arichardson since I can't do that in the reviewers setting....

Note to reviewers: This is my GSoC student's libification of makesyscalls.lua. At this stage, it's a drop in replacement. I'll work with my student on the reviews / commits aspect of the review. I'm looking for reviews on the final product. It should be 'no diffs' or nearly so (I think there's extra comments in a few places still, but I've not checked this final version). I'll also focus initially on the no-diff aspect, and hope the other reviewers have time to review this as to structure, lua goodness, etc.

It specifically doesn't have anything relating to reducing the number of files we have to check in as we can generate them on the fly now since (a) make is better able to handle that (b) machines are faster than in the 90s and (c) dependency madness has receeded since the 90s for many (but not all) of these files. These issues will be worked out (and the details and extent litigated) in phase 2.

Also, lsg was my first, half-completed attempt at this. He finished it off and got it to this point. Yea!

@agge3
Copy link
Contributor Author

agge3 commented Aug 5, 2024

Yes. Thank you Warner! I'm excited to get this where it needs to be. I'll appreciate any time and effort spent.

There are bits and pieces that are still being iterated on, but the guts are there. Files are being generated (mostly) similar.

-Tyler

Copy link
Contributor

@brooksdavis brooksdavis left a comment

Choose a reason for hiding this comment

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

This is quite hard to review in any kind of meaningful way. There needs to be some sort of overview of the structure in a README.md as well as the commit message.

What I'll want to do before a merge is to take something closer to final and bring it over to CheriBSD so I can apply our local diffs and see how that works in practice.

Some comments:

  • Despite all the indentation commits (that need to be squashed), indentation is wildly inconsistent even within files.
  • This is missing some commits to makesyscalls.lua (FREEBSD14 is the canary, but everything since the original split needs a review and merge).
  • If there are any differences in generated output they need to be very well documented. The desired number is zero.
  • The code might benefit from some subdirectories to differentiate code that generates specific files from library code.
  • There should probably be three total commits: add new code, switch what the Makefile uses, remove old code.

sys/tools/syscalls/bsdio.lua Outdated Show resolved Hide resolved
sys/tools/syscalls/bsdio.lua Outdated Show resolved Hide resolved
sys/tools/syscalls/config.lua Show resolved Hide resolved
sys/tools/syscalls/config.lua Outdated Show resolved Hide resolved
Copy link
Contributor

@kevans91 kevans91 left a comment

Choose a reason for hiding this comment

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

Initial pass with some feedback; apologies for largely being a ghost this term. I'll try to scrape some time together in the next week or so to do a more thorough review.

sys/tools/syscalls/bsdio.lua Outdated Show resolved Hide resolved
-- in.
-- Useful when a file has multiple stages of generation.
function bsdio:store(str, level)
level = level or 1 -- default to level one if not provided
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's just consolidate the comment on this line up with that above the function. Maybe:

Can also specify which order (level) to store in, which defaults to one if not provided.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are other comments that could use a similar suggestion. I've changed those to match this suggestion (and this one). Please inform me if you see anything else.

sys/tools/syscalls/config.lua Outdated Show resolved Hide resolved
sys/tools/syscalls/config.lua Outdated Show resolved Hide resolved
sys/tools/syscalls/freebsd-syscall.lua Outdated Show resolved Hide resolved
@agge3 agge3 force-pushed the refactor-makesyscalls.lua branch from d62a646 to 4af7106 Compare August 5, 2024 20:41
@agge3 agge3 requested a review from bsdjhb as a code owner August 5, 2024 20:41
@agge3 agge3 force-pushed the refactor-makesyscalls.lua branch from 4af7106 to 8c96194 Compare August 5, 2024 20:45
@jlduran
Copy link
Member

jlduran commented Aug 5, 2024

It would be good to first address luacheck's suggestions:

luacheck sys/tools/syscalls

@bsdimp
Copy link
Member

bsdimp commented Aug 6, 2024

I've noticed 2 real differences so far (the other differences are comments or sorting deltas):

We have #define nosys linux_nosys added to the linux files. what is this done? It doesn't seem to be needed.
The return type of linux_exit changes from int to void, which is incorrect.

There may be other issues as well.

@agge3 agge3 force-pushed the refactor-makesyscalls.lua branch 2 times, most recently from 77a16d0 to ded238c Compare August 9, 2024 19:09
Copy link
Contributor

@brooksdavis brooksdavis left a comment

Choose a reason for hiding this comment

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

I like the code reorganization. Much improved!

My main gripe: pick an indent style and use it consistently. I personally prefer a tabbed style following our C practices, but 4-spaces would be fine.

sys/tools/syscalls/config.lua Outdated Show resolved Hide resolved
sys/tools/syscalls/config.lua Outdated Show resolved Hide resolved
ptr_intptr_t_cast = "intptr_t",
obsol = {},
unimpl = {},
capabilities_conf = "capabilities.conf",
Copy link
Contributor

Choose a reason for hiding this comment

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

Support for capabilities.conf should be dropped as the last consumer went away with be67ea4. It should provably not be removed as part of the refactor, but done on one side or the other.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was unsure of this. We'll be able to easily approach this after the refactor, in a separate PR. This is an easy change to make.

sys/tools/syscalls/config.lua Outdated Show resolved Hide resolved
sys/tools/syscalls/config.lua Outdated Show resolved Hide resolved
Comment on lines 89 to 91
if t:validate(t.num - 1) then
table.insert(self.syscalls, t)
else
util.abort(1, "Skipped system call at number " .. t.num)
end
Copy link
Contributor

Choose a reason for hiding this comment

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

more spaces. There are several more instances in this file and presumably others, but I'm going to stop commenting here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In regards to spaces that should be tabs. I've changed all of them to tabs--but programmatically. If I catch any (which I haven't) I will continue to change. This should be done.

sys/tools/syscalls/core/syscall.lua Outdated Show resolved Hide resolved
Comment on lines 415 to 417
-- reseved system calls. this function deals with both knowing that the specific
-- ones are more copy and so we should just return the object we just made w/o
-- an extra clone.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure what this sentence is trying to say.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've reworded. Please let me know if it is still unclear.

sys/tools/syscalls/scripts/init_sysent.lua Outdated Show resolved Hide resolved
sys/tools/syscalls/main.lua Outdated Show resolved Hide resolved
@bsdimp bsdimp self-assigned this Aug 23, 2024
@agge3
Copy link
Contributor Author

agge3 commented Aug 26, 2024

It would be good to first address luacheck's suggestions:

luacheck sys/tools/syscalls

This has been followed up on. All luacheck suggestions are addressed. Thanks for the suggestion! This will be the precedent moving forward.

@agge3
Copy link
Contributor Author

agge3 commented Aug 26, 2024

I like the code reorganization. Much improved!

My main gripe: pick an indent style and use it consistently. I personally prefer a tabbed style following our C practices, but 4-spaces would be fine.

Great!! I agree with this sentiment. I will be following your preference. I did not catch that (also the source of why there's differences, as code from makesyscalls.lua followed FreeBSD C practices). It's going to be something I do as I correct the diffs, so it probably won't be changed right away, but it should follow a consistent indentation when it's ready.

@agge3 agge3 force-pushed the refactor-makesyscalls.lua branch 3 times, most recently from 3aed7c8 to d45f7ff Compare September 8, 2024 15:22
@agge3 agge3 force-pushed the refactor-makesyscalls.lua branch from c360d4e to 0ad7862 Compare September 17, 2024 01:03
agge3 added a commit to agge3/freebsd-src that referenced this pull request Sep 29, 2024
Comment aligning was inconsistent and required a ton of book-keeping
Replaced comment aligning with just a single tab out
Part of refactor of makesyscalls.lua
See [Refactor makesyscalls.lua freebsd#1362](freebsd#1362)
agge3 added a commit to agge3/freebsd-src that referenced this pull request Sep 29, 2024
Comment aligning was inconsistent and required a ton of book-keeping.
Replaced comment aligning with a simpler, single tab out.
Part of refactor of makesyscalls.lua.
See Refactor makesyscalls.lua freebsd#1362: freebsd#1362
agge3 added a commit to agge3/freebsd-src that referenced this pull request Sep 29, 2024
Comment aligning was inconsistent and required a ton of book-keeping.
Replaced comment aligning with a simpler, single tab out.
Part of refactor of makesyscalls.lua.
See Refactor makesyscalls.lua: freebsd#1362.
agge3 added a commit to agge3/freebsd-src that referenced this pull request Sep 29, 2024
Comment aligning was inconsistent and required a ton of book-keeping.
Replaced comment aligning with a simple, single tab out.
See Refactor makesyscalls.lua freebsd#1362.
agge3 added a commit to agge3/freebsd-src that referenced this pull request Sep 29, 2024
Comment aligning was inconsistent and required a ton of book-keeping.
Replaced comment aligning with a simple, single tab out.
See Refactor makesyscalls.lua freebsd#1362.

Signed-off-by: agge3 <[email protected]>
agge3 added a commit to agge3/freebsd-src that referenced this pull request Sep 29, 2024
Comment aligning was inconsistent and required a ton of book-keeping.
Replaced comment aligning with a simple, single tab out.
See Refactor makesyscalls.lua freebsd#1362.

Signed-off-by: agge3 <[email protected]>
agge3 added a commit to agge3/freebsd-src that referenced this pull request Sep 29, 2024
Comment aligning was inconsistent and required a ton of book-keeping.
Replaced comment aligning with a simple, single tab out.
See Refactor makesyscalls.lua freebsd#1362.

Signed-off-by: agge3 <[email protected]>
@agge3 agge3 force-pushed the refactor-makesyscalls.lua branch from 72cc0fc to c9c0ec2 Compare October 8, 2024 17:25
Copy link
Contributor

@brooksdavis brooksdavis left a comment

Choose a reason for hiding this comment

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

I've updated my branch with a bunch of whitespace fixes and a few fixups of my prior commits. Except for the extra file generation bits the commits on my branch can be seen as reviews in commit form and squashed directly into your commit without credit. The other two add enough content that a Co-authored-by: credit might be nice if squashed.

https://github.com/brooksdavis/freebsd/tree/refactor-makesyscalls.lua

sys/tools/syscalls/config.lua Outdated Show resolved Hide resolved
brooksdavis pushed a commit to brooksdavis/freebsd that referenced this pull request Oct 21, 2024
* main.lua replicates the functionality of makesyscalls.lua
* Individual files are generated by their associated module
  * Modules can be called as standalone scripts to generate a specific
    file
* Data and procedures are performed by objects instead of procedual code
* Bitmasks are replaced by declarative types
* Temporary files are no longer produced, writing is stored in memory
* Comments provide explanation to functions and semantics

Google Summer of Code 2024 Final Work Product

Sponsored by:    Google (GSoC 24)
Co-authored-by: Warner Losh <[email protected]>
Co-authored-by: Brooks Davis <[email protected]>
Pull Request:	freebsd#1362
@brooksdavis
Copy link
Contributor

I've added a proposed rebasing and squashing of the new code with follow on commits to connect the new code at https://github.com/brooksdavis/freebsd/tree/refactor-makesyscalls.lua-rebased. Happy to take any feedback about the organization or contents.

If it looks good, I'll plan to push to FreeBSD once the current stabilization week ends.

@agge3 agge3 force-pushed the refactor-makesyscalls.lua branch 6 times, most recently from cdb0e81 to 018b136 Compare October 22, 2024 08:12
@agge3
Copy link
Contributor Author

agge3 commented Oct 22, 2024

I've added a proposed rebasing and squashing of the new code with follow on commits to connect the new code at https://github.com/brooksdavis/freebsd/tree/refactor-makesyscalls.lua-rebased. Happy to take any feedback about the organization or contents.

If it looks good, I'll plan to push to FreeBSD once the current stabilization week ends.

Sorry I didn't follow-up more properly on your previous work. Last week, and this week, are very busy for me. I'll be less busy after this week.

This is great!!! Thank you for your help on the final stretch! I appreciate the work!! I'm glad you are pleased with the library. I'm happy to contribute and I really value the effort you've put into this.

I've merged 505d596 from that branch to be part of this commit.

On my part, I've went through everything thoroughly. All changes are minor or non-invasive. Some final changes that I'd like to add (currently squashed into this commit):

  • Commit message includes Kyle as co-author. Him and Warner were both my mentors during GSoC, so that seems fitting with Warner as a co-author.
  • Commit message includes a Signed-off-by agge3 as FreeBSD GitHub documentation instructs.
  • Removed syscall:comment() as it's broken/unimplemented and there's no longer a use for it.
  • Removed other XXX remarks that are implementation relics and should not be included.
  • Added syscall:validate() to both branches of FreeBSDSyscall:parseSysfile(). That's correct and numbers should be validated in either case.
  • audit_idx constant in sysproto_h is now just a decimal number. Following the goal that the refactor should be more readable, hexadecimal seems unfitting here.
  • syscall_mk has config as a parameter once again, the same as you've done with libsys.h and syscalls.map. Luacheck complains about unused parameter. Having config available in every module is more intuitive and semantically makes sense.
  • enforced style.lua(9) on outside credited functions, for consistency.
  • Punctuation (periods) were inconsistent in comments; comment punctuation is now consistent.
  • Semantics in comments are more consistent. I opted for Doxygen-style comments in some places, without a strict enforcement everywhere. I see that you continued the Doxygen-style. I've made comments more consistent, but this divide still exists.

Additionally, I noticed that "converstion" in systrace generation is misspelled. I've changed to be spelled correctly. Considering how minor, now seems like a good time to change that. Pending feedback, I've left that as a second commit on this PR (which can be squashed).

On the weekend (before next week), I'm hoping to go through again. But I'm happy with this being my final input.

In terms of this PR, would you like me to pull your commits over, or would you prefer I leave it how it is?

@agge3 agge3 force-pushed the refactor-makesyscalls.lua branch from 068622b to b52a459 Compare October 22, 2024 09:31
@brooksdavis
Copy link
Contributor

I've rebased my branch with your changes (including the typo fix squashed into the main commit). I also fixed the typo upstream to reduce diffs in generated files.

I've added commits removing capabilities.conf and capenabled= support. I think it's ok to commit with the support and them immediately remove it on the grounds that someone might be using them downstream and this would make it easier to restore that functionality temporarily.

I'm happy to do another update Monday if you want to take another pass through the code over the weekend. It's probably somewhat easier if you don't incorporate my changes, but if there are any you want to take as part of the main commit, go ahead.

@agge3
Copy link
Contributor Author

agge3 commented Oct 23, 2024

I've rebased my branch with your changes (including the typo fix squashed into the main commit). I also fixed the typo upstream to reduce diffs in generated files.

I've added commits removing capabilities.conf and capenabled= support. I think it's ok to commit with the support and them immediately remove it on the grounds that someone might be using them downstream and this would make it easier to restore that functionality temporarily.

I'm happy to do another update Monday if you want to take another pass through the code over the weekend. It's probably somewhat easier if you don't incorporate my changes, but if there are any you want to take as part of the main commit, go ahead.

Great. Sounds good!

Yes, I'll take another pass over the weekend.

I'll report any changes I have (if any at all), so everything's ready for Monday.

In that case, that will be a bit easier. That's probably what I'll opt for.

@agge3 agge3 force-pushed the refactor-makesyscalls.lua branch from 5c3a81f to 8931f15 Compare October 28, 2024 13:04
* main.lua replicates the functionality of makesyscalls.lua
* Individual files are generated by their associated module
  * Modules can be called as standalone scripts to generate a specific
    file
* Data and procedures are performed by objects instead of procedual code
* Bitmasks are replaced by declarative types
* Temporary files are no longer produced, writing is stored in memory
* Comments provide explanation to functions and semantics

Google Summer of Code 2024 Final Work Product

Sponsored by:    Google (GSoC 24)
Co-authored-by: Warner Losh <[email protected]>
Co-authored-by: Kyle Evans <[email protected]>
Co-authored-by: Brooks Davis <[email protected]>
Signed-off-by: agge3 <[email protected]>
@agge3 agge3 force-pushed the refactor-makesyscalls.lua branch from 8931f15 to 1529735 Compare October 28, 2024 13:10
@agge3
Copy link
Contributor Author

agge3 commented Oct 28, 2024

Okay, great!

I've went through everything thoroughly again.

Final changes I have are:

  • More minor consistency changes in comments, as a result of going through it consecutively.
  • (Notable) config.merge() claimed and was intended to return nil and a message if file was nil. It did not. It now does, and as a happy side-effect is less pushed over to the right side of the terminal.

I've regression tested locally to confirm everything's working as it should. If you're ready to commit, I don't see more areas I would like to address before that.

I've opted for keeping the PR as the singular commit that is mine. I appreciate the help and that makes the most sense. It is a lot easier, so thanks!

Thank you for the thorough review!

I'd like to stay in the loop and continue to maintain (and iterate, if necessary) areas revolving around this library. I'd like to consider myself knowledgeable in the library and would be excited to continue.

  • Tyler

brooksdavis pushed a commit to brooksdavis/freebsd that referenced this pull request Oct 30, 2024
* main.lua replicates the functionality of makesyscalls.lua
* Individual files are generated by their associated module
  * Modules can be called as standalone scripts to generate a specific
    file
* Data and procedures are performed by objects instead of procedual code
* Bitmasks are replaced by declarative types
* Temporary files are no longer produced, writing is stored in memory
* Comments provide explanation to functions and semantics

Google Summer of Code 2024 Final Work Product

Sponsored by:    Google (GSoC 24)
Co-authored-by: Warner Losh <[email protected]>
Co-authored-by: Kyle Evans <[email protected]>
Co-authored-by: Brooks Davis <[email protected]>
Pull Request:	freebsd#1362
Signed-off-by: agge3 <[email protected]>
brooksdavis pushed a commit to brooksdavis/freebsd that referenced this pull request Oct 30, 2024
* main.lua replicates the functionality of makesyscalls.lua
* Individual files are generated by their associated module
  * Modules can be called as standalone scripts to generate a specific
    file
* Data and procedures are performed by objects instead of procedual code
* Bitmasks are replaced by declarative types
* Temporary files are no longer produced, writing is stored in memory
* Comments provide explanation to functions and semantics

Google Summer of Code 2024 Final Work Product

Sponsored by:    Google (GSoC 24)
Pull Request:	freebsd#1362
Signed-off-by: agge3 <[email protected]>
Co-authored-by: Warner Losh <[email protected]>
Co-authored-by: Kyle Evans <[email protected]>
Co-authored-by: Brooks Davis <[email protected]>
brooksdavis added a commit to brooksdavis/freebsd that referenced this pull request Oct 30, 2024
* main.lua replicates the functionality of makesyscalls.lua
* Individual files are generated by their associated module
  * Modules can be called as standalone scripts to generate a specific
    file
* Data and procedures are performed by objects instead of procedual code
* Bitmasks are replaced by declarative types
* Temporary files are no longer produced, writing is stored in memory
* Comments provide explanation to functions and semantics

Google Summer of Code 2024 Final Work Product

Co-authored-by: Warner Losh <[email protected]>
Co-authored-by: Kyle Evans <[email protected]>
Co-authored-by: Brooks Davis <[email protected]>
Sponsored by:    Google (GSoC 24)
Pull Request:	freebsd#1362
Signed-off-by: agge3 <[email protected]>
brooksdavis added a commit to brooksdavis/freebsd that referenced this pull request Oct 30, 2024
* main.lua replicates the functionality of makesyscalls.lua
* Individual files are generated by their associated module
  * Modules can be called as standalone scripts to generate a specific
    file
* Data and procedures are performed by objects instead of procedual code
* Bitmasks are replaced by declarative types
* Temporary files are no longer produced, writing is stored in memory
* Comments provide explanation to functions and semantics

Google Summer of Code 2024 Final Work Product

Co-authored-by: Warner Losh <[email protected]>
Co-authored-by: Kyle Evans <[email protected]>
Co-authored-by: Brooks Davis <[email protected]>
Sponsored by:    Google (GSoC 24)
Pull Request:	freebsd#1362
Signed-off-by: agge3 <[email protected]>
@brooksdavis
Copy link
Contributor

Merged as commit 9ded074

freebsd-git pushed a commit that referenced this pull request Oct 30, 2024
* main.lua replicates the functionality of makesyscalls.lua
* Individual files are generated by their associated module
  * Modules can be called as standalone scripts to generate a specific
    file
* Data and procedures are performed by objects instead of procedual code
* Bitmasks are replaced by declarative types
* Temporary files are no longer produced, writing is stored in memory
* Comments provide explanation to functions and semantics

Google Summer of Code 2024 Final Work Product

Co-authored-by: Warner Losh <[email protected]>
Co-authored-by: Kyle Evans <[email protected]>
Co-authored-by: Brooks Davis <[email protected]>
Sponsored by:    Google (GSoC 24)
Pull Request:	#1362
Signed-off-by: agge3 <[email protected]>
brooksdavis pushed a commit to CTSRD-CHERI/cheribsd that referenced this pull request Nov 6, 2024
* main.lua replicates the functionality of makesyscalls.lua
* Individual files are generated by their associated module
  * Modules can be called as standalone scripts to generate a specific
    file
* Data and procedures are performed by objects instead of procedual code
* Bitmasks are replaced by declarative types
* Temporary files are no longer produced, writing is stored in memory
* Comments provide explanation to functions and semantics

Google Summer of Code 2024 Final Work Product

Co-authored-by: Warner Losh <[email protected]>
Co-authored-by: Kyle Evans <[email protected]>
Co-authored-by: Brooks Davis <[email protected]>
Sponsored by:    Google (GSoC 24)
Pull Request:	freebsd/freebsd-src#1362
Signed-off-by: agge3 <[email protected]>

(cherry picked from commit 9ded074e875c29cb92d5f643801990d7bb23cca4)
bsdjhb pushed a commit to CTSRD-CHERI/cheribsd that referenced this pull request Nov 11, 2024
* main.lua replicates the functionality of makesyscalls.lua
* Individual files are generated by their associated module
  * Modules can be called as standalone scripts to generate a specific
    file
* Data and procedures are performed by objects instead of procedual code
* Bitmasks are replaced by declarative types
* Temporary files are no longer produced, writing is stored in memory
* Comments provide explanation to functions and semantics

Google Summer of Code 2024 Final Work Product

Co-authored-by: Warner Losh <[email protected]>
Co-authored-by: Kyle Evans <[email protected]>
Co-authored-by: Brooks Davis <[email protected]>
Sponsored by:    Google (GSoC 24)
Pull Request:	freebsd/freebsd-src#1362
Signed-off-by: agge3 <[email protected]>

(cherry picked from commit 9ded074e875c29cb92d5f643801990d7bb23cca4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants