Skip to content

Commit 5092aea

Browse files
Darksonnojeda
authored andcommitted
rust: mm: add __rust_helper to helpers
This is needed to inline these helpers into Rust code. Reviewed-by: Boqun Feng <boqun.feng@gmail.com> Reviewed-by: Gary Guo <gary@garyguo.net> Signed-off-by: Alice Ryhl <aliceryhl@google.com> Acked-by: Liam R. Howlett <Liam.Howlett@oracle.com> Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> Link: https://patch.msgid.link/20260105-define-rust-helper-v2-11-51da5f454a67@google.com Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent fa6cbf1 commit 5092aea

3 files changed

Lines changed: 16 additions & 15 deletions

File tree

rust/helpers/mm.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,48 +3,48 @@
33
#include <linux/mm.h>
44
#include <linux/sched/mm.h>
55

6-
void rust_helper_mmgrab(struct mm_struct *mm)
6+
__rust_helper void rust_helper_mmgrab(struct mm_struct *mm)
77
{
88
mmgrab(mm);
99
}
1010

11-
void rust_helper_mmdrop(struct mm_struct *mm)
11+
__rust_helper void rust_helper_mmdrop(struct mm_struct *mm)
1212
{
1313
mmdrop(mm);
1414
}
1515

16-
void rust_helper_mmget(struct mm_struct *mm)
16+
__rust_helper void rust_helper_mmget(struct mm_struct *mm)
1717
{
1818
mmget(mm);
1919
}
2020

21-
bool rust_helper_mmget_not_zero(struct mm_struct *mm)
21+
__rust_helper bool rust_helper_mmget_not_zero(struct mm_struct *mm)
2222
{
2323
return mmget_not_zero(mm);
2424
}
2525

26-
void rust_helper_mmap_read_lock(struct mm_struct *mm)
26+
__rust_helper void rust_helper_mmap_read_lock(struct mm_struct *mm)
2727
{
2828
mmap_read_lock(mm);
2929
}
3030

31-
bool rust_helper_mmap_read_trylock(struct mm_struct *mm)
31+
__rust_helper bool rust_helper_mmap_read_trylock(struct mm_struct *mm)
3232
{
3333
return mmap_read_trylock(mm);
3434
}
3535

36-
void rust_helper_mmap_read_unlock(struct mm_struct *mm)
36+
__rust_helper void rust_helper_mmap_read_unlock(struct mm_struct *mm)
3737
{
3838
mmap_read_unlock(mm);
3939
}
4040

41-
struct vm_area_struct *rust_helper_vma_lookup(struct mm_struct *mm,
42-
unsigned long addr)
41+
__rust_helper struct vm_area_struct *
42+
rust_helper_vma_lookup(struct mm_struct *mm, unsigned long addr)
4343
{
4444
return vma_lookup(mm, addr);
4545
}
4646

47-
void rust_helper_vma_end_read(struct vm_area_struct *vma)
47+
__rust_helper void rust_helper_vma_end_read(struct vm_area_struct *vma)
4848
{
4949
vma_end_read(vma);
5050
}

rust/helpers/page.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,24 @@
44
#include <linux/highmem.h>
55
#include <linux/mm.h>
66

7-
struct page *rust_helper_alloc_pages(gfp_t gfp_mask, unsigned int order)
7+
__rust_helper struct page *rust_helper_alloc_pages(gfp_t gfp_mask,
8+
unsigned int order)
89
{
910
return alloc_pages(gfp_mask, order);
1011
}
1112

12-
void *rust_helper_kmap_local_page(struct page *page)
13+
__rust_helper void *rust_helper_kmap_local_page(struct page *page)
1314
{
1415
return kmap_local_page(page);
1516
}
1617

17-
void rust_helper_kunmap_local(const void *addr)
18+
__rust_helper void rust_helper_kunmap_local(const void *addr)
1819
{
1920
kunmap_local(addr);
2021
}
2122

2223
#ifndef NODE_NOT_IN_PAGE_FLAGS
23-
int rust_helper_page_to_nid(const struct page *page)
24+
__rust_helper int rust_helper_page_to_nid(const struct page *page)
2425
{
2526
return page_to_nid(page);
2627
}

rust/helpers/vmalloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include <linux/vmalloc.h>
44

5-
void * __must_check __realloc_size(2)
5+
__rust_helper void *__must_check __realloc_size(2)
66
rust_helper_vrealloc_node_align(const void *p, size_t size, unsigned long align,
77
gfp_t flags, int node)
88
{

0 commit comments

Comments
 (0)