Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
54bb1da
mm: stop making SPARSEMEM_VMEMMAP user-selectable
Aug 21, 2025
c4445b7
arm64: Kconfig: drop superfluous "select SPARSEMEM_VMEMMAP"
Aug 21, 2025
81bfc53
s390/Kconfig: drop superfluous "select SPARSEMEM_VMEMMAP"
Aug 21, 2025
b7144a2
x86/Kconfig: drop superfluous "select SPARSEMEM_VMEMMAP"
Aug 21, 2025
b630b5c
wireguard: selftests: remove CONFIG_SPARSEMEM_VMEMMAP=y from qemu ker…
Aug 21, 2025
a72b49f
mm/page_alloc: reject unreasonable folio/compound page sizes in alloc…
Aug 21, 2025
d524c87
mm/memremap: reject unreasonable folio/compound page sizes in memrema…
Aug 21, 2025
b1263dd
mm/hugetlb: check for unreasonable folio sizes when registering hstate
Aug 21, 2025
d17bbac
mm/mm_init: make memmap_init_compound() look more like prep_compound_…
Aug 21, 2025
b961663
mm/hugetlb: cleanup hugetlb_folio_init_tail_vmemmap()
Aug 21, 2025
60edbab
mm: sanity-check maximum folio size in folio_set_order()
Aug 21, 2025
1eb66d6
mm: limit folio/compound page sizes in problematic kernel configs
Aug 21, 2025
15d6dde
mm: simplify folio_page() and folio_page_idx()
Aug 21, 2025
6f47b5b
mm/mm/percpu-km: drop nth_page() usage within single allocation
Aug 21, 2025
d2ee790
fs: hugetlbfs: remove nth_page() usage within folio in adjust_range_h…
Aug 21, 2025
15008ee
mm/pagewalk: drop nth_page() usage within folio in folio_walk_start()
Aug 21, 2025
bb4a02d
mm/gup: drop nth_page() usage within folio when recording subpages
Aug 21, 2025
86b6e33
io_uring/zcrx: remove "struct io_copy_cache" and one nth_page() usage
Aug 21, 2025
4fe1759
io_uring/zcrx: remove nth_page() usage within folio
Aug 21, 2025
340eab8
mips: mm: convert __flush_dcache_pages() to __flush_dcache_folio_pages()
Aug 21, 2025
3664eb8
mm/cma: refuse handing out non-contiguous page ranges
Aug 21, 2025
57fa0ab
dma-remap: drop nth_page() in dma_common_contiguous_remap()
Aug 21, 2025
e0eb43d
scatterlist: disallow non-contigous page ranges in a single SG entry
Aug 21, 2025
04fb34d
ata: libata-eh: drop nth_page() usage within SG entry
Aug 21, 2025
383fc75
drm/i915/gem: drop nth_page() usage within SG entry
Aug 21, 2025
e6bdc45
mspro_block: drop nth_page() usage within SG entry
Aug 21, 2025
f121955
memstick: drop nth_page() usage within SG entry
Aug 21, 2025
1715023
mmc: drop nth_page() usage within SG entry
Aug 21, 2025
1795475
scsi: core: drop nth_page() usage within SG entry
Aug 21, 2025
f39a574
vfio/pci: drop nth_page() usage within SG entry
Aug 21, 2025
c45cb0e
crypto: remove nth_page() usage within SG entry
Aug 21, 2025
9f08cf7
mm/gup: drop nth_page() usage in unpin_user_page_range_dirty_lock()
Aug 21, 2025
812a722
kfence: drop nth_page() usage
Aug 21, 2025
807d31e
block: update comment of "struct bio_vec" regarding nth_page()
Aug 21, 2025
792e3ff
mm: remove nth_page()
Aug 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion arch/arm64/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1570,7 +1570,6 @@ source "kernel/Kconfig.hz"
config ARCH_SPARSEMEM_ENABLE
def_bool y
select SPARSEMEM_VMEMMAP_ENABLE
select SPARSEMEM_VMEMMAP

