Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

io_uring/zcrx: introduce io_parse_rqe()

Add a helper for verifying a rqe and extracting a niov out of it. It'll
be reused in following patches.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Pavel Begunkov and committed by
Jens Axboe
8fd08d8d 5a8b6e7c

+23 -13
+23 -13
io_uring/zcrx.c
··· 750 750 return &ifq->rqes[idx]; 751 751 } 752 752 753 + static inline bool io_parse_rqe(struct io_uring_zcrx_rqe *rqe, 754 + struct io_zcrx_ifq *ifq, 755 + struct net_iov **ret_niov) 756 + { 757 + unsigned niov_idx, area_idx; 758 + struct io_zcrx_area *area; 759 + 760 + area_idx = rqe->off >> IORING_ZCRX_AREA_SHIFT; 761 + niov_idx = (rqe->off & ~IORING_ZCRX_AREA_MASK) >> ifq->niov_shift; 762 + 763 + if (unlikely(rqe->__pad || area_idx)) 764 + return false; 765 + area = ifq->area; 766 + 767 + if (unlikely(niov_idx >= area->nia.num_niovs)) 768 + return false; 769 + niov_idx = array_index_nospec(niov_idx, area->nia.num_niovs); 770 + 771 + *ret_niov = &area->nia.niovs[niov_idx]; 772 + return true; 773 + } 774 + 753 775 static void io_zcrx_ring_refill(struct page_pool *pp, 754 776 struct io_zcrx_ifq *ifq) 755 777 { ··· 787 765 788 766 do { 789 767 struct io_uring_zcrx_rqe *rqe = io_zcrx_get_rqe(ifq, mask); 790 - struct io_zcrx_area *area; 791 768 struct net_iov *niov; 792 - unsigned niov_idx, area_idx; 793 769 netmem_ref netmem; 794 770 795 - area_idx = rqe->off >> IORING_ZCRX_AREA_SHIFT; 796 - niov_idx = (rqe->off & ~IORING_ZCRX_AREA_MASK) >> ifq->niov_shift; 797 - 798 - if (unlikely(rqe->__pad || area_idx)) 771 + if (!io_parse_rqe(rqe, ifq, &niov)) 799 772 continue; 800 - area = ifq->area; 801 - 802 - if (unlikely(niov_idx >= area->nia.num_niovs)) 803 - continue; 804 - niov_idx = array_index_nospec(niov_idx, area->nia.num_niovs); 805 - 806 - niov = &area->nia.niovs[niov_idx]; 807 773 if (!io_zcrx_put_niov_uref(niov)) 808 774 continue; 809 775