From patchwork Tue Jun 29 02:37:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12349023 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A3B1C11F66 for ; Tue, 29 Jun 2021 02:37:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E4A2361D07 for ; Tue, 29 Jun 2021 02:37:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E4A2361D07 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 47AB28D00C1; Mon, 28 Jun 2021 22:37:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 451298D008F; Mon, 28 Jun 2021 22:37:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 318AA8D00C1; Mon, 28 Jun 2021 22:37:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0139.hostedemail.com [216.40.44.139]) by kanga.kvack.org (Postfix) with ESMTP id 0B8B18D008F for ; Mon, 28 Jun 2021 22:37:18 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 04F3D18155250 for ; Tue, 29 Jun 2021 02:37:18 +0000 (UTC) X-FDA: 78305199756.25.18ED85F Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf18.hostedemail.com (Postfix) with ESMTP id C0B492001060 for ; Tue, 29 Jun 2021 02:37:17 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 8546561A2B; Tue, 29 Jun 2021 02:37:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1624934237; bh=/POV9UGgpCHcoyUw9DZKte6UudXS13gszgGH8144giU=; h=Date:From:To:Subject:In-Reply-To:From; b=CmS0oOhG48lqbOPvD/NEuM13vA1tX3zwNxnskNUUnIqa77f6AT3GpJd2f9lzrqHUp 8TTA196QrsXcNajdICYXaaKxe1JUaOboR4po4pQVHqb7OVgVhBkuzr8PIcMzgJ4k7h BjDpYnj3lJi1CdcH2ZRmwoeEgeOLLdlz02DL0Z3U= Date: Mon, 28 Jun 2021 19:37:16 -0700 From: Andrew Morton To: akpm@linux-foundation.org, dan.j.williams@intel.com, hannes@cmpxchg.org, hch@lst.de, hughd@google.com, iamjoonsoo.kim@lge.com, idryomov@gmail.com, linmiaohe@huawei.com, linux-mm@kvack.org, mgorman@techsingularity.net, mhocko@kernel.org, minchan@kernel.org, mm-commits@vger.kernel.org, torvalds@linux-foundation.org, vbabka@suse.cz, willy@infradead.org, ying.huang@intel.com Subject: [patch 076/192] swap: check mapping_empty() for swap cache before being freed Message-ID: <20210629023716.zBdJg2iAG%akpm@linux-foundation.org> In-Reply-To: <20210628193256.008961950a714730751c1423@linux-foundation.org> User-Agent: s-nail v14.8.16 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=CmS0oOhG; dmarc=none; spf=pass (imf18.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Rspamd-Server: rspam02 X-Stat-Signature: 94g4y7gim88644ssue6o5jhchoott4oi X-Rspamd-Queue-Id: C0B492001060 X-HE-Tag: 1624934237-685077 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: Huang Ying Subject: swap: check mapping_empty() for swap cache before being freed To check whether all pages and shadow entries in swap cache has been removed before swap cache is freed. Link: https://lkml.kernel.org/r/20210608005121.511140-1-ying.huang@intel.com Signed-off-by: "Huang, Ying" Cc: Miaohe Lin Cc: Matthew Wilcox Cc: Minchan Kim Cc: Joonsoo Kim Cc: Johannes Weiner Cc: Vlastimil Babka Cc: Hugh Dickins Cc: Mel Gorman Cc: Michal Hocko Cc: Dan Williams Cc: Christoph Hellwig Cc: Ilya Dryomov Signed-off-by: Andrew Morton --- mm/swap_state.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/mm/swap_state.c~swap-check-mapping_empty-for-swap-cache-before-being-freed +++ a/mm/swap_state.c @@ -693,7 +693,12 @@ int init_swap_address_space(unsigned int void exit_swap_address_space(unsigned int type) { - kvfree(swapper_spaces[type]); + int i; + struct address_space *spaces = swapper_spaces[type]; + + for (i = 0; i < nr_swapper_spaces[type]; i++) + VM_WARN_ON_ONCE(!mapping_empty(&spaces[i])); + kvfree(spaces); nr_swapper_spaces[type] = 0; swapper_spaces[type] = NULL; }