summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShivank Garg <shivankg@amd.com>2025-06-11 05:27:07 +0000
committerAndrew Morton <akpm@linux-foundation.org>2025-07-09 22:42:08 -0700
commita984f16fba2cbadfd8f3310cf506a484dc5bdeb6 (patch)
tree5e9d205f33fdb7fac4c75d7e7f8642ca3a91bf3d
parenta788b6e571f3cb1aceb1611e97010be7334cbd63 (diff)
mm: use folio_expected_ref_count() helper for reference counting
Replace open-coded folio reference count calculations with the folio_expected_ref_count(). No functional changes intended. Link: https://lkml.kernel.org/r/20250611052706.515408-2-shivankg@amd.com Signed-off-by: Shivank Garg <shivankg@amd.com> Acked-by: David Hildenbrand <david@redhat.com> Reviewed-by: Oscar Salvador <osalvador@suse.de> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Alistair Popple <apopple@nvidia.com> Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Marc Rutland <mark.rutland@arm.com> Cc: "Masami Hiramatsu (Google)" <mhiramat@kernel.org> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Namhyung kim <namhyung@kernel.org> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rw-r--r--kernel/events/uprobes.c3
-rw-r--r--mm/memfd.c3
2 files changed, 2 insertions, 4 deletions
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 4c965ba77f9f..8a601df87072 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -436,8 +436,7 @@ static int __uprobe_write_opcode(struct vm_area_struct *vma,
* there are no unexpected folio references ...
*/
if (is_register || userfaultfd_missing(vma) ||
- (folio_ref_count(folio) != folio_mapcount(folio) + 1 +
- folio_test_swapcache(folio) * folio_nr_pages(folio)))
+ (folio_ref_count(folio) != folio_expected_ref_count(folio) + 1))
goto remap;
/*
diff --git a/mm/memfd.c b/mm/memfd.c
index 4fc98abe6627..65a107f72e39 100644
--- a/mm/memfd.c
+++ b/mm/memfd.c
@@ -32,8 +32,7 @@
static bool memfd_folio_has_extra_refs(struct folio *folio)
{
- return folio_ref_count(folio) - folio_mapcount(folio) !=
- folio_nr_pages(folio);
+ return folio_ref_count(folio) != folio_expected_ref_count(folio);
}
static void memfd_tag_pins(struct xa_state *xas)