From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 30D49212554 for ; Wed, 22 Apr 2026 13:03:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776862994; cv=none; b=Imzyxq0nTvQbcu0o9/LYN46pdrREW8ImDxg2r9CicJYTvde9ymRHsuhbfCgU+D8EdRmkjOdVXj13FHlcoT7jLu0LtOBkCaEFXuOBIe4eBAsnyLdgUkU8aw6mPmG8mxqP1cTUWAhirylWRkhHbtEH36/kd1oD9FlNEGAN6ow42Ic= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776862994; c=relaxed/simple; bh=GBN3jwDn6bo4Tibm1BrX0MIn2ftYBAN5f5do3Y3FhPk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=oUdul+QvMir74F3FYddQny187/AIjh39P6GPQraL5zHMbHCxfQF+ZDKIvkzC/QZNrWj4EnRQZ7oqEP5J6TuQDtsd3YjZurwoH4lZbO3DMyI4lS0TOP2m9zI4mPbqFokBtl/9wr3Gi1sFMjAULwo4twaTg1gomq0MyTrmj93YNr0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=bC0asDaL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="bC0asDaL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26828C19425; Wed, 22 Apr 2026 13:03:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776862993; bh=GBN3jwDn6bo4Tibm1BrX0MIn2ftYBAN5f5do3Y3FhPk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bC0asDaLNTu2iSdNA8WmsfSl4/kzLELsMVxfoXFooFBtASZiGpI0J4Yh2T1LoXC2E rWPdXRlMBbqiAoLOztXCR6VcMxc5SusDTxh++JkPbUmvDEOwfdL2cAJUDkmS9juf/z 9+qHmgAh2Np2JYErANk6iizXQ6UkGCXi8KYEcHMY= Date: Wed, 22 Apr 2026 15:03:11 +0200 From: Greg Kroah-Hartman To: Jens Axboe Cc: io-uring@vger.kernel.org Subject: Re: [PATCH] io_uring: take page references for NOMMU pbuf_ring mmaps Message-ID: <2026042236-alienable-lilac-f857@gregkh> References: <2026042115-body-attention-d15b@gregkh> <177679318887.642042.703437019420919449.b4-ty@b4> <9c20876f-1cdb-429a-abb3-5ddbcd8cac00@kernel.dk> <2026042205-coroner-animosity-51b2@gregkh> Precedence: bulk X-Mailing-List: io-uring@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 Wed, Apr 22, 2026 at 06:40:37AM -0600, Jens Axboe wrote: > On 4/22/26 2:11 AM, Greg Kroah-Hartman wrote: > > On Tue, Apr 21, 2026 at 08:26:08PM -0600, Jens Axboe wrote: > >> On 4/21/26 7:56 PM, Jens Axboe wrote: > >>> On 4/21/26 7:17 PM, Jens Axboe wrote: > >>>> On 4/21/26 11:39 AM, Jens Axboe wrote: > >>>>> > >>>>> On Tue, 21 Apr 2026 15:46:16 +0200, Greg Kroah-Hartman wrote: > >>>>>> Under !CONFIG_MMU, io_uring_get_unmapped_area() returns the kernel > >>>>>> virtual address of the io_mapped_region's backing pages directly; > >>>>>> the user's VMA aliases the kernel allocation. io_uring_mmap() then > >>>>>> just returns 0 -- it takes no page references. > >>>>>> > >>>>>> The CONFIG_MMU path uses vm_insert_pages(), which takes a reference on > >>>>>> each inserted page. Those references are released when the VMA is torn > >>>>>> down (zap_pte_range -> put_page). io_free_region() -> release_pages() > >>>>>> drops the io_uring-side references, but the pages survive until munmap > >>>>>> drops the VMA-side references. > >>>>>> > >>>>>> [...] > >>>>> > >>>>> Applied, thanks! > >>>>> > >>>>> [1/1] io_uring: take page references for NOMMU pbuf_ring mmaps > >>>>> commit: d9b7b3d9c5286a786c7fe8220c55a6e012088c2e > >>>> > >>>> Actually, I take that back - what prevents the io_mmap_get_region() > >>>> in the newly added io_uring_nommu_vm_close() from getting the same > >>>> region that we initially referenced the pages from in the nommu > >>>> variant of io_uring_mmap()? > >>> > >>> I think we can get rid of that and simplify the code at the same > >>> time. Rather than need to re-lookup the buffer list, we can just iterate > >>> the pages mapped in the vma. Since this is a file backed mapping and > >>> io_uring doesn't allow remaps, that should always be the same. > >>> > >>> Greg, can you test this? I will fold this in. > >> > >> Here's the full patch - the incremental was missing a ')'. And > >> for good measure, ensure that the vma size matches the pages in > >> the region. > > > > Yes, this works, thanks! > > > > Tested-by: Greg Kroah-Hartman > > I kept your attribution with the changes folded in, it's here > since last night: > > https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux.git/commit/?h=io_uring-7.1&id=d0be8884f56b0b800cd8966e37ce23417cd5044e > > Let me know if that's still fine with you. No objection at all, looks fine, thanks. And sorry for this, no-mmu is odd, hopefully the 3 users of it and io_uring are thankful for this work :) greg k-h