public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: "Danilo Krummrich" <dakr@kernel.org>
To: "Alice Ryhl" <aliceryhl@google.com>
Cc: "Shivam Kalra" <shivamklr@cock.li>, <cmllamas@google.com>,
	<gregkh@linuxfoundation.org>, <rust-for-linux@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <lorenzo.stoakes@oracle.com>,
	<vbabka@suse.cz>, <Liam.Howlett@oracle.com>, <urezki@gmail.com>
Subject: Re: [PATCH v2 1/3] rust: alloc: Add shrink_to and shrink_to_fit methods to Vec
Date: Wed, 04 Feb 2026 12:50:37 +0100	[thread overview]
Message-ID: <DG65LJ401SCS.S5LFKDR4AEE1@kernel.org> (raw)
In-Reply-To: <aYMgWr6iDTus0vDE@google.com>

On Wed Feb 4, 2026 at 11:32 AM CET, Alice Ryhl wrote:
> I would kind of prefer that we do this in two steps. First have
> shrink_to() use the implementation it does right now. Then a follow-up
> patch fix the TODOs in vrealloc().

This is fine with me as a short term workaround, but we should only do the full
copy under certain conditions only:

  (1) is_vmalloc_addr() returns true.

  (2) The new size of the allocation requires at least one page less in total.

I.e. if it is a kmalloc() buffer we don't do anything. And if it's a vmalloc()
buffer, we only shrink if we can get rid of at least one page, since otherwise
there are no savings effectively.

Shivam do you plan to follow up on the vrealloc() TODOs subsequently?

  reply	other threads:[~2026-02-04 11:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-31 15:40 [PATCH v2 0/3] rust: alloc: add Vec shrinking methods Shivam Kalra
2026-01-31 15:40 ` [PATCH v2 1/3] rust: alloc: Add shrink_to and shrink_to_fit methods to Vec Shivam Kalra
2026-02-03 15:19   ` Danilo Krummrich
2026-02-03 15:38     ` Alice Ryhl
2026-02-03 15:43       ` Danilo Krummrich
2026-02-03 17:48         ` Shivam Kalra
2026-02-04 10:32           ` Alice Ryhl
2026-02-04 11:50             ` Danilo Krummrich [this message]
2026-02-04 21:55               ` Shivam Kalra
2026-01-31 15:40 ` [PATCH v2 2/3] rust: alloc: add KUnit tests for Vec shrinking Shivam Kalra
2026-02-01  0:08 ` [PATCH v2 3/3] binder: context: shrink all_procs vector to reclaim memory Shivam Kalra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DG65LJ401SCS.S5LFKDR4AEE1@kernel.org \
    --to=dakr@kernel.org \
    --cc=Liam.Howlett@oracle.com \
    --cc=aliceryhl@google.com \
    --cc=cmllamas@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=shivamklr@cock.li \
    --cc=urezki@gmail.com \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox