From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 8D4283DB636; Mon, 17 Aug 2026 14:08:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786975697; cv=none; b=hO8qp58CU2n1FsWTSn1rXvoWPbu3NvhuJewn6Auf/g1BziP4ZF3Q19SAV5OpSOKjhCvlzL+MOXyMkX0dKK2Cbi0hraq9i4ZA2+O9lT21O6dIa4iamX5bPGxjCnY0o73DFgZxwyjXKqnFjh4peqRkzpJ83Y9p2ECLJ42lnl6/IhQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786975697; c=relaxed/simple; bh=xxy0gHLKhdxtuUAFYQ8rWUWihf1KnUG6LllOzkRyE90=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:To:From:Subject: References:In-Reply-To; b=UsWz+SInVghPGvsk3cnB29lYn7uMxCiVpNNN+oLqn2JqKgPWWpQiH1rT9u7MoG1CEt80EAGSeufRTTAzsXm6hJ52K4STX92Rai+v38KmrNU27IG39NKsV8XCtexBMI6MCsca32bWQSMmc2EP8WZAYA9GEn9FNhtz25bV6MhqVCY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Jtv/Vobn; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Jtv/Vobn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 264B91F00A3D; Mon, 17 Aug 2026 14:08:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786975696; bh=xxy0gHLKhdxtuUAFYQ8rWUWihf1KnUG6LllOzkRyE90=; h=Date:Cc:To:From:Subject:References:In-Reply-To; b=Jtv/Vobnmlg6DM04eaz2kLJKTht4m5jYkvnTMmQB+vxstfx4e1GVnc0h6yNLA3BKa s4JGuQrDe8RlhzVvoNU5J7pqSwVDMrOowrZHRp5YCh+07v4QnMW+vczzROYAXLS9mQ 5Eca6vSJ244zkNpfgGJKiUWRm1xC0mJmXDDmMoAhSBMcp/Yn0O24JSlMDY9NxVvCRY hW0Rn/iXpQKWJFrFWcmt/N6kDpcDYln5ZB03/t/OnSxaKMzbk3oorl1gA13vm5/qGm qoj4q5EX+ggSCBPU4PK/xrd1RE8vR2vAoWaO0yTe4q5xfNdt9/z+UyNyWK/SMk+0UD vaFH80nhpFfqA== Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 17 Aug 2026 16:08:09 +0200 Message-Id: Cc: "Eliot Courtney" , "Yury Norov" , "Alice Ryhl" , "Burak Emir" , "Yury Norov" , "Miguel Ojeda" , "Boqun Feng" , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , "Benno Lossin" , "Andreas Hindborg" , "Trevor Gross" , "Daniel Almeida" , "Tamir Duberstein" , "Alexandre Courbot" , =?utf-8?q?Onur_=C3=96zkan?= , "David Airlie" , "Simona Vetter" , "Greg Kroah-Hartman" , "John Hubbard" , "Alistair Popple" , "Timur Tabi" , "Zhi Wang" , , , , , "dri-devel" To: "Gary Guo" From: "Danilo Krummrich" Subject: Re: [PATCH v5 5/5] gpu: nova-core: add ChannelIdPool References: <20260812-chid-v5-0-6c767770b3f4@nvidia.com> <20260812-chid-v5-5-6c767770b3f4@nvidia.com> In-Reply-To: On Mon Aug 17, 2026 at 3:02 PM CEST, Gary Guo wrote: > Now, with `NonZero` or `Bounded`, we are doing none of that. The only thi= ng here > is that there is a range restriction. Other than the value restriction > themselves, they carry no other semantic meanings. How you interpret thes= e types > still fully depend on the API that accepts them. Therefore, it is very co= mmon > that you'd be using these with literals, and it becomes an ergnomic pain. I agree that NonZero and Bounded are on the weaker end of the argument. But there's still the flexibility argument. The API itself, i.e. alloc_area(), does not need to bother with how the val= ue is checked. I.e. is it a runtime check, compile or build time check, or is it = even unchecked (or panicking) because we can derive the invariant from another t= ype. > Personally I value ergnomics higher than possibility of misuse if latter = can > be easily mitigated otherwise (in this case, by WARN_ON or just support > zero-sized alloc). Both is not a mitigation IMO. WARN_ON() is does not prevent misuse of the API in the first place and in c= ase the value comes from userspace even introduces a vulnerability. Making zero a valid argument simply ignores the problem or just moves it elsewhere, e.g. where the caller has to validate the returned type instead,= i.e. the ChannelIdArea. IOW, we'd remove the invariant ChannelIdArea carries.