Skip to contentSkip to conversation

rust: page: mark Page::nid as inline

PATCH Applied Nakamura Shuta 3 participants 3 messages May 29

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rust: page: mark Page::nid as inline

When building the kernel, the following Rust symbol is generated:

  $ nm vmlinux | grep ' _R'.*Page | rustfilt
  <kernel::page::Page>::nid

Page::nid is a trivial wrapper around the C function page_to_nid. It does not make sense to go through a trivial wrapper for this function, so mark it inline.

This follows commit 878620c5a93a ("rust: page: optimize rust symbol generation for Page"), which did the same for alloc_page and drop.

---
 rust/kernel/page.rs | 1 +
 1 file changed, 1 insertion(+)
rust/kernel/page.rs +1 -0
index adecb200c654..764bb5acc90a 100644
@@ -193,6 +193,7 @@ pub fn as_ptr(&self) -> *mut bindings::page {
     }
 
     /// Get the node id containing this page.
+    #[inline]
     pub fn nid(&self) -> i32 {
         // SAFETY: Always safe to call with a valid page.
         unsafe { bindings::page_to_nid(self.as_ptr()) }

base-commit: 72d33b8bfeacbfdccf2cda4650e8e002def036f8

Signature · 1 line
2.51.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Nakamura Shuta

When building the kernel, the following Rust symbol is generated:

  $ nm vmlinux | grep ' _R'.*Page | rustfilt
  <kernel::page::Page>::nid

Page::nid is a trivial wrapper around the C function page_to_nid. It does not make sense to go through a trivial wrapper for this function, so mark it inline.

Quoted 5 lines

This follows commit 878620c5a93a ("rust: page: optimize rust symbol generation for Page"), which did the same for alloc_page and drop.

Andrew, can you pick this? Thanks!

reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to Nakamura Shuta
Quoted 9 lines · Nakamura Shuta

When building the kernel, the following Rust symbol is generated:

  $ nm vmlinux | grep ' _R'.*Page | rustfilt
  <kernel::page::Page>::nid

Page::nid is a trivial wrapper around the C function page_to_nid. It does not make sense to go through a trivial wrapper for this function, so mark it inline.

Quoted 5 lines

This follows commit 878620c5a93a ("rust: page: optimize rust symbol generation for Page"), which did the same for alloc_page and drop.

Quoted 3 lines
---
 rust/kernel/page.rs | 1 +
 1 file changed, 1 insertion(+)