diff options
Diffstat (limited to 'mm/swap.c')
-rw-r--r-- | mm/swap.c | 30 |
1 files changed, 19 insertions, 11 deletions
@@ -887,18 +887,14 @@ void lru_add_drain_all(void) | |||
887 | mutex_unlock(&lock); | 887 | mutex_unlock(&lock); |
888 | } | 888 | } |
889 | 889 | ||
890 | /* | 890 | /** |
891 | * Batched page_cache_release(). Decrement the reference count on all the | 891 | * release_pages - batched page_cache_release() |
892 | * passed pages. If it fell to zero then remove the page from the LRU and | 892 | * @pages: array of pages to release |
893 | * free it. | 893 | * @nr: number of pages |
894 | * | 894 | * @cold: whether the pages are cache cold |
895 | * Avoid taking zone->lru_lock if possible, but if it is taken, retain it | ||
896 | * for the remainder of the operation. | ||
897 | * | 895 | * |
898 | * The locking in this function is against shrink_inactive_list(): we recheck | 896 | * Decrement the reference count on all the pages in @pages. If it |
899 | * the page count inside the lock to see whether shrink_inactive_list() | 897 | * fell to zero, remove the page from the LRU and free it. |
900 | * grabbed the page via the LRU. If it did, give up: shrink_inactive_list() | ||
901 | * will free it. | ||
902 | */ | 898 | */ |
903 | void release_pages(struct page **pages, int nr, bool cold) | 899 | void release_pages(struct page **pages, int nr, bool cold) |
904 | { | 900 | { |
@@ -907,6 +903,7 @@ void release_pages(struct page **pages, int nr, bool cold) | |||
907 | struct zone *zone = NULL; | 903 | struct zone *zone = NULL; |
908 | struct lruvec *lruvec; | 904 | struct lruvec *lruvec; |
909 | unsigned long uninitialized_var(flags); | 905 | unsigned long uninitialized_var(flags); |
906 | unsigned int uninitialized_var(lock_batch); | ||
910 | 907 | ||
911 | for (i = 0; i < nr; i++) { | 908 | for (i = 0; i < nr; i++) { |
912 | struct page *page = pages[i]; | 909 | struct page *page = pages[i]; |
@@ -920,6 +917,16 @@ void release_pages(struct page **pages, int nr, bool cold) | |||
920 | continue; | 917 | continue; |
921 | } | 918 | } |
922 | 919 | ||
920 | /* | ||
921 | * Make sure the IRQ-safe lock-holding time does not get | ||
922 | * excessive with a continuous string of pages from the | ||
923 | * same zone. The lock is held only if zone != NULL. | ||
924 | */ | ||
925 | if (zone && ++lock_batch == SWAP_CLUSTER_MAX) { | ||
926 | spin_unlock_irqrestore(&zone->lru_lock, flags); | ||
927 | zone = NULL; | ||
928 | } | ||
929 | |||
923 | if (!put_page_testzero(page)) | 930 | if (!put_page_testzero(page)) |
924 | continue; | 931 | continue; |
925 | 932 | ||
@@ -930,6 +937,7 @@ void release_pages(struct page **pages, int nr, bool cold) | |||
930 | if (zone) | 937 | if (zone) |
931 | spin_unlock_irqrestore(&zone->lru_lock, | 938 | spin_unlock_irqrestore(&zone->lru_lock, |
932 | flags); | 939 | flags); |
940 | lock_batch = 0; | ||
933 | zone = pagezone; | 941 | zone = pagezone; |
934 | spin_lock_irqsave(&zone->lru_lock, flags); | 942 | spin_lock_irqsave(&zone->lru_lock, flags); |
935 | } | 943 | } |