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 branch 'akpm' (patches from Andrew)

Merge misc fixes from Andrew Morton:
"11 fixes"

MM fixes and one xz decompressor fix.

* emailed patches from Andrew Morton <akpm@linux-foundation.org>:
mm/debug.c: PageAnon() is true for PageKsm() pages
mm/debug.c: __dump_page() prints an extra line
mm/page_io.c: do not free shared swap slots
mm/memory_hotplug: fix try_offline_node()
mm,thp: recheck each page before collapsing file THP
mm: slub: really fix slab walking for init_on_free
mm: hugetlb: switch to css_tryget() in hugetlb_cgroup_charge_cgroup()
mm: memcg: switch to css_tryget() in get_mem_cgroup_from_mm()
lib/xz: fix XZ_DYNALLOC to avoid useless memory reallocations
mm: fix trying to reclaim unevictable lru page when calling madvise_pageout
mm: mempolicy: fix the wrong return value and potential pages leak of mbind

+134 -87
+36
drivers/base/memory.c
··· 872 872 } 873 873 return ret; 874 874 } 875 + 876 + struct for_each_memory_block_cb_data { 877 + walk_memory_blocks_func_t func; 878 + void *arg; 879 + }; 880 + 881 + static int for_each_memory_block_cb(struct device *dev, void *data) 882 + { 883 + struct memory_block *mem = to_memory_block(dev); 884 + struct for_each_memory_block_cb_data *cb_data = data; 885 + 886 + return cb_data->func(mem, cb_data->arg); 887 + } 888 + 889 + /** 890 + * for_each_memory_block - walk through all present memory blocks 891 + * 892 + * @arg: argument passed to func 893 + * @func: callback for each memory block walked 894 + * 895 + * This function walks through all present memory blocks, calling func on 896 + * each memory block. 897 + * 898 + * In case func() returns an error, walking is aborted and the error is 899 + * returned. 900 + */ 901 + int for_each_memory_block(void *arg, walk_memory_blocks_func_t func) 902 + { 903 + struct for_each_memory_block_cb_data cb_data = { 904 + .func = func, 905 + .arg = arg, 906 + }; 907 + 908 + return bus_for_each_dev(&memory_subsys, NULL, &cb_data, 909 + for_each_memory_block_cb); 910 + }
+1
include/linux/memory.h
··· 119 119 typedef int (*walk_memory_blocks_func_t)(struct memory_block *, void *); 120 120 extern int walk_memory_blocks(unsigned long start, unsigned long size, 121 121 void *arg, walk_memory_blocks_func_t func); 122 + extern int for_each_memory_block(void *arg, walk_memory_blocks_func_t func); 122 123 #define CONFIG_MEM_BLOCK_SIZE (PAGES_PER_SECTION<<PAGE_SHIFT) 123 124 #endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */ 124 125
+1
lib/xz/xz_dec_lzma2.c
··· 1146 1146 1147 1147 if (DEC_IS_DYNALLOC(s->dict.mode)) { 1148 1148 if (s->dict.allocated < s->dict.size) { 1149 + s->dict.allocated = s->dict.size; 1149 1150 vfree(s->dict.buf); 1150 1151 s->dict.buf = vmalloc(s->dict.size); 1151 1152 if (s->dict.buf == NULL) {
+17 -14
mm/debug.c
··· 67 67 */ 68 68 mapcount = PageSlab(page) ? 0 : page_mapcount(page); 69 69 70 - pr_warn("page:%px refcount:%d mapcount:%d mapping:%px index:%#lx", 71 - page, page_ref_count(page), mapcount, 72 - page->mapping, page_to_pgoff(page)); 73 70 if (PageCompound(page)) 74 - pr_cont(" compound_mapcount: %d", compound_mapcount(page)); 75 - pr_cont("\n"); 76 - if (PageAnon(page)) 77 - pr_warn("anon "); 78 - else if (PageKsm(page)) 79 - pr_warn("ksm "); 71 + pr_warn("page:%px refcount:%d mapcount:%d mapping:%px " 72 + "index:%#lx compound_mapcount: %d\n", 73 + page, page_ref_count(page), mapcount, 74 + page->mapping, page_to_pgoff(page), 75 + compound_mapcount(page)); 76 + else 77 + pr_warn("page:%px refcount:%d mapcount:%d mapping:%px index:%#lx\n", 78 + page, page_ref_count(page), mapcount, 79 + page->mapping, page_to_pgoff(page)); 80 + if (PageKsm(page)) 81 + pr_warn("ksm flags: %#lx(%pGp)\n", page->flags, &page->flags); 82 + else if (PageAnon(page)) 83 + pr_warn("anon flags: %#lx(%pGp)\n", page->flags, &page->flags); 80 84 else if (mapping) { 81 - pr_warn("%ps ", mapping->a_ops); 82 85 if (mapping->host && mapping->host->i_dentry.first) { 83 86 struct dentry *dentry; 84 87 dentry = container_of(mapping->host->i_dentry.first, struct dentry, d_u.d_alias); 85 - pr_warn("name:\"%pd\" ", dentry); 86 - } 88 + pr_warn("%ps name:\"%pd\"\n", mapping->a_ops, dentry); 89 + } else 90 + pr_warn("%ps\n", mapping->a_ops); 91 + pr_warn("flags: %#lx(%pGp)\n", page->flags, &page->flags); 87 92 } 88 93 BUILD_BUG_ON(ARRAY_SIZE(pageflag_names) != __NR_PAGEFLAGS + 1); 89 - 90 - pr_warn("flags: %#lx(%pGp)\n", page->flags, &page->flags); 91 94 92 95 hex_only: 93 96 print_hex_dump(KERN_WARNING, "raw: ", DUMP_PREFIX_NONE, 32,
+1 -1
mm/hugetlb_cgroup.c
··· 196 196 again: 197 197 rcu_read_lock(); 198 198 h_cg = hugetlb_cgroup_from_task(current); 199 - if (!css_tryget_online(&h_cg->css)) { 199 + if (!css_tryget(&h_cg->css)) { 200 200 rcu_read_unlock(); 201 201 goto again; 202 202 }
+16 -12
mm/khugepaged.c
··· 1602 1602 result = SCAN_FAIL; 1603 1603 goto xa_unlocked; 1604 1604 } 1605 - } else if (!PageUptodate(page)) { 1606 - xas_unlock_irq(&xas); 1607 - wait_on_page_locked(page); 1608 - if (!trylock_page(page)) { 1609 - result = SCAN_PAGE_LOCK; 1610 - goto xa_unlocked; 1611 - } 1612 - get_page(page); 1613 - } else if (PageDirty(page)) { 1614 - result = SCAN_FAIL; 1615 - goto xa_locked; 1616 1605 } else if (trylock_page(page)) { 1617 1606 get_page(page); 1618 1607 xas_unlock_irq(&xas); ··· 1616 1627 * without racing with truncate. 1617 1628 */ 1618 1629 VM_BUG_ON_PAGE(!PageLocked(page), page); 1619 - VM_BUG_ON_PAGE(!PageUptodate(page), page); 1630 + 1631 + /* make sure the page is up to date */ 1632 + if (unlikely(!PageUptodate(page))) { 1633 + result = SCAN_FAIL; 1634 + goto out_unlock; 1635 + } 1620 1636 1621 1637 /* 1622 1638 * If file was truncated then extended, or hole-punched, before ··· 1634 1640 1635 1641 if (page_mapping(page) != mapping) { 1636 1642 result = SCAN_TRUNCATED; 1643 + goto out_unlock; 1644 + } 1645 + 1646 + if (!is_shmem && PageDirty(page)) { 1647 + /* 1648 + * khugepaged only works on read-only fd, so this 1649 + * page is dirty because it hasn't been flushed 1650 + * since first write. 1651 + */ 1652 + result = SCAN_FAIL; 1637 1653 goto out_unlock; 1638 1654 } 1639 1655
+12 -4
mm/madvise.c
··· 363 363 ClearPageReferenced(page); 364 364 test_and_clear_page_young(page); 365 365 if (pageout) { 366 - if (!isolate_lru_page(page)) 367 - list_add(&page->lru, &page_list); 366 + if (!isolate_lru_page(page)) { 367 + if (PageUnevictable(page)) 368 + putback_lru_page(page); 369 + else 370 + list_add(&page->lru, &page_list); 371 + } 368 372 } else 369 373 deactivate_page(page); 370 374 huge_unlock: ··· 445 441 ClearPageReferenced(page); 446 442 test_and_clear_page_young(page); 447 443 if (pageout) { 448 - if (!isolate_lru_page(page)) 449 - list_add(&page->lru, &page_list); 444 + if (!isolate_lru_page(page)) { 445 + if (PageUnevictable(page)) 446 + putback_lru_page(page); 447 + else 448 + list_add(&page->lru, &page_list); 449 + } 450 450 } else 451 451 deactivate_page(page); 452 452 }
+1 -1
mm/memcontrol.c
··· 960 960 if (unlikely(!memcg)) 961 961 memcg = root_mem_cgroup; 962 962 } 963 - } while (!css_tryget_online(&memcg->css)); 963 + } while (!css_tryget(&memcg->css)); 964 964 rcu_read_unlock(); 965 965 return memcg; 966 966 }
+28 -17
mm/memory_hotplug.c
··· 1646 1646 return 0; 1647 1647 } 1648 1648 1649 + static int check_no_memblock_for_node_cb(struct memory_block *mem, void *arg) 1650 + { 1651 + int nid = *(int *)arg; 1652 + 1653 + /* 1654 + * If a memory block belongs to multiple nodes, the stored nid is not 1655 + * reliable. However, such blocks are always online (e.g., cannot get 1656 + * offlined) and, therefore, are still spanned by the node. 1657 + */ 1658 + return mem->nid == nid ? -EEXIST : 0; 1659 + } 1660 + 1649 1661 /** 1650 1662 * try_offline_node 1651 1663 * @nid: the node ID ··· 1670 1658 void try_offline_node(int nid) 1671 1659 { 1672 1660 pg_data_t *pgdat = NODE_DATA(nid); 1673 - unsigned long start_pfn = pgdat->node_start_pfn; 1674 - unsigned long end_pfn = start_pfn + pgdat->node_spanned_pages; 1675 - unsigned long pfn; 1661 + int rc; 1676 1662 1677 - for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) { 1678 - unsigned long section_nr = pfn_to_section_nr(pfn); 1679 - 1680 - if (!present_section_nr(section_nr)) 1681 - continue; 1682 - 1683 - if (pfn_to_nid(pfn) != nid) 1684 - continue; 1685 - 1686 - /* 1687 - * some memory sections of this node are not removed, and we 1688 - * can't offline node now. 1689 - */ 1663 + /* 1664 + * If the node still spans pages (especially ZONE_DEVICE), don't 1665 + * offline it. A node spans memory after move_pfn_range_to_zone(), 1666 + * e.g., after the memory block was onlined. 1667 + */ 1668 + if (pgdat->node_spanned_pages) 1690 1669 return; 1691 - } 1670 + 1671 + /* 1672 + * Especially offline memory blocks might not be spanned by the 1673 + * node. They will get spanned by the node once they get onlined. 1674 + * However, they link to the node in sysfs and can get onlined later. 1675 + */ 1676 + rc = for_each_memory_block(&nid, check_no_memblock_for_node_cb); 1677 + if (rc) 1678 + return; 1692 1679 1693 1680 if (check_cpu_on_node(pgdat)) 1694 1681 return;
+9 -5
mm/mempolicy.c
··· 672 672 * 1 - there is unmovable page, but MPOL_MF_MOVE* & MPOL_MF_STRICT were 673 673 * specified. 674 674 * 0 - queue pages successfully or no misplaced page. 675 - * -EIO - there is misplaced page and only MPOL_MF_STRICT was specified. 675 + * errno - i.e. misplaced pages with MPOL_MF_STRICT specified (-EIO) or 676 + * memory range specified by nodemask and maxnode points outside 677 + * your accessible address space (-EFAULT) 676 678 */ 677 679 static int 678 680 queue_pages_range(struct mm_struct *mm, unsigned long start, unsigned long end, ··· 1288 1286 flags | MPOL_MF_INVERT, &pagelist); 1289 1287 1290 1288 if (ret < 0) { 1291 - err = -EIO; 1289 + err = ret; 1292 1290 goto up_out; 1293 1291 } 1294 1292 ··· 1307 1305 1308 1306 if ((ret > 0) || (nr_failed && (flags & MPOL_MF_STRICT))) 1309 1307 err = -EIO; 1310 - } else 1311 - putback_movable_pages(&pagelist); 1312 - 1308 + } else { 1313 1309 up_out: 1310 + if (!list_empty(&pagelist)) 1311 + putback_movable_pages(&pagelist); 1312 + } 1313 + 1314 1314 up_write(&mm->mmap_sem); 1315 1315 mpol_out: 1316 1316 mpol_put(new);
+3 -3
mm/page_io.c
··· 73 73 { 74 74 struct swap_info_struct *sis; 75 75 struct gendisk *disk; 76 + swp_entry_t entry; 76 77 77 78 /* 78 79 * There is no guarantee that the page is in swap cache - the software ··· 105 104 * we again wish to reclaim it. 106 105 */ 107 106 disk = sis->bdev->bd_disk; 108 - if (disk->fops->swap_slot_free_notify) { 109 - swp_entry_t entry; 107 + entry.val = page_private(page); 108 + if (disk->fops->swap_slot_free_notify && __swap_count(entry) == 1) { 110 109 unsigned long offset; 111 110 112 - entry.val = page_private(page); 113 111 offset = swp_offset(entry); 114 112 115 113 SetPageDirty(page);
+9 -30
mm/slub.c
··· 1433 1433 void *old_tail = *tail ? *tail : *head; 1434 1434 int rsize; 1435 1435 1436 - if (slab_want_init_on_free(s)) { 1437 - void *p = NULL; 1436 + /* Head and tail of the reconstructed freelist */ 1437 + *head = NULL; 1438 + *tail = NULL; 1438 1439 1439 - do { 1440 - object = next; 1441 - next = get_freepointer(s, object); 1440 + do { 1441 + object = next; 1442 + next = get_freepointer(s, object); 1443 + 1444 + if (slab_want_init_on_free(s)) { 1442 1445 /* 1443 1446 * Clear the object and the metadata, but don't touch 1444 1447 * the redzone. ··· 1451 1448 : 0; 1452 1449 memset((char *)object + s->inuse, 0, 1453 1450 s->size - s->inuse - rsize); 1454 - set_freepointer(s, object, p); 1455 - p = object; 1456 - } while (object != old_tail); 1457 - } 1458 1451 1459 - /* 1460 - * Compiler cannot detect this function can be removed if slab_free_hook() 1461 - * evaluates to nothing. Thus, catch all relevant config debug options here. 1462 - */ 1463 - #if defined(CONFIG_LOCKDEP) || \ 1464 - defined(CONFIG_DEBUG_KMEMLEAK) || \ 1465 - defined(CONFIG_DEBUG_OBJECTS_FREE) || \ 1466 - defined(CONFIG_KASAN) 1467 - 1468 - next = *head; 1469 - 1470 - /* Head and tail of the reconstructed freelist */ 1471 - *head = NULL; 1472 - *tail = NULL; 1473 - 1474 - do { 1475 - object = next; 1476 - next = get_freepointer(s, object); 1452 + } 1477 1453 /* If object's reuse doesn't have to be delayed */ 1478 1454 if (!slab_free_hook(s, object)) { 1479 1455 /* Move object to the new freelist */ ··· 1467 1485 *tail = NULL; 1468 1486 1469 1487 return *head != NULL; 1470 - #else 1471 - return true; 1472 - #endif 1473 1488 } 1474 1489 1475 1490 static void *setup_object(struct kmem_cache *s, struct page *page,