Skip to content

Commit 53fbef5

Browse files
Matthew Wilcox (Oracle)akpm00
authored andcommitted
mm: introduce memdesc_flags_t
Patch series "Add and use memdesc_flags_t". At some point struct page will be separated from struct slab and struct folio. This is a step towards that by introducing a type for the 'flags' word of all three structures. This gives us a certain amount of type safety by establishing that some of these unsigned longs are different from other unsigned longs in that they contain things like node ID, section number and zone number in the upper bits. That lets us have functions that can be easily called by anyone who has a slab, folio or page (but not easily by anyone else) to get the node or zone. There's going to be some unusual merge problems with this as some odd bits of the kernel decide they want to print out the flags value or something similar by writing page->flags and now they'll need to write page->flags.f instead. That's most of the churn here. Maybe we should be removing these things from the debug output? This patch (of 11): Wrap the unsigned long flags in a typedef. In upcoming patches, this will provide a strong hint that you can't just pass a random unsigned long to functions which take this as an argument. [willy@infradead.org: s/flags/flags.f/ in several architectures] Link: https://lkml.kernel.org/r/aKMgPRLD-WnkPxYm@casper.infradead.org [nicola.vetrini@gmail.com: mips: fix compilation error] Link: https://lore.kernel.org/lkml/CA+G9fYvkpmqGr6wjBNHY=dRp71PLCoi2341JxOudi60yqaeUdg@mail.gmail.com/ Link: https://lkml.kernel.org/r/20250825214245.1838158-1-nicola.vetrini@gmail.com Link: https://lkml.kernel.org/r/20250805172307.1302730-1-willy@infradead.org Link: https://lkml.kernel.org/r/20250805172307.1302730-2-willy@infradead.org Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Acked-by: Zi Yan <ziy@nvidia.com> Cc: Shakeel Butt <shakeel.butt@linux.dev> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 4e91565 commit 53fbef5

File tree

58 files changed

+195
-190
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+195
-190
lines changed

arch/arc/mm/cache.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ static inline void arc_slc_enable(void)
704704

