The patch titled Subject: mm/swapfile: fold scan_swap_map() into the only caller get_swap_page_of_type() has been removed from the -mm tree. Its filename was mm-swapfile-move-get_swap_page_of_type-under-config_hibernation-fix-2.patch This patch was dropped because it was folded into mm-swapfile-move-get_swap_page_of_type-under-config_hibernation.patch ------------------------------------------------------ From: Miaohe Lin <linmiaohe@xxxxxxxxxx> Subject: mm/swapfile: fold scan_swap_map() into the only caller get_swap_page_of_type() We should fold scan_swap_map() into the only caller get_swap_page_of_type() and update the comments referring to it to make the code more succinct. Link: https://lkml.kernel.org/r/20210527120328.3935132-1-linmiaohe@xxxxxxxxxx Signed-off-by: Miaohe Lin <linmiaohe@xxxxxxxxxx> Cc: Hugh Dickins <hughd@xxxxxxxxxx> Cc: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/swapfile.c | 57 +++++++++++++++--------------------------------- 1 file changed, 18 insertions(+), 39 deletions(-) --- a/mm/swapfile.c~mm-swapfile-move-get_swap_page_of_type-under-config_hibernation-fix-2 +++ a/mm/swapfile.c @@ -453,10 +453,10 @@ static void swap_cluster_schedule_discar unsigned int idx) { /* - * If scan_swap_map() can't find a free cluster, it will check + * If scan_swap_map_slots() can't find a free cluster, it will check * si->swap_map directly. To make sure the discarding cluster isn't - * taken by scan_swap_map(), mark the swap entries bad (occupied). It - * will be cleared after discard + * taken by scan_swap_map_slots(), mark the swap entries bad (occupied). + * It will be cleared after discard */ memset(si->swap_map + idx * SWAPFILE_CLUSTER, SWAP_MAP_BAD, SWAPFILE_CLUSTER); @@ -589,7 +589,7 @@ static void dec_cluster_info_page(struct } /* - * It's possible scan_swap_map() uses a free cluster in the middle of free + * It's possible scan_swap_map_slots() uses a free cluster in the middle of free * cluster list. Avoiding such abuse to avoid list corruption. */ static bool @@ -1099,14 +1099,14 @@ start_over: nextsi: /* * if we got here, it's likely that si was almost full before, - * and since scan_swap_map() can drop the si->lock, multiple - * callers probably all tried to get a page from the same si - * and it filled up before we could get one; or, the si filled - * up between us dropping swap_avail_lock and taking si->lock. - * Since we dropped the swap_avail_lock, the swap_avail_head - * list may have been modified; so if next is still in the - * swap_avail_head list then try it, otherwise start over - * if we have not gotten any slots. + * and since scan_swap_map_slots() can drop the si->lock, + * multiple callers probably all tried to get a page from the + * same si and it filled up before we could get one; or, the si + * filled up between us dropping swap_avail_lock and taking + * si->lock. Since we dropped the swap_avail_lock, the + * swap_avail_head list may have been modified; so if next is + * still in the swap_avail_head list then try it, otherwise + * start over if we have not gotten any slots. */ if (plist_node_empty(&next->avail_lists[node])) goto start_over; @@ -1774,42 +1774,21 @@ int free_swap_and_cache(swp_entry_t entr #ifdef CONFIG_HIBERNATION -static unsigned long scan_swap_map(struct swap_info_struct *si, - unsigned char usage) -{ - swp_entry_t entry; - int n_ret; - - n_ret = scan_swap_map_slots(si, usage, 1, &entry); - - if (n_ret) - return swp_offset(entry); - else - return 0; - -} - swp_entry_t get_swap_page_of_type(int type) { struct swap_info_struct *si = swap_type_to_swap_info(type); - pgoff_t offset; + swp_entry_t entry = {0}; if (!si) goto fail; + /* This is called for allocating swap entry, not cache */ spin_lock(&si->lock); - if (si->flags & SWP_WRITEOK) { - /* This is called for allocating swap entry, not cache */ - offset = scan_swap_map(si, 1); - if (offset) { - atomic_long_dec(&nr_swap_pages); - spin_unlock(&si->lock); - return swp_entry(type, offset); - } - } + if ((si->flags & SWP_WRITEOK) && scan_swap_map_slots(si, 1, 1, &entry)) + atomic_long_dec(&nr_swap_pages); spin_unlock(&si->lock); fail: - return (swp_entry_t) {0}; + return entry; } /* @@ -2649,7 +2628,7 @@ SYSCALL_DEFINE1(swapoff, const char __us spin_lock(&p->lock); drain_mmlist(); - /* wait for anyone still in scan_swap_map */ + /* wait for anyone still in scan_swap_map_slots */ p->highest_bit = 0; /* cuts scans short */ while (p->flags >= SWP_SCANNING) { spin_unlock(&p->lock); _ Patches currently in -mm which might be from linmiaohe@xxxxxxxxxx are mm-swapfile-use-percpu_ref-to-serialize-against-concurrent-swapoff.patch swap-fix-do_swap_page-race-with-swapoff.patch mm-swap-remove-confusing-checking-for-non_swap_entry-in-swap_ra_info.patch mm-shmem-fix-shmem_swapin-race-with-swapoff.patch mm-swapfile-move-get_swap_page_of_type-under-config_hibernation.patch mm-swap-remove-unused-local-variable-nr_shadows.patch mm-swap_slotsc-delete-meaningless-forward-declarations.patch mm-huge_memoryc-remove-dedicated-macro-hpage_cache_index_mask.patch mm-huge_memoryc-use-page-deferred_list.patch mm-huge_memoryc-add-missing-read-only-thp-checking-in-transparent_hugepage_enabled.patch mm-huge_memoryc-add-missing-read-only-thp-checking-in-transparent_hugepage_enabled-v4.patch mm-huge_memoryc-remove-unnecessary-tlb_remove_page_size-for-huge-zero-pmd.patch mm-huge_memoryc-dont-discard-hugepage-if-other-processes-are-mapping-it.patch mm-workingset-define-macro-workingset_shift.patch mm-z3fold-define-macro-nchunks-as-total_chunks-zhdr_chunks.patch mm-z3fold-avoid-possible-underflow-in-z3fold_alloc.patch mm-z3fold-remove-magic-number-in-z3fold_create_pool.patch mm-z3fold-remove-unused-function-handle_to_z3fold_header.patch mm-z3fold-fix-potential-memory-leak-in-z3fold_destroy_pool.patch mm-z3fold-use-release_z3fold_page_locked-to-release-locked-z3fold-page.patch mm-zbud-reuse-unbuddied-as-buddied-in-zbud_pool.patch mm-zbud-dont-export-any-zbud-api.patch mm-zbud-dont-export-any-zbud-api-fix.patch mm-zswapc-remove-unused-function-zswap_debugfs_exit.patch mm-zswapc-avoid-unnecessary-copy-in-at-map-time.patch mm-zswapc-fix-two-bugs-in-zswap_writeback_entry.patch mm-zsmallocc-remove-confusing-code-in-obj_free.patch mm-zsmallocc-combine-two-atomic-ops-in-zs_pool_dec_isolated.patch mm-zsmallocc-improve-readability-for-async_free_zspage.patch