config HW_PERF_EVENTS
def_bool y
Expand Down
11 changes: 7 additions & 4 deletions arch/mips/include/asm/cacheflush.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,27 @@ extern void (*flush_cache_mm)(struct mm_struct *mm);
extern void (*flush_cache_range)(struct vm_area_struct *vma,
unsigned long start, unsigned long end);
extern void (*flush_cache_page)(struct vm_area_struct *vma, unsigned long page, unsigned long pfn);
extern void __flush_dcache_pages(struct page *page, unsigned int nr);
extern void __flush_dcache_folio_pages(struct folio *folio, struct page *page, unsigned int nr);

#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1
static inline void flush_dcache_folio(struct folio *folio)
{
if (cpu_has_dc_aliases)
__flush_dcache_pages(&folio->page, folio_nr_pages(folio));
__flush_dcache_folio_pages(folio, folio_page(folio, 0),
folio_nr_pages(folio));
else if (!cpu_has_ic_fills_f_dc)
folio_set_dcache_dirty(folio);
}
#define flush_dcache_folio flush_dcache_folio

static inline void flush_dcache_page(struct page *page)
{
struct folio *folio = page_folio(page);

if (cpu_has_dc_aliases)
__flush_dcache_pages(page, 1);
__flush_dcache_folio_pages(folio, page, folio_nr_pages(folio));
else if (!cpu_has_ic_fills_f_dc)
folio_set_dcache_dirty(page_folio(page));
folio_set_dcache_dirty(folio);
}

#define flush_dcache_mmap_lock(mapping) do { } while (0)
Expand Down
8 changes: 4 additions & 4 deletions arch/mips/mm/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ SYSCALL_DEFINE3(cacheflush, unsigned long, addr, unsigned long, bytes,
return 0;
}

void __flush_dcache_pages(struct page *page, unsigned int nr)
void __flush_dcache_folio_pages(struct folio *folio, struct page *page,
unsigned int nr)
{
struct folio *folio = page_folio(page);
struct address_space *mapping = folio_flush_mapping(folio);
unsigned long addr;
unsigned int i;
Expand All @@ -117,12 +117,12 @@ void __flush_dcache_pages(struct page *page, unsigned int nr)
* get faulted into the tlb (and thus flushed) anyways.
*/
for (i = 0; i < nr; i++) {
addr = (unsigned long)kmap_local_page(nth_page(page, i));
addr = (unsigned long)kmap_local_page(page + i);
flush_data_cache_page(addr);
kunmap_local((void *)addr);
}
}
EXPORT_SYMBOL(__flush_dcache_pages);
EXPORT_SYMBOL(__flush_dcache_folio_pages);

void __flush_anon_page(struct page *page, unsigned long vmaddr)
{
Expand Down
1 change: 0 additions & 1 deletion arch/s390/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,6 @@ menu "Memory setup"
config ARCH_SPARSEMEM_ENABLE
def_bool y
select SPARSEMEM_VMEMMAP_ENABLE
select SPARSEMEM_VMEMMAP

config ARCH_SPARSEMEM_DEFAULT
def_bool y
Expand Down
1 change: 0 additions & 1 deletion arch/x86/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1552,7 +1552,6 @@ config ARCH_SPARSEMEM_ENABLE
def_bool y
select SPARSEMEM_STATIC if X86_32
select SPARSEMEM_VMEMMAP_ENABLE if X86_64
select SPARSEMEM_VMEMMAP if X86_64

config ARCH_SPARSEMEM_DEFAULT
def_bool X86_64 || (NUMA && X86_32)
Expand Down
4 changes: 2 additions & 2 deletions crypto/ahash.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static int hash_walk_new_entry(struct crypto_hash_walk *walk)

sg = walk->sg;
walk->offset = sg->offset;
walk->pg = nth_page(sg_page(walk->sg), (walk->offset >> PAGE_SHIFT));
walk->pg = sg_page(walk->sg) + walk->offset / PAGE_SIZE;
walk->offset = offset_in_page(walk->offset);
walk->entrylen = sg->length;

Expand Down Expand Up @@ -226,7 +226,7 @@ int shash_ahash_digest(struct ahash_request *req, struct shash_desc *desc)
if (!IS_ENABLED(CONFIG_HIGHMEM))
return crypto_shash_digest(desc, data, nbytes, req->result);

page = nth_page(page, offset >> PAGE_SHIFT);
page += offset / PAGE_SIZE;
offset = offset_in_page(offset);

if (nbytes > (unsigned int)PAGE_SIZE - offset)
Expand Down
8 changes: 4 additions & 4 deletions crypto/scompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ static int scomp_acomp_comp_decomp(struct acomp_req *req, int dir)
} else
return -ENOSYS;

