Re: [PATCH 2/8] io_uring: add infra for importing vectored reg buffers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Mar 03, 2025 at 12:49:38PM -0800, Caleb Sander Mateos wrote:
> > +               u64 buf_end;
> > +
> > +               if (unlikely(check_add_overflow(buf_addr, (u64)iov_len, &buf_end)))
> > +                       return -EFAULT;
> > +               if (unlikely(buf_addr < imu->ubuf || buf_end > (imu->ubuf + imu->len)))
> > +                       return -EFAULT;
> > +
> > +               total_len += iov_len;
> > +               /* by using folio address it also accounts for bvec offset */
> > +               offset = buf_addr - folio_addr;
> > +               src_bvec = imu->bvec + (offset >> imu->folio_shift);
> > +               offset &= folio_mask;
> > +
> > +               for (; iov_len; offset = 0, bvec_idx++, src_bvec++) {
> > +                       size_t seg_size = min_t(size_t, iov_len,
> > +                                               folio_size - offset);
> > +
> > +                       res_bvec[bvec_idx].bv_page = src_bvec->bv_page;
> > +                       res_bvec[bvec_idx].bv_offset = offset;
> > +                       res_bvec[bvec_idx].bv_len = seg_size;
> 
> Could just increment res_bvec to avoid the variable bvec_idx?

And utilizing bvec_set_page() to initialize looks a bit cleaner too.




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux