From patchwork Fri Jan 22 22:05:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhao X-Patchwork-Id: 12040733 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=-16.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham 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 1D49DC433E0 for ; Fri, 22 Jan 2021 22:06:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B85EB23B06 for ; Fri, 22 Jan 2021 22:06:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B85EB23B06 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E30216B0025; Fri, 22 Jan 2021 17:06:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D16D76B0026; Fri, 22 Jan 2021 17:06:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C2C8B6B0027; Fri, 22 Jan 2021 17:06:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0194.hostedemail.com [216.40.44.194]) by kanga.kvack.org (Postfix) with ESMTP id AB8A36B0025 for ; Fri, 22 Jan 2021 17:06:13 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 78C4D3ABF for ; Fri, 22 Jan 2021 22:06:13 +0000 (UTC) X-FDA: 77734795026.21.cast95_5e08e392756f Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id 498E1181EE429 for ; Fri, 22 Jan 2021 22:06:13 +0000 (UTC) X-HE-Tag: cast95_5e08e392756f X-Filterd-Recvd-Size: 5362 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Fri, 22 Jan 2021 22:06:12 +0000 (UTC) Received: by mail-yb1-f201.google.com with SMTP id y1so6887428ybe.11 for ; Fri, 22 Jan 2021 14:06:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=fAuiFEZ8FCk1cyn9mPE9ipM3xtIpXox+XMx0+fOv6K0=; b=Tj3WeTBV23IF4aMWa4+0shsXAgeLKrQYNXoF2rnMDFzObm0V3stFevul6MDDuv0Vjy Uveak3xihcbz4I0qEFCBUG9x+WRhUSOYvOYJddiGvbmvnYZVRCJEwlN4LSfIwJtsMeMj WYTw2yQ36r6EHIJVvUKyK1o1e8rBlvI8xIi1PdDD61BzAbjGfvrK4hTjit/ZUPj8hBAx AeWHuF3krzcIQD5JGpwgGxNrwXjLtM7re+126AiQbRwzc7qMNaw4EdvwjTXfXUgnJ2e6 NHP6clrqZtkZBATC9zU9jT/XBZqoUQr7+GJXkqYkGh5vo7ahJe1CSzFdfRGGK+he8pus vqFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=fAuiFEZ8FCk1cyn9mPE9ipM3xtIpXox+XMx0+fOv6K0=; b=Wc8zxriVrwXkdKuPVEzZgg1q/NgbnfxXvZfhP/7sZjNfXkFH+MJyQUBwiKs1yOPnv2 M4sy0P5OMrNM8RRAGoGDtnLQxeyQKi+Xnwl1IdgppbJoopO7fGjMxTX++uJ1K37GGvRy R1A5nDj3PgkViX90BuiqhsUMG8ck715HyxUIUKLnrefJ94GrlsHlACz6avTd/uP56OB+ MpZWW03nAiaKteK1uM3ReCBGALRb7FVPfvzUtO4BVdocB/Z82NJ00hutusaLV4iOxqeI lqegTeWcd1NUrv6wdRI4FQeVKo5SS62zVlu3/EqFbU0v/bFtynJFFBlSUNlpMnlfgRga 8hgA== X-Gm-Message-State: AOAM532OkJD45xrDzyJm0yqPGfKGVCo3devOZyqP+4WELALaQL2yyQep +pp7H6z5mmNb1Pl8uaY/DPC2q1Ize20= X-Google-Smtp-Source: ABdhPJzNQu1VwToQATIslnVn1F+DC21pIfxNwXyzzKXRWXw7PukDCkvFCwvjuDiotly+Vtus46FsaQy6rPw= X-Received: from yuzhao.bld.corp.google.com ([2620:15c:183:200:5129:9a91:ef0e:c1a9]) (user=yuzhao job=sendgmr) by 2002:a25:2505:: with SMTP id l5mr9365754ybl.292.1611353172069; Fri, 22 Jan 2021 14:06:12 -0800 (PST) Date: Fri, 22 Jan 2021 15:05:57 -0700 In-Reply-To: <20210122220600.906146-1-yuzhao@google.com> Message-Id: <20210122220600.906146-8-yuzhao@google.com> Mime-Version: 1.0 References: <20210122220600.906146-1-yuzhao@google.com> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog Subject: [PATCH v2 07/10] mm: VM_BUG_ON lru page flags From: Yu Zhao To: Andrew Morton , Hugh Dickins , Alex Shi Cc: Michal Hocko , Johannes Weiner , Vladimir Davydov , Roman Gushchin , Vlastimil Babka , Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yu Zhao 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: Move scattered VM_BUG_ONs to two essential places that cover all lru list additions and deletions. Link: https://lore.kernel.org/linux-mm/20201207220949.830352-8-yuzhao@google.com/ Signed-off-by: Yu Zhao --- include/linux/mm_inline.h | 4 ++++ mm/swap.c | 2 -- mm/vmscan.c | 1 - 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h index ef3fd79222e5..6d907a4dd6ad 100644 --- a/include/linux/mm_inline.h +++ b/include/linux/mm_inline.h @@ -66,6 +66,8 @@ static inline enum lru_list page_lru_base_type(struct page *page) */ static __always_inline void __clear_page_lru_flags(struct page *page) { + VM_BUG_ON_PAGE(!PageLRU(page), page); + __ClearPageLRU(page); /* this shouldn't happen, so leave the flags to bad_page() */ @@ -87,6 +89,8 @@ static __always_inline enum lru_list page_lru(struct page *page) { enum lru_list lru; + VM_BUG_ON_PAGE(PageActive(page) && PageUnevictable(page), page); + if (PageUnevictable(page)) lru = LRU_UNEVICTABLE; else { diff --git a/mm/swap.c b/mm/swap.c index 38900d672051..31b844d4ed94 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -83,7 +83,6 @@ static void __page_cache_release(struct page *page) unsigned long flags; lruvec = lock_page_lruvec_irqsave(page, &flags); - VM_BUG_ON_PAGE(!PageLRU(page), page); del_page_from_lru_list(page, lruvec); __clear_page_lru_flags(page); unlock_page_lruvec_irqrestore(lruvec, flags); @@ -909,7 +908,6 @@ void release_pages(struct page **pages, int nr) if (prev_lruvec != lruvec) lock_batch = 0; - VM_BUG_ON_PAGE(!PageLRU(page), page); del_page_from_lru_list(page, lruvec); __clear_page_lru_flags(page); } diff --git a/mm/vmscan.c b/mm/vmscan.c index 452dd3818aa3..348a90096550 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -4281,7 +4281,6 @@ void check_move_unevictable_pages(struct pagevec *pvec) lruvec = relock_page_lruvec_irq(page, lruvec); if (page_evictable(page) && PageUnevictable(page)) { - VM_BUG_ON_PAGE(PageActive(page), page); del_page_from_lru_list(page, lruvec); ClearPageUnevictable(page); add_page_to_lru_list(page, lruvec);