From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7584337A497; Thu, 29 Jan 2026 11:36:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769686576; cv=none; b=pZu45BKJzXQqPZKlAo9gKl4n41x+fHyBeRZGSBAnyS9Gs830GEVHsWYf+oMO4kgORfLkDPt24pRJTl84Mp2ciBmu2cVCLDx6Qg9WoP+PHq/9xxAPgmlBfM4yqS+VW9D6dOFOhOGDB4GESSSWVZxqQbWXzz4++w6MCPPuGUxkb5k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769686576; c=relaxed/simple; bh=d4CmdYYqvsYOE6rAuMRjm6IC6UqDM9BG3uDwhGiiAlg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=A6s5zM+9/8n7k6inBTgmUcb+edZmluTNVk2S/w/iE/TUKwBy508/sTv9Jc/AQQ1OSBnsWW3pjntfzz0pgnmnYnpydTNOjT5ra9WPUBWoQa/ziQ3kTPDKw7SjMO4xP16lkoRC1D+/kPjdkFw0eUOW6/rkpSi4t7y9sh3YO1v5Qhg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=VLRUTcDO; arc=none smtp.client-ip=115.124.30.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="VLRUTcDO" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1769686570; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type; bh=wI26mgk49lgLhCsakpVqc1lnp0wxouQs7L+0UFUDFuo=; b=VLRUTcDOC6sdDDZoNGp/5LTM95JVuf8oiKV84vOZX3OoPIfAB7K0LLLqwHuMptcDYeG+dFBM+p7P61Fe26ZHNMQCLnNMUZxZRksYWu5uiqv5oJh8RhfMZpjGAZZGYWgGR4goFl54NMdbdsMAXd7pRxJS+41ljtPrkTpVMQykgOg= Received: from localhost(mailfrom:alibuda@linux.alibaba.com fp:SMTPD_---0Wy7EuPK_1769686569 cluster:ay36) by smtp.aliyun-inc.com; Thu, 29 Jan 2026 19:36:09 +0800 Date: Thu, 29 Jan 2026 19:36:09 +0800 From: "D. Wythe" To: Jason Gunthorpe Cc: "D. Wythe" , Leon Romanovsky , Uladzislau Rezki , "David S. Miller" , Andrew Morton , Dust Li , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Sidraya Jayagond , Wenjia Zhang , Mahanta Jambigi , Simon Horman , Tony Lu , Wen Gu , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org, netdev@vger.kernel.org, oliver.yang@linux.alibaba.com Subject: Re: [PATCH net-next 2/3] mm: vmalloc: export find_vm_area() Message-ID: <20260129113609.GA37734@j66a10360.sqa.eu95> References: <20260123082349.42663-1-alibuda@linux.alibaba.com> <20260123082349.42663-3-alibuda@linux.alibaba.com> <20260124093505.GA98529@j66a10360.sqa.eu95> <20260124145754.GA57116@j66a10360.sqa.eu95> <20260127133417.GU13967@unreal> <20260128034558.GA126415@j66a10360.sqa.eu95> <20260128180629.GT1641016@ziepe.ca> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260128180629.GT1641016@ziepe.ca> User-Agent: Mutt/1.5.21 (2010-09-15) On Wed, Jan 28, 2026 at 02:06:29PM -0400, Jason Gunthorpe wrote: > On Wed, Jan 28, 2026 at 11:45:58AM +0800, D. Wythe wrote: > > > By leveraging vmalloc_huge() and the proposed helper to increase the > > page_size in ib_map_mr_sg(), each MTTE covers a much larger contiguous > > physical block. > > This doesn't seem right, if your goal is to take a vmalloc() pointer > and convert it to a MR via a scatterlist and ib_map_mr_sg() then you > should be asking for a helper to convert a kernel pointer into a > scatterlist. > > Even if you do this in a naive way and call the > sg_alloc_append_table_from_pages() function it will automatically join > physically contiguous ranges together for you. > > From there you can check the resulting scatterlist and compute the > page_size to pass to ib_map_mr_sg(). > > No need to ask the MM for anything other than the list of physicals to > build the scatterlist with. > > Still, I wouldn't mind seeing a helper to convert a kernel pointer > into a scatterlist because I have see that opencoded in a few places, > and maybe there are ways to optimize that using more information from > the MM - but it should be APIs used only by this helper not exposed to > drivers. > > Jason Hi Jason, To be honest, I was previously unaware of the sg_alloc_append_table_from_pages() function, although I had indeed considered manually calculating the size of contiguous physical blocks. The reason I proposed the MM helper is that SMC is not driver, it utilizes vmalloc() for memory allocation and is thus in direct contact with the MM; from this perspective, having the MM provide the page_order would be the most straightforward approach. Given the significant opposition and our plans to transition SMC to newer APIs in the future anyway, I agree that introducing this helper now is less justified. I will follow your suggestion and update the next version accordingly. Thanks.