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 7CAF3215F40; Mon, 17 Feb 2025 14:37:54 +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=1739803074; cv=none; b=sw//wOCdpLbdxRybw9O125H58wav9wLCivehuSvoy2PDzgsFyUknwbFFUFdybnmcitVGPMZ7zNXOGzblgfYKp+QLTbURcN4UyGPTW20rKyVb94QacR4Lz+aaWuQM6CuMn5JeQggHaX/4jdRKqn070oC589J7kScbniKWZvdnovs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739803074; c=relaxed/simple; bh=/OwhTvXO606OA4pqdHgVMbVF9fCjRmz8tESTQDrpLhw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LlSm8BUu2cA/kzc2dy0f0myMkhvoJny+aCGWQ1i8Wt+pVXdSez1aF4LMCQrU4wG1yp3/FuXd1lGK5Gd9ZCRCZMFl9iq8hTtNkP1+qx65B8+9C6COcFX92IHLVejWoxEI2HaUpNEN1q1ZwiqzTtRwjpELioKkkENPFaqTREiz2og= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qhBkePjH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qhBkePjH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91CADC4CEE9; Mon, 17 Feb 2025 14:37:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739803074; bh=/OwhTvXO606OA4pqdHgVMbVF9fCjRmz8tESTQDrpLhw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qhBkePjHukuGEqv8NyIXqXDPDDV6g0I8eFkKkKc+Rd2Sho2XK+uLSe8YWAuEwa+PU vhZuc5HNzWffTsZPbDezTUdLkASDk4JvMV0QKQvvUg8wEibV4RaergFyLy9ppRUxX7 CkmWMVNb5C9zJUHQicigF7XDY7y4ZKuvXtP7jeNJ2RhUgEbOu7AyCzkIwGWJv49WOl iZ+gKDcE6p/ZS5pqeiEnICVF+Xca3teZWK3F9e+Z04MIyYmt+HREEH/Go+BcaS+8fU 2MxpVpXUfT/lhmQvYVf7pDVw7ncyxPmIleji2bxyT++NWRMQ2CvAwfIFXin2rC6dIU gvouA5QrVUSNg== Date: Mon, 17 Feb 2025 15:37:46 +0100 From: Danilo Krummrich To: Tamir Duberstein Cc: Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Matthew Wilcox , Bjorn Helgaas , Greg Kroah-Hartman , "Rafael J. Wysocki" , FUJITA Tomonori , "Rob Herring (Arm)" , =?iso-8859-1?Q?Ma=EDra?= Canal , Asahi Lina , rust-for-linux@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Fiona Behrens Subject: Re: [PATCH v16 2/4] rust: types: add `ForeignOwnable::PointedTo` Message-ID: References: <20250207-rust-xarray-bindings-v16-0-256b0cf936bd@gmail.com> <20250207-rust-xarray-bindings-v16-2-256b0cf936bd@gmail.com> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Mon, Feb 17, 2025 at 09:21:00AM -0500, Tamir Duberstein wrote: > On Mon, Feb 17, 2025 at 9:15 AM Danilo Krummrich wrote: > > > > On Mon, Feb 17, 2025 at 09:02:12AM -0500, Tamir Duberstein wrote: > > > > > diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs > > > > > index 6c3bc14b42ad..eb25fabbff9c 100644 > > > > > --- a/rust/kernel/pci.rs > > > > > +++ b/rust/kernel/pci.rs > > > > > @@ -73,6 +73,7 @@ extern "C" fn probe_callback( > > > > > match T::probe(&mut pdev, info) { > > > > > Ok(data) => { > > > > > let data = data.into_foreign(); > > > > > + let data = data.cast(); > > > > > > > > Same here and below, see also [2]. > > > > > > You're the maintainer, > > > > This isn't true. I'm the original author, but I'm not an official maintainer of > > this code. :) > > > > > so I'll do what you ask here as well. I did it > > > this way because it avoids shadowing the git history with this change, > > > which I thought was the dominant preference. > > > > As mentioned in [2], if you do it the other way around first the "rust: types: > > add `ForeignOwnable::PointedTo`" patch and then the conversion to cast() it's > > even cleaner and less code to change. > > This is true for the two instances of `as _`, Yes, those are the ones I talk about. > but not for all the > other instances where currently there's no cast, but one is now > needed. > > > > > > > > I understand you like this style and I'm not saying it's wrong or forbidden and > > > > for code that you maintain such nits are entirely up to you as far as I'm > > > > concerned. > > > > > > > > But I also don't think there is a necessity to convert things to your preference > > > > wherever you touch existing code. > > > > > > This isn't a conversion, it's a choice made specifically to avoid > > > touching code that doesn't need to be touched (in this instance). > > > > See above. > > This doesn't address my point. I claim that > > @@ -246,6 +248,7 @@ impl VtableHelper { > ) -> c_int { > // SAFETY: The release call of a file owns the private data. > let private = unsafe { (*file).private_data }; > + let private = private.cast(); > // SAFETY: The release call of a file owns the private data. > let ptr = unsafe { ::from_foreign(private) }; > > is a better diff than > > @@ -245,7 +245,7 @@ impl VtableHelper { > file: *mut bindings::file, > ) -> c_int { > // SAFETY: The release call of a file owns the private data. > - let private = unsafe { (*file).private_data }; > + let private = unsafe { (*file).private_data }.cast(); > // SAFETY: The release call of a file owns the private data. > let ptr = unsafe { ::from_foreign(private) }; > > because it doesn't acquire the git blame on the existing line. I disagree with the *rationale*, because it would also mean that if I have let result = a + b; and it turns out that we're off by one later on, it'd be reasonable to change it to let result = a - b; let result = result + 1; in order to not acquire the git blame of the existing line. > > > > > > > > I already explicitly asked you not to do so in [3] and yet you did so while > > > > keeping my ACK. :( > > > > > > > > (Only saying the latter for reference, no need to send a new version of [3], > > > > otherwise I would have replied.) > > > > > > > > [2] https://lore.kernel.org/rust-for-linux/Z7MYNQgo28sr_4RS@cassiopeiae/ > > > > [3] https://lore.kernel.org/rust-for-linux/20250213-aligned-alloc-v7-1-d2a2d0be164b@gmail.com/ > > > > > > I will drop [2] and leave the `as _` casts in place to minimize > > > controversy here. > > > > As mentioned I think the conversion to cast() is great, just do it after this > > one and keep it a single line -- no controversy. :) > > The code compiles either way, so I'll leave it untouched rather than > risk being scolded for sneaking unrelated changes. Again, I never did that, but as already mentioned if it came across this way, please consider that I tell you now, that it wasn't meant to be. You're free to do the change (I encourage that), but that's of course up to you. Subsequently, I kindly ask you though to abstain from saying that I accused you of something or do scold you. Thanks!