From patchwork Wed Sep 14 03:37:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhaoyang.huang" X-Patchwork-Id: 12975548 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 C3F38ECAAD8 for ; Wed, 14 Sep 2022 03:37:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C2FAF6B0071; Tue, 13 Sep 2022 23:37:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BDE908D0002; Tue, 13 Sep 2022 23:37:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA72C8D0001; Tue, 13 Sep 2022 23:37:57 -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 9875D6B0071 for ; Tue, 13 Sep 2022 23:37:57 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 6AC35AB1F8 for ; Wed, 14 Sep 2022 03:37:57 +0000 (UTC) X-FDA: 79909282194.13.7F1A15A Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) by imf10.hostedemail.com (Postfix) with ESMTP id 3925BC0085 for ; Wed, 14 Sep 2022 03:37:55 +0000 (UTC) Received: from SHSend.spreadtrum.com (bjmbx01.spreadtrum.com [10.0.64.7]) by SHSQR01.spreadtrum.com with ESMTPS id 28E3bKew069060 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NO); Wed, 14 Sep 2022 11:37:20 +0800 (CST) (envelope-from zhaoyang.huang@unisoc.com) Received: from bj03382pcu.spreadtrum.com (10.0.74.65) by BJMBX01.spreadtrum.com (10.0.64.7) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Wed, 14 Sep 2022 11:37:20 +0800 From: "zhaoyang.huang" To: Andrew Morton , Catalin Marinas , Matthew Wilcox , Zhaoyang Huang , , , Subject: [PATCH 1/2] mm: fix logic error of page_expected_state Date: Wed, 14 Sep 2022 11:37:00 +0800 Message-ID: <1663126621-26926-1-git-send-email-zhaoyang.huang@unisoc.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.0.74.65] X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX01.spreadtrum.com (10.0.64.7) X-MAIL: SHSQR01.spreadtrum.com 28E3bKew069060 ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of zhaoyang.huang@unisoc.com designates 222.66.158.135 as permitted sender) smtp.mailfrom=zhaoyang.huang@unisoc.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663126677; a=rsa-sha256; cv=none; b=MfKmJtk41UK43gBLHxiAwlLO/0Ue6dK7t9mp7r5PvqZuFlS6130bjLQTRhB9Ot+F1A7u9M CEd3UQ/ftn19OSL8zHkiiGpGnxnMfGUcfh8QX4+WzclC2ELLncXp9C9njM/YU3MdmONZuV FiZhXG69Mkl688+vGJ2JQwYdYnFSkL4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663126677; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references; bh=iR19rd3RLT6GzH/NzASvzOaIDIlW05DjT3u/v+nzIS8=; b=fB5r01UDE3tUm3Bj1ccar7FM1ahlUvQiMB18igxurA6KDuwMcKk9z0K3QayDmyFPkC+UEE MLIWaXFi3kt2S7idKXAGJ0zcG6UiVxfa79VaRtXcEr5qqg0D4InGY38mMLvbfAFNN3a1n5 Emvxrj2pn5ZGbOqhKrpXG97mmsYjwUY= X-Rspam-User: X-Stat-Signature: y8ckjywi9gyk9u1b9bmit1bu7gjoc8hb X-Rspamd-Queue-Id: 3925BC0085 X-Rspamd-Server: rspam05 Authentication-Results: imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of zhaoyang.huang@unisoc.com designates 222.66.158.135 as permitted sender) smtp.mailfrom=zhaoyang.huang@unisoc.com; dmarc=none X-HE-Tag: 1663126675-323333 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: Zhaoyang Huang The page with special page type will be deemed as bad page wrongly since type share the same address with mapcount. Signed-off-by: Zhaoyang Huang --- include/linux/page-flags.h | 4 ++-- mm/page_alloc.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index e66f7aa..5d3274b 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -946,9 +946,9 @@ static inline bool is_page_hwpoison(struct page *page) #define PageType(page, flag) \ ((page->page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE) -static inline int page_has_type(struct page *page) +static inline bool page_has_type(struct page *page) { - return (int)page->page_type < PAGE_MAPCOUNT_RESERVE; + return page->page_type < PAGE_MAPCOUNT_RESERVE; } #define PAGE_TYPE_OPS(uname, lname) \ diff --git a/mm/page_alloc.c b/mm/page_alloc.c index e008a3d..3714680 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1164,7 +1164,7 @@ int split_free_page(struct page *free_page, static inline bool page_expected_state(struct page *page, unsigned long check_flags) { - if (unlikely(atomic_read(&page->_mapcount) != -1)) + if (unlikely(!page_has_type(page) && atomic_read(&page->_mapcount) != -1)) return false; if (unlikely((unsigned long)page->mapping |