Skip to content

Commit 7d3e93e

Browse files
Matthew Wilcox (Oracle)akpm00
authored andcommitted
mm: use page_pgoff() in more places
There are several places which currently open-code page_pgoff(), convert them to call it. Link: https://lkml.kernel.org/r/20241005200121.3231142-3-willy@infradead.org Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent f747059 commit 7d3e93e

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

kernel/futex/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ int get_futex_key(u32 __user *uaddr, unsigned int flags, union futex_key *key,
399399

400400
key->both.offset |= FUT_OFF_INODE; /* inode-based key */
401401
key->shared.i_seq = get_inode_sequence_number(inode);
402-
key->shared.pgoff = folio->index + folio_page_idx(folio, page);
402+
key->shared.pgoff = page_pgoff(folio, page);
403403
rcu_read_unlock();
404404
}
405405

mm/page_vma_mapped.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,15 +340,14 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)
340340
unsigned long page_mapped_in_vma(struct page *page, struct vm_area_struct *vma)
341341
{
342342
struct folio *folio = page_folio(page);
343-
pgoff_t pgoff = folio->index + folio_page_idx(folio, page);
344343
struct page_vma_mapped_walk pvmw = {
345344
.pfn = page_to_pfn(page),
346345
.nr_pages = 1,
347346
.vma = vma,
348347
.flags = PVMW_SYNC,
349348
};
350349

351-
pvmw.address = vma_address(vma, pgoff, 1);
350+
pvmw.address = vma_address(vma, page_pgoff(folio, page), 1);
352351
if (pvmw.address == -EFAULT)
353352
goto out;
354353
if (!page_vma_mapped_walk(&pvmw))

mm/rmap.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,6 @@ static bool should_defer_flush(struct mm_struct *mm, enum ttu_flags flags)
774774
unsigned long page_address_in_vma(struct page *page, struct vm_area_struct *vma)
775775
{
776776
struct folio *folio = page_folio(page);
777-
pgoff_t pgoff;
778777

779778
if (folio_test_anon(folio)) {
780779
struct anon_vma *page__anon_vma = folio_anon_vma(folio);
@@ -792,8 +791,7 @@ unsigned long page_address_in_vma(struct page *page, struct vm_area_struct *vma)
792791
}
793792

794793
/* The !page__anon_vma above handles KSM folios */
795-
pgoff = folio->index + folio_page_idx(folio, page);
796-
return vma_address(vma, pgoff, 1);
794+
return vma_address(vma, page_pgoff(folio, page), 1);
797795
}
798796

799797
/*

0 commit comments

Comments
 (0)