From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.71 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795958499; b=3AjFSYSqXHFAe0EibQpFAPTfp52ooNWIs6Je02pMGLqcKeQDM3E7sA5IrxnKLTaETwX9 u4Qz3tsFVHp2Gb2vjus+YRMPZgbwD1VTuN0FzvmOlPYXtjhWHPBz702SD8WnO3JgCW1c2 rVqFkg/ITHjwGflKdlKfn8ApKoBBRWTfzabo8niDbkWrRX+gaJddtytCB1QZch5GUBv3s ixY9GDQ3U8cgrYo2rzRmvZz6x4pyQsYu5kEMe8W4p+hPPQbPnoknPYUSCVCBA897rDhh9 hTppbWJcfJb+fKWQybaXlV9qAi4SCsekz8Ml2jDNT6glAJmlwXSFGUWvlI/KfhQhvwQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795958499; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=l2pdzxlYFK52lnZbi1luqb7V+baNNWN9bahHf7ew6Uo=; b=A8uqvPFSXyAOzPaB+epA+OaJIQipGr9WdNbURroFN2ExfbfF6v1eS1IVbQCUY65gg/xZ +JgnCn+Wp55wjt3RkwV3AZIc2w3XvjwYdOPgR1OQq7SCMC1bOj8MlxcY4RFCJhrKOeMjQ 4FJt7esU+oLigaHE7Ua+ga3M1jHP4phc0fs6ngwhQvLiCxNlRVqtkFPXChXarhAK9OH+L 8Q9eCn4WsNk3+HIRyqFIpBShD7KUMPuVWG3Yq5yZwi6x9szPyoyW0pmnrg1sQL8WQb8/x t4bmwr+iTVfYlE8x19hPx2wWSAwKkegsqvthYbg7jnFbBRsY3wrIVAxFh7110Y2rlVw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=MSuAs+nj; arc=none smtp.remote-ip=209.85.128.71 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE61E606A323 for ; Sun, 29 Nov 2026 13:21:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EE61E606A323 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=MSuAs+nj Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4a204f135ffso49136885e9.1 for ; Sun, 29 Nov 2026 05:21:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1795958497; x=1796563297; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=l2pdzxlYFK52lnZbi1luqb7V+baNNWN9bahHf7ew6Uo=; b=MSuAs+njJhJoD2mcoq1Cv/HIK6CKDjmm08foo4XJ9hq0lDUS1wKGjXFOCcAZseLT4O Iygew20gIDkDBpjdO5bpLVz+YxfHg/GnFbc23queFR91ZrrpDCz4NbokDkat/i0jkDBu /DWOSB7GQj1b2CwF9drMHCcWhAKub6IprjhxLaVReSanHRZyM+oW7bggD0c1uyjzTjPM /7/rVwt/ycu2J37qqdGPZvXhoWmQewQIrRL3T869CTszqMQ5vFrywVenNkHvzGYBXXmM uoBtl3ERZISeLxPVjy2qSBW3kbtyPWsjC+5XjLgkNbc1/NvT74WdLBiSHDpVOcav+lMe NUYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795958497; x=1796563297; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=l2pdzxlYFK52lnZbi1luqb7V+baNNWN9bahHf7ew6Uo=; b=kebQAMkmX0TxA1C+rT2t4D7cGh8JF71Nn0MUDpWTbJzsXOnzMvwBWGi9wBhvRVccFs FC/DO0S3OKxRpcuCKyPMp2+w/2U2PISPE9CLNM8fwC9BHsZMdmm5tzeZk7+0VZ17UWXi AXzNfq6fzpdB1m9r3AtEbCryfsMKX8TcCv7T8pA8BhPHx8l8geHOi1kur5z/wMu4CYWc H6JJMTTpYZuqJHuR2UIekjKziju8ujU2LUwyhLPJY9HsBdLneRzOWgG0E0hLXfRvyoQU 8b1TF7du4dnzmKWJR3cPrh6dYMOrkrgY3ovdH/PX1bSUYPR0LSeuGPjyFhcuLb63DQgL GFcA== X-Forwarded-Encrypted: i=1; AL+hErFDQW8R4AoWHN9XKVfFLIWx8Bmmw6999DiKfu+03bNsUmIJL1W+xIqeIc3WtAJ9+Vs/lEJfyToRa9Z7l8E=@vger.kernel.org X-Gm-Message-State: APuU4Z+ReguwKuUiMFPh61u4zl3BwlaDvxGQ5mXjwKvITWHdTKIDyfE3 EZPPs9J2uH6nAp978wvxm5ssgTtNXh4zs5ntfwHlr+mDfY9U5dMn7NJoU2tbXIoNElb/AVxgK8S 9wzjg042Z6Oe5IUy4sA== X-Received: from wrpq17.prod.google.com ([2002:adf:f791:0:b0:4a4:35d8:cd7b]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:a55:b0:49f:ce78:356d with SMTP id 5b1f17b1804b1-4bb88827db0mr651650295e9.30.1795958497100; Sun, 29 Nov 2026 05:21:37 -0800 (PST) Date: Sun, 29 Nov 2026 13:21:36 +0000 In-Reply-To: <20261126-perf-binder-range-allocator-v1-1-7d924585d735@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261126-perf-binder-range-allocator-v1-1-7d924585d735@gmail.com> X-Mailer: git-send-email 2.56.1.839.g22a8290db9-goog Message-ID: <20261129132136.1489927-1-aliceryhl@google.com> Subject: Re: [PATCH] rust_binder: Reuse the free-index node in the range allocator From: Alice Ryhl To: Peder Bergan Cc: Alice Ryhl , Carlos Llamas , Greg Kroah-Hartman , "=?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?=" , Todd Kjos , Christian Brauner , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" On Thu, Nov 26, 2026 at 07:06:03PM +0100, Peder Bergan wrote: > Convert the detached node into an RBTreeNodeReservation and store it > with the buffer. The release path can initialize the key after > coalescing the range. This reduces preparation from three fresh node > allocations to two and avoids one free under the process spinlock > per successful tree reservation, for both exact fits and splits. Nice optimization, thanks! > + // Keep the removed index node so releasing this buffer can restore a free range > + // without allocating under the lock. > + let free_node_res = self > + .free_tree > + .remove_node(&(found_size, found_off)) > + .ok_or(EINVAL)? > + .into_reservation(); > + desc.state = Some((DescriptorState::new(is_oneway, debug_id, pid), free_node_res)); Please run `rustfmt` on drivers/android/binder/range_alloc/tree.rs. Also, optionally, you could use `self.free_tree.cursor_lower_bound_mut()` and `cursor.remove_current().1.into_reservation()` to avoid the second `free_tree` lookup and the unreachable `EINVAL` path, though I'm fine with either approach. With the `rustfmt` diff fixed, feel free to add: Reviewed-by: Alice Ryhl Alice