From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 A89F236C9C1 for ; Tue, 7 Apr 2026 02:39:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775529543; cv=none; b=qDLLGkD8twXNibSLBOybgsxZxsXfccO6B3ncAMzcXxqgB0TxgDI4kNk8tObCmUcGEa3DZzDCTzCc5xXRnXPiJavHwWLzDde0hA3yHO0Uvt3FRjqYOdIO/Sjlk4QYuEPkK4afA2jHTpJjv64Q1A9P9r1rEVUw2WqqKNpW/AbAm8o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775529543; c=relaxed/simple; bh=mE2GiIstfDJqfzgPfG0hJe+MDh582+G/cxSUX9uSz8Y=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=lBx8WQD3UsOPo6V2Ch38uDx+wQiMIRs7ylvATvTv56HPSO5W/rtw7PV5FJtvjinsrjDhHK8zZpdbfHX3Ar5roZ4rIxJT+1IcEgJ/bEOheOLu+Y7mYTfpNC9/uLgn2XmgoAj+hLxEJoPxWOgRZY385C3i59yF47A+Am/QWayMiwA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Q0ypKFHz; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Q0ypKFHz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775529540; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hypC+HKSrSaxIfKWAvyWqRZO752rr8Ufa1l6Jn48w0g=; b=Q0ypKFHz+LSDLSShEVY0EngHZzgELNjXnwswoYDGai0kxRv56QFWyvWHMfStuzrFAiN/r5 5fQR8J9Oz2txy4BQe74DK9fZHF6FimN2xxOPobKrn4bvhQ6cSc/juPNWcpdjd/Y01skyYF RbWepRvfr6jyN0cm645ykqjhXntjvkY= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-696-R1gcwJoLORKRDwdpb5rhSw-1; Mon, 06 Apr 2026 22:38:57 -0400 X-MC-Unique: R1gcwJoLORKRDwdpb5rhSw-1 X-Mimecast-MFC-AGG-ID: R1gcwJoLORKRDwdpb5rhSw_1775529536 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D6E4F1956080; Tue, 7 Apr 2026 02:38:55 +0000 (UTC) Received: from fedora (unknown [10.72.116.2]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 333E018001FE; Tue, 7 Apr 2026 02:38:52 +0000 (UTC) Date: Tue, 7 Apr 2026 10:38:47 +0800 From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org Cc: Caleb Sander Mateos Subject: Re: [PATCH v2 00/10] ublk: add shared memory zero-copy support Message-ID: References: <20260331153207.3635125-1-ming.lei@redhat.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260331153207.3635125-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 On Tue, Mar 31, 2026 at 11:31:51PM +0800, Ming Lei wrote: > Hello, > > Add shared memory based zero-copy (UBLK_F_SHMEM_ZC) support for ublk. > > The ublk server and its client share a memory region (e.g. memfd or > hugetlbfs file) via MAP_SHARED mmap. The server registers this region > with the kernel via UBLK_U_CMD_REG_BUF, which pins the pages and > builds a PFN maple tree. When I/O arrives, the driver looks up bio > pages in the maple tree — if they match registered buffer pages, the > data is used directly without copying. > > Please see details on document added in patch 3. > > Patches 1-4 implement the kernel side: > - buffer register/unregister control commands with PFN coalescing, > including read-only buffer support (UBLK_SHMEM_BUF_READ_ONLY) > - PFN-based matching in the I/O path, with enforcement that read-only > buffers reject non-WRITE requests > - UBLK_F_SHMEM_ZC feature flag > - eliminate permanent pages[] array from struct ublk_buf; the maple > tree already stores PFN ranges, so pages[] becomes temporary > > Patches 5-10 add kublk (selftest server) support and tests: > - hugetlbfs buffer sharing (both kublk and fio mmap the same file) > - null target and loop target tests with fio verify > - filesystem-level test (ext4 on ublk, fio verify on a file) > - read-only buffer registration test (--rdonly_shmem_buf) > > Changes since V1: > - rename struct ublk_buf_reg to struct ublk_shmem_buf_reg, add __u32 > flags field for extensibility, narrow __u64 len to __u32 (max 4GB > per UBLK_SHMEM_ZC_OFF_MASK), remove __u32 reserved (patch 1) > - add UBLK_SHMEM_BUF_READ_ONLY flag: pin pages without FOLL_WRITE, > enabling registration of write-sealed memfd buffers (patch 1) > - use backward-compatible struct reading: memset zero + copy > min(header->len, sizeof(struct)) (patch 1) > - reorder struct ublk_buf_range fields for better packing (16 bytes > vs 24 bytes), change buf_index to unsigned short, add unsigned short > flags to store per-range read-only state (patch 1) > - enforce read-only buffer semantics in ublk_try_buf_match(): reject > non-WRITE requests on read-only buffers since READ I/O needs to > write data into the buffer (patch 2) > - narrow struct ublk_buf::nr_pages to unsigned int, narrow struct > ublk_buf_range::base_offset to unsigned int (patch 1) > - add new patch 4: eliminate permanent pages[] array from struct > ublk_buf — recover struct page pointers via pfn_to_page() from the > maple tree during unregistration, saving 2MB per 1GB buffer > - add UBLK_F_SHMEM_ZC to feat_map in kublk (patch 5) > - add new patch 10: read-only buffer registration selftest with > --rdonly_shmem_buf option on null target + hugetlbfs Hello, Ping... thanks, Ming