dpage = nth_page(dpage, doff / PAGE_SIZE);
dpage += doff / PAGE_SIZE;
doff = offset_in_page(doff);

n = (dlen - 1) / PAGE_SIZE;
Expand All @@ -220,12 +220,12 @@ static int scomp_acomp_comp_decomp(struct acomp_req *req, int dir)
} else
break;

spage = nth_page(spage, soff / PAGE_SIZE);
spage = spage + soff / PAGE_SIZE;
soff = offset_in_page(soff);

n = (slen - 1) / PAGE_SIZE;
n += (offset_in_page(slen - 1) + soff) / PAGE_SIZE;
if (PageHighMem(nth_page(spage, n)) &&
if (PageHighMem(spage + n) &&
size_add(soff, slen) > PAGE_SIZE)
break;
src = kmap_local_page(spage) + soff;
Expand Down Expand Up @@ -270,7 +270,7 @@ static int scomp_acomp_comp_decomp(struct acomp_req *req, int dir)
if (dlen <= PAGE_SIZE)
break;
dlen -= PAGE_SIZE;
dpage = nth_page(dpage, 1);
dpage++;
}
}

Expand Down
6 changes: 3 additions & 3 deletions drivers/ata/libata-sff.c
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ static void ata_pio_sector(struct ata_queued_cmd *qc)
offset = qc->cursg->offset + qc->cursg_ofs;

/* get the current page and offset */
page = nth_page(page, (offset >> PAGE_SHIFT));
page += offset / PAGE_SHIFT;
offset %= PAGE_SIZE;

/* don't overrun current sg */
Expand All @@ -631,7 +631,7 @@ static void ata_pio_sector(struct ata_queued_cmd *qc)
unsigned int split_len = PAGE_SIZE - offset;

ata_pio_xfer(qc, page, offset, split_len);
ata_pio_xfer(qc, nth_page(page, 1), 0, count - split_len);
ata_pio_xfer(qc, page + 1, 0, count - split_len);
} else {
ata_pio_xfer(qc, page, offset, count);
}
Expand Down Expand Up @@ -751,7 +751,7 @@ static int __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes)
offset = sg->offset + qc->cursg_ofs;

/* get the current page and offset */
page = nth_page(page, (offset >> PAGE_SHIFT));
page += offset / PAGE_SIZE;
offset %= PAGE_SIZE;

/* don't overrun current sg */
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/i915/gem/i915_gem_pages.c
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ __i915_gem_object_get_page(struct drm_i915_gem_object *obj, pgoff_t n)
GEM_BUG_ON(!i915_gem_object_has_struct_page(obj));

sg = i915_gem_object_get_sg(obj, n, &offset);
return nth_page(sg_page(sg), offset);
return sg_page(sg) + offset;
}

