Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+114 -94
+2 -2
arch/sh/mm/ioremap.c
··· 72 72 #define __ioremap_29bit(offset, size, prot) NULL 73 73 #endif /* CONFIG_29BIT */ 74 74 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) 77 77 { 78 78 void __iomem *mapped; 79 79 pgprot_t pgprot = __pgprot(prot);
-2
fs/proc/internal.h
··· 289 289 struct inode *inode; 290 290 struct task_struct *task; 291 291 struct mm_struct *mm; 292 - #ifdef CONFIG_MMU 293 292 struct vma_iterator iter; 294 - #endif 295 293 #ifdef CONFIG_NUMA 296 294 struct mempolicy *task_mempolicy; 297 295 #endif
+40 -30
fs/proc/task_nommu.c
··· 175 175 return nommu_vma_show(m, _p); 176 176 } 177 177 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) 179 193 { 180 194 struct proc_maps_private *priv = m->private; 195 + unsigned long last_addr = *ppos; 181 196 struct mm_struct *mm; 182 - struct vm_area_struct *vma; 183 - unsigned long addr = *pos; 184 197 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) 187 200 return NULL; 188 201 189 202 /* pin the task and mm whilst we play with them */ ··· 205 192 return ERR_PTR(-ESRCH); 206 193 207 194 mm = priv->mm; 208 - if (!mm || !mmget_not_zero(mm)) 195 + if (!mm || !mmget_not_zero(mm)) { 196 + put_task_struct(priv->task); 197 + priv->task = NULL; 209 198 return NULL; 199 + } 210 200 211 201 if (mmap_read_lock_killable(mm)) { 212 202 mmput(mm); 203 + put_task_struct(priv->task); 204 + priv->task = NULL; 213 205 return ERR_PTR(-EINTR); 214 206 } 215 207 216 - /* start the next element from addr */ 217 - vma = find_vma(mm, addr); 218 - if (vma) 219 - return vma; 208 + vma_iter_init(&priv->iter, mm, last_addr); 209 + 210 + return proc_get_vma(priv, ppos); 211 + } 212 + 213 + static void m_stop(struct seq_file *m, void *v) 214 + { 215 + struct proc_maps_private *priv = m->private; 216 + struct mm_struct *mm = priv->mm; 217 + 218 + if (!priv->task) 219 + return; 220 220 221 221 mmap_read_unlock(mm); 222 222 mmput(mm); 223 - return NULL; 223 + put_task_struct(priv->task); 224 + priv->task = NULL; 224 225 } 225 226 226 - static void m_stop(struct seq_file *m, void *_vml) 227 + static void *m_next(struct seq_file *m, void *_p, loff_t *ppos) 227 228 { 228 - struct proc_maps_private *priv = m->private; 229 - 230 - if (!IS_ERR_OR_NULL(_vml)) { 231 - mmap_read_unlock(priv->mm); 232 - mmput(priv->mm); 233 - } 234 - if (priv->task) { 235 - put_task_struct(priv->task); 236 - priv->task = NULL; 237 - } 238 - } 239 - 240 - static void *m_next(struct seq_file *m, void *_p, loff_t *pos) 241 - { 242 - struct vm_area_struct *vma = _p; 243 - 244 - *pos = vma->vm_end; 245 - return find_vma(vma->vm_mm, vma->vm_end); 229 + return proc_get_vma(m->private, ppos); 246 230 } 247 231 248 232 static const struct seq_operations proc_pid_maps_ops = {
+2 -2
include/linux/memcontrol.h
··· 920 920 return READ_ONCE(mz->lru_zone_size[zone_idx][lru]); 921 921 } 922 922 923 - void mem_cgroup_handle_over_high(void); 923 + void mem_cgroup_handle_over_high(gfp_t gfp_mask); 924 924 925 925 unsigned long mem_cgroup_get_max(struct mem_cgroup *memcg); 926 926 ··· 1458 1458 rcu_read_unlock(); 1459 1459 } 1460 1460 1461 - static inline void mem_cgroup_handle_over_high(void) 1461 + static inline void mem_cgroup_handle_over_high(gfp_t gfp_mask) 1462 1462 { 1463 1463 } 1464 1464
+1 -1
include/linux/resume_user_mode.h
··· 55 55 } 56 56 #endif 57 57 58 - mem_cgroup_handle_over_high(); 58 + mem_cgroup_handle_over_high(GFP_KERNEL); 59 59 blkcg_maybe_throttle_current(); 60 60 61 61 rseq_handle_notify_resume(NULL, regs);
+1 -1
kernel/pid.c
··· 609 609 } 610 610 611 611 /** 612 - * pidfd_open() - Open new pid file descriptor. 612 + * sys_pidfd_open() - Open new pid file descriptor. 613 613 * 614 614 * @pid: pid for which to retrieve a pidfd 615 615 * @flags: flags to pass
+1
kernel/task_work.c
··· 78 78 * task_work_cancel_match - cancel a pending work added by task_work_add() 79 79 * @task: the task which should execute the work 80 80 * @match: match function to call 81 + * @data: data to be passed in to match function 81 82 * 82 83 * RETURNS: 83 84 * The found work or NULL if not found.
+2 -2
lib/argv_split.c
··· 28 28 29 29 /** 30 30 * argv_free - free an argv 31 - * @argv - the argument vector to be freed 31 + * @argv: the argument vector to be freed 32 32 * 33 33 * Frees an argv and the strings it points to. 34 34 */ ··· 46 46 * @str: the string to be split 47 47 * @argcp: returned argument count 48 48 * 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 50 50 * @str. This is performed by strictly splitting on white-space; no 51 51 * quote processing is performed. Multiple whitespace characters are 52 52 * considered to be a single argument separator. The returned array
+3 -1
lib/scatterlist.c
··· 265 265 * @table: The sg table header to use 266 266 * @nents: Number of entries in sg list 267 267 * @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 269 270 * scatterlist chunk, 0 means no such preallocated chunk provided by user 270 271 * @gfp_mask: GFP allocation mask 271 272 * @alloc_fn: Allocator to use ··· 789 788 * @miter: sg mapping iter to be started 790 789 * @sgl: sg list to iterate over 791 790 * @nents: number of sg entries 791 + * @flags: sg iterator flags 792 792 * 793 793 * Description: 794 794 * Starts mapping iterator @miter.
+48 -21
mm/filemap.c
··· 3475 3475 */ 3476 3476 static vm_fault_t filemap_map_folio_range(struct vm_fault *vmf, 3477 3477 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) 3479 3480 { 3480 3481 vm_fault_t ret = 0; 3481 - struct vm_area_struct *vma = vmf->vma; 3482 - struct file *file = vma->vm_file; 3483 3482 struct page *page = folio_page(folio, start); 3484 - unsigned int mmap_miss = READ_ONCE(file->f_ra.mmap_miss); 3485 3483 unsigned int count = 0; 3486 3484 pte_t *old_ptep = vmf->pte; 3487 3485 ··· 3487 3489 if (PageHWPoison(page + count)) 3488 3490 goto skip; 3489 3491 3490 - if (mmap_miss > 0) 3491 - mmap_miss--; 3492 + (*mmap_miss)++; 3492 3493 3493 3494 /* 3494 3495 * NOTE: If there're PTE markers, we'll leave them to be ··· 3522 3525 } 3523 3526 3524 3527 vmf->pte = old_ptep; 3525 - WRITE_ONCE(file->f_ra.mmap_miss, mmap_miss); 3528 + 3529 + return ret; 3530 + } 3531 + 3532 + static vm_fault_t filemap_map_order0_folio(struct vm_fault *vmf, 3533 + struct folio *folio, unsigned long addr, 3534 + unsigned int *mmap_miss) 3535 + { 3536 + vm_fault_t ret = 0; 3537 + struct page *page = &folio->page; 3538 + 3539 + if (PageHWPoison(page)) 3540 + return ret; 3541 + 3542 + (*mmap_miss)++; 3543 + 3544 + /* 3545 + * NOTE: If there're PTE markers, we'll leave them to be 3546 + * handled in the specific fault path, and it'll prohibit 3547 + * the fault-around logic. 3548 + */ 3549 + if (!pte_none(ptep_get(vmf->pte))) 3550 + return ret; 3551 + 3552 + if (vmf->address == addr) 3553 + ret = VM_FAULT_NOPAGE; 3554 + 3555 + set_pte_range(vmf, folio, page, 1, addr); 3556 + folio_ref_inc(folio); 3526 3557 3527 3558 return ret; 3528 3559 } ··· 3566 3541 XA_STATE(xas, &mapping->i_pages, start_pgoff); 3567 3542 struct folio *folio; 3568 3543 vm_fault_t ret = 0; 3569 - int nr_pages = 0; 3544 + unsigned int nr_pages = 0, mmap_miss = 0, mmap_miss_saved; 3570 3545 3571 3546 rcu_read_lock(); 3572 3547 folio = next_uptodate_folio(&xas, mapping, end_pgoff); ··· 3594 3569 end = folio->index + folio_nr_pages(folio) - 1; 3595 3570 nr_pages = min(end, end_pgoff) - xas.xa_index + 1; 3596 3571 3597 - /* 3598 - * NOTE: If there're PTE markers, we'll leave them to be 3599 - * handled in the specific fault path, and it'll prohibit the 3600 - * fault-around logic. 3601 - */ 3602 - if (!pte_none(ptep_get(vmf->pte))) 3603 - goto unlock; 3572 + if (!folio_test_large(folio)) 3573 + ret |= filemap_map_order0_folio(vmf, 3574 + folio, addr, &mmap_miss); 3575 + else 3576 + ret |= filemap_map_folio_range(vmf, folio, 3577 + xas.xa_index - folio->index, addr, 3578 + nr_pages, &mmap_miss); 3604 3579 3605 - ret |= filemap_map_folio_range(vmf, folio, 3606 - xas.xa_index - folio->index, addr, nr_pages); 3607 - 3608 - unlock: 3609 3580 folio_unlock(folio); 3610 3581 folio_put(folio); 3611 - folio = next_uptodate_folio(&xas, mapping, end_pgoff); 3612 - } while (folio); 3582 + } while ((folio = next_uptodate_folio(&xas, mapping, end_pgoff)) != NULL); 3613 3583 pte_unmap_unlock(vmf->pte, vmf->ptl); 3614 3584 out: 3615 3585 rcu_read_unlock(); 3586 + 3587 + mmap_miss_saved = READ_ONCE(file->f_ra.mmap_miss); 3588 + if (mmap_miss >= mmap_miss_saved) 3589 + WRITE_ONCE(file->f_ra.mmap_miss, 0); 3590 + else 3591 + WRITE_ONCE(file->f_ra.mmap_miss, mmap_miss_saved - mmap_miss); 3592 + 3616 3593 return ret; 3617 3594 } 3618 3595 EXPORT_SYMBOL(filemap_map_pages);
+3 -3
mm/memcontrol.c
··· 2555 2555 * Scheduled by try_charge() to be executed from the userland return path 2556 2556 * and reclaims memory over the high limit. 2557 2557 */ 2558 - void mem_cgroup_handle_over_high(void) 2558 + void mem_cgroup_handle_over_high(gfp_t gfp_mask) 2559 2559 { 2560 2560 unsigned long penalty_jiffies; 2561 2561 unsigned long pflags; ··· 2583 2583 */ 2584 2584 nr_reclaimed = reclaim_high(memcg, 2585 2585 in_retry ? SWAP_CLUSTER_MAX : nr_pages, 2586 - GFP_KERNEL); 2586 + gfp_mask); 2587 2587 2588 2588 /* 2589 2589 * memory.high is breached and reclaim is unable to keep up. Throttle ··· 2819 2819 if (current->memcg_nr_pages_over_high > MEMCG_CHARGE_BATCH && 2820 2820 !(current->flags & PF_MEMALLOC) && 2821 2821 gfpflags_allow_blocking(gfp_mask)) { 2822 - mem_cgroup_handle_over_high(); 2822 + mem_cgroup_handle_over_high(gfp_mask); 2823 2823 } 2824 2824 return 0; 2825 2825 }
+6 -6
mm/page_alloc.c
··· 2400 2400 struct per_cpu_pages *pcp; 2401 2401 struct zone *zone; 2402 2402 unsigned long pfn = page_to_pfn(page); 2403 - int migratetype; 2403 + int migratetype, pcpmigratetype; 2404 2404 2405 2405 if (!free_unref_page_prepare(page, pfn, order)) 2406 2406 return; ··· 2408 2408 /* 2409 2409 * We only track unmovable, reclaimable and movable on pcp lists. 2410 2410 * Place ISOLATE pages on the isolated list because they are being 2411 - * offlined but treat HIGHATOMIC as movable pages so we can get those 2412 - * areas back if necessary. Otherwise, we may have to free 2411 + * offlined but treat HIGHATOMIC and CMA as movable pages so we can 2412 + * get those areas back if necessary. Otherwise, we may have to free 2413 2413 * excessively into the page allocator 2414 2414 */ 2415 - migratetype = get_pcppage_migratetype(page); 2415 + migratetype = pcpmigratetype = get_pcppage_migratetype(page); 2416 2416 if (unlikely(migratetype >= MIGRATE_PCPTYPES)) { 2417 2417 if (unlikely(is_migrate_isolate(migratetype))) { 2418 2418 free_one_page(page_zone(page), page, pfn, order, migratetype, FPI_NONE); 2419 2419 return; 2420 2420 } 2421 - migratetype = MIGRATE_MOVABLE; 2421 + pcpmigratetype = MIGRATE_MOVABLE; 2422 2422 } 2423 2423 2424 2424 zone = page_zone(page); 2425 2425 pcp_trylock_prepare(UP_flags); 2426 2426 pcp = pcp_spin_trylock(zone->per_cpu_pageset); 2427 2427 if (pcp) { 2428 - free_unref_page_commit(zone, pcp, page, migratetype, order); 2428 + free_unref_page_commit(zone, pcp, page, pcpmigratetype, order); 2429 2429 pcp_spin_unlock(pcp); 2430 2430 } else { 2431 2431 free_one_page(zone, page, pfn, order, migratetype, FPI_NONE);
+2 -21
scripts/gdb/linux/symbols.py
··· 111 111 return "{textaddr} {sections}".format( 112 112 textaddr=textaddr, sections="".join(args)) 113 113 114 - def load_module_symbols(self, module, module_file=None): 114 + def load_module_symbols(self, module): 115 115 module_name = module['name'].string() 116 116 module_addr = str(module['mem'][constants.LX_MOD_TEXT]['base']).split()[0] 117 117 118 - if not module_file: 119 - module_file = self._get_module_file(module_name) 118 + module_file = self._get_module_file(module_name) 120 119 if not module_file and not self.module_files_updated: 121 120 self._update_module_files() 122 121 module_file = self._get_module_file(module_name) ··· 137 138 self.loaded_modules.append(module_name) 138 139 else: 139 140 gdb.write("no module object found for '{0}'\n".format(module_name)) 140 - 141 - def load_ko_symbols(self, mod_path): 142 - self.loaded_modules = [] 143 - module_list = modules.module_list() 144 - 145 - for module in module_list: 146 - module_name = module['name'].string() 147 - module_pattern = ".*/{0}\.ko(?:.debug)?$".format( 148 - module_name.replace("_", r"[_\-]")) 149 - if re.match(module_pattern, mod_path) and os.path.exists(mod_path): 150 - self.load_module_symbols(module, mod_path) 151 - return 152 - raise gdb.GdbError("%s is not a valid .ko\n" % mod_path) 153 141 154 142 def load_all_symbols(self): 155 143 gdb.write("loading vmlinux\n") ··· 175 189 # enforce update 176 190 self.module_files = [] 177 191 self.module_files_updated = False 178 - 179 - argv = gdb.string_to_argv(arg) 180 - if len(argv) == 1: 181 - self.load_ko_symbols(argv[0]) 182 - return 183 192 184 193 self.load_all_symbols() 185 194
+1 -1
tools/testing/selftests/fchmodat2/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0-or-later 2 2 3 - CFLAGS += -Wall -O2 -g -fsanitize=address -fsanitize=undefined $(KHDR_INCLUDES) 3 + CFLAGS += -Wall -O2 -g -fsanitize=address -fsanitize=undefined -static-libasan $(KHDR_INCLUDES) 4 4 TEST_GEN_PROGS := fchmodat2_test 5 5 6 6 include ../lib.mk
+1 -1
tools/testing/selftests/openat2/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0-or-later 2 2 3 - CFLAGS += -Wall -O2 -g -fsanitize=address -fsanitize=undefined 3 + CFLAGS += -Wall -O2 -g -fsanitize=address -fsanitize=undefined -static-libasan 4 4 TEST_GEN_PROGS := openat2_test resolve_test rename_attack_test 5 5 6 6 include ../lib.mk
+1
tools/testing/selftests/proc/proc-empty-vm.c
··· 267 267 "Private_Dirty: 0 kB\n" 268 268 "Referenced: 0 kB\n" 269 269 "Anonymous: 0 kB\n" 270 + "KSM: 0 kB\n" 270 271 "LazyFree: 0 kB\n" 271 272 "AnonHugePages: 0 kB\n" 272 273 "ShmemPmdMapped: 0 kB\n"