From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) (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 0FF31385EF0 for ; Tue, 10 Feb 2026 17:42:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.195 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770745360; cv=none; b=bd5wRMzrIIIr6nOMAcNzLCn0dUhTnUiz21QL/qvLESC154f4OGjPQI/osOzu0bxpmtCX9J1sma02lk+55e/+2vwBglPMsEEJVzqded0sgUuRV8G+TNnXEPTT3A8v/7uXMmTKSfvFq6KPjbFcrFprkK/KQqISxNzaE+nyun40E8E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770745360; c=relaxed/simple; bh=0Xhp2QGcmkmNyV+Fe0H7w4lIBDRyGvMa5Lcgo3QuUQs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=BgnGPaa6v/TVD6O6imTovgneaqAm/hF+YA0tsGuDZZvKaKJp9g8aoiMiOwwtxyP50B2Yba96tek/ZaKgQAQOpaW7e4pHwBT9VttrQw0HK5nUGuo5VPr6SkSHreIbHFlSrySmOUc5A9BZrbsXD7vQuwF+JbOKfF+R7z1Btfc6I7Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VjdGLvQL; arc=none smtp.client-ip=209.85.215.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VjdGLvQL" Received: by mail-pg1-f195.google.com with SMTP id 41be03b00d2f7-c0ec27cad8cso422278a12.1 for ; Tue, 10 Feb 2026 09:42:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770745358; x=1771350158; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=CO3zP9uq/ElKqAXO1nS8oSm6kxoOJrH5l2Qa2UH57+c=; b=VjdGLvQL6zcHQWGX5lJRxUwQ2SocXdHuzDH3j0cUdHAgjiu3wu+VZeBevidOMBnona jrfRb9o7NaaAS0K+UKWIG6FCvm88Y6rsA6NTSksiAwfGC+pHOb5odvKOo0Q5GtwB4S/d aEzO8VIzYZpMb02TcGfmh0CpEymAa+iAR8tSNfofSLtlZHHEHMTJizif0I740SX7N+C+ Km/XFFUnObiZOoCl8NC9Ga6n3qzdl9/vtzJieFAkblKHccZdYGjLlC4Zp8nKAI6IjDiI 2httZ7o1o2Qtv0UUnLRcGjmBTMpu+KyGIot8r5G7KODhIAJ65rCj7ZjZf3726v1rtvB0 VHvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770745358; x=1771350158; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=CO3zP9uq/ElKqAXO1nS8oSm6kxoOJrH5l2Qa2UH57+c=; b=KBqvfrvs3fekGDWO95DLtGeRw3BwH9jfZOCPAR6YUFbTesYBaAA+CcA8zxcJkXJ83W 3pS/A0BldfDzBY3zT5ljUqapJXCTNPP0MGQvAeg9FHNarGVxLPQ8OgUvglWvF3koq6Z5 pa5FyntXPt1ctEzTXfDuk+5jF5GNTb0h0dO6FZe6dWw3gxbtQ07RHMMw1EoLwfRJUaa/ AK9gYWV3v/PRcuaOPXHH1XQA2Itbq+Om/owx69tVhlY50jDuqHBcFmoms36kNC/lyNti AqwfcBBqd3iAR5rdnwMysvsF5LhTFSaxp7q2xMUlT8sSIeMX2s87xWWh9ftlw9wDPQ7Z DlSg== X-Forwarded-Encrypted: i=1; AJvYcCUPSfouCz79zXZ8IEZx8eciHWisYnIYDpHEfaa7N1W/fldxwEAzzUcdcQCbCrqaSNpV/DH0nt9TjvHzRZk=@vger.kernel.org X-Gm-Message-State: AOJu0Yyu3UrhJ48h70y9nnuUr7LIc8I1WDZmUukmlo9vclkyD7sMnoGa fu401nu65Ep8WBV8QKRJGO74iZRxZu8p9lWG4gspSQFxkxrWNhLncyXi X-Gm-Gg: AZuq6aKqTTWMebzvKS+q0grnaDcqhmmAdtZAKKp/8nFEoqKSnn/NxTlEBVQgBL80lPh vzXqPWe6T2XBdQtGqne9rxSmkFOTgGEpv9NlftMvU4qi4KA1BeD8dXr3vbYNGUvX2OiGvCSVbUy a26BlwmC9O6uPqQR1s2v5tBEeV0DJepQrmZK6CWEl3IlHzasExU1VJNatrgX1agMhG8K3KzhbW1 cQqvDyLwXCCMrYYBO306a9NRf421WvgwNUg6uOAqGGaMFdQZG5dNabMuop8L8zEt+yFYamfFeoe EMi0ATgdtelJHTao7AQFzDCNZyLBE6hi83vat6GS9X+D2GD5pGqkP7b0CW9uZaL7SlKVjN3Jefp O0JzNatQ/v284HyAJqswvGtxdWGP+kSDyZu5pbEES5iEueAyCm2iGiMfR/CcRxoxCP4WNqIb/wL LZeWyagTTnlL5aVeuxX6E5U1HNx/1fWUjQDir4OIQ+40+t7P1RSwxZuA== X-Received: by 2002:a17:90b:4b49:b0:341:124f:474f with SMTP id 98e67ed59e1d1-354b3e648acmr12936955a91.32.1770745358156; Tue, 10 Feb 2026 09:42:38 -0800 (PST) Received: from [192.168.116.129] ([49.205.43.62]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35662ebfde0sm3407207a91.15.2026.02.10.09.42.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 10 Feb 2026 09:42:37 -0800 (PST) Message-ID: Date: Tue, 10 Feb 2026 23:12:30 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 0/4] rust: alloc: add Vec shrinking methods To: Danilo Krummrich , Alice Ryhl Cc: Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Miguel Ojeda , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Trevor Gross , Greg Kroah-Hartman , =?UTF-8?Q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Christian Brauner , Carlos Llamas , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org References: <20260207-binder-shrink-vec-v3-v3-0-8ff388563427@cock.li> <0d336a3f-f317-4a70-942a-d87a3faa3a89@gmail.com> Content-Language: en-US From: Shivam Kalra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 10/02/26 20:35, Danilo Krummrich wrote: > On Tue Feb 10, 2026 at 2:57 PM CET, Alice Ryhl wrote: >> On Tue, Feb 10, 2026 at 07:08:09PM +0530, Shivam Kalra wrote: >>> This is a follow-up to my v3 series: >>> https://lore.kernel.org/rust-for-linux/20260207-binder-shrink-vec-v3-v3-0-8ff388563427@cock.li/ >>> >>> Hi all, >>> >>> Thanks for the feedback on v3. Before I respin, I want to confirm >>> the direction for v4 to avoid unnecessary iterations. >>> >>> Proposed changes for v4: >>> >>> 1. Drop the Shrinkable trait entirely. Make shrink_to() a normal >>> method on Vec that calls A::realloc(). (Danilo) >>> >>> 2. Add a temporary ShrinkQuirk trait to handle the vmalloc workaround >>> (page-boundary check + manual alloc+copy+free) until vrealloc >>> gains in-place shrinking support. (Danilo) >> >> I don't think you want any new traits at all. What types would even >> implement the trait? The special code can go in the realloc() method of >> Vmalloc struct in rust/kernel/alloc/allocator.rs. > > I did not propose to move this into the realloc() functions of the corresponding > allocators intentionally, as there is a difference between calling realloc() and > shrink_to(). > > I don't want that some user of e.g. Vmalloc::realloc() experiences page wise > shrinking by copy. This is acceptable for Vec::shrink_to(), but not for > realloc() in general. I think this aligns with the reasoning behind the Shrinkable trait in v3- keeping the shrink workaround separate from realloc() so that other users of realloc() (like IntoIter) don't unexpectedly get alloc+copy+free behavior. Happy to implement whichever approach you both agree on.