/* Like i915_gem_object_get_page(), but mark the returned page dirty */
Expand Down
3 changes: 1 addition & 2 deletions drivers/memstick/core/mspro_block.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,7 @@ static int h_mspro_block_transfer_data(struct memstick_dev *card,
t_offset += msb->current_page * msb->page_size;

sg_set_page(&t_sg,
nth_page(sg_page(&(msb->req_sg[msb->current_seg])),
t_offset >> PAGE_SHIFT),
sg_page(&(msb->req_sg[msb->current_seg])) + t_offset / PAGE_SIZE,
msb->page_size, offset_in_page(t_offset));

memstick_init_req_sg(*mrq, msb->data_dir == READ
Expand Down
3 changes: 1 addition & 2 deletions drivers/memstick/host/jmb38x_ms.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,7 @@ static int jmb38x_ms_transfer_data(struct jmb38x_ms_host *host)
unsigned int p_off;

if (host->req->long_data) {
pg = nth_page(sg_page(&host->req->sg),
off >> PAGE_SHIFT);
pg = sg_page(&host->req->sg) + off / PAGE_SIZE;
p_off = offset_in_page(off);
p_cnt = PAGE_SIZE - p_off;
p_cnt = min(p_cnt, length);
Expand Down
3 changes: 1 addition & 2 deletions drivers/memstick/host/tifm_ms.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@ static unsigned int tifm_ms_transfer_data(struct tifm_ms *host)
unsigned int p_off;

if (host->req->long_data) {
pg = nth_page(sg_page(&host->req->sg),
off >> PAGE_SHIFT);
pg = sg_page(&host->req->sg) + off / PAGE_SIZE;
p_off = offset_in_page(off);
p_cnt = PAGE_SIZE - p_off;
p_cnt = min(p_cnt, length);
Expand Down
4 changes: 2 additions & 2 deletions drivers/mmc/host/tifm_sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static void tifm_sd_transfer_data(struct tifm_sd *host)
}
off = sg[host->sg_pos].offset + host->block_pos;

pg = nth_page(sg_page(&sg[host->sg_pos]), off >> PAGE_SHIFT);
pg = sg_page(&sg[host->sg_pos]) + off / PAGE_SIZE;
p_off = offset_in_page(off);
p_cnt = PAGE_SIZE - p_off;
p_cnt = min(p_cnt, cnt);
Expand Down Expand Up @@ -240,7 +240,7 @@ static void tifm_sd_bounce_block(struct tifm_sd *host, struct mmc_data *r_data)
}
off = sg[host->sg_pos].offset + host->block_pos;

pg = nth_page(sg_page(&sg[host->sg_pos]), off >> PAGE_SHIFT);
pg = sg_page(&sg[host->sg_pos]) + off / PAGE_SIZE;
p_off = offset_in_page(off);
p_cnt = PAGE_SIZE - p_off;
p_cnt = min(p_cnt, cnt);
Expand Down
4 changes: 2 additions & 2 deletions drivers/mmc/host/usdhi6rol0.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ static void usdhi6_blk_bounce(struct usdhi6_host *host,

host->head_pg.page = host->pg.page;
host->head_pg.mapped = host->pg.mapped;
host->pg.page = nth_page(host->pg.page, 1);
host->pg.page = host->pg.page + 1;
host->pg.mapped = kmap(host->pg.page);

host->blk_page = host->bounce_buf;
Expand Down Expand Up @@ -503,7 +503,7 @@ static void usdhi6_sg_advance(struct usdhi6_host *host)
/* We cannot get here after crossing a page border */

/* Next page in the same SG */
host->pg.page = nth_page(sg_page(host->sg), host->page_idx);
host->pg.page = sg_page(host->sg) + host->page_idx;
host->pg.mapped = kmap(host->pg.page);
host->blk_page = host->pg.mapped;

Expand Down
3 changes: 1 addition & 2 deletions drivers/scsi/scsi_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -3148,8 +3148,7 @@ void *scsi_kmap_atomic_sg(struct scatterlist *sgl, int sg_count,
/* Offset starting from the beginning of first page in this sg-entry */
*offset = *offset - len_complete + sg->offset;

/* Assumption: contiguous pages can be accessed as "page + i" */
page = nth_page(sg_page(sg), (*offset >> PAGE_SHIFT));
page = sg_page(sg) + *offset / PAGE_SIZE;
*offset &= ~PAGE_MASK;

/* Bytes in this sg-entry from *offset to the end of the page */
Expand Down
3 changes: 1 addition & 2 deletions drivers/scsi/sg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1235,8 +1235,7 @@ sg_vma_fault(struct vm_fault *vmf)
len = vma->vm_end - sa;
len = (len < length) ? len : length;
if (offset < len) {
struct page *page = nth_page(rsv_schp->pages[k],
offset >> PAGE_SHIFT);
struct page *page = rsv_schp->pages[k] + offset / PAGE_SIZE;
get_page(page); /* increment page count */
vmf->page = page;
return 0; /* success */
Expand Down
3 changes: 1 addition & 2 deletions drivers/vfio/pci/pds/lm.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ static struct page *pds_vfio_get_file_page(struct pds_vfio_lm_file *lm_file,
lm_file->last_offset_sg = sg;
lm_file->sg_last_entry += i;
lm_file->last_offset = cur_offset;
return nth_page(sg_page(sg),
(offset - cur_offset) / PAGE_SIZE);
return sg_page(sg) + (offset - cur_offset) / PAGE_SIZE;
}
cur_offset += sg->length;
}
Expand Down
3 changes: 1 addition & 2 deletions drivers/vfio/pci/virtio/migrate.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ virtiovf_get_migration_page(struct virtiovf_data_buffer *buf,
buf->last_offset_sg = sg;
buf->sg_last_entry += i;
buf->last_offset = cur_offset;
return nth_page(sg_page(sg),
(offset - cur_offset) / PAGE_SIZE);
return sg_page(sg) + (offset - cur_offset) / PAGE_SIZE;
}
cur_offset += sg->length;
}
Expand Down
25 changes: 8 additions & 17 deletions fs/hugetlbfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,31 +198,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
static size_t adjust_range_hwpoison(struct folio *folio, size_t offset,
size_t bytes)
{
struct page *page;
size_t n = 0;
size_t res = 0;
struct page *page = folio_page(folio, offset / PAGE_SIZE);
size_t n, safe_bytes;

/* First page to start the loop. */
page = folio_page(folio, offset / PAGE_SIZE);
offset %= PAGE_SIZE;
while (1) {
for (safe_bytes = 0; safe_bytes < bytes; safe_bytes += n) {

if (is_raw_hwpoison_page_in_hugepage(page))
break;

/* Safe to read n bytes without touching HWPOISON subpage. */
n = min(bytes, (size_t)PAGE_SIZE - offset);
res += n;
bytes -= n;
if (!bytes || !n)
break;
offset += n;
if (offset == PAGE_SIZE) {
page = nth_page(page, 1);
offset = 0;
}
n = min(bytes - safe_bytes, (size_t)PAGE_SIZE - offset);
offset = 0;
page++;
}

return res;
return safe_bytes;
}

/*
Expand Down
4 changes: 2 additions & 2 deletions include/crypto/scatterwalk.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static inline void scatterwalk_map(struct scatter_walk *walk)
if (IS_ENABLED(CONFIG_HIGHMEM)) {
struct page *page;

page = nth_page(base_page, offset >> PAGE_SHIFT);
page = base_page + offset / PAGE_SIZE;
offset = offset_in_page(offset);
addr = kmap_local_page(page) + offset;
} else {
Expand Down Expand Up @@ -259,7 +259,7 @@ static inline void scatterwalk_done_dst(struct scatter_walk *walk,
end += (offset_in_page(offset) + offset_in_page(nbytes) +
PAGE_SIZE - 1) >> PAGE_SHIFT;
for (i = start; i < end; i++)
flush_dcache_page(nth_page(base_page, i));
flush_dcache_page(base_page + i);
}
scatterwalk_advance(walk, nbytes);
}
Expand Down
7 changes: 2 additions & 5 deletions include/linux/bvec.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@ struct page;
* @bv_len: Number of bytes in the address range.
* @bv_offset: Start of the address range relative to the start of @bv_page.
*
* The following holds for a bvec if n * PAGE_SIZE < bv_offset + bv_len:
*
* nth_page(@bv_page, n) == @bv_page + n
*
* This holds because page_is_mergeable() checks the above property.
* All pages within a bio_vec starting from @bv_page are contiguous and
* can simply be iterated (see bvec_advance()).
*/
struct bio_vec {
struct page *bv_page;
Expand Down
Loading
Loading