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
640640 */
641641 __visible void __stack_chk_fail(void)
642642 {
643− panic("stack-protector: Kernel stack is corrupted in: %p\n",
643+ panic("stack-protector: Kernel stack is corrupted in: %pB\n",
644644 __builtin_return_address(0));
645645 }
646646 EXPORT_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
150150 return BUG_TRAP_TYPE_NONE;
151151
152152 bug = find_bug(bugaddr);
153+ if (!bug)
154+ return BUG_TRAP_TYPE_NONE;
153155
154156 file = NULL;
155157 line = 0;
@@ -191,7 +193,7 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs) · 35 unmodified lines
191193 if (file)
192194 pr_crit("kernel BUG at %s:%u!\n", file, line);
193195 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",
195197 (void *)bugaddr);
196198
197199 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
11411141 mutex_lock(&reg_dev_mutex);
11421142
11431143 /* 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) {
11451145 pr_err("reached limit of number of test devices\n");
11461146 goto out;
11471147 }
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
516516 }
517517
518518 if (ret & VM_FAULT_RETRY) {
519− if (nonblocking)
519+ if (nonblocking && !(fault_flags & FAULT_FLAG_RETRY_NOWAIT))
520520 *nonblocking = 0;
521521 return -EBUSY;
522522 }
@@ -890,7 +890,10 @@ static __always_inline long __get_user_pages_locked(struct task_struct *tsk, · 367 unmodified lines
890890 break;
891891 }
892892 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+ */
894897 if (!pages_done)
895898 pages_done = ret;
896899 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
15831583 page = NULL;
15841584 } else {
15851585 h->surplus_huge_pages++;
1586− h->nr_huge_pages_node[page_to_nid(page)]++;
1586+ h->surplus_huge_pages_node[page_to_nid(page)]++;
15871587 }
15881588
15891589 out_unlock:
mm/memblock.c+5−5
@@ -1107,7 +1107,7 @@ unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn, · 1106 unmodified lines
11071107 struct memblock_type *type = &memblock.memory;
11081108 unsigned int right = type->cnt;
11091109 unsigned int mid, left = 0;
1110− phys_addr_t addr = PFN_PHYS(pfn + 1);
1110+ phys_addr_t addr = PFN_PHYS(++pfn);
11111111
11121112 do {
11131113 mid = (right + left) / 2;
@@ -1118,15 +1118,15 @@ unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn, · 4 unmodified lines
11181118 type->regions[mid].size))
11191119 left = mid + 1;
11201120 else {
1121− /* addr is within the region, so pfn + 1 is valid */
1122− return min(pfn + 1, max_pfn);
1121+ /* addr is within the region, so pfn is valid */
1122+ return pfn;
11231123 }
11241124 } while (left < right);
11251125
11261126 if (right == type->cnt)
1127− return max_pfn;
1127+ return -1UL;
11281128 else
1129− return min(PHYS_PFN(type->regions[right].base), max_pfn);
1129+ return PHYS_PFN(type->regions[right].base);
11301130 }
11311131
11321132 /**
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
53595359 /*
53605360 * Skip to the pfn preceding the next valid one (or
53615361 * 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.
53635367 */
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;
53655370 #endif
53665371 continue;
53675372 }
tools/testing/selftests/vm/run_vmtests+17−8
@@ -2,25 +2,33 @@ · 1 unmodified line
22 # SPDX-License-Identifier: GPL-2.0
33 #please run as root
44
5−#we need 256M, below is the size in kB
6−needmem=262144
75 mnt=./huge
86 exitcode=0
97
10−#get pagesize and freepages from /proc/meminfo
8+#get huge pagesize and freepages from /proc/meminfo
119 while read name size unit; do
1210 if [ "$name" = "HugePages_Free:" ]; then
1311 freepgs=$size
1412 fi
1513 if [ "$name" = "Hugepagesize:" ]; then
16− pgsize=$size
14+ hpgsize_KB=$size
1715 fi
1816 done < /proc/meminfo
1917
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.
23+nr_cpus=$(nproc)
24+hpgsize_MB=$((hpgsize_KB / 1024))
25+half_ufd_size_MB=$((((nr_cpus * hpgsize_MB + 127) / 128) * 128))
26+needmem_KB=$((half_ufd_size_MB * 2 * 1024))
27+
2028 #set proper nr_hugepages
21−if [ -n "$freepgs" ] && [ -n "$pgsize" ]; then
29+if [ -n "$freepgs" ] && [ -n "$hpgsize_KB" ]; then
2230 nr_hugepgs=`cat /proc/sys/vm/nr_hugepages`
23− needpgs=`expr $needmem / $pgsize`
31+ needpgs=$((needmem_KB / hpgsize_KB))
2432 tries=2
2533 while [ $tries -gt 0 ] && [ $freepgs -lt $needpgs ]; do
2634 lackpgs=$(( $needpgs - $freepgs ))
@@ -107,8 +115,9 @@ fi · 80 unmodified lines
107115 echo "---------------------------"
108116 echo "running userfaultfd_hugetlb"
109117 echo "---------------------------"
110−# 256MB total huge pages == 128MB src and 128MB dst
111−./userfaultfd hugetlb 128 32 $mnt/ufd_test_file
118+# Test requires source and destination huge pages. Size of source
119+# (half_ufd_size_MB) is passed as argument to test.
120+./userfaultfd hugetlb $half_ufd_size_MB 32 $mnt/ufd_test_file
112121 if [ $? -ne 0 ]; then
113122 echo "[FAIL]"
114123 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