From patchwork Mon Nov 13 15:22:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13454136 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 7FCE0C4332F for ; Mon, 13 Nov 2023 15:41:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 010176B01A1; Mon, 13 Nov 2023 10:41:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F02686B0253; Mon, 13 Nov 2023 10:41:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DCB276B0255; Mon, 13 Nov 2023 10:41:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C9C216B01A1 for ; Mon, 13 Nov 2023 10:41:21 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9F92A1CB3BC for ; Mon, 13 Nov 2023 15:41:21 +0000 (UTC) X-FDA: 81453345162.29.A158D85 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf18.hostedemail.com (Postfix) with ESMTP id 128BD1C0027 for ; Mon, 13 Nov 2023 15:41:17 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf18.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699890079; 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=rr/e7Pgw+PsllWM48hvVrGsg9ztVLWWIS7ydQNjBaFM=; b=zv7yu1V8YqZMADUGn3UxcewvGIefnd8C2mLxfMCMLSR4qmcN8XO3iifpCXQG5+0f3zoRgB RhXKuELUTLcWGo5YbDQf+T+RLgq6Xe0TIdYQsqAm6TubTbxDCDHAOWHy1sQVz26Jlu4dUf +tvu5IgirPspD/YTRNcmgr99PTzN680= 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 wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699890079; a=rsa-sha256; cv=none; b=q0TA1NokkE1hDmHPdc134HcMGeqollaaEsT6iHjOmGQQ+SNWpcAJCj+Nj0KqFk7DsuH/e3 DUPNfeaZ4X3GEtrTdtza5TZg2wHk/Ew8nodVRzCLYBHhma4xMqYFcvGSQ5w/s0oc7+jWam 2zMi1oVSNdHjmctDBHB0/RVPIdTjGLM= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4STY4J2R6pz1P88S; Mon, 13 Nov 2023 23:19:12 +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; Mon, 13 Nov 2023 23:22:29 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , Sidhartha Kumar , Kefeng Wang Subject: [PATCH v2 2/6] mm: memory: use a folio in validate_page_before_insert() Date: Mon, 13 Nov 2023 23:22:18 +0800 Message-ID: <20231113152222.3495908-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231113152222.3495908-1-wangkefeng.wang@huawei.com> References: <20231113152222.3495908-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 128BD1C0027 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: w94os63x56m58ky7xf5yihcfgbwbrr7m X-HE-Tag: 1699890077-418722 X-HE-Meta: U2FsdGVkX18f9/1r4tneCWSbRLXZS4C2nzX7fuzMNZGiAfzMJ74t19X87u43cj7lMtz/p+t2QlV1wWKpC1SwYLkHJOPyQaueHBktkm9msrudDLAM54Jp3DGeEIONka+AOCCVyU6zxuOWoSFmXmEQr4dQJ1N156mX9u4FuVnChwTi/KDqzXIrLFVT/J844tBOup9HC6Bh3/g5iLW22jy4eitw8SEJRH+EbxXouWrdS/y69mCNIA4cxzy3E/0IbWpR/gb+n++Ds6hHwUX+npR1FdCEKHfMxVN9UUGAFEnC+TfnRb962utgaMRM14EXULjvF8AXQ9E+HrDNmoRsh4FZojH6m+he9TW/zpFNYEO/qMoK23mN8wn2IokeVJeDvS1sm0DTnFrAOR5oyMhq3GDvYkQThC6Pv+A9IzFis1EHjdouB4OlmzMqUczZH78Nyc9T7poz1k2FVd1HrI9zeTWKxly/ZKtdB1n5MDgxD8OcL9TE5fVpbRy1mUFVMbl+a6ue9FdDl6/6C45MdAkbPBtH+tR5YGEc59QbLhHOJcwI+NyEJ1f9LdWw2aQdlKAN6E+6oHog1NtCjc08UvYJUvxiX1nLEDzjr3xuoXk7SYzK125sxHuZr/YMwQV2aoUhJdaDoFvncL4t+GtpZ7FGhSC742m1BYGM8urKBOWYniPkaOxyGpa4Xn0tTroJ45PQuE5nkVhd7mi4WqMIEfCfNGD62kKHVrjXlrpEQgu6wRRG7mffMbqUR/XUCOVX2aOWsulZOOVDlX23fjcsDAU278V/q4hrhkQ2Ztt9gADyz77E9mGz7EF6dL3IUgKm+sLQX8YyapT0+Lxy4/qezD8OgFCrX2/UmbjxeHlXT7uvD1IeLX0IMvaCvBelKknymhjFL74jcFrfw8C46QInev59d0kVREy2omNr+sSYkQ9bmFo6LhVXnN/iSj17oZLHPvX1dQc+zkppHFGtmyG4IlxFeH3 Zx+9xv8K K86Hs/OgncaenfCLGPw0shceuBDEab8+bsa6uQ2MiNKdxsXWjxj5fL9EhP+JVpXEClKW+/mSxvd4Tg9nkxRVP1zUMY5Oj/1bndsjaoL7wYEbHnzbrS3QT1gpxIbu71H/bQmrsMvzfJkU/MF7PtRjbqBGlM8AA0RjdmZv8HPl5sVioKjrvXX2sKwmiKhjRlmhs+Dnn26T9j+TGejcFhNcplMmWuJyNAf0OncXeKQMY+xA9yP0= 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. Reviewed-by: Sidhartha Kumar Signed-off-by: Kefeng Wang Reviewed-by: Vishal Moola (Oracle) --- mm/memory.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index c32954e16b28..379354b35891 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1841,9 +1841,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; }