From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-vk1-f173.google.com (mail-vk1-f173.google.com [209.85.221.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 710074218A0 for ; Tue, 30 Jun 2026 15:36:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782833801; cv=none; b=Ohe/uBWWnqv+RTBBN416pwG/KXYSufLkfMTSTHHDqbSSYFPGOdx/3kYNZl91bEq9n8buscrwoOCy4Q21HHQOj/pOV9DOKX7FFtrFsZ1AJw+rBACfhmfG4CYQMmz2EV2gubpqIbyZQEEJRWsdlPJ9kWSqzh46ehg/v3xTqQrUTvg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782833801; c=relaxed/simple; bh=4q0vaF5MWy51dKqmov1q9cdn3rNSzn7pdy35MyGzocg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=s68o11DFuvhbzzPWBNDBADFAWNLq0Gf3ArHZJ1SyABAJiHj6PEqdr6POdMqT1KJn74sfg/Gqeg641Y4QKaW4dQ6cWzYBKgf4n7JYlc9nzJAXePHAySOEUtKNdyycmOQbZ49KiCJ6fWVUUEFabIUh/l42HBLwY1bPkZdDUHuCglo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=RP94WKnf; arc=none smtp.client-ip=209.85.221.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="RP94WKnf" Received: by mail-vk1-f173.google.com with SMTP id 71dfb90a1353d-59e23d70dfaso1375548e0c.2 for ; Tue, 30 Jun 2026 08:36:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1782833799; x=1783438599; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=bOotVAkov7vZS3oHX7LedVS6qWxqMk2u2b36hVEW5oU=; b=RP94WKnfRTCy/TpaWkdV3RNT5G27v7kPEAq7EOUvEWp2kUDGVDxMkZYBBouYwQjWv+ ShgSFfRS6tbyrYIXn+cOH5BJU4yXIb6yxu8rGmyioQaiTAAYr96IS9IwfWl3WbELfw5n Fn9gE7ghQEzr/jVWwC07TokTMqgyMoMOzskSSvoIGsH3CVdotG3RFoFopQtk4RRw2Aap i30SrkiGajpRe9UYnZxWBWhpEcyxWkWHOsvbqc4cDApVLEsbcGk/fn1BOCKqSWssIO52 h8UwNV7SO3l/VDovZofaPVciBdo4606Ne7gde4AbWLI/QIpUqOGCWIVg/x1X9BprDVMZ mTPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782833799; x=1783438599; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bOotVAkov7vZS3oHX7LedVS6qWxqMk2u2b36hVEW5oU=; b=gANIxkZo6MtVHBGaU1lH8EKCViS/vfMYlQiJsA1oljDWjXA1Li49Gy0fYEh5d8DDff o1S2JQTO+EbyM3KKW8CPPgy7LNjxeLg4pjM9rGFrf5KIR+lovDMwxBYfViYMhdmoQA2D R9qOZof0gR82HuqnYP7VEU0yKUXepon/ShbZOGNQDHLcxnoKQMfKo4swvBL52fYp7azS x5mjFua5HR3OPQ2xtYnMoRi8/zKANUiqdJdjfkaTb+pzhvB/C3j57aGbRyDP8b4QJWL9 6lAsad/q7A+L4vM0i02ryrkJIwfldIG/pyZCs0CajJmsI9CqkHHcfQFAyFohBCpVGcCH SrIQ== X-Forwarded-Encrypted: i=1; AHgh+Rpq8USRKzrb+JXCHPIpdE/yAl8Ycn5eoIvaxMX4645BZ+6MAc/x6soq/NnCK/RTbWS0/t8Qy/Tq662Ca30=@vger.kernel.org X-Gm-Message-State: AOJu0Yxw2BsveIq4/o74oH7ZUaCiTJMyqFexf89+yciJ9xx5FeQTGIVP 52Pml99EG8UEGem7xB4MHXo/zF79GKyi/1q5iXfQ1wV4twQDotkX7HNFolacRwt1CWM= X-Gm-Gg: AfdE7ckItBnHjYS//7EJeKLvt5vGRGwGj820fk1jwaMJREi25VjizcrV1whxZWw/UPN HpLLzEhySsc1bLrGarUeMyX+c5svtI6qUfEPCd77xlaAOjYX4UN7xyZW5tb9wRA7YetgwTS//IH lwY9mYsPN6Ogw3wxag5MHjv3EACpqzoYV9nZ9lJRBzHGFOkPQ7o9560Dz0grRxPjrPGXl5PdiRb 4ZwRmNDT7JQb5mR3Nh3V7hBmmRggsh7xn5Hw++pocG1R8hEm0Emr3wVShvhrZsIA+7MTYstR5KP MdJug4WID3GxLBkSfHuZzt0TcyVRkIBHM/k1L4S+dgG6nuFMF0w0+4Qf9fdXVGmc9w4UxfotSGZ VwrRewRqJ3qGabDUjA7eXKS4pvf1nVE98gv4fPUPwHNxSla2kImKh9juKn1AXNd2kPUInlV6MKl vCOL4NMd5bQXkL0kGikS8Hg9WpWBcpc5Kd0i38yK09aWhWqq8pzXhO0KwGYgNCnsI2fZ8= X-Received: by 2002:a05:6122:6595:b0:5a0:afff:78a6 with SMTP id 71dfb90a1353d-5bdbee055cbmr1681151e0c.14.1782833799373; Tue, 30 Jun 2026 08:36:39 -0700 (PDT) Received: from ziepe.ca (crbknf0213w-47-54-130-67.pppoe-dynamic.high-speed.nl.bellaliant.net. [47.54.130.67]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8f1a69c283fsm27620016d6.26.2026.06.30.08.36.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2026 08:36:38 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1weaVq-000000024yv-0mtk; Tue, 30 Jun 2026 12:36:38 -0300 Date: Tue, 30 Jun 2026 12:36:38 -0300 From: Jason Gunthorpe To: Mike Rapoport Cc: Vlastimil Babka , Leon Romanovsky , Dennis Dalessandro , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rdma@vger.kernel.org Subject: Re: [PATCH 1/5] RDMA/umem: ib_umem_get(): use kmalloc() to allocate page array Message-ID: <20260630153638.GG7525@ziepe.ca> References: <20260630-b4-rdma-v1-0-ab42bcf0de92@kernel.org> <20260630-b4-rdma-v1-1-ab42bcf0de92@kernel.org> <20260630123150.GB7525@ziepe.ca> Precedence: bulk X-Mailing-List: linux-kernel@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: On Tue, Jun 30, 2026 at 06:01:17PM +0300, Mike Rapoport wrote: > (actually adding Vlastimil :) ) > > On Tue, Jun 30, 2026 at 06:00:24PM +0300, Mike Rapoport wrote: > > (adding Vlastimil) > > > > On Tue, Jun 30, 2026 at 09:31:50AM -0300, Jason Gunthorpe wrote: > > > On Tue, Jun 30, 2026 at 01:52:29PM +0300, Mike Rapoport (Microsoft) wrote: > > > > ib_umem_get() allocates an array of pointers to struct page for > > > > pin_user_pages_fast() calls during memory registration. > > > > > > A whole bunch of these use cases in rdma are really "give me some > > > temporary memory, I want it fast and as large as possible. In a > > > syscall context I will free it before returning back to userspace" > > > > Not sure I follow where "as large as possible" comes from. Here it's > > explicitly a page. It is a page because that is "fast" There will be a calculation what the upper limit of memory is that this algorithm can use. > > And does "fast" mean that vmalloc() is not an option? Yes. The trade off is you do fewer iterations of some loop if you have a bigger temporary buffer. But if it takes longer to allocate than the loop iterations then it doesn't help. > > > So, how would you feel about a new API? > > > > > > void *kmalloc_temporary(size_t min_size, size_t max_size, size_t *actual_size, gfp); > > > > > > I know of a few other cases like this in the kernel at least. > > > > > > The implementation could try to find an available high order page and > > > immediately return it, otherwise do a small reclaim allocation? > > > > How do you suggest to decide how much of reclaim should happen? > > With the usual semantics of gfp? Yeah, when all options are exhausted you do some allocation with the usual GFP options. Jason