Skip to content

Conversation

assembler-0
Copy link
Owner

@assembler-0 assembler-0 commented Sep 5, 2025

virtio driver read/write

Summary by CodeRabbit

  • New Features

    • Added write support to the VirtIO block driver.
    • Improved I/O handling to support multiple in-flight requests with better completion and resource cleanup.
  • Documentation

    • Fixed Quickstart command path to run the configuration script from the correct directory.
  • Chores

    • Updated CI to run on pull requests targeting both main and dev; removed push builds to these branches.
    • Introduced a command-line utility to mangle C function names across a project, with mapping output and progress reporting.

Copy link

coderabbitai bot commented Sep 5, 2025

Caution

Review failed

The pull request is closed.


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ea3bbb8 and 9fd184f.

📒 Files selected for processing (4)
  • .github/workflows/main.yaml (1 hunks)
  • README.md (1 hunks)
  • drivers/virtio/VirtioBlk.h (1 hunks)
  • scripts/mangle.py (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch Development

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 9

🧹 Nitpick comments (3)
drivers/virtio/VirtioBlk.c (3)

299-312: Make write buffer const in implementation to match the header

Keep signatures consistent and protect writes.

Apply:

-int VirtioBlkWrite(uint64_t sector, void* buffer) {
+int VirtioBlkWrite(uint64_t sector, const void* buffer) {
...
-    vq_desc_table[head_idx + 1].addr  = VIRT_TO_PHYS((uint64_t)buffer);
+    vq_desc_table[head_idx + 1].addr  = VIRT_TO_PHYS((uint64_t)buffer);

221-229: VMemAlloc per-request is heavyweight; consider a small object cache

Allocating and mapping full pages for tiny structs/status bytes per I/O is costly and increases TLB pressure. Use a slab/pool or pre-allocated per-request structures.

I can sketch a fixed-size pool (power-of-two) with a free list and no locks under virtio_lock if helpful.

Also applies to: 289-297


24-24: Wrap-around handling for last_used_idx

Keep last_used_idx as uint16_t (good). When comparing to vq_used_ring->idx, the loop is fine, but ensure producers can’t starve consumers. Consider reading used->idx once per outer iteration to reduce live racing.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9005515 and ea3bbb8.

📒 Files selected for processing (2)
  • drivers/virtio/VirtioBlk.c (3 hunks)
  • drivers/virtio/VirtioBlk.h (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
drivers/virtio/VirtioBlk.h (1)
drivers/virtio/VirtioBlk.c (1)
  • VirtioBlkWrite (280-346)
drivers/virtio/VirtioBlk.c (4)
kernel/etc/Console.c (1)
  • PrintKernel (181-199)
kernel/atomic/Spinlock.h (2)
  • SpinLock (26-60)
  • SpinUnlock (120-122)
mm/VMem.c (2)
  • VMemAlloc (243-309)
  • VMemFree (311-375)
kernel/atomic/Atomics.c (1)
  • AtomicInc (6-8)
🔇 Additional comments (2)
drivers/virtio/VirtioBlk.c (2)

8-8: Including Virtio.h here is correct

Localizing the dependency to the implementation file is the right call.


171-175: Sanity-check queue_size vs descriptor allocations

After reading queue_size, consider validating it’s divisible by 3 if you only support fixed 3-desc chains, or implement wrap-aware chaining across the ring boundary to avoid unusable tail fragments.

I can provide a trivial boundary-crossing chain builder (idx, (idx+1)%vq_size, (idx+2)%vq_size) if you want to keep the simple allocator.

Also applies to: 177-193

@assembler-0 assembler-0 merged commit 209a200 into main Sep 5, 2025
1 check passed
@coderabbitai coderabbitai bot mentioned this pull request Oct 11, 2025
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.

1 participant