Skip to content

Commit 85eba5f

Browse files
committed
Merge tag 'mm-hotfixes-stable-2023-09-23-10-31' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Pull misc fixes from Andrew Morton: "13 hotfixes, 10 of which pertain to post-6.5 issues. The other three are cc:stable" * tag 'mm-hotfixes-stable-2023-09-23-10-31' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: proc: nommu: fix empty /proc/<pid>/maps filemap: add filemap_map_order0_folio() to handle order0 folio proc: nommu: /proc/<pid>/maps: release mmap read lock mm: memcontrol: fix GFP_NOFS recursion in memory.high enforcement pidfd: prevent a kernel-doc warning argv_split: fix kernel-doc warnings scatterlist: add missing function params to kernel-doc selftests/proc: fixup proc-empty-vm test after KSM changes revert "scripts/gdb/symbols: add specific ko module load command" selftests: link libasan statically for tests with -fsanitize=address task_work: add kerneldoc annotation for 'data' argument mm: page_alloc: fix CMA and HIGHATOMIC landing on the wrong buddy list sh: mm: re-add lost __ref to ioremap_prot() to fix modpost warning
2 parents 8565bdf + fe44198 commit 85eba5f

File tree

16 files changed

+111
-91
lines changed

16 files changed

+111
-91
lines changed

arch/sh/mm/ioremap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ __ioremap_29bit(phys_addr_t offset, unsigned long size, pgprot_t prot)
7272
#define __ioremap_29bit(offset, size, prot) NULL
7373
#endif /* CONFIG_29BIT */
7474

75-
void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size,
76-
unsigned long prot)
75+
void __iomem __ref *ioremap_prot(phys_addr_t phys_addr, size_t size,
76+
unsigned long prot)
7777
{
7878
void __iomem *mapped;
7979
pgprot_t pgprot = __pgprot(prot);

fs/proc/internal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,7 @@ struct proc_maps_private {
289289
struct inode *inode;
290290
struct task_struct *task;
291291
struct mm_struct *mm;
292-
#ifdef CONFIG_MMU
293292
struct vma_iterator iter;
294-
#endif
295293
#ifdef CONFIG_NUMA
296294
struct mempolicy *task_mempolicy;
297295
#endif

fs/proc/task_nommu.c

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,28 @@ static int show_map(struct seq_file *m, void *_p)
175175
return nommu_vma_show(m, _p);
176176
}
177177

178-
static void *m_start(struct seq_file *m, loff_t *pos)
178+
static struct vm_area_struct *proc_get_vma(struct proc_maps_private *priv,
179+
loff_t *ppos)
180+
{
181+
struct vm_area_struct *vma = vma_next(&priv->iter);
182+
183+
if (vma) {
184+
*ppos = vma->vm_start;
185+
} else {
186+
*ppos = -1UL;
187+
}
188+
189+
return vma;
190+
}
191+
192+
static void *m_start(struct seq_file *m, loff_t *ppos)
179193
{
180194
struct proc_maps_private *priv = m->private;
195+
unsigned long last_addr = *ppos;
181196
struct mm_struct *mm;
182-
struct vm_area_struct *vma;
183-
unsigned long addr = *pos;
184197

185-
/* See m_next(). Zero at the start or after lseek. */
186-
if (addr == -1UL)
198+
/* See proc_get_vma(). Zero at the start or after lseek. */
199+
if (last_addr == -1UL)
187200
return NULL;
188201

189202
/* pin the task and mm whilst we play with them */
@@ -192,44 +205,41 @@ static void *m_start(struct seq_file *m, loff_t *pos)
192205
return ERR_PTR(-ESRCH);
193206

194207
mm = priv->mm;
195-
if (!mm || !mmget_not_zero(mm))
208+
if (!mm || !mmget_not_zero(mm)) {
209+
put_task_struct(priv->task);
210+
priv->task = NULL;
196211
return NULL;
212+
}
197213

198214
if (mmap_read_lock_killable(mm)) {
199215
mmput(mm);
216+
put_task_struct(priv->task);
217+
priv->task = NULL;
200218
return ERR_PTR(-EINTR);
201219
}
202220

203-
/* start the next element from addr */
204-
vma = find_vma(mm, addr);
205-
if (vma)
206-
return vma;
221+
vma_iter_init(&priv->iter, mm, last_addr);
207222

208-
mmap_read_unlock(mm);
209-
mmput(mm);
210-
return NULL;
223+
return proc_get_vma(priv, ppos);
211224
}
212225

213-
static void m_stop(struct seq_file *m, void *_vml)
226+
static void m_stop(struct seq_file *m, void *v)
214227
{
215228
struct proc_maps_private *priv = m->private;
229+
struct mm_struct *mm = priv->mm;
216230

217-
if (!IS_ERR_OR_NULL(_vml)) {
218-
mmap_read_unlock(priv->mm);
219-
mmput(priv->mm);
220-
}
221-
if (priv->task) {
222-
put_task_struct(priv->task);
223-
priv->task = NULL;
224-
}
231+
if (!priv->task)
232+
return;
233+
234+
mmap_read_unlock(mm);
235+
mmput(mm);
236+
put_task_struct(priv->task);
237+
priv->task = NULL;
225238
}
226239

227-
static void *m_next(struct seq_file *m, void *_p, loff_t *pos)
240+
static void *m_next(struct seq_file *m, void *_p, loff_t *ppos)
228241
{
229-
struct vm_area_struct *vma = _p;
230-
231-
*pos = vma->vm_end;
232-
return find_vma(vma->vm_mm, vma->vm_end);
242+
return proc_get_vma(m->private, ppos);
233243
}
234244

235245
static const struct seq_operations proc_pid_maps_ops = {

include/linux/memcontrol.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ unsigned long mem_cgroup_get_zone_lru_size(struct lruvec *lruvec,
920920
return READ_ONCE(mz->lru_zone_size[zone_idx][lru]);
921921
}
922922

923-
void mem_cgroup_handle_over_high(void);
923+
void mem_cgroup_handle_over_high(gfp_t gfp_mask);
924924

925925
unsigned long mem_cgroup_get_max(struct mem_cgroup *memcg);
926926

@@ -1458,7 +1458,7 @@ static inline void mem_cgroup_unlock_pages(void)
14581458
rcu_read_unlock();
14591459
}
14601460

1461-
static inline void mem_cgroup_handle_over_high(void)
1461+
static inline void mem_cgroup_handle_over_high(gfp_t gfp_mask)
14621462
{
14631463
}
14641464

include/linux/resume_user_mode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static inline void resume_user_mode_work(struct pt_regs *regs)
5555
}
5656
#endif
5757

