From patchwork Tue Oct 22 19:24:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13846077 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CF34CDD0D7 for ; Tue, 22 Oct 2024 19:29:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E6C6A6B0089; Tue, 22 Oct 2024 15:29:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E1BED6B008A; Tue, 22 Oct 2024 15:29:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C95946B008C; Tue, 22 Oct 2024 15:29:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id AA7136B0089 for ; Tue, 22 Oct 2024 15:29:58 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 0CE8EA0469 for ; Tue, 22 Oct 2024 19:29:28 +0000 (UTC) X-FDA: 82702227972.10.C2E609D Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by imf09.hostedemail.com (Postfix) with ESMTP id CC2FB14001B for ; Tue, 22 Oct 2024 19:29:44 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Uln1YLlP; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf09.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.179 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729625345; a=rsa-sha256; cv=none; b=M+FYNK7rBphPkJgsGsXlzgH53pwqKILf9J68ZknuV8H13GZ54oc4w5oKkd8eOT7Gg7/pKQ EEEgDaQmmgbcRveW7Z60i4p3wjlLan1mfMRHdMLJNojKV6l3tgu+aOZeqKcXKKV/dyxiai zjEmIshOAstqiZ06v62uYRocJpSGydI= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Uln1YLlP; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf09.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.179 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729625345; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=3VbfK94vYMM7w9zgk7A3WhLYxN2WUErtpJ6jwxCUlfQ=; b=Qoi53mJnIdb7OHcZeUXejxLriK6H39UeuNP7hsXaBxbcl8aO/EQoyBm5HXWcHJDXUTsLMB whmUNEeHSkYs/GLfQpX6JJOyZEh/WMxr1Z6hrSfEHnX+E1UK3Z9tMujodHmYOzRIpapIAW KNFaD+Xq9ORorO6ctR4l7sf0xV2jh/0= Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-20c803787abso1319205ad.0 for ; Tue, 22 Oct 2024 12:29:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729625395; x=1730230195; darn=kvack.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=3VbfK94vYMM7w9zgk7A3WhLYxN2WUErtpJ6jwxCUlfQ=; b=Uln1YLlPsqwKgWUqVCHfCLocBvv8hfkS1juxlonmv2/2aaAWGCYd8uqop3ddHeaQL6 K1LH4mtbhlYEIBXzwvX0RoEGeA05+3j1D4icnwzRr7F2ZwaruoAP+FjPOqQ0GVMM2uAF qHk2hA6d2WG5q62gZX2Aoca1jnWYBTmlvAu6EDGWpamJVL85HlVMcVN69z2fPD241BJB /NBM9B4Y5N/ADzuNXngyKgrXr7nkeC56uPeTClm+Vw91Y2/ofMAzYeJTCL2ojpz80QDM lfn+jWZVPuiZzaOM8pzaKKMulWX5XeN01xuv0zWTs2latnPEHR4IVrBh4LayRfnhqtAH dMog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729625395; x=1730230195; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=3VbfK94vYMM7w9zgk7A3WhLYxN2WUErtpJ6jwxCUlfQ=; b=YP+QyMHpEd417pJOvBuzch5LGJbcOxTdkCjSx07FwAT+XXLEaLwh5KevuCJlGQEOit YeMrbU4L1CPGeo4CX0mlzCq68FSSQynP4bLWSF2lhi8KsUGAxe5M9OMSRViyk0VlhadB z+EkXhUjtVgvXekRCDLP4DBM+AiPOy6xVdAZrwxvM4VqzDSdz0eRe9dntEBulERpnRMi lwSypm0SGbQTzc0t1sxpaspLGHEPrLgeV3dPcLdn3SqRlRXnKNtBphuxxc7ZNso1Zavr BdIInU3WPKNl0CvtTWaA8+UF0uj1Zh7RWG6Y3vsGDrN/2/Idz+UZkjW2ck0D4RaOuirv XxUg== X-Gm-Message-State: AOJu0YxoaGJpuI4Mub98WfqjkjOuhicYzZHqQK7G3h3EkmnvBp6RWbnV YUqBMm7jNbHtv+NwFQQPlLXEAwwQYV8vih+KZviDqqdjCiIpF/7JAsoe4pOhlMg= X-Google-Smtp-Source: AGHT+IGC2ct67tQlrbrn/euF7RF/i0JZyKYC9YgNS29vka34ew1P1aDh5IqUWUcc+iJ+99k9cKHp5A== X-Received: by 2002:a17:902:c40f:b0:20b:6c1e:1e13 with SMTP id d9443c01a7336-20e970c794cmr70541015ad.23.1729625394613; Tue, 22 Oct 2024 12:29:54 -0700 (PDT) Received: from KASONG-MC4.tencent.com ([106.37.123.36]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20e7f0d9f05sm45895305ad.186.2024.10.22.12.29.51 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 22 Oct 2024 12:29:54 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: Andrew Morton , Chris Li , Barry Song , Ryan Roberts , Hugh Dickins , Yosry Ahmed , "Huang, Ying" , Tim Chen , Nhat Pham , linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH 03/13] mm, swap: remove old allocation path for HDD Date: Wed, 23 Oct 2024 03:24:41 +0800 Message-ID: <20241022192451.38138-4-ryncsn@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022192451.38138-1-ryncsn@gmail.com> References: <20241022192451.38138-1-ryncsn@gmail.com> Reply-To: Kairui Song MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: CC2FB14001B X-Rspamd-Server: rspam01 X-Stat-Signature: te8mcw7m7ccaqedk6uij353irkqqypp1 X-HE-Tag: 1729625384-149411 X-HE-Meta: U2FsdGVkX1/WjYwK657LctkmuQPlGiKWxMli0lnCOQexKy7KqxtLiBYdYgOANODG0cPwdlu7xfRC9IF5PD+EymRfZHFwcTiparVJ85QfdrjEe/6zWuYb0Kmyr7wx8zufGL1bMqGEzQc6Pa4KS+tO7pUrkAQS6wsS2suAwWP+8fol81LKlh46l8ay3PDJOD0yZA0cykn4Jlj1HbcTibtVF18I1qhzqNRpSBWTQXM6aUR2PBejsdpRI53pTozjrJGK4t3QZ/7w3rk0QBgtUzEsshmecda5sP5jjuTA62D0KiJHCCiwGCf2eDp9GVpHONZZ55TkJTHoKwpnxgKXQvuikjT1M9Gb1989HSPvSeo1laazjEfmX1LetMYFBJr+Ak9nIMFHODWTAr058TWsuspGcvfcbBV0FDJm9sCMCsVWRwTdswe/RZPhjRMwB1ADpLpiKnzGzFP9XZg9cbGX7ldwiYv5PCKoBzMrpDIzdoaKOf+Mg0bBUngkZ0oBS3GKLEjVEY2tfH+M3UnyZQYdKnKQ2ui0c/t8gyp1KS9nBfSBRsmqxSomQ7xzRlD5hZeogbs9ojIb9e1ilOLKSUmnievVUUh3euxLkRau/cgpfeFPo0yHxr5Q36f1SGyMxSpnDuLZSiN3g6oYA6O7BUSDn8YFJyC8A723m8zz78BupT57yEM9pSMDvObt9zXWZvdmzf9S5ZmOKnRcU3QjT16bqJeQVOl/gXf3MQSF1KHfmKXCNbvlyAK0U9BwO8FneZxxRT4YeUIPcbmrqhXvLMW4E1hO8nOrYc6mhVP2iSzSHsChNgCKa73lc9JcNOSkklVknJJ/WSKdm1C9KPJ1ito+GXPL2lweEBKbNPI3pAF4fZVWWmgwXy1JmfA+cWd5kVoSL/QNizSC0pf7lMWgKa6yuW4651tA4Hcr1zir2a13X1R15Oats4VZZFkfbf+5nYfnXO8jOVpFMkNlpiGdpnxVM6l rmnqTNva qQJ+h9Fizo356RGNxFuPTAJhEF7pWJOQQ2rLRMdzy+yyqq5iA8L3F25zxhbpcjWAJu6AkY5aB/Eae8tECmNorBFX1AvvGm97+yDJ4kzGFj8Gqb3kW8qb8n1cSds1Vzoxp0TF0qRsuvX3cTsB2pTBwmM0j8oH0UaAn9rdNYs821I02up+FFdCb2cleVsMskg58XO34SA0jyvhTg70oPDbw1IIy7IQsDC3aisBENMLVe1Iye9nalCiPHtUiUGy+oq+VomOXiE5Av2TxPzzKhcVnwyvMZ6kH7/ypYpNBbOJQAS/FutnoM26Bab/mxFXYw8qkgn2Su13BgPAW/YgEU7ZQ0IB1w17k7BbCgiJWv3fGSKEBVILY2NJp6ZYub+Sqj7jyagfSBX9XyNaglLD1rdo5XRjq6Ynb1mSU7AhMppRg9spjNxNo6CKmaMh9KD8F1Y8zYOH55/0E2LjWiZLF8mx+kGdsKZavDvB6aP2RbOqIce9tMM7rfmJACNUSeDq63ozG/jB6PgJInAH2ni77e0bieE6q+LbpZhHwJSG6rAQLUGz57ZDb/kINrZcG7xh8fjMOX2C2 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Kairui Song We are currently using different swap allocation algorithm for HDD and non-HDD. This leads to the existing of different set of locking, and the code path is heavily bloated, causing troubles for further optimization and maintenance. This commit removes all HDD swap allocation and related dead code, and use cluster allocation algorithm instead. The performance may drop a little bit temporarily, and should be negligible: The main advantage of legacy HDD allocation algorithm is that is tend to use continuous slots, but swap device gets fragmented quickly anyway, and the attempt to use continuous slots will fail easily. This commit also enables mTHP swap on HDD, which should be beneficial, and following commits will adapt and optimize the cluster allocator for HDD. Suggested-by: Chris Li Suggested-by: "Huang, Ying" Signed-off-by: Kairui Song --- include/linux/swap.h | 3 - mm/swapfile.c | 235 ++----------------------------------------- 2 files changed, 9 insertions(+), 229 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index f3e0ac20c2e8..3a71198a6957 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -309,9 +309,6 @@ struct swap_info_struct { unsigned int highest_bit; /* index of last free in swap_map */ unsigned int pages; /* total of usable pages of swap */ unsigned int inuse_pages; /* number of those currently in use */ - unsigned int cluster_next; /* likely index for next allocation */ - unsigned int cluster_nr; /* countdown to next cluster search */ - unsigned int __percpu *cluster_next_cpu; /*percpu index for next allocation */ struct percpu_cluster __percpu *percpu_cluster; /* per cpu's swap location */ struct rb_root swap_extent_root;/* root of the swap extent rbtree */ struct block_device *bdev; /* swap device or bdev of swap file */ diff --git a/mm/swapfile.c b/mm/swapfile.c index e1e4a1ba4fc5..ffdf7eedecb5 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -989,49 +989,6 @@ static void swap_range_free(struct swap_info_struct *si, unsigned long offset, WRITE_ONCE(si->inuse_pages, si->inuse_pages - nr_entries); } -static void set_cluster_next(struct swap_info_struct *si, unsigned long next) -{ - unsigned long prev; - - if (!(si->flags & SWP_SOLIDSTATE)) { - si->cluster_next = next; - return; - } - - prev = this_cpu_read(*si->cluster_next_cpu); - /* - * Cross the swap address space size aligned trunk, choose - * another trunk randomly to avoid lock contention on swap - * address space if possible. - */ - if ((prev >> SWAP_ADDRESS_SPACE_SHIFT) != - (next >> SWAP_ADDRESS_SPACE_SHIFT)) { - /* No free swap slots available */ - if (si->highest_bit <= si->lowest_bit) - return; - next = get_random_u32_inclusive(si->lowest_bit, si->highest_bit); - next = ALIGN_DOWN(next, SWAP_ADDRESS_SPACE_PAGES); - next = max_t(unsigned int, next, si->lowest_bit); - } - this_cpu_write(*si->cluster_next_cpu, next); -} - -static bool swap_offset_available_and_locked(struct swap_info_struct *si, - unsigned long offset) -{ - if (data_race(!si->swap_map[offset])) { - spin_lock(&si->lock); - return true; - } - - if (vm_swap_full() && READ_ONCE(si->swap_map[offset]) == SWAP_HAS_CACHE) { - spin_lock(&si->lock); - return true; - } - - return false; -} - static int cluster_alloc_swap(struct swap_info_struct *si, unsigned char usage, int nr, swp_entry_t slots[], int order) @@ -1055,13 +1012,7 @@ static int scan_swap_map_slots(struct swap_info_struct *si, unsigned char usage, int nr, swp_entry_t slots[], int order) { - unsigned long offset; - unsigned long scan_base; - unsigned long last_in_cluster = 0; - int latency_ration = LATENCY_LIMIT; unsigned int nr_pages = 1 << order; - int n_ret = 0; - bool scanned_many = false; /* * We try to cluster swap pages by allocating them sequentially @@ -1073,7 +1024,6 @@ static int scan_swap_map_slots(struct swap_info_struct *si, * But we do now try to find an empty cluster. -Andrea * And we let swap pages go all over an SSD partition. Hugh */ - if (order > 0) { /* * Should not even be attempting large allocations when huge @@ -1093,158 +1043,7 @@ static int scan_swap_map_slots(struct swap_info_struct *si, return 0; } - if (si->cluster_info) - return cluster_alloc_swap(si, usage, nr, slots, order); - - si->flags += SWP_SCANNING; - - /* For HDD, sequential access is more important. */ - scan_base = si->cluster_next; - offset = scan_base; - - if (unlikely(!si->cluster_nr--)) { - if (si->pages - si->inuse_pages < SWAPFILE_CLUSTER) { - si->cluster_nr = SWAPFILE_CLUSTER - 1; - goto checks; - } - - spin_unlock(&si->lock); - - /* - * If seek is expensive, start searching for new cluster from - * start of partition, to minimize the span of allocated swap. - */ - scan_base = offset = si->lowest_bit; - last_in_cluster = offset + SWAPFILE_CLUSTER - 1; - - /* Locate the first empty (unaligned) cluster */ - for (; last_in_cluster <= READ_ONCE(si->highest_bit); offset++) { - if (si->swap_map[offset]) - last_in_cluster = offset + SWAPFILE_CLUSTER; - else if (offset == last_in_cluster) { - spin_lock(&si->lock); - offset -= SWAPFILE_CLUSTER - 1; - si->cluster_next = offset; - si->cluster_nr = SWAPFILE_CLUSTER - 1; - goto checks; - } - if (unlikely(--latency_ration < 0)) { - cond_resched(); - latency_ration = LATENCY_LIMIT; - } - } - - offset = scan_base; - spin_lock(&si->lock); - si->cluster_nr = SWAPFILE_CLUSTER - 1; - } - -checks: - if (!(si->flags & SWP_WRITEOK)) - goto no_page; - if (!si->highest_bit) - goto no_page; - if (offset > si->highest_bit) - scan_base = offset = si->lowest_bit; - - /* reuse swap entry of cache-only swap if not busy. */ - if (vm_swap_full() && si->swap_map[offset] == SWAP_HAS_CACHE) { - int swap_was_freed; - spin_unlock(&si->lock); - swap_was_freed = __try_to_reclaim_swap(si, offset, TTRS_ANYWAY | TTRS_DIRECT); - spin_lock(&si->lock); - /* entry was freed successfully, try to use this again */ - if (swap_was_freed > 0) - goto checks; - goto scan; /* check next one */ - } - - if (si->swap_map[offset]) { - if (!n_ret) - goto scan; - else - goto done; - } - memset(si->swap_map + offset, usage, nr_pages); - - swap_range_alloc(si, offset, nr_pages); - slots[n_ret++] = swp_entry(si->type, offset); - - /* got enough slots or reach max slots? */ - if ((n_ret == nr) || (offset >= si->highest_bit)) - goto done; - - /* search for next available slot */ - - /* time to take a break? */ - if (unlikely(--latency_ration < 0)) { - if (n_ret) - goto done; - spin_unlock(&si->lock); - cond_resched(); - spin_lock(&si->lock); - latency_ration = LATENCY_LIMIT; - } - - if (si->cluster_nr && !si->swap_map[++offset]) { - /* non-ssd case, still more slots in cluster? */ - --si->cluster_nr; - goto checks; - } - - /* - * Even if there's no free clusters available (fragmented), - * try to scan a little more quickly with lock held unless we - * have scanned too many slots already. - */ - if (!scanned_many) { - unsigned long scan_limit; - - if (offset < scan_base) - scan_limit = scan_base; - else - scan_limit = si->highest_bit; - for (; offset <= scan_limit && --latency_ration > 0; - offset++) { - if (!si->swap_map[offset]) - goto checks; - } - } - -done: - if (order == 0) - set_cluster_next(si, offset + 1); - si->flags -= SWP_SCANNING; - return n_ret; - -scan: - VM_WARN_ON(order > 0); - spin_unlock(&si->lock); - while (++offset <= READ_ONCE(si->highest_bit)) { - if (unlikely(--latency_ration < 0)) { - cond_resched(); - latency_ration = LATENCY_LIMIT; - scanned_many = true; - } - if (swap_offset_available_and_locked(si, offset)) - goto checks; - } - offset = si->lowest_bit; - while (offset < scan_base) { - if (unlikely(--latency_ration < 0)) { - cond_resched(); - latency_ration = LATENCY_LIMIT; - scanned_many = true; - } - if (swap_offset_available_and_locked(si, offset)) - goto checks; - offset++; - } - spin_lock(&si->lock); - -no_page: - si->flags -= SWP_SCANNING; - return n_ret; + return cluster_alloc_swap(si, usage, nr, slots, order); } int get_swap_pages(int n_goal, swp_entry_t swp_entries[], int entry_order) @@ -2855,8 +2654,6 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile) mutex_unlock(&swapon_mutex); free_percpu(p->percpu_cluster); p->percpu_cluster = NULL; - free_percpu(p->cluster_next_cpu); - p->cluster_next_cpu = NULL; vfree(swap_map); kvfree(zeromap); kvfree(cluster_info); @@ -3168,8 +2965,6 @@ static unsigned long read_swap_header(struct swap_info_struct *si, } si->lowest_bit = 1; - si->cluster_next = 1; - si->cluster_nr = 0; maxpages = swapfile_maximum_size; last_page = swap_header->info.last_page; @@ -3255,7 +3050,6 @@ static struct swap_cluster_info *setup_clusters(struct swap_info_struct *si, unsigned long maxpages) { unsigned long nr_clusters = DIV_ROUND_UP(maxpages, SWAPFILE_CLUSTER); - unsigned long col = si->cluster_next / SWAPFILE_CLUSTER % SWAP_CLUSTER_COLS; struct swap_cluster_info *cluster_info; unsigned long i, j, k, idx; int cpu, err = -ENOMEM; @@ -3267,15 +3061,6 @@ static struct swap_cluster_info *setup_clusters(struct swap_info_struct *si, for (i = 0; i < nr_clusters; i++) spin_lock_init(&cluster_info[i].lock); - si->cluster_next_cpu = alloc_percpu(unsigned int); - if (!si->cluster_next_cpu) - goto err_free; - - /* Random start position to help with wear leveling */ - for_each_possible_cpu(cpu) - per_cpu(*si->cluster_next_cpu, cpu) = - get_random_u32_inclusive(1, si->highest_bit); - si->percpu_cluster = alloc_percpu(struct percpu_cluster); if (!si->percpu_cluster) goto err_free; @@ -3317,7 +3102,7 @@ static struct swap_cluster_info *setup_clusters(struct swap_info_struct *si, * sharing same address space. */ for (k = 0; k < SWAP_CLUSTER_COLS; k++) { - j = (k + col) % SWAP_CLUSTER_COLS; + j = k % SWAP_CLUSTER_COLS; for (i = 0; i < DIV_ROUND_UP(nr_clusters, SWAP_CLUSTER_COLS); i++) { struct swap_cluster_info *ci; idx = i * SWAP_CLUSTER_COLS + j; @@ -3467,18 +3252,18 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) if (si->bdev && bdev_nonrot(si->bdev)) { si->flags |= SWP_SOLIDSTATE; - - cluster_info = setup_clusters(si, swap_header, maxpages); - if (IS_ERR(cluster_info)) { - error = PTR_ERR(cluster_info); - cluster_info = NULL; - goto bad_swap_unlock_inode; - } } else { atomic_inc(&nr_rotate_swap); inced_nr_rotate_swap = true; } + cluster_info = setup_clusters(si, swap_header, maxpages); + if (IS_ERR(cluster_info)) { + error = PTR_ERR(cluster_info); + cluster_info = NULL; + goto bad_swap_unlock_inode; + } + if ((swap_flags & SWAP_FLAG_DISCARD) && si->bdev && bdev_max_discard_sectors(si->bdev)) { /* @@ -3559,8 +3344,6 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) bad_swap: free_percpu(si->percpu_cluster); si->percpu_cluster = NULL; - free_percpu(si->cluster_next_cpu); - si->cluster_next_cpu = NULL; inode = NULL; destroy_swap_extents(si); swap_cgroup_swapoff(si->type);