swapfile.c (6b16f5d12202a23d875915349cc031c07fe1b3ec) | swapfile.c (2cf855837b89d92996cf264713f3bed2bf9b0b4f) |
---|---|
1/* 2 * linux/mm/swapfile.c 3 * 4 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds 5 * Swap reorganised 29.12.95, Stephen Tweedie 6 */ 7 8#include <linux/mm.h> --- 3717 unchanged lines hidden (view full) --- 3726 list_for_each_entry_safe(page, next, &head->lru, lru) { 3727 list_del(&page->lru); 3728 __free_page(page); 3729 } 3730 } 3731 } 3732} 3733 | 1/* 2 * linux/mm/swapfile.c 3 * 4 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds 5 * Swap reorganised 29.12.95, Stephen Tweedie 6 */ 7 8#include <linux/mm.h> --- 3717 unchanged lines hidden (view full) --- 3726 list_for_each_entry_safe(page, next, &head->lru, lru) { 3727 list_del(&page->lru); 3728 __free_page(page); 3729 } 3730 } 3731 } 3732} 3733 |
3734#if defined(CONFIG_MEMCG) && defined(CONFIG_BLK_CGROUP) 3735void mem_cgroup_throttle_swaprate(struct mem_cgroup *memcg, int node, 3736 gfp_t gfp_mask) 3737{ 3738 struct swap_info_struct *si, *next; 3739 if (!(gfp_mask & __GFP_IO) || !memcg) 3740 return; 3741 3742 if (!blk_cgroup_congested()) 3743 return; 3744 3745 /* 3746 * We've already scheduled a throttle, avoid taking the global swap 3747 * lock. 3748 */ 3749 if (current->throttle_queue) 3750 return; 3751 3752 spin_lock(&swap_avail_lock); 3753 plist_for_each_entry_safe(si, next, &swap_avail_heads[node], 3754 avail_lists[node]) { 3755 if (si->bdev) { 3756 blkcg_schedule_throttle(bdev_get_queue(si->bdev), 3757 true); 3758 break; 3759 } 3760 } 3761 spin_unlock(&swap_avail_lock); 3762} 3763#endif 3764 |
|
3734static int __init swapfile_init(void) 3735{ 3736 int nid; 3737 3738 swap_avail_heads = kmalloc_array(nr_node_ids, sizeof(struct plist_head), 3739 GFP_KERNEL); 3740 if (!swap_avail_heads) { 3741 pr_emerg("Not enough memory for swap heads, swap is disabled\n"); 3742 return -ENOMEM; 3743 } 3744 3745 for_each_node(nid) 3746 plist_head_init(&swap_avail_heads[nid]); 3747 3748 return 0; 3749} 3750subsys_initcall(swapfile_init); | 3765static int __init swapfile_init(void) 3766{ 3767 int nid; 3768 3769 swap_avail_heads = kmalloc_array(nr_node_ids, sizeof(struct plist_head), 3770 GFP_KERNEL); 3771 if (!swap_avail_heads) { 3772 pr_emerg("Not enough memory for swap heads, swap is disabled\n"); 3773 return -ENOMEM; 3774 } 3775 3776 for_each_node(nid) 3777 plist_head_init(&swap_avail_heads[nid]); 3778 3779 return 0; 3780} 3781subsys_initcall(swapfile_init); |