58-
mem_cgroup_handle_over_high();
58+
mem_cgroup_handle_over_high(GFP_KERNEL);
5959
blkcg_maybe_throttle_current();
6060

6161
rseq_handle_notify_resume(NULL, regs);

kernel/pid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ int pidfd_create(struct pid *pid, unsigned int flags)
609609
}
610610

611611
/**
612-
* pidfd_open() - Open new pid file descriptor.
612+
* sys_pidfd_open() - Open new pid file descriptor.
613613
*
614614
* @pid: pid for which to retrieve a pidfd
615615
* @flags: flags to pass

kernel/task_work.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ int task_work_add(struct task_struct *task, struct callback_head *work,
7878
* task_work_cancel_match - cancel a pending work added by task_work_add()
7979
* @task: the task which should execute the work
8080
* @match: match function to call
81+
* @data: data to be passed in to match function
8182
*
8283
* RETURNS:
8384
* The found work or NULL if not found.

lib/argv_split.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static int count_argc(const char *str)
2828

2929
/**
3030
* argv_free - free an argv
31-
* @argv - the argument vector to be freed
31+
* @argv: the argument vector to be freed
3232
*
3333
* Frees an argv and the strings it points to.
3434
*/
@@ -46,7 +46,7 @@ EXPORT_SYMBOL(argv_free);
4646
* @str: the string to be split
4747
* @argcp: returned argument count
4848
*
49-
* Returns an array of pointers to strings which are split out from
49+
* Returns: an array of pointers to strings which are split out from
5050
* @str. This is performed by strictly splitting on white-space; no
5151
* quote processing is performed. Multiple whitespace characters are
5252
* considered to be a single argument separator. The returned array

lib/scatterlist.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ EXPORT_SYMBOL(sg_free_table);
265265
* @table: The sg table header to use
266266
* @nents: Number of entries in sg list
267267
* @max_ents: The maximum number of entries the allocator returns per call
268-
* @nents_first_chunk: Number of entries int the (preallocated) first
268+
* @first_chunk: first SGL if preallocated (may be %NULL)
269+
* @nents_first_chunk: Number of entries in the (preallocated) first
269270
* scatterlist chunk, 0 means no such preallocated chunk provided by user
270271
* @gfp_mask: GFP allocation mask
271272
* @alloc_fn: Allocator to use
@@ -788,6 +789,7 @@ EXPORT_SYMBOL(__sg_page_iter_dma_next);
788789
* @miter: sg mapping iter to be started
789790
* @sgl: sg list to iterate over
790791
* @nents: number of sg entries
792+
* @flags: sg iterator flags
791793
*
792794
* Description:
793795
* Starts mapping iterator @miter.

mm/filemap.c

