From patchwork Tue Nov 7 13:52:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13448861 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 104B5C4167D for ; Tue, 7 Nov 2023 13:53:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9F2D18D0050; Tue, 7 Nov 2023 08:53:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 97C498D0048; Tue, 7 Nov 2023 08:53:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 86AD18D0050; Tue, 7 Nov 2023 08:53:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 79E768D0048 for ; Tue, 7 Nov 2023 08:53:34 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4154D1402F1 for ; Tue, 7 Nov 2023 13:53:34 +0000 (UTC) X-FDA: 81431300748.04.1D4A5B7 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf26.hostedemail.com (Postfix) with ESMTP id 07BE6140004 for ; Tue, 7 Nov 2023 13:53:31 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699365212; 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=HTwqTJZP/kylVWu0m1TUQf16I6uo3SZHS8jdaln9Ki0=; b=KMtPa5mE/BQoxG926kPKwtDx9kH/MZSmDRWkz9LHl2MjmKkmavr8ZQNiXdXBtpHUVSQFnv DkEm81ViDSxmd7LUP6uWsaMWEG4vYFYVZOTPhsAq61TGtxalQh/meb4YaN7kZSL/4Il4oN WRmEF/M611wDNxXMKCqWUV8C61Spgus= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699365212; a=rsa-sha256; cv=none; b=d9SFTFJpOCWqcPsjP1dxaE1pxP7Yn0SodweH4cBKb+vtPKhKrDzIXi9lW8mugEN58eXwST vUWPtJfbwa/pskdWHZgSS1Bd/NThn0iPdCMysbo4B1scSKwYOdzM8eNYBjiE/eYmIU3Wp0 UMR5j6kkcMP7H52/w58cN7GiqYrld68= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4SPqLK0NQlzMm4V; Tue, 7 Nov 2023 21:48:25 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Tue, 7 Nov 2023 21:52:52 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , Kefeng Wang Subject: [PATCH 2/6] mm: memory: use a folio in validate_page_before_insert() Date: Tue, 7 Nov 2023 21:52:12 +0800 Message-ID: <20231107135216.415926-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231107135216.415926-1-wangkefeng.wang@huawei.com> References: <20231107135216.415926-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 07BE6140004 X-Rspam-User: X-Stat-Signature: u38dwwjcm6juaz7tbhmsadcyyxfae7rz X-Rspamd-Server: rspam01 X-HE-Tag: 1699365211-382384 X-HE-Meta: U2FsdGVkX1+5bkdRBKhhhlpt+WlR3Bhr33WsRnNw9dZV0HihXkwT8DoslphaM2TKB1LWC5UQah1ROfzN5UKF+fDarpwTh2glwBrXHYDVdrNrmRUe9o8hW2/0hn2GbGkuyES4ck+1jYuBOmH860GUvcUjAELPVeOoCvjd54SNnBpyMb4bBF4g3eGNrUWlydlAwJwcLr5LhQSWG2sqHpeIR5QfnivMVgqfbp64TMIHEjAp35/M15uJ/u6d8jhVSX2fLRTvBlOkbHmJ8ZMsGXU4gaE+r+Xt9EYDMB0YIEO7TWp1GGmFj0OcnfqR8UFoZEv4cGt7TXPzDyTE9xvQds1SZ4UrQEgC9HgdaZZLr1XLlCHeBANJ9PJanC0bVbEHF+QnXDSNmmcOXAAbDgCH50mf4++SRT07Ynjaiy+g2fbW0fd3SjbgwO5kJ7X6S1GAEk3EYpZsAE6J9pAZdfLdBdCSADGwGHrAEUv7jOnVrDToTILqa+MUfg97PRek9nQoKqVFAzFM8P4rKObXjUfuLinEMDbUQ39NTBSyiSFsIG2rGhNcoy50doBrV/ddDUpbL8r2TYrSQ0AGwQfMyNjr/8mtc5FPss071y6AmVwQKv6IUjz1g7DYoFX1NWJ9hnYoZ78OjegeiKkpWbgqfaBRQC5qpNaLd0P0r5j8RcekzFJJ2bzuxoCi9SF4duzXYoWtiWjhAqJa3s2CrEh8CbLhHLEXxUXs2jHsXqcrjX6xqGtRy1n0WHIp5tRBYN54ynCVSrzdBoM9zAUF9KP3hykf3VCDgIeRoHyQMs47dteehKGogJRJY0nPltM930B7uS8NLgErR1aqBSK1+18/rHlKSVGTiqnCmBebs7/1oARF2KZcenm29gIteYc+TrrQotC7VL7ITZK53eUgq5V+9oJWr7CyJs2oSCpxs/ATRsAad7ztd/sgiQEJ+aDdtO/JcYVPGXmAg2BZnBDYIMVbrp/XHI7 wLD7ICxw rIrRdeQtcDE1U42new3ihtqCJdSqWNU+tAbD9vDOj6AbDheq+pPups0RjABE/heEKOtTxtxFAwZ2Fg6yccYxWUwWa6bwr6gH+MUbRUsu/lO9C+azT4CfQ8fKfyxzDV4mtEnoCz+NPJ5l8yyHrP7B3a8RZ2PL1DxyjuSsQ8W2J/1T3IdcIvCZybESIlV6EDWGxEZdWhTrF5dBcyyIsZi1RW7/lxQ== 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: Use a folio in validate_page_before_insert() to save two compound_head() calls. Signed-off-by: Kefeng Wang Reviewed-by: Sidhartha Kumar --- mm/memory.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 1f18ed4a5497..b1bff4d245da 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1836,9 +1836,12 @@ pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr, static int validate_page_before_insert(struct page *page) { - if (PageAnon(page) || PageSlab(page) || page_has_type(page)) + struct folio *folio = page_folio(page); + + if (folio_test_anon(folio) || folio_test_slab(folio) || + page_has_type(page)) return -EINVAL; - flush_dcache_page(page); + flush_dcache_folio(folio); return 0; }