From patchwork Tue Jun 27 12:08:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mawupeng X-Patchwork-Id: 13294403 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 C16F6EB64DC for ; Tue, 27 Jun 2023 12:08:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 17B328D0003; Tue, 27 Jun 2023 08:08:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 12C0F8D0001; Tue, 27 Jun 2023 08:08:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0196A8D0003; Tue, 27 Jun 2023 08:08:45 -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 E90008D0001 for ; Tue, 27 Jun 2023 08:08:45 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id A9D7C1A092D for ; Tue, 27 Jun 2023 12:08:45 +0000 (UTC) X-FDA: 80948406210.19.013E94F Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf18.hostedemail.com (Postfix) with ESMTP id B85FC1C0009 for ; Tue, 27 Jun 2023 12:08:42 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf18.hostedemail.com: domain of mawupeng1@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=mawupeng1@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687867723; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JG+MxX5N+LS7YTjk/+01l2Yc0IeaacdIWZ6zRJ97y0A=; b=fQ0AJsLQMVeuO/HYOkmfRW+oIcAiN1pgOH7BpYRbmkgPcB9WkeMIhYtsyB4VRX2ldmtQdG YKhIOA3lp4mpBTed7LdHeGDAf+Ai9ElqF8VbABC9Ifwbm6eWLVBiJqyLFoxo+fRp8v0OU4 52wl0o4Rbb1Q5bDOIbhAAfWQFj2yETc= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf18.hostedemail.com: domain of mawupeng1@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=mawupeng1@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687867723; a=rsa-sha256; cv=none; b=KZDTAckDvBbtPXdm/co5Jj+54vtL28ra6SluCNd5nNy34p2d/KkrAnVihj6+BKsAU+8jXE dBpD/O7mCjqykklHBAA26KM6z/wdfRJK99hmxVSCEMm+X5FkDzKnAKX506IW9QF0uqE9Nb ubAsJiysfncmrnlZCbc2EPA3T9fE0MY= Received: from dggpemm500014.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Qr3QG5QRCzqV0Q; Tue, 27 Jun 2023 20:08:22 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm500014.china.huawei.com (7.185.36.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 27 Jun 2023 20:08:38 +0800 From: Wupeng Ma To: CC: , , Subject: [PATCH 1/2] swap: Cleanup duplicated WARN_ON in add_to_avail_list Date: Tue, 27 Jun 2023 20:08:32 +0800 Message-ID: <20230627120833.2230766-2-mawupeng1@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230627120833.2230766-1-mawupeng1@huawei.com> References: <20230627120833.2230766-1-mawupeng1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500014.china.huawei.com (7.185.36.153) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: B85FC1C0009 X-Stat-Signature: zmuj155pdthjmtd4g6dmxwdght1geq78 X-Rspam-User: X-HE-Tag: 1687867722-364438 X-HE-Meta: U2FsdGVkX1/4x9eSHl9QrG58qJ6Zsflyp0AhTOUbU3PFYtD69s3NfkOzRqHVolHvLmEWwmlyFXeGnYIy2FS0X+t7Xwlh78NFr7zVJ101hi+rXuM6HMwmZYuLDl456FX/cb11q4aEMEbHIy4xl8GJo5tVGA8dlatnqIvXayepJtylzKlQ6X7eM6DmV8OlX/IoiP6i4bgVfb/JU5VWjlX9XHtjqkgu8KTKB1QGMMOgNmD5gXtGhBteaCM3C3enbIKsbzv+1OolXHwSyp625hENGtNK4PfwH3PjiLe6WvJU7pjwERKHGkbftcN9ziPlevlAdPUpId8Fvuogk3N9AEgBGLHXeM/MgQnUx/GyNVpY1RmcwdhikINFWwPACyWNcS1YTv4+qMiniGWswNOPNbSVdxM6zuaBydZO0QuXsYD8hmTWAsqN64F9fcMNvmkAmj1lMY/Ls04Ry/hq0897P22cZeLbls17HtAHm/l2Y3BIqyoY7Lo4Z0Qco9Ekf5Nvjar28MPoxtQ3rplbvikFVYy5d3CsYRdAjrd00BC/+UO3LGh4cXDI5YeNvRQBPjeZSXwaKwbmPfJGs7DDVhnfsPtiziZ1SWpI87SAf4v7nZWUJVBMYLnnTNnE4OcgsHAu8jXYyQZG6DMEsrgS4yoYq5NTsgrYXxvHyIuyJ/EifRfWAaExNneZ+vlRRI6dsmS0Y5Sl1RUvuWWWcczZyZ3VqOfO6tEI72RTnkp7eTF2QsH3NIfRavqw2/yquLO0vCy3Ep94JWRrVd5xWXPtCkNJtALisehsvGNShCx5KsTClTdfWyjttou1JpuRoGyCMGhRNvteSMWlguMaOKwU8qjNtFyugx8nvGMpqngwYyJJBPSfB3ELxvGbp67D2QmUxRpzEgTmvk8oZCD3Psst45mlIF1IJyZT9VIlzHtcG60NgdoiKA752pcF5y4aShaogfxlgHJLNaUGH9t+2078n/ni5yH /xkDGLAb pqfNs8FIcA2WEMdkHZ1CLZjaHCR4TsKxmYXbbheiRApLo1trJTG5IOynEGZFoVA3k5sWGeKY9VFJpg4vAbwYM2h1/tdFZDEYq8wOMKvO+w7aXYRqCz0XD3KdAklcaLggOqTQP88+PL3JV57xq+uFtrEt4S72i4fICVLEoysRLKR+JC2yg0sumVQGPg5q6+G8Ahddq 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: From: Ma Wupeng Empty check for plist_node is checked in add_to_avail_list and plist_add. Drop the duplicate one in add_to_avail_list. Signed-off-by: Ma Wupeng --- mm/swapfile.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index 274bbf797480..879cb80bf37b 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -713,10 +713,8 @@ static void add_to_avail_list(struct swap_info_struct *p) int nid; spin_lock(&swap_avail_lock); - for_each_node(nid) { - WARN_ON(!plist_node_empty(&p->avail_lists[nid])); + for_each_node(nid) plist_add(&p->avail_lists[nid], &swap_avail_heads[nid]); - } spin_unlock(&swap_avail_lock); } From patchwork Tue Jun 27 12:08:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mawupeng X-Patchwork-Id: 13294405 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 14E89C0015E for ; Tue, 27 Jun 2023 12:08:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E79BA8D0006; Tue, 27 Jun 2023 08:08:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E245E8D0001; Tue, 27 Jun 2023 08:08:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B648F8D0006; Tue, 27 Jun 2023 08:08:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id A9D9E8D0001 for ; Tue, 27 Jun 2023 08:08:48 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 778251C8924 for ; Tue, 27 Jun 2023 12:08:48 +0000 (UTC) X-FDA: 80948406336.14.D0DCC69 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf13.hostedemail.com (Postfix) with ESMTP id 6F6B620022 for ; Tue, 27 Jun 2023 12:08:44 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.hostedemail.com: domain of mawupeng1@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=mawupeng1@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687867726; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=J8leeMhKmOQ7jOYumvmUp9PcrhJvsFWwBwZe5HOZi0M=; b=gnYYIc/tV42bE9a1itXjv70IeRo4VU8UZN4Edp6W+WTnFaTULB6AWYA0iKZhrGKAcg9AQG UCzipwYWxtDhJG03pZCjr/YB50g7bJHUpf18qu6+fMOxZRAla4PPqFEeOlAQcug3sTp1vj ZHjOL0xWvAcl9RHlZVRHeaKEdPfm0p8= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.hostedemail.com: domain of mawupeng1@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=mawupeng1@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687867726; a=rsa-sha256; cv=none; b=scnPpVD0KchE2fU8k9UBje+4WMFCvEoQQj3O3dHXZD2yxkA4ys9dWh5i3P2C4gsYFzp1Lv C2vnVYlbSeGGWpd5WIGcz5DPMEWYny/dEZjkpqONR46362PZVSkoqICs9PNuEZxQxTb5ya IttGAFSm76h+fxSfLugLKcpq1DebI5Y= Received: from dggpemm500014.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Qr3Pc1D1mzTlP5; Tue, 27 Jun 2023 20:07:48 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm500014.china.huawei.com (7.185.36.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 27 Jun 2023 20:08:38 +0800 From: Wupeng Ma To: CC: , , Subject: [PATCH 2/2] swap: Stop add to avail list is swap is full Date: Tue, 27 Jun 2023 20:08:33 +0800 Message-ID: <20230627120833.2230766-3-mawupeng1@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230627120833.2230766-1-mawupeng1@huawei.com> References: <20230627120833.2230766-1-mawupeng1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500014.china.huawei.com (7.185.36.153) X-CFilter-Loop: Reflected X-Rspam-User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xbZAymYWEDdDQ0QgsP2 Uekom+49 c5MOrs7feM0DD95uG0Gzh1HFI95u2BYPnq8S2QO6d79YT53cBIG2dwXW9S3aPbscp1e9nyq1IUGyxmZKJ45JkBnt4XXVCv7bdWVpTBaPWZJHgKgBN+6q/l3/BzCyE0xXGd9o/L3WI0iW/++OtxtXnsG+iP3VVA8yyw8HgrN+I8av3keHMZz7gPHzVIx5ngX3lfzvUx6lwfJ27WYWHta/kthSn+Q== 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: From: Ma Wupeng Our test find a WARN_ON in add_to_avail_list. During add_to_avail_list, avail_lists is already in swap_avail_heads, while lead to this WARN_ON. Here is the simplified calltrace: ------------[ cut here ]------------ Call trace: add_to_avail_list+0xb8/0xc0 swap_range_free+0x110/0x138 swapcache_free_entries+0x100/0x1c0 free_swap_slot+0xbc/0xe0 put_swap_folio+0x1f0/0x2ec delete_from_swap_cache+0x6c/0xd0 folio_free_swap+0xa4/0xe4 __try_to_reclaim_swap+0x9c/0x190 free_swap_and_cache+0x84/0x88 unmap_page_range+0x31c/0x934 unmap_single_vma.isra.0+0x48/0x84 unmap_vmas+0x98/0x10c exit_mmap+0xa4/0x210 mmput+0x88/0x158 do_exit+0x284/0x970 do_group_exit+0x34/0x90 post_copy_siginfo_from_user32+0x0/0x1cc do_notify_resume+0x15c/0x470 el0_svc+0x74/0x84 el0t_64_sync_handler+0xb8/0xbc el0t_64_sync+0x190/0x194 During swapoff, try_to_unuse fail to alloc memory due to memory limit and this lead the failure of swapoff and casing re-insert swap space back into swap_list. During _enable_swap_info, this swap device is added to avail list even this swap device if full. At the same time, one entry in this full swap device in released and try to add this device into avail list and found it is already in the avail list. This cause this WARN_ON. To fix this. Stop add to avail list is swap is full. Signed-off-by: Ma Wupeng --- mm/swapfile.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index 879cb80bf37b..0167999fa228 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -2337,7 +2337,10 @@ static void _enable_swap_info(struct swap_info_struct *p) * swap_info_struct. */ plist_add(&p->list, &swap_active_head); - add_to_avail_list(p); + + /* add to avaliable list iff swap device is not full */ + if (p->highest_bit) + add_to_avail_list(p); } static void enable_swap_info(struct swap_info_struct *p, int prio,