These are modeled on the API used for m_copydata/m_copyback and the
crypto buffer APIs. One day it might be nice to reduce the
proliferation of these by adding cursors and using memdesc directly
for crypto request buffers.
Details
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Skipped - Unit
Tests Skipped - Build Status
Buildable 52653 Build 49544: arc lint + arc unit
Event Timeline
I use this in the NVMe over TCP transport to copy data between command buffers associated with NVMe commands and mbuf chains containing NVMe/TCP PDUs.
sys/kern/kern_memdesc.c | ||
---|---|---|
2 | can I get a spdx-indentifier for this? | |
54 | any way to static_assert this? | |
172 | I'm not entirely sure I'm happy that we need to decode these details in yet another place. Maybe this should be a cam function that's called instead? ksan needs it as does _bus_dmamap_load_ccb | |
407 | and another copy here, see above :( |
sys/kern/kern_memdesc.c | ||
---|---|---|
54 | Not really. The question is if this if the MD code creates mappings this way or not. The other way to fix this is to do a loop invoking PHYS_TO_DMAP on each page which I could do easily enough. | |
172 | I do think it would be nice to basically have a function which returns a memdesc for a ccb. That would basically be the moral equivalent. I could add that and fix the existing places. | |
285 | Humm, presumably if i fix this to do a loop on each page and not rely on the assumption (which probably isn't safe in some cases?) then it would matter, but yes, otherwise it would not. | |
497 | Because this routine is intended to be safe to use in contexts where you can't sleep or fault. It could perhaps permit UIO_SYSSPACE, but I also knew I didn't need it for nvmf so figured it could be added in when there was an actual user. TBH, I would probably not like to have uio in memdesc and instead change MEMDESC_VLIST to use a iovec array instead of abusing bus_dma_segment_t to store virtual pointers in ds_addr_t. That really means fixing that abuse in CAM CCBs though which is a bigger change. |
This still does not handle uio's (for which I think uiomove is already a sufficient API), but I think I've addressed all the other feedback.
As an aside, I'm never sure when a file in sys/kern should start with kern_ vs. subr_. Are there any rules around that?
sys/kern/kern_memdesc.c | ||
---|---|---|
209 | It should be possible to fold this prologue into the loop if the loop sets page_off = 0 at the end of the first iteration. | |
209 | Don't you want to write pa += PAGE_SIZE - page_off here? | |
306 | Perhaps assert off >= 0 && size >= 0. |
I'm not aware of any rules. My vague hand-wavy thought is that subr_* is lower level than kern_*, and given some other examples like subr_sglist.c and subr_bus_dma.c, maybe subr_ is the better prefix in this case?
sys/kern/kern_memdesc.c | ||
---|---|---|
209 | I was debating if I wanted to deal with page_off in the loop, vs make the loop more streamlined. However, it probably is less code to just set page_off to 0 at the end of the loop. And yes, I messed up the pa addition, and forgot to axe the trunc_page from PHYS_TO_DMAP above. Bah. My problem is that my test case (my NVMeoF host) doesn't currently use memdesc's with paddr ranges. It does test both bio and ccb's with unmapped I/O, but those use the vmpages memdesc. |