From: Deborah Brouwer <deborah.brouwer@collabora.com>
To: Ke Sun <sunke@kylinos.cn>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
"Lorenzo Stoakes" <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
"Lyude Paul" <lyude@redhat.com>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Sami Tolvanen" <samitolvanen@google.com>,
rust-for-linux@vger.kernel.org, linux-mm@kvack.org,
dri-devel@lists.freedesktop.org, driver-core@lists.linux.dev,
linux-kernel@vger.kernel.org, "Alvin Sun" <alvin.sun@linux.dev>
Subject: Re: [PATCH v4 02/11] rust: mm: add `task_size` helper
Date: Thu, 22 Oct 2026 16:53:07 -0700 [thread overview]
Message-ID: <atqh41vrlC4xVtaj@um790> (raw)
In-Reply-To: <20261020-tyr-ioctls-v4-2-704de77da223@kylinos.cn>
On Tue, Oct 20, 2026 at 04:25:19PM +0800, Ke Sun wrote:
> From: Alvin Sun <alvin.sun@linux.dev>
I was testing Tyr's auto allocation for the user va range,
and was surprised to see that mm.task_size() is always returning 0.
It seems like it should work since it uses the task_size from
struct mm_struct, but it doesn't, at least for me.
If you look at tyr-dev, I think it would be better to use Sami's approach:
428d71932b6f rust: task: add task_size()
Sami creates a task_size() method for CurrentTask which is our equivalent
to the `current` global and then you can see that task_size becomes much
more clearly the equivalent of "TASK_SIZE_OF" used by panthor.
This approach also correctly returns a user va range when Tyr has to
assign it in my tests, so let's switch over.
>
> Expose the task's address space size. It is used by the Tyr driver
> for splitting a VM's GPU address space into user and kernel regions.
>
> Signed-off-by: Alvin Sun <alvin.sun@linux.dev>
> Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
> ---
> rust/kernel/mm.rs | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/rust/kernel/mm.rs b/rust/kernel/mm.rs
> index 4764d7b68f2a7..d2dfbb7d43972 100644
> --- a/rust/kernel/mm.rs
> +++ b/rust/kernel/mm.rs
> @@ -149,6 +149,13 @@ pub fn mmget_not_zero(&self) -> Option<ARef<MmWithUser>> {
> None
> }
> }
> +
> + /// The size of the process virtual address space.
> + #[inline]
> + pub fn task_size(&self) -> usize {
> + // SAFETY: `self.as_raw()` is a valid pointer to an `mm_struct` per the type invariants.
> + unsafe { (*self.as_raw()).__bindgen_anon_1.task_size }
> + }
> }
>
> // These methods require `mm_users` to be non-zero.
>
> --
> 2.43.0
>
next prev parent reply other threads:[~2026-10-22 23:53 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-20 8:25 [PATCH v4 00/11] drm/tyr: add VM and BO ioctl support Ke Sun via B4 Relay
2026-10-20 8:25 ` Ke Sun
2026-10-20 8:25 ` [PATCH v4 01/11] rust: sizes: add SZ_4G constant Ke Sun via B4 Relay
2026-10-20 8:25 ` Ke Sun
2026-10-20 8:25 ` [PATCH v4 02/11] rust: mm: add `task_size` helper Ke Sun via B4 Relay
2026-10-20 8:25 ` Ke Sun
2026-10-22 23:53 ` Deborah Brouwer [this message]
2026-10-23 11:53 ` Alice Ryhl
2026-10-20 8:25 ` [PATCH v4 03/11] rust: sync: arc: relax `ForeignOwnable` for `Arc<T>` Ke Sun via B4 Relay
2026-10-20 8:25 ` Ke Sun
2026-10-20 8:25 ` [PATCH v4 04/11] drm/tyr: add per-file VM pool Ke Sun via B4 Relay
2026-10-20 8:25 ` Ke Sun
2026-10-21 22:59 ` Deborah Brouwer
2026-10-20 8:25 ` [PATCH v4 05/11] drm/tyr: add user and MCU VM specifications Ke Sun via B4 Relay
2026-10-20 8:25 ` Ke Sun
2026-10-20 8:25 ` [PATCH v4 06/11] drm/tyr: add BO creation and lookup helpers Ke Sun via B4 Relay
2026-10-20 8:25 ` Ke Sun
2026-10-20 8:25 ` [PATCH v4 07/11] drm/tyr: add VM-related ioctls Ke Sun via B4 Relay
2026-10-20 8:25 ` Ke Sun
2026-10-20 8:25 ` [PATCH v4 08/11] drm/tyr: add BO-related ioctls Ke Sun via B4 Relay
2026-10-20 8:25 ` Ke Sun
2026-10-20 8:25 ` [PATCH v4 09/11] rust: device: expose the device DMA attribute Ke Sun via B4 Relay
2026-10-20 8:25 ` Ke Sun
2026-10-20 8:25 ` [PATCH v4 10/11] drm/tyr: gem: flush write-combine BOs from probe-time coherence Ke Sun via B4 Relay
2026-10-20 8:25 ` Ke Sun
2026-10-20 8:25 ` [PATCH v4 11/11] drm/tyr: gem: map cached BOs for DRM_PANTHOR_BO_WB_MMAP Ke Sun via B4 Relay
2026-10-20 8:25 ` Ke Sun
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=atqh41vrlC4xVtaj@um790 \
--to=deborah.brouwer@collabora.com \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=alvin.sun@linux.dev \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=driver-core@lists.linux.dev \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=lossin@kernel.org \
--cc=lyude@redhat.com \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=samitolvanen@google.com \
--cc=simona@ffwll.ch \
--cc=sunke@kylinos.cn \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.