705705
void flush_dcache_folio(struct folio *folio)
706706
{
707-
clear_bit(PG_dc_clean, &folio->flags);
707+
clear_bit(PG_dc_clean, &folio->flags.f);
708708
return;
709709
}
710710
EXPORT_SYMBOL(flush_dcache_folio);
@@ -889,8 +889,8 @@ void copy_user_highpage(struct page *to, struct page *from,
889889

890890
copy_page(kto, kfrom);
891891

892-
clear_bit(PG_dc_clean, &dst->flags);
893-
clear_bit(PG_dc_clean, &src->flags);
892+
clear_bit(PG_dc_clean, &dst->flags.f);
893+
clear_bit(PG_dc_clean, &src->flags.f);
894894

895895
kunmap_atomic(kto);
896896
kunmap_atomic(kfrom);
@@ -900,7 +900,7 @@ void clear_user_page(void *to, unsigned long u_vaddr, struct page *page)
900900
{
901901
struct folio *folio = page_folio(page);
902902
clear_page(to);
903-
clear_bit(PG_dc_clean, &folio->flags);
903+
clear_bit(PG_dc_clean, &folio->flags.f);
904904
}
905905
EXPORT_SYMBOL(clear_user_page);
906906

arch/arc/mm/tlb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ void update_mmu_cache_range(struct vm_fault *vmf, struct vm_area_struct *vma,
488488
*/
489489
if (vma->vm_flags & VM_EXEC) {
490490
struct folio *folio = page_folio(page);
491-
int dirty = !test_and_set_bit(PG_dc_clean, &folio->flags);
491+
int dirty = !test_and_set_bit(PG_dc_clean, &folio->flags.f);
492492
if (dirty) {
493493
unsigned long offset = offset_in_folio(folio, paddr);
494494
nr = folio_nr_pages(folio);

arch/arm/include/asm/hugetlb.h

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

1818
static inline void arch_clear_hugetlb_flags(struct folio *folio)
1919
{
20-
clear_bit(PG_dcache_clean, &folio->flags);
20+
clear_bit(PG_dcache_clean, &folio->flags.f);
2121
}
2222
#define arch_clear_hugetlb_flags arch_clear_hugetlb_flags
2323

arch/arm/mm/copypage-v4mc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void v4_mc_copy_user_highpage(struct page *to, struct page *from,
6767
struct folio *src = page_folio(from);
6868
void *kto = kmap_atomic(to);
6969

70-
if (!test_and_set_bit(PG_dcache_clean, &src->flags))
70+
if (!test_and_set_bit(PG_dcache_clean, &src->flags.f))
7171
__flush_dcache_folio(folio_flush_mapping(src), src);
7272

7373
raw_spin_lock(&minicache_lock);

arch/arm/mm/copypage-v6.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static void v6_copy_user_highpage_aliasing(struct page *to,
7373
unsigned int offset = CACHE_COLOUR(vaddr);
7474
unsigned long kfrom, kto;
7575

76-
if (!test_and_set_bit(PG_dcache_clean, &src->flags))
76+
if (!test_and_set_bit(PG_dcache_clean, &src->flags.f))
7777
__flush_dcache_folio(folio_flush_mapping(src), src);
7878

7979
/* FIXME: not highmem safe */

arch/arm/mm/copypage-xscale.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void xscale_mc_copy_user_highpage(struct page *to, struct page *from,
8787
struct folio *src = page_folio(from);
8888
void *kto = kmap_atomic(to);
8989

90-
if (!test_and_set_bit(PG_dcache_clean, &src->flags))
90+
if (!test_and_set_bit(PG_dcache_clean, &src->flags.f))
9191
__flush_dcache_folio(folio_flush_mapping(src), src);
9292

9393
raw_spin_lock(&minicache_lock);

arch/arm/mm/dma-mapping.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ static void __dma_page_dev_to_cpu(struct page *page, unsigned long off,
718718
if (size < sz)
719719
break;
720720
if (!offset)
721-
set_bit(PG_dcache_clean, &folio->flags);
721+
set_bit(PG_dcache_clean, &folio->flags.f);
722722
offset = 0;
723723
size -= sz;
724724
if (!size)

arch/arm/mm/fault-armv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ void update_mmu_cache_range(struct vm_fault *vmf, struct vm_area_struct *vma,
203203

204204
folio = page_folio(pfn_to_page(pfn));
205205
mapping = folio_flush_mapping(folio);
206-
if (!test_and_set_bit(PG_dcache_clean, &folio->flags))
206+
if (!test_and_set_bit(PG_dcache_clean, &folio->flags.f))
207207
__flush_dcache_folio(mapping, folio);
208208
if (mapping) {
209209
if (cache_is_vivt())

arch/arm/mm/flush.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ void __sync_icache_dcache(pte_t pteval)
304304
else
305305
mapping = NULL;
306306

307-
if (!test_and_set_bit(PG_dcache_clean, &folio->flags))
307+
if (!test_and_set_bit(PG_dcache_clean, &folio->flags.f))
308308
__flush_dcache_folio(mapping, folio);
309309

310310
if (pte_exec(pteval))
@@ -343,23 +343,23 @@ void flush_dcache_folio(struct folio *folio)
343343
return;
344344

345345
if (!cache_ops_need_broadcast() && cache_is_vipt_nonaliasing()) {
346-
if (test_bit(PG_dcache_clean, &folio->flags))
347-
clear_bit(PG_dcache_clean, &folio->flags);
346+
if (test_bit(PG_dcache_clean, &folio->flags.f))
347+
clear_bit(PG_dcache_clean, &folio->flags.f);
348348
return;
349349
}
350350

351351
mapping = folio_flush_mapping(folio);
352352

353353
if (!cache_ops_need_broadcast() &&
354354
mapping && !folio_mapped(folio))
355-
clear_bit(PG_dcache_clean, &folio->flags);
355+
clear_bit(PG_dcache_clean, &folio->flags.f);
356356
else {
357357
__flush_dcache_folio(mapping, folio);
358358
if (mapping && cache_is_vivt())
359359
__flush_dcache_aliases(mapping, folio);
360360
else if (mapping)
361361
__flush_icache_all();
362-
set_bit(PG_dcache_clean, &folio->flags);
362+
set_bit(PG_dcache_clean, &folio->flags.f);
363363
}
364364
}
365365
EXPORT_SYMBOL(flush_dcache_folio);

arch/arm64/include/asm/hugetlb.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ extern bool arch_hugetlb_migration_supported(struct hstate *h);
2121

2222
static inline void arch_clear_hugetlb_flags(struct folio *folio)
2323
{
24-
clear_bit(PG_dcache_clean, &folio->flags);
24+
clear_bit(PG_dcache_clean, &folio->flags.f);
2525

2626
#ifdef CONFIG_ARM64_MTE
2727
if (system_supports_mte()) {
28-
clear_bit(PG_mte_tagged, &folio->flags);
29-
clear_bit(PG_mte_lock, &folio->flags);
28+
clear_bit(PG_mte_tagged, &folio->flags.f);
29+
clear_bit(PG_mte_lock, &folio->flags.f);
3030
}
3131
#endif
3232
}

0 commit comments

Comments
 (0)