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

Merge branch 'akpm' (patches from Andrew)

Merge fixes from Andrew Morton:
"8 fixes"

* emailed patches from Andrew Morton <akpm@linux-foundation.org>:
mm, fs: check for fatal signals in do_generic_file_read()
fs: break out of iomap_file_buffered_write on fatal signals
base/memory, hotplug: fix a kernel oops in show_valid_zones()
mm/memory_hotplug.c: check start_pfn in test_pages_in_a_zone()
jump label: pass kbuild_cflags when checking for asm goto support
shmem: fix sleeping from atomic context
kasan: respect /proc/sys/kernel/traceoff_on_warning
zswap: disable changing params if init fails

+84 -18
+1 -1
Makefile
··· 797 797 KBUILD_ARFLAGS := $(call ar-option,D) 798 798 799 799 # check for 'asm goto' 800 - ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC)), y) 800 + ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y) 801 801 KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO 802 802 KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO 803 803 endif
+6 -6
drivers/base/memory.c
··· 389 389 { 390 390 struct memory_block *mem = to_memory_block(dev); 391 391 unsigned long start_pfn, end_pfn; 392 + unsigned long valid_start, valid_end, valid_pages; 392 393 unsigned long nr_pages = PAGES_PER_SECTION * sections_per_block; 393 - struct page *first_page; 394 394 struct zone *zone; 395 395 int zone_shift = 0; 396 396 397 397 start_pfn = section_nr_to_pfn(mem->start_section_nr); 398 398 end_pfn = start_pfn + nr_pages; 399 - first_page = pfn_to_page(start_pfn); 400 399 401 400 /* The block contains more than one zone can not be offlined. */ 402 - if (!test_pages_in_a_zone(start_pfn, end_pfn)) 401 + if (!test_pages_in_a_zone(start_pfn, end_pfn, &valid_start, &valid_end)) 403 402 return sprintf(buf, "none\n"); 404 403 405 - zone = page_zone(first_page); 404 + zone = page_zone(pfn_to_page(valid_start)); 405 + valid_pages = valid_end - valid_start; 406 406 407 407 /* MMOP_ONLINE_KEEP */ 408 408 sprintf(buf, "%s", zone->name); 409 409 410 410 /* MMOP_ONLINE_KERNEL */ 411 - zone_can_shift(start_pfn, nr_pages, ZONE_NORMAL, &zone_shift); 411 + zone_can_shift(valid_start, valid_pages, ZONE_NORMAL, &zone_shift); 412 412 if (zone_shift) { 413 413 strcat(buf, " "); 414 414 strcat(buf, (zone + zone_shift)->name); 415 415 } 416 416 417 417 /* MMOP_ONLINE_MOVABLE */ 418 - zone_can_shift(start_pfn, nr_pages, ZONE_MOVABLE, &zone_shift); 418 + zone_can_shift(valid_start, valid_pages, ZONE_MOVABLE, &zone_shift); 419 419 if (zone_shift) { 420 420 strcat(buf, " "); 421 421 strcat(buf, (zone + zone_shift)->name);
+5
fs/dax.c
··· 1031 1031 struct blk_dax_ctl dax = { 0 }; 1032 1032 ssize_t map_len; 1033 1033 1034 + if (fatal_signal_pending(current)) { 1035 + ret = -EINTR; 1036 + break; 1037 + } 1038 + 1034 1039 dax.sector = dax_iomap_sector(iomap, pos); 1035 1040 dax.size = (length + offset + PAGE_SIZE - 1) & PAGE_MASK; 1036 1041 map_len = dax_map_atomic(iomap->bdev, &dax);
+3
fs/iomap.c
··· 114 114 115 115 BUG_ON(pos + len > iomap->offset + iomap->length); 116 116 117 + if (fatal_signal_pending(current)) 118 + return -EINTR; 119 + 117 120 page = grab_cache_page_write_begin(inode->i_mapping, index, flags); 118 121 if (!page) 119 122 return -ENOMEM;
+2 -1
include/linux/memory_hotplug.h
··· 85 85 extern int add_one_highpage(struct page *page, int pfn, int bad_ppro); 86 86 /* VM interface that may be used by firmware interface */ 87 87 extern int online_pages(unsigned long, unsigned long, int); 88 - extern int test_pages_in_a_zone(unsigned long, unsigned long); 88 + extern int test_pages_in_a_zone(unsigned long start_pfn, unsigned long end_pfn, 89 + unsigned long *valid_start, unsigned long *valid_end); 89 90 extern void __offline_isolated_pages(unsigned long, unsigned long); 90 91 91 92 typedef void (*online_page_callback_t)(struct page *page);
+5
mm/filemap.c
··· 1791 1791 1792 1792 cond_resched(); 1793 1793 find_page: 1794 + if (fatal_signal_pending(current)) { 1795 + error = -EINTR; 1796 + goto out; 1797 + } 1798 + 1794 1799 page = find_get_page(mapping, index); 1795 1800 if (!page) { 1796 1801 page_cache_sync_readahead(mapping,
+3
mm/kasan/report.c
··· 13 13 * 14 14 */ 15 15 16 + #include <linux/ftrace.h> 16 17 #include <linux/kernel.h> 17 18 #include <linux/mm.h> 18 19 #include <linux/printk.h> ··· 300 299 301 300 if (likely(!kasan_report_enabled())) 302 301 return; 302 + 303 + disable_trace_on_warning(); 303 304 304 305 info.access_addr = (void *)addr; 305 306 info.access_size = size;
+21 -7
mm/memory_hotplug.c
··· 1483 1483 } 1484 1484 1485 1485 /* 1486 - * Confirm all pages in a range [start, end) is belongs to the same zone. 1486 + * Confirm all pages in a range [start, end) belong to the same zone. 1487 + * When true, return its valid [start, end). 1487 1488 */ 1488 - int test_pages_in_a_zone(unsigned long start_pfn, unsigned long end_pfn) 1489 + int test_pages_in_a_zone(unsigned long start_pfn, unsigned long end_pfn, 1490 + unsigned long *valid_start, unsigned long *valid_end) 1489 1491 { 1490 1492 unsigned long pfn, sec_end_pfn; 1493 + unsigned long start, end; 1491 1494 struct zone *zone = NULL; 1492 1495 struct page *page; 1493 1496 int i; 1494 - for (pfn = start_pfn, sec_end_pfn = SECTION_ALIGN_UP(start_pfn); 1497 + for (pfn = start_pfn, sec_end_pfn = SECTION_ALIGN_UP(start_pfn + 1); 1495 1498 pfn < end_pfn; 1496 - pfn = sec_end_pfn + 1, sec_end_pfn += PAGES_PER_SECTION) { 1499 + pfn = sec_end_pfn, sec_end_pfn += PAGES_PER_SECTION) { 1497 1500 /* Make sure the memory section is present first */ 1498 1501 if (!present_section_nr(pfn_to_section_nr(pfn))) 1499 1502 continue; ··· 1512 1509 page = pfn_to_page(pfn + i); 1513 1510 if (zone && page_zone(page) != zone) 1514 1511 return 0; 1512 + if (!zone) 1513 + start = pfn + i; 1515 1514 zone = page_zone(page); 1515 + end = pfn + MAX_ORDER_NR_PAGES; 1516 1516 } 1517 1517 } 1518 - return 1; 1518 + 1519 + if (zone) { 1520 + *valid_start = start; 1521 + *valid_end = end; 1522 + return 1; 1523 + } else { 1524 + return 0; 1525 + } 1519 1526 } 1520 1527 1521 1528 /* ··· 1852 1839 long offlined_pages; 1853 1840 int ret, drain, retry_max, node; 1854 1841 unsigned long flags; 1842 + unsigned long valid_start, valid_end; 1855 1843 struct zone *zone; 1856 1844 struct memory_notify arg; 1857 1845 ··· 1863 1849 return -EINVAL; 1864 1850 /* This makes hotplug much easier...and readable. 1865 1851 we assume this for now. .*/ 1866 - if (!test_pages_in_a_zone(start_pfn, end_pfn)) 1852 + if (!test_pages_in_a_zone(start_pfn, end_pfn, &valid_start, &valid_end)) 1867 1853 return -EINVAL; 1868 1854 1869 - zone = page_zone(pfn_to_page(start_pfn)); 1855 + zone = page_zone(pfn_to_page(valid_start)); 1870 1856 node = zone_to_nid(zone); 1871 1857 nr_pages = end_pfn - start_pfn; 1872 1858
+9 -2
mm/shmem.c
··· 415 415 struct shrink_control *sc, unsigned long nr_to_split) 416 416 { 417 417 LIST_HEAD(list), *pos, *next; 418 + LIST_HEAD(to_remove); 418 419 struct inode *inode; 419 420 struct shmem_inode_info *info; 420 421 struct page *page; ··· 442 441 /* Check if there's anything to gain */ 443 442 if (round_up(inode->i_size, PAGE_SIZE) == 444 443 round_up(inode->i_size, HPAGE_PMD_SIZE)) { 445 - list_del_init(&info->shrinklist); 444 + list_move(&info->shrinklist, &to_remove); 446 445 removed++; 447 - iput(inode); 448 446 goto next; 449 447 } 450 448 ··· 453 453 break; 454 454 } 455 455 spin_unlock(&sbinfo->shrinklist_lock); 456 + 457 + list_for_each_safe(pos, next, &to_remove) { 458 + info = list_entry(pos, struct shmem_inode_info, shrinklist); 459 + inode = &info->vfs_inode; 460 + list_del_init(&info->shrinklist); 461 + iput(inode); 462 + } 456 463 457 464 list_for_each_safe(pos, next, &list) { 458 465 int ret;
+29 -1
mm/zswap.c
··· 78 78 79 79 /* Enable/disable zswap (disabled by default) */ 80 80 static bool zswap_enabled; 81 - module_param_named(enabled, zswap_enabled, bool, 0644); 81 + static int zswap_enabled_param_set(const char *, 82 + const struct kernel_param *); 83 + static struct kernel_param_ops zswap_enabled_param_ops = { 84 + .set = zswap_enabled_param_set, 85 + .get = param_get_bool, 86 + }; 87 + module_param_cb(enabled, &zswap_enabled_param_ops, &zswap_enabled, 0644); 82 88 83 89 /* Crypto compressor to use */ 84 90 #define ZSWAP_COMPRESSOR_DEFAULT "lzo" ··· 181 175 182 176 /* used by param callback function */ 183 177 static bool zswap_init_started; 178 + 179 + /* fatal error during init */ 180 + static bool zswap_init_failed; 184 181 185 182 /********************************* 186 183 * helpers and fwd declarations ··· 633 624 char *s = strstrip((char *)val); 634 625 int ret; 635 626 627 + if (zswap_init_failed) { 628 + pr_err("can't set param, initialization failed\n"); 629 + return -ENODEV; 630 + } 631 + 636 632 /* no change required */ 637 633 if (!strcmp(s, *(char **)kp->arg)) 638 634 return 0; ··· 715 701 const struct kernel_param *kp) 716 702 { 717 703 return __zswap_param_set(val, kp, NULL, zswap_compressor); 704 + } 705 + 706 + static int zswap_enabled_param_set(const char *val, 707 + const struct kernel_param *kp) 708 + { 709 + if (zswap_init_failed) { 710 + pr_err("can't enable, initialization failed\n"); 711 + return -ENODEV; 712 + } 713 + 714 + return param_set_bool(val, kp); 718 715 } 719 716 720 717 /********************************* ··· 1226 1201 dstmem_fail: 1227 1202 zswap_entry_cache_destroy(); 1228 1203 cache_fail: 1204 + /* if built-in, we aren't unloaded on failure; don't allow use */ 1205 + zswap_init_failed = true; 1206 + zswap_enabled = false; 1229 1207 return -ENOMEM; 1230 1208 } 1231 1209 /* must be late so crypto has time to come up */