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

user_driver: specify tags when allocating dma buffers #912

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

chris-oo
Copy link
Member

Specify allocation tags when allocating dma buffers.

Restore requires some additional thought as drivers will need to save/restore tags if we want to require them to match. But this at least helps attribute the allocations that previously just had a not very useful tag.

@chris-oo chris-oo requested review from a team as code owners February 26, 2025 18:22
@chris-oo chris-oo force-pushed the dma-client-allocation-tags branch from 0d69fd1 to 681ed2a Compare February 26, 2025 18:25
.allocate_dma_buffer(HV_PAGE_SIZE as usize)
.allocate_dma_buffer(
HV_PAGE_SIZE as usize,
format!("tdx-flush-page vp {}", params.vp_info.base.vp_index.index()),
Copy link
Contributor

Choose a reason for hiding this comment

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

This one doesn't really follow the format of all the others, but i guess it doesn't matter?

@@ -273,7 +273,7 @@ pub struct EmulatedDmaAllocator {
}

impl DmaClient for EmulatedDmaAllocator {
fn allocate_dma_buffer(&self, len: usize) -> anyhow::Result<MemoryBlock> {
fn allocate_dma_buffer(&self, len: usize, _tag: String) -> anyhow::Result<MemoryBlock> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could still be useful here right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, add it to .context below

fn allocate_dma_buffer(
&self,
len: usize,
_tag: String,
Copy link
Contributor

Choose a reason for hiding this comment

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

Could be useful here too right?

@@ -1835,7 +1835,7 @@ async fn request_igvm_attest(
let allocator = gpa_allocator.ok_or(FatalError::GpaAllocatorUnavailable)?;
let dma_size = request.response_buffer_len;
let mem = allocator
.allocate_dma_buffer(dma_size)
.allocate_dma_buffer(dma_size, "attest request".into())
Copy link
Contributor

Choose a reason for hiding this comment

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

This one too

@@ -185,7 +185,7 @@ impl QueuePair {
QueuePair::SQ_SIZE + QueuePair::CQ_SIZE + QueuePair::PER_QUEUE_PAGES * PAGE_SIZE;
let dma_client = device.dma_client();
let mem = dma_client
.allocate_dma_buffer(total_size)
.allocate_dma_buffer(total_size, "nvme-queues".into())
Copy link
Contributor

Choose a reason for hiding this comment

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

We should include qid here at least, and possibly pci_id if we can retreive one

Copy link
Member Author

Choose a reason for hiding this comment

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

pci_id is tied to the client (this is allocated off a specific device's client), but sure - what's the source of qid you want here?

Copy link
Contributor

Choose a reason for hiding this comment

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

qid is passed as a parameter to this function, I think it would help to know for which queue number (qid) we allocated this particular block.

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.

3 participants