From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) (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 24AA544C93 for ; Wed, 14 Aug 2024 21:10:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.43.22 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723669826; cv=none; b=gEgXxfdBHT6jWLrD3i7WKoCrj3SQOdP4kcnEc+8kZVYX3JTrfpMggkH8uCY0jopKB41HBjddvnmO90xKY1j2kNWoBO7zNsp7OVQ3m9UgTbVbnfcdTu09bUdnS41Nbhs3W9ZK9+XGhS2gCkFs/6l+cqkTOBoF6uoDG1qN+ec0fVQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723669826; c=relaxed/simple; bh=BUOPubvBNvWiovsd836uznv4khRkwVqGpe5OVPT0LDk=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lWfsEVmPdSAx5RRVqP2RwR5l45jlUgwjII1iDbe/gBu03LGIYoUopq+v2ako0eGWG9PBM9A2FRYjaG2eOU/ff697iC4QvAzG/NKn3NgyGQtaipq0dsMzenAC+Ww9+0Ex9Gx6/WCi6LbeNSoEGAUjZumkoCWvNc3HIt3Dz1L02NE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me; spf=pass smtp.mailfrom=proton.me; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b=Pxr28h/P; arc=none smtp.client-ip=185.70.43.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=proton.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b="Pxr28h/P" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1723669822; x=1723929022; bh=BUOPubvBNvWiovsd836uznv4khRkwVqGpe5OVPT0LDk=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=Pxr28h/P48Z7GbVpx1FH+zG9d1e2JToTdmQtRy103y9JnIzGnDZHnCAEeFlqGkAwA wotaHSeHwRWcvrKJPKmh/rYIRz4/DPAu6yig16iT1MEseRXszTJquArdFRGaVg4DrH BWOeFjVkJPxBwQhfhNIfWO6vZzS4g523YBn/Gyd0q2ZlOXV4uMxDGBrLqAd8xhMpR8 tcQY0Z+nX68hNajYmarAzyTQ+nd1/LZI6UJvriqIv5nDDEwoNPCwDbVnHwrapmpQZp mWQD5MSHVnEw3HXpF0zVKYtFc+AECMATlUnyvTKecoX0bnLQw3uubwWaD6HlojDJsl Odt6dH3y+9C2g== Date: Wed, 14 Aug 2024 21:10:19 +0000 To: Danilo Krummrich From: Benno Lossin Cc: ojeda@kernel.org, alex.gaynor@gmail.com, wedsonaf@gmail.com, boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com, a.hindborg@samsung.com, aliceryhl@google.com, akpm@linux-foundation.org, daniel.almeida@collabora.com, faith.ekstrand@collabora.com, boris.brezillon@collabora.com, lina@asahilina.net, mcanal@igalia.com, zhiw@nvidia.com, cjia@nvidia.com, jhubbard@nvidia.com, airlied@redhat.com, ajanulgu@redhat.com, lyude@redhat.com, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v5 04/26] rust: alloc: implement `Allocator` for `Kmalloc` Message-ID: In-Reply-To: References: <20240812182355.11641-1-dakr@kernel.org> <20240812182355.11641-5-dakr@kernel.org> <04b0fd96-c91c-4f38-90e9-8acee31e8445@proton.me> Feedback-ID: 71780778:user:proton X-Pm-Message-ID: 73eec96c4b72b2b0ae127de1c0a689aa229f6d5a 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-Transfer-Encoding: quoted-printable On 14.08.24 19:13, Danilo Krummrich wrote: > On Wed, Aug 14, 2024 at 04:28:04PM +0000, Benno Lossin wrote: >> On 12.08.24 20:22, Danilo Krummrich wrote: >>> +unsafe impl Allocator for Kmalloc { >> >> There is a missing SAFETY comment here (and also for Vmalloc, probably >> also for VKmalloc then). >=20 > Any suggestion on what to write here? >=20 > I'd probably come up with something like: >=20 > -- > Memory returned from `Kmalloc` remains valid until explicitly freed. >=20 > It is valid to pass any pointer to an allocated memory buffer obtained wi= th any > function of `Kmalloc` to any other function of `Kmalloc`. >=20 > If `Kmalloc::realloc` is called with a size of zero, the given memory > allocation, if any, is freed. >=20 > If `Kmalloc::realloc` is called with `None` it behaves like `Kmalloc::all= oc`, > i.e. a new memory allocation is created. > -- >=20 > and repeat that for `Vmalloc` and `KVmalloc`. >=20 > I'm not sure how useful that is though. Ideally you would write down how the guarantees are satisfied in addition to the invariants. But I guess this is only guaranteed by the `ReallocFunc::call`, since that handles the ZSTs... Maybe this is a bit excessive. If I come up with something better I will let you know. --- Cheers, Benno