History

Merge branch 'akpm' (patches from Andrew)

Merge misc fixes from Andrew Morton: "8 fixes" * emailed patches from Andrew Morton <akpm@linux-foundation.org>: lib/test_kmod.c: fix limit check on number of test devices created selftests/vm/run_vmtests: adjust hugetlb size according to nr_cpus mm/page_alloc: fix memmap_init_zone pageblock alignment mm/memblock.c: hardcode the end_pfn being -1 mm/gup.c: teach get_user_pages_unlocked to handle FOLL_NOWAIT lib/bug.c: exclude non-BUG/WARN exceptions from report_bug() bug: use %pB in BUG and stack protector failure hugetlb: fix surplus pages accounting

Linus Torvalds committed 8 years ago

Commit cfc79ae2 parents c68a2cf ac68b1b8 files · +40 −21Browse files

Unified · Split

8 files
  1. kernel/panic.c +1 −1
  2. lib/bug.c +3 −1
  3. lib/test_kmod.c +1 −1
  4. mm/gup.c +5 −2
  5. mm/hugetlb.c +1 −1
  6. mm/memblock.c +5 −5
  7. mm/page_alloc.c +7 −2
  8. tools/testing/selftests/vm/run_vmtests +17 −8
kernel/panic.c+1−1
@@ -640,7 +640,7 @@ device_initcall(register_warn_debugfs); · 639 unmodified lines
640 */640 */
641__visible void __stack_chk_fail(void)641__visible void __stack_chk_fail(void)
642{642{
643 panic("stack-protector: Kernel stack is corrupted in: %p\n",643 panic("stack-protector: Kernel stack is corrupted in: %pB\n",
644 __builtin_return_address(0));644 __builtin_return_address(0));
645}645}
646EXPORT_SYMBOL(__stack_chk_fail);646EXPORT_SYMBOL(__stack_chk_fail);
lib/bug.c+3−1
@@ -150,6 +150,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs) · 149 unmodified lines
150 return BUG_TRAP_TYPE_NONE;150 return BUG_TRAP_TYPE_NONE;
151 151
152 bug = find_bug(bugaddr);152 bug = find_bug(bugaddr);
153 if (!bug)
154 return BUG_TRAP_TYPE_NONE;
153 155
154 file = NULL;156 file = NULL;
155 line = 0;157 line = 0;
@@ -191,7 +193,7 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs) · 35 unmodified lines
191 if (file)193 if (file)
192 pr_crit("kernel BUG at %s:%u!\n", file, line);194 pr_crit("kernel BUG at %s:%u!\n", file, line);
193 else195 else
194 pr_crit("Kernel BUG at %p [verbose debug info unavailable]\n",196 pr_crit("Kernel BUG at %pB [verbose debug info unavailable]\n",
195 (void *)bugaddr);197 (void *)bugaddr);
196 198
197 return BUG_TRAP_TYPE_BUG;199 return BUG_TRAP_TYPE_BUG;
lib/test_kmod.c+1−1
@@ -1141,7 +1141,7 @@ static struct kmod_test_device *register_test_dev_kmod(void) · 1140 unmodified lines
1141 mutex_lock(&reg_dev_mutex);1141 mutex_lock(&reg_dev_mutex);
1142 1142
1143 /* int should suffice for number of devices, test for wrap */1143 /* int should suffice for number of devices, test for wrap */
1144 if (unlikely(num_test_devs + 1) < 0) {1144 if (num_test_devs + 1 == INT_MAX) {
1145 pr_err("reached limit of number of test devices\n");1145 pr_err("reached limit of number of test devices\n");
1146 goto out;1146 goto out;
1147 }1147 }
mm/gup.c+5−2
@@ -516,7 +516,7 @@ static int faultin_page(struct task_struct *tsk, struct vm_area_struct *vma, · 515 unmodified lines
516 }516 }
517 517
518 if (ret & VM_FAULT_RETRY) {518 if (ret & VM_FAULT_RETRY) {
519 if (nonblocking)519 if (nonblocking && !(fault_flags & FAULT_FLAG_RETRY_NOWAIT))
520 *nonblocking = 0;520 *nonblocking = 0;
521 return -EBUSY;521 return -EBUSY;
522 }522 }
@@ -890,7 +890,10 @@ static __always_inline long __get_user_pages_locked(struct task_struct *tsk, · 367 unmodified lines
890 break;890 break;
891 }891 }
892 if (*locked) {892 if (*locked) {
893 /* VM_FAULT_RETRY didn't trigger */893 /*
894 * VM_FAULT_RETRY didn't trigger or it was a
895 * FOLL_NOWAIT.
896 */
894 if (!pages_done)897 if (!pages_done)
895 pages_done = ret;898 pages_done = ret;
896 break;899 break;
mm/hugetlb.c+1−1
@@ -1583,7 +1583,7 @@ static struct page *alloc_surplus_huge_page(struct hstate *h, gfp_t gfp_mask, · 1582 unmodified lines
1583 page = NULL;1583 page = NULL;
1584 } else {1584 } else {
1585 h->surplus_huge_pages++;1585 h->surplus_huge_pages++;
1586 h->nr_huge_pages_node[page_to_nid(page)]++;1586 h->surplus_huge_pages_node[page_to_nid(page)]++;
1587 }1587 }
1588 1588
1589out_unlock:1589out_unlock:
mm/memblock.c+5−5
@@ -1107,7 +1107,7 @@ unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn, · 1106 unmodified lines
1107 struct memblock_type *type = &memblock.memory;1107 struct memblock_type *type = &memblock.memory;
1108 unsigned int right = type->cnt;1108 unsigned int right = type->cnt;
1109 unsigned int mid, left = 0;1109 unsigned int mid, left = 0;
1110 phys_addr_t addr = PFN_PHYS(pfn + 1);1110 phys_addr_t addr = PFN_PHYS(++pfn);
1111 1111
1112 do {1112 do {
1113 mid = (right + left) / 2;1113 mid = (right + left) / 2;
@@ -1118,15 +1118,15 @@ unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn, · 4 unmodified lines
1118 type->regions[mid].size))1118 type->regions[mid].size))
1119 left = mid + 1;1119 left = mid + 1;
1120 else {1120 else {
1121 /* addr is within the region, so pfn + 1 is valid */1121 /* addr is within the region, so pfn is valid */
1122 return min(pfn + 1, max_pfn);1122 return pfn;
1123 }1123 }
1124 } while (left < right);1124 } while (left < right);
1125 1125
1126 if (right == type->cnt)1126 if (right == type->cnt)
1127 return max_pfn;1127 return -1UL;
1128 else1128 else
1129 return min(PHYS_PFN(type->regions[right].base), max_pfn);1129 return PHYS_PFN(type->regions[right].base);
1130}1130}
1131 1131
1132/**1132/**
mm/page_alloc.c+7−2
@@ -5359,9 +5359,14 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone, · 5358 unmodified lines
5359 /*5359 /*
5360 * Skip to the pfn preceding the next valid one (or5360 * Skip to the pfn preceding the next valid one (or
5361 * end_pfn), such that we hit a valid pfn (or end_pfn)5361 * end_pfn), such that we hit a valid pfn (or end_pfn)
5362 * on our next iteration of the loop.5362 * on our next iteration of the loop. Note that it needs
5363 * to be pageblock aligned even when the region itself
5364 * is not. move_freepages_block() can shift ahead of
5365 * the valid region but still depends on correct page
5366 * metadata.
5363 */5367 */
5364 pfn = memblock_next_valid_pfn(pfn, end_pfn) - 1;5368 pfn = (memblock_next_valid_pfn(pfn, end_pfn) &
5369 ~(pageblock_nr_pages-1)) - 1;
5365#endif5370#endif
5366 continue;5371 continue;
5367 }5372 }
tools/testing/selftests/vm/run_vmtests+17−8
@@ -2,25 +2,33 @@ · 1 unmodified line
2# SPDX-License-Identifier: GPL-2.02# SPDX-License-Identifier: GPL-2.0
3#please run as root3#please run as root
4 4
5#we need 256M, below is the size in kB
6needmem=262144
7mnt=./huge5mnt=./huge
8exitcode=06exitcode=0
9 7
10#get pagesize and freepages from /proc/meminfo8#get huge pagesize and freepages from /proc/meminfo
11while read name size unit; do9while read name size unit; do
12 if [ "$name" = "HugePages_Free:" ]; then10 if [ "$name" = "HugePages_Free:" ]; then
13 freepgs=$size11 freepgs=$size
14 fi12 fi
15 if [ "$name" = "Hugepagesize:" ]; then13 if [ "$name" = "Hugepagesize:" ]; then
16 pgsize=$size14 hpgsize_KB=$size
17 fi15 fi
18done < /proc/meminfo16done < /proc/meminfo
19 17
18# Simple hugetlbfs tests have a hardcoded minimum requirement of
19# huge pages totaling 256MB (262144KB) in size. The userfaultfd
20# hugetlb test requires a minimum of 2 * nr_cpus huge pages. Take
21# both of these requirements into account and attempt to increase
22# number of huge pages available.
23nr_cpus=$(nproc)
24hpgsize_MB=$((hpgsize_KB / 1024))
25half_ufd_size_MB=$((((nr_cpus * hpgsize_MB + 127) / 128) * 128))
26needmem_KB=$((half_ufd_size_MB * 2 * 1024))
27
20#set proper nr_hugepages28#set proper nr_hugepages
21if [ -n "$freepgs" ] && [ -n "$pgsize" ]; then29if [ -n "$freepgs" ] && [ -n "$hpgsize_KB" ]; then
22 nr_hugepgs=`cat /proc/sys/vm/nr_hugepages`30 nr_hugepgs=`cat /proc/sys/vm/nr_hugepages`
23 needpgs=`expr $needmem / $pgsize`31 needpgs=$((needmem_KB / hpgsize_KB))
24 tries=232 tries=2
25 while [ $tries -gt 0 ] && [ $freepgs -lt $needpgs ]; do33 while [ $tries -gt 0 ] && [ $freepgs -lt $needpgs ]; do
26 lackpgs=$(( $needpgs - $freepgs ))34 lackpgs=$(( $needpgs - $freepgs ))
@@ -107,8 +115,9 @@ fi · 80 unmodified lines
107echo "---------------------------"115echo "---------------------------"
108echo "running userfaultfd_hugetlb"116echo "running userfaultfd_hugetlb"
109echo "---------------------------"117echo "---------------------------"
110# 256MB total huge pages == 128MB src and 128MB dst118# Test requires source and destination huge pages. Size of source
111./userfaultfd hugetlb 128 32 $mnt/ufd_test_file119# (half_ufd_size_MB) is passed as argument to test.
120./userfaultfd hugetlb $half_ufd_size_MB 32 $mnt/ufd_test_file
112if [ $? -ne 0 ]; then121if [ $? -ne 0 ]; then
113 echo "[FAIL]"122 echo "[FAIL]"
114 exitcode=1123 exitcode=1

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t