From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 EE0D82D9EDC for ; Thu, 24 Jul 2025 16:05:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753373134; cv=none; b=fjDpydxNQ5ZhzpNUCr+hsQa83/aD55Ggo3YNJp55qPZNUgMQV6rHTfFkmI0hZLmeoFw9fmTi/IoCiHvSFtVRjj4LR86MqHeWqez1paOd74DjnSJUEfxW1EAh9BVbzNqrhPT6nEGqeIUQbcJ1Cmku/vVZ/c6i3+WWNXGwKhLtvZ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753373134; c=relaxed/simple; bh=0VUcTAlTKI8Uut+YrFJ9JnFPeuS1MyI+ehjEzU6u9SU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BSXLSZIa3X/rsVI4n6uxnUWbWZkCr7eKTpxE4n/8f5aw2Zxkg7YLsfZA4boQkVRytS5R23vQ51L3tyGxTuHkwMb8adZ9pcjxtTbg0vSZRDdaT3x9VKEXoIwukrVXB/f68y9hTjyi0JXyF2ea4zcaP4QEOqU2eEyU9HXD6N/xnR8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=furiosa.ai; spf=none smtp.mailfrom=furiosa.ai; dkim=pass (1024-bit key) header.d=furiosa.ai header.i=@furiosa.ai header.b=RTcZwWK0; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=furiosa.ai Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=furiosa.ai Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=furiosa.ai header.i=@furiosa.ai header.b="RTcZwWK0" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-235ea292956so10843015ad.1 for ; Thu, 24 Jul 2025 09:05:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=furiosa.ai; s=google; t=1753373132; x=1753977932; 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=lPrDAQdM9SEh1PC8EgiE1RAI5sFJN3A+tD++JaDKFmM=; b=RTcZwWK08KSyMDVKrfSebH8hoeuDIYUlw5feYTyayOgg2QYqwsMAVXlRuzUHzT0gGa zh97hlaBLZd6JXnHS0NFBzg6Rph+ttaux0ByZIzet+MyJ9aSITzw04sUx4UlSlA2FSim GofF3h7y09FlPRUGLA0dt1gPfICTmVsgF8I/0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753373132; x=1753977932; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=lPrDAQdM9SEh1PC8EgiE1RAI5sFJN3A+tD++JaDKFmM=; b=giHthBeXwgK+sDClIUqAZ/IgZjfQxBNbT135mcg1j9T7Gsn3cKDdeDOFlYB7RkajTS YO5IVITyh3TAkZetW7Sk40TmbQtPcA9nyYprGVueB9d+Ic4QM5+NDb4iBOoZVOoxeO87 4UB1iAQZEIFJ4rT6CoHaux67o21KRhR1N+YeWMQEzQmSuqtx5b4ltoMsC5swoLMxskbY OhRqMDPlkpLcja9htjPrMdqRCCmtPQtrAQvEhdF9b3uauDt/cfDbOneyiMjBDNdyFKyd /ttJPGwncH8KywnkH876A+o4BEvEzjc07YhLTnck2li1DYwzTdUB82cxdW/eT4wd4+JM jv2A== X-Forwarded-Encrypted: i=1; AJvYcCXG4bN+gm345JbgYn5KLUMLwtW7guB0xrrseqyp6oDi5aoOez2eBinfZq8ciOwys2oxS641aa8s0rOw9KDz9Q==@vger.kernel.org X-Gm-Message-State: AOJu0YyLwwZ7844o2+ygq5ayTJHcPD3q+r032F7xln0vxNtAEBc6L9Hf 1U3sSDeJkU06nz9MM1hiN6Lkaw837Ez2oATHNvT7aQuAmNUyB7YS/LbubSlSb7kwKKE= X-Gm-Gg: ASbGncvPJxSpwup8DyOQQI33vsYW7F04dkaYW/MgQA5Dl7Wry8gX+wUyQVqxOqgJaY1 4pIJTtDgP1nQrHDh6uA79YV9D5QU33xosz/eb9GDBQXKjDCT/MpZtbWqmRH3+zIQ+/GNT9tHyUr 09ZzyJqwCBr9duZyh0TuJp54ARAdDkqG425Zr1i4LMiwpHGu8A12eXi4qHgxSomQqFC4UxmWEP/ 4Sz7tK9Bg4eNXOhqQVSF2mnqGHgOke/Q5WuPvjVUlKuAwqR4WPvcwVBd1xmcZCBRZ76+cX+eM8s 6tEWuALUdTn0fXm4cG5WIry39ojY0kTdbTIH8VH31F17rN5M3DI/Qud8+qJ4zjeOloNrFV8nYgi Kj3J4CzdTsJ08JWQ4uhent/2MHyM4H7A1OgDjUkHJIJ1yh68JxU0B+9tx X-Google-Smtp-Source: AGHT+IFOb7VV+hEvYr5JMOJR9pYJzMfOIn04UMDsdukQyZlKdVzKoT94AbgXvi68H4CvfhuA1xh5ag== X-Received: by 2002:a17:902:d2ca:b0:234:8c64:7885 with SMTP id d9443c01a7336-23f981efd84mr99141955ad.53.1753373132037; Thu, 24 Jul 2025 09:05:32 -0700 (PDT) Received: from sidongui-MacBookPro.local ([175.195.128.78]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23fa475f3d3sm18905165ad.40.2025.07.24.09.05.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 09:05:31 -0700 (PDT) Date: Fri, 25 Jul 2025 01:05:10 +0900 From: Sidong Yang To: Benno Lossin Cc: Caleb Sander Mateos , Miguel Ojeda , Arnd Bergmann , Jens Axboe , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, io-uring@vger.kernel.org Subject: Re: [PATCH 2/4] rust: io_uring: introduce rust abstraction for io-uring cmd Message-ID: References: <20250719143358.22363-1-sidong.yang@furiosa.ai> <20250719143358.22363-3-sidong.yang@furiosa.ai> Precedence: bulk X-Mailing-List: rust-for-linux@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, Jul 22, 2025 at 08:52:05PM +0200, Benno Lossin wrote: > On Tue Jul 22, 2025 at 4:30 PM CEST, Sidong Yang wrote: > > On Mon, Jul 21, 2025 at 06:28:09PM +0200, Benno Lossin wrote: > >> On Mon Jul 21, 2025 at 5:47 PM CEST, Sidong Yang wrote: > >> > It's safest to get NonNull from from_raw and it returns > >> > Pin<&mut IoUringCmd>. > >> > >> I don't think you need `NonNull`. > > > > NonNull gurantees that it's not null. It could be also dangling but it's > > safer than *mut T. Could you tell me why I don't need it? > > Raw pointers have better ergonomics and if you're just passing it back > into ffi, I don't see the point of using `NonNull`... Agreed, from_raw() would be called in rust kernel unsafe condition not in safe driver. Thinking it over, using a raw pointer would be convenient. > > >> > from_raw() name is weird. it should be from_nonnnull()? Also, done() > >> > would get Pin<&mut Self>. > >> > >> That sounds reasonable. > >> > >> Are you certain that it's an exclusive reference? > > > > As far as I know, yes. > > So the `IoUringCmd` is not refcounted and it is also not owned by the > `done` callee? Yes, io_uring_cmd would be allocated in io_submit_sqes() and it's not accessed concurrently. io_uring_cmd_done() sets its result to io_uring_cmd and prepare some field to completion. Thanks, Sidong > > --- > Cheers, > Benno