Lines changed: 48 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3475,22 +3475,19 @@ static struct folio *next_uptodate_folio(struct xa_state *xas,
34753475
*/
34763476
static vm_fault_t filemap_map_folio_range(struct vm_fault *vmf,
34773477
struct folio *folio, unsigned long start,
3478-
unsigned long addr, unsigned int nr_pages)
3478+
unsigned long addr, unsigned int nr_pages,
3479+
unsigned int *mmap_miss)
34793480
{
34803481
vm_fault_t ret = 0;
3481-
struct vm_area_struct *vma = vmf->vma;
3482-
struct file *file = vma->vm_file;
34833482
struct page *page = folio_page(folio, start);
3484-
unsigned int mmap_miss = READ_ONCE(file->f_ra.mmap_miss);
34853483
unsigned int count = 0;
34863484
pte_t *old_ptep = vmf->pte;
34873485

34883486
do {
34893487
if (PageHWPoison(page + count))
34903488
goto skip;
34913489

3492-
if (mmap_miss > 0)
3493-
mmap_miss--;
3490+
(*mmap_miss)++;
34943491

34953492
/*
34963493
* NOTE: If there're PTE markers, we'll leave them to be
@@ -3525,7 +3522,35 @@ static vm_fault_t filemap_map_folio_range(struct vm_fault *vmf,
35253522
}
35263523

35273524
vmf->pte = old_ptep;
3528-
WRITE_ONCE(file->f_ra.mmap_miss, mmap_miss);
3525+
3526+
return ret;
3527+
}
3528+
3529+
static vm_fault_t filemap_map_order0_folio(struct vm_fault *vmf,
3530+
struct folio *folio, unsigned long addr,
3531+
unsigned int *mmap_miss)
3532+
{
3533+
vm_fault_t ret = 0;
3534+
struct page *page = &folio->page;
3535+
3536+
if (PageHWPoison(page))
3537+
return ret;
3538+
3539+
(*mmap_miss)++;
3540+
3541+
/*
3542+
* NOTE: If there're PTE markers, we'll leave them to be
3543+
* handled in the specific fault path, and it'll prohibit
3544+
* the fault-around logic.
3545+
*/
3546+
if (!pte_none(ptep_get(vmf->pte)))
3547+
return ret;
3548+
3549+
if (vmf->address == addr)
3550+
ret = VM_FAULT_NOPAGE;
3551+
3552+
set_pte_range(vmf, folio, page, 1, addr);
3553+
folio_ref_inc(folio);
35293554

35303555
return ret;
35313556
}
@@ -3541,7 +3566,7 @@ vm_fault_t filemap_map_pages(struct vm_fault *vmf,
35413566
XA_STATE(xas, &mapping->i_pages, start_pgoff);
35423567
struct folio *folio;
35433568
vm_fault_t ret = 0;
3544-
int nr_pages = 0;
3569+
unsigned int nr_pages = 0, mmap_miss = 0, mmap_miss_saved;
35453570

35463571
rcu_read_lock();
35473572
folio = next_uptodate_folio(&xas, mapping, end_pgoff);
@@ -3569,25 +3594,27 @@ vm_fault_t filemap_map_pages(struct vm_fault *vmf,
35693594
end = folio->index + folio_nr_pages(folio) - 1;
35703595
nr_pages = min(end, end_pgoff) - xas.xa_index + 1;
35713596

3572-
/*
3573-
* NOTE: If there're PTE markers, we'll leave them to be
3574-
* handled in the specific fault path, and it'll prohibit the
3575-
* fault-around logic.
3576-
*/
3577-
if (!pte_none(ptep_get(vmf->pte)))
3578-
goto unlock;
3579-
3580-
ret |= filemap_map_folio_range(vmf, folio,
3581-
xas.xa_index - folio->index, addr, nr_pages);
3597+
if (!folio_test_large(folio))
3598+
ret |= filemap_map_order0_folio(vmf,
3599+
folio, addr, &mmap_miss);
3600+
else
3601+
ret |= filemap_map_folio_range(vmf, folio,
3602+
xas.xa_index - folio->index, addr,
3603+
nr_pages, &mmap_miss);
35823604

3583-
unlock:
35843605
folio_unlock(folio);
35853606
folio_put(folio);
3586-
folio = next_uptodate_folio(&xas, mapping, end_pgoff);
3587-
} while (folio);
3607+
} while ((folio = next_uptodate_folio(&xas, mapping, end_pgoff)) != NULL);
35883608
pte_unmap_unlock(vmf->pte, vmf->ptl);
35893609
out:
35903610
rcu_read_unlock();
3611+
3612+
mmap_miss_saved = READ_ONCE(file->f_ra.mmap_miss);
3613+
if (mmap_miss >= mmap_miss_saved)
3614+
WRITE_ONCE(file->f_ra.mmap_miss, 0);
3615+
else
3616+
WRITE_ONCE(file->f_ra.mmap_miss, mmap_miss_saved - mmap_miss);
3617+
35913618
return ret;
35923619
}
35933620
EXPORT_SYMBOL(filemap_map_pages);

0 commit comments

Comments
 (0)