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 various fixes from Andrew Morton:
"10 fixes"

* emailed patches from Andrew Morton <akpm@linux-foundation.org>:
mm, page_alloc: recalculate the preferred zoneref if the context can ignore memory policies
mm, page_alloc: reset zonelist iterator after resetting fair zone allocation policy
mm, oom_reaper: do not use siglock in try_oom_reaper()
mm, page_alloc: prevent infinite loop in buffered_rmqueue()
checkpatch: reduce git commit description style false positives
mm/z3fold.c: avoid modifying HEADLESS page and minor cleanup
memcg: add RCU locking around css_for_each_descendant_pre() in memcg_offline_kmem()
mm: check the return value of lookup_page_ext for all call sites
kdump: fix dmesg gdbmacro to work with record based printk
mm: fix overflow in vm_map_ram()

+205 -50
+82 -11
Documentation/kdump/gdbmacros.txt
··· 170 170 address the kernel panicked. 171 171 end 172 172 173 + define dump_log_idx 174 + set $idx = $arg0 175 + if ($argc > 1) 176 + set $prev_flags = $arg1 177 + else 178 + set $prev_flags = 0 179 + end 180 + set $msg = ((struct printk_log *) (log_buf + $idx)) 181 + set $prefix = 1 182 + set $newline = 1 183 + set $log = log_buf + $idx + sizeof(*$msg) 184 + 185 + # prev & LOG_CONT && !(msg->flags & LOG_PREIX) 186 + if (($prev_flags & 8) && !($msg->flags & 4)) 187 + set $prefix = 0 188 + end 189 + 190 + # msg->flags & LOG_CONT 191 + if ($msg->flags & 8) 192 + # (prev & LOG_CONT && !(prev & LOG_NEWLINE)) 193 + if (($prev_flags & 8) && !($prev_flags & 2)) 194 + set $prefix = 0 195 + end 196 + # (!(msg->flags & LOG_NEWLINE)) 197 + if (!($msg->flags & 2)) 198 + set $newline = 0 199 + end 200 + end 201 + 202 + if ($prefix) 203 + printf "[%5lu.%06lu] ", $msg->ts_nsec / 1000000000, $msg->ts_nsec % 1000000000 204 + end 205 + if ($msg->text_len != 0) 206 + eval "printf \"%%%d.%ds\", $log", $msg->text_len, $msg->text_len 207 + end 208 + if ($newline) 209 + printf "\n" 210 + end 211 + if ($msg->dict_len > 0) 212 + set $dict = $log + $msg->text_len 213 + set $idx = 0 214 + set $line = 1 215 + while ($idx < $msg->dict_len) 216 + if ($line) 217 + printf " " 218 + set $line = 0 219 + end 220 + set $c = $dict[$idx] 221 + if ($c == '\0') 222 + printf "\n" 223 + set $line = 1 224 + else 225 + if ($c < ' ' || $c >= 127 || $c == '\\') 226 + printf "\\x%02x", $c 227 + else 228 + printf "%c", $c 229 + end 230 + end 231 + set $idx = $idx + 1 232 + end 233 + printf "\n" 234 + end 235 + end 236 + document dump_log_idx 237 + Dump a single log given its index in the log buffer. The first 238 + parameter is the index into log_buf, the second is optional and 239 + specified the previous log buffer's flags, used for properly 240 + formatting continued lines. 241 + end 173 242 174 243 define dmesg 175 - set $i = 0 176 - set $end_idx = (log_end - 1) & (log_buf_len - 1) 244 + set $i = log_first_idx 245 + set $end_idx = log_first_idx 246 + set $prev_flags = 0 177 247 178 - while ($i < logged_chars) 179 - set $idx = (log_end - 1 - logged_chars + $i) & (log_buf_len - 1) 180 - 181 - if ($idx + 100 <= $end_idx) || \ 182 - ($end_idx <= $idx && $idx + 100 < log_buf_len) 183 - printf "%.100s", &log_buf[$idx] 184 - set $i = $i + 100 248 + while (1) 249 + set $msg = ((struct printk_log *) (log_buf + $i)) 250 + if ($msg->len == 0) 251 + set $i = 0 185 252 else 186 - printf "%c", log_buf[$idx] 187 - set $i = $i + 1 253 + dump_log_idx $i $prev_flags 254 + set $i = $i + $msg->len 255 + set $prev_flags = $msg->flags 256 + end 257 + if ($i == $end_idx) 258 + loop_break 188 259 end 189 260 end 190 261 end
+36 -7
include/linux/page_idle.h
··· 46 46 47 47 static inline bool page_is_young(struct page *page) 48 48 { 49 - return test_bit(PAGE_EXT_YOUNG, &lookup_page_ext(page)->flags); 49 + struct page_ext *page_ext = lookup_page_ext(page); 50 + 51 + if (unlikely(!page_ext)) 52 + return false; 53 + 54 + return test_bit(PAGE_EXT_YOUNG, &page_ext->flags); 50 55 } 51 56 52 57 static inline void set_page_young(struct page *page) 53 58 { 54 - set_bit(PAGE_EXT_YOUNG, &lookup_page_ext(page)->flags); 59 + struct page_ext *page_ext = lookup_page_ext(page); 60 + 61 + if (unlikely(!page_ext)) 62 + return; 63 + 64 + set_bit(PAGE_EXT_YOUNG, &page_ext->flags); 55 65 } 56 66 57 67 static inline bool test_and_clear_page_young(struct page *page) 58 68 { 59 - return test_and_clear_bit(PAGE_EXT_YOUNG, 60 - &lookup_page_ext(page)->flags); 69 + struct page_ext *page_ext = lookup_page_ext(page); 70 + 71 + if (unlikely(!page_ext)) 72 + return false; 73 + 74 + return test_and_clear_bit(PAGE_EXT_YOUNG, &page_ext->flags); 61 75 } 62 76 63 77 static inline bool page_is_idle(struct page *page) 64 78 { 65 - return test_bit(PAGE_EXT_IDLE, &lookup_page_ext(page)->flags); 79 + struct page_ext *page_ext = lookup_page_ext(page); 80 + 81 + if (unlikely(!page_ext)) 82 + return false; 83 + 84 + return test_bit(PAGE_EXT_IDLE, &page_ext->flags); 66 85 } 67 86 68 87 static inline void set_page_idle(struct page *page) 69 88 { 70 - set_bit(PAGE_EXT_IDLE, &lookup_page_ext(page)->flags); 89 + struct page_ext *page_ext = lookup_page_ext(page); 90 + 91 + if (unlikely(!page_ext)) 92 + return; 93 + 94 + set_bit(PAGE_EXT_IDLE, &page_ext->flags); 71 95 } 72 96 73 97 static inline void clear_page_idle(struct page *page) 74 98 { 75 - clear_bit(PAGE_EXT_IDLE, &lookup_page_ext(page)->flags); 99 + struct page_ext *page_ext = lookup_page_ext(page); 100 + 101 + if (unlikely(!page_ext)) 102 + return; 103 + 104 + clear_bit(PAGE_EXT_IDLE, &page_ext->flags); 76 105 } 77 106 #endif /* CONFIG_64BIT */ 78 107
+3
mm/memcontrol.c
··· 2896 2896 * ordering is imposed by list_lru_node->lock taken by 2897 2897 * memcg_drain_all_list_lrus(). 2898 2898 */ 2899 + rcu_read_lock(); /* can be called from css_free w/o cgroup_mutex */ 2899 2900 css_for_each_descendant_pre(css, &memcg->css) { 2900 2901 child = mem_cgroup_from_css(css); 2901 2902 BUG_ON(child->kmemcg_id != kmemcg_id); ··· 2904 2903 if (!memcg->use_hierarchy) 2905 2904 break; 2906 2905 } 2906 + rcu_read_unlock(); 2907 + 2907 2908 memcg_drain_all_list_lrus(kmemcg_id, parent->kmemcg_id); 2908 2909 2909 2910 memcg_free_cache_id(kmemcg_id);
+1 -6
mm/oom_kill.c
··· 625 625 if (atomic_read(&mm->mm_users) > 1) { 626 626 rcu_read_lock(); 627 627 for_each_process(p) { 628 - bool exiting; 629 - 630 628 if (!process_shares_mm(p, mm)) 631 629 continue; 632 630 if (fatal_signal_pending(p)) ··· 634 636 * If the task is exiting make sure the whole thread group 635 637 * is exiting and cannot acces mm anymore. 636 638 */ 637 - spin_lock_irq(&p->sighand->siglock); 638 - exiting = signal_group_exit(p->signal); 639 - spin_unlock_irq(&p->sighand->siglock); 640 - if (exiting) 639 + if (signal_group_exit(p->signal)) 641 640 continue; 642 641 643 642 /* Give up */
+28 -11
mm/page_alloc.c
··· 656 656 return; 657 657 658 658 page_ext = lookup_page_ext(page); 659 + if (unlikely(!page_ext)) 660 + return; 661 + 659 662 __set_bit(PAGE_EXT_DEBUG_GUARD, &page_ext->flags); 660 663 661 664 INIT_LIST_HEAD(&page->lru); ··· 676 673 return; 677 674 678 675 page_ext = lookup_page_ext(page); 676 + if (unlikely(!page_ext)) 677 + return; 678 + 679 679 __clear_bit(PAGE_EXT_DEBUG_GUARD, &page_ext->flags); 680 680 681 681 set_page_private(page, 0); ··· 2615 2609 page = list_last_entry(list, struct page, lru); 2616 2610 else 2617 2611 page = list_first_entry(list, struct page, lru); 2618 - } while (page && check_new_pcp(page)); 2619 2612 2620 - __dec_zone_state(zone, NR_ALLOC_BATCH); 2621 - list_del(&page->lru); 2622 - pcp->count--; 2613 + __dec_zone_state(zone, NR_ALLOC_BATCH); 2614 + list_del(&page->lru); 2615 + pcp->count--; 2616 + 2617 + } while (check_new_pcp(page)); 2623 2618 } else { 2624 2619 /* 2625 2620 * We most definitely don't want callers attempting to ··· 3030 3023 apply_fair = false; 3031 3024 fair_skipped = false; 3032 3025 reset_alloc_batches(ac->preferred_zoneref->zone); 3026 + z = ac->preferred_zoneref; 3033 3027 goto zonelist_scan; 3034 3028 } 3035 3029 ··· 3604 3596 */ 3605 3597 alloc_flags = gfp_to_alloc_flags(gfp_mask); 3606 3598 3599 + /* 3600 + * Reset the zonelist iterators if memory policies can be ignored. 3601 + * These allocations are high priority and system rather than user 3602 + * orientated. 3603 + */ 3604 + if ((alloc_flags & ALLOC_NO_WATERMARKS) || !(alloc_flags & ALLOC_CPUSET)) { 3605 + ac->zonelist = node_zonelist(numa_node_id(), gfp_mask); 3606 + ac->preferred_zoneref = first_zones_zonelist(ac->zonelist, 3607 + ac->high_zoneidx, ac->nodemask); 3608 + } 3609 + 3607 3610 /* This is the last chance, in general, before the goto nopage. */ 3608 3611 page = get_page_from_freelist(gfp_mask, order, 3609 3612 alloc_flags & ~ALLOC_NO_WATERMARKS, ac); ··· 3623 3604 3624 3605 /* Allocate without watermarks if the context allows */ 3625 3606 if (alloc_flags & ALLOC_NO_WATERMARKS) { 3626 - /* 3627 - * Ignore mempolicies if ALLOC_NO_WATERMARKS on the grounds 3628 - * the allocation is high priority and these type of 3629 - * allocations are system rather than user orientated 3630 - */ 3631 - ac->zonelist = node_zonelist(numa_node_id(), gfp_mask); 3632 3607 page = get_page_from_freelist(gfp_mask, order, 3633 3608 ALLOC_NO_WATERMARKS, ac); 3634 3609 if (page) ··· 3821 3808 /* Dirty zone balancing only done in the fast path */ 3822 3809 ac.spread_dirty_pages = (gfp_mask & __GFP_WRITE); 3823 3810 3824 - /* The preferred zone is used for statistics later */ 3811 + /* 3812 + * The preferred zone is used for statistics but crucially it is 3813 + * also used as the starting point for the zonelist iterator. It 3814 + * may get reset for allocations that ignore memory policies. 3815 + */ 3825 3816 ac.preferred_zoneref = first_zones_zonelist(ac.zonelist, 3826 3817 ac.high_zoneidx, ac.nodemask); 3827 3818 if (!ac.preferred_zoneref) {
+26
mm/page_owner.c
··· 55 55 56 56 for (i = 0; i < (1 << order); i++) { 57 57 page_ext = lookup_page_ext(page + i); 58 + if (unlikely(!page_ext)) 59 + continue; 58 60 __clear_bit(PAGE_EXT_OWNER, &page_ext->flags); 59 61 } 60 62 } ··· 64 62 void __set_page_owner(struct page *page, unsigned int order, gfp_t gfp_mask) 65 63 { 66 64 struct page_ext *page_ext = lookup_page_ext(page); 65 + 67 66 struct stack_trace trace = { 68 67 .nr_entries = 0, 69 68 .max_entries = ARRAY_SIZE(page_ext->trace_entries), 70 69 .entries = &page_ext->trace_entries[0], 71 70 .skip = 3, 72 71 }; 72 + 73 + if (unlikely(!page_ext)) 74 + return; 73 75 74 76 save_stack_trace(&trace); 75 77 ··· 88 82 void __set_page_owner_migrate_reason(struct page *page, int reason) 89 83 { 90 84 struct page_ext *page_ext = lookup_page_ext(page); 85 + if (unlikely(!page_ext)) 86 + return; 91 87 92 88 page_ext->last_migrate_reason = reason; 93 89 } ··· 97 89 gfp_t __get_page_owner_gfp(struct page *page) 98 90 { 99 91 struct page_ext *page_ext = lookup_page_ext(page); 92 + if (unlikely(!page_ext)) 93 + /* 94 + * The caller just returns 0 if no valid gfp 95 + * So return 0 here too. 96 + */ 97 + return 0; 100 98 101 99 return page_ext->gfp_mask; 102 100 } ··· 112 98 struct page_ext *old_ext = lookup_page_ext(oldpage); 113 99 struct page_ext *new_ext = lookup_page_ext(newpage); 114 100 int i; 101 + 102 + if (unlikely(!old_ext || !new_ext)) 103 + return; 115 104 116 105 new_ext->order = old_ext->order; 117 106 new_ext->gfp_mask = old_ext->gfp_mask; ··· 210 193 gfp_t gfp_mask = page_ext->gfp_mask; 211 194 int mt = gfpflags_to_migratetype(gfp_mask); 212 195 196 + if (unlikely(!page_ext)) { 197 + pr_alert("There is not page extension available.\n"); 198 + return; 199 + } 200 + 213 201 if (!test_bit(PAGE_EXT_OWNER, &page_ext->flags)) { 214 202 pr_alert("page_owner info is not active (free page?)\n"); 215 203 return; ··· 273 251 } 274 252 275 253 page_ext = lookup_page_ext(page); 254 + if (unlikely(!page_ext)) 255 + continue; 276 256 277 257 /* 278 258 * Some pages could be missed by concurrent allocation or free, ··· 341 317 continue; 342 318 343 319 page_ext = lookup_page_ext(page); 320 + if (unlikely(!page_ext)) 321 + continue; 344 322 345 323 /* Maybe overraping zone */ 346 324 if (test_bit(PAGE_EXT_OWNER, &page_ext->flags))
+7 -1
mm/page_poison.c
··· 54 54 struct page_ext *page_ext; 55 55 56 56 page_ext = lookup_page_ext(page); 57 + if (unlikely(!page_ext)) 58 + return; 59 + 57 60 __set_bit(PAGE_EXT_DEBUG_POISON, &page_ext->flags); 58 61 } 59 62 ··· 65 62 struct page_ext *page_ext; 66 63 67 64 page_ext = lookup_page_ext(page); 65 + if (unlikely(!page_ext)) 66 + return; 67 + 68 68 __clear_bit(PAGE_EXT_DEBUG_POISON, &page_ext->flags); 69 69 } 70 70 ··· 76 70 struct page_ext *page_ext; 77 71 78 72 page_ext = lookup_page_ext(page); 79 - if (!page_ext) 73 + if (unlikely(!page_ext)) 80 74 return false; 81 75 82 76 return test_bit(PAGE_EXT_DEBUG_POISON, &page_ext->flags);
+5 -4
mm/vmalloc.c
··· 1105 1105 */ 1106 1106 void vm_unmap_ram(const void *mem, unsigned int count) 1107 1107 { 1108 - unsigned long size = count << PAGE_SHIFT; 1108 + unsigned long size = (unsigned long)count << PAGE_SHIFT; 1109 1109 unsigned long addr = (unsigned long)mem; 1110 1110 1111 1111 BUG_ON(!addr); ··· 1140 1140 */ 1141 1141 void *vm_map_ram(struct page **pages, unsigned int count, int node, pgprot_t prot) 1142 1142 { 1143 - unsigned long size = count << PAGE_SHIFT; 1143 + unsigned long size = (unsigned long)count << PAGE_SHIFT; 1144 1144 unsigned long addr; 1145 1145 void *mem; 1146 1146 ··· 1574 1574 unsigned long flags, pgprot_t prot) 1575 1575 { 1576 1576 struct vm_struct *area; 1577 + unsigned long size; /* In bytes */ 1577 1578 1578 1579 might_sleep(); 1579 1580 1580 1581 if (count > totalram_pages) 1581 1582 return NULL; 1582 1583 1583 - area = get_vm_area_caller((count << PAGE_SHIFT), flags, 1584 - __builtin_return_address(0)); 1584 + size = (unsigned long)count << PAGE_SHIFT; 1585 + area = get_vm_area_caller(size, flags, __builtin_return_address(0)); 1585 1586 if (!area) 1586 1587 return NULL; 1587 1588
+2
mm/vmstat.c
··· 1061 1061 continue; 1062 1062 1063 1063 page_ext = lookup_page_ext(page); 1064 + if (unlikely(!page_ext)) 1065 + continue; 1064 1066 1065 1067 if (!test_bit(PAGE_EXT_OWNER, &page_ext->flags)) 1066 1068 continue;
+14 -10
mm/z3fold.c
··· 412 412 /* HEADLESS page stored */ 413 413 bud = HEADLESS; 414 414 } else { 415 - bud = (handle - zhdr->first_num) & BUDDY_MASK; 415 + bud = handle_to_buddy(handle); 416 416 417 417 switch (bud) { 418 418 case FIRST: ··· 572 572 pool->pages_nr--; 573 573 spin_unlock(&pool->lock); 574 574 return 0; 575 - } else if (zhdr->first_chunks != 0 && 576 - zhdr->last_chunks != 0 && zhdr->middle_chunks != 0) { 577 - /* Full, add to buddied list */ 578 - list_add(&zhdr->buddy, &pool->buddied); 579 - } else if (!test_bit(PAGE_HEADLESS, &page->private)) { 580 - z3fold_compact_page(zhdr); 581 - /* add to unbuddied list */ 582 - freechunks = num_free_chunks(zhdr); 583 - list_add(&zhdr->buddy, &pool->unbuddied[freechunks]); 575 + } else if (!test_bit(PAGE_HEADLESS, &page->private)) { 576 + if (zhdr->first_chunks != 0 && 577 + zhdr->last_chunks != 0 && 578 + zhdr->middle_chunks != 0) { 579 + /* Full, add to buddied list */ 580 + list_add(&zhdr->buddy, &pool->buddied); 581 + } else { 582 + z3fold_compact_page(zhdr); 583 + /* add to unbuddied list */ 584 + freechunks = num_free_chunks(zhdr); 585 + list_add(&zhdr->buddy, 586 + &pool->unbuddied[freechunks]); 587 + } 584 588 } 585 589 586 590 /* add to beginning of LRU */
+1
scripts/checkpatch.pl
··· 2454 2454 2455 2455 # Check for git id commit length and improperly formed commit descriptions 2456 2456 if ($in_commit_log && !$commit_log_possible_stack_dump && 2457 + $line !~ /^\s*(?:Link|Patchwork|http|BugLink):/i && 2457 2458 ($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i || 2458 2459 ($line =~ /\b[0-9a-f]{12,40}\b/i && 2459 2460 $line !~ /[\<\[][0-9a-f]{12,40}[\>\]]/i &&