> Date: Mon, 6 Jul 2026 11:33:56 +0200 > From: Reinoud Zandijk <[email protected]> > > hereby an adjusted version that re-applies after the latest changes in > uvm_swap.c made recently. > > @@ -1405,48 +1415,60 @@ swstrategy(struct buf *bp) > /* > - * B_RAW here implies user i/o on /dev/drum, for which we need > - * to handle encryption/decryption here. > - * for swap in/out, it's handled by the caller. > + * if the swap is encrypted, we encrypt before we write. in the > + * callback we ensure its always decrypted (again). > */ > - if ((bp->b_flags & B_RAW) != 0 && > - atomic_load_relaxed(&uvm_swap_encrypt)) { > - struct sw_physio_decrypt_context *ctx; > + if (atomic_load_relaxed(&uvm_swap_encrypt)) { > ... > + /* get iobuf for our decryption nestio setup */ > + nbp = getiobuf(bp->b_vp, !uvm_lwp_is_pagedaemon(curlwp)); > ... > @@ -2083,13 +2105,6 @@ uvm_swap_io(struct vm_page **pps, int st > kva = uvm_pagermapin(pps, npages, mapinflags); > > /* > - * encrypt writes in place if requested > - */ > - if (write) { > - uvm_swap_encrypt_pages(startslot, (void *)kva, npages); > - }
Do I understand correctly that this introduces a new allocation, not just when _reading_ from swap, but also when _writing_ to swap because we are under memory pressure and unable to allocate? That strikes me as extremely risky, and not worth the value of what otherwise appears to be a minor refactoring. I think this change needs a clearer justification.
