On Wed, Jul 19, 2023 at 06:00:50AM +0000, Daisuke Matsuda (Fujitsu) wrote: > On Tue, June 13, 2023 1:19 AM Jason Gunthorpe wrote: > > Sorry for my long silence. > I must spend most of my time for other works these days, > but I am still willing to complete this and subsequent works. > > > > > On Thu, May 18, 2023 at 05:21:50PM +0900, Daisuke Matsuda wrote: > > > > > +static void rxe_mr_set_xarray(struct rxe_mr *mr, unsigned long start, > > > + unsigned long end, unsigned long *pfn_list) > > > +{ > > > + unsigned long lower, upper, idx; > > > + struct page *page; > > > + > > > + lower = rxe_mr_iova_to_index(mr, start); > > > + upper = rxe_mr_iova_to_index(mr, end); > > > + > > > + /* make pages visible in xarray. no sleep while taking the lock */ > > > + spin_lock(&mr->page_list.xa_lock); > > > + for (idx = lower; idx <= upper; idx++) { > > > + page = hmm_pfn_to_page(pfn_list[idx]); > > > + __xa_store(&mr->page_list, idx, page, GFP_ATOMIC); > > > > All of these loops can be performance improved a lot by using xas > > loops > > Well, do you mean I should use 'xas_for_each()' here? > That is the same 'for-loop' after all, so performance may not be improved. > Additionally, the 'idx' value above must be counted separately in that case. xa_store is O(n log(n)), xas_store()/xas_next() more like O(n) per store operation. Jason