The patch titled Subject: migrate_pages: silence gcc notes for mis-casting has been added to the -mm mm-hotfixes-unstable branch. Its filename is migrate_pages-silence-gcc-notes-for-mis-casting.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/migrate_pages-silence-gcc-notes-for-mis-casting.patch This patch will later appear in the mm-hotfixes-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Huang Ying <ying.huang@xxxxxxxxx> Subject: migrate_pages: silence gcc notes for mis-casting Date: Thu, 2 Mar 2023 09:26:10 +0800 The following GCC notes was reported for commit 64c8902ed441 ("migrate_pages: split unmap_and_move() to _unmap() and _move()"). mm/migrate.c: In function `__migrate_folio_extract': mm/migrate.c:1050:20: note: randstruct: casting between randomized structure pointer types (ssa): `struct anon_vma' and `struct address_space' 1050 | *anon_vmap = (void *)dst->mapping; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ The casting itself is safe. Because we only use dst->mapping to store the pointer itself temporarily and dst is a newly allocated folio and not used by anyone else during that. But the notes should be silenced and some comments are deserved. So, we do that in this patch. Link: https://lkml.kernel.org/r/20230302012610.17055-1-ying.huang@xxxxxxxxx Fixes: 64c8902ed441 ("migrate_pages: split unmap_and_move() to _unmap() and _move()") Signed-off-by: "Huang, Ying" <ying.huang@xxxxxxxxx> Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> Cc: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx> Cc: Xin Hao <xhao@xxxxxxxxxxxxxxxxx> Cc: Zi Yan <ziy@xxxxxxxxxx> Cc: Yang Shi <shy828301@xxxxxxxxx> Cc: Oscar Salvador <osalvador@xxxxxxx> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> Cc: Bharata B Rao <bharata@xxxxxxx> Cc: Alistair Popple <apopple@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- --- a/mm/migrate.c~migrate_pages-silence-gcc-notes-for-mis-casting +++ a/mm/migrate.c @@ -1047,7 +1047,16 @@ static void __migrate_folio_extract(stru int *page_was_mappedp, struct anon_vma **anon_vmap) { - *anon_vmap = (void *)dst->mapping; + struct anon_vma *anon_vma; + + /* + * 2 steps assignment to silence gcc notes for mis-casting. The + * casting is safe. Because we only use dst->mapping to store + * the pointer itself temporarily and dst is a newly allocated + * folio and not used by anyone else during that. + */ + anon_vma = (void *)dst->mapping; + *anon_vmap = anon_vma; *page_was_mappedp = (unsigned long)dst->private; dst->mapping = NULL; dst->private = NULL; _ Patches currently in -mm which might be from ying.huang@xxxxxxxxx are migrate_pages-fix-deadlock-in-batched-migration.patch migrate_pages-move-split-folios-processing-out-of-migrate_pages_batch.patch migrate_pages-try-migrate-in-batch-asynchronously-firstly.patch migrate_pages-silence-gcc-notes-for-mis-casting.patch