From patchwork Sat Nov 18 02:32:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13459822 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 AA0E7C5AD4C for ; Sat, 18 Nov 2023 02:33:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 01D9A6B00F6; Fri, 17 Nov 2023 21:33:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EE8626B0167; Fri, 17 Nov 2023 21:33:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD7406B019A; Fri, 17 Nov 2023 21:33:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id CC5226B00F6 for ; Fri, 17 Nov 2023 21:33:11 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A926640682 for ; Sat, 18 Nov 2023 02:33:11 +0000 (UTC) X-FDA: 81469502982.29.0270C4D Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf29.hostedemail.com (Postfix) with ESMTP id 66A55120003 for ; Sat, 18 Nov 2023 02:33:07 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; spf=pass (imf29.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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=1700274790; a=rsa-sha256; cv=none; b=rK7TaSPmWlYnhoNu4hoz+UVqWddVvx72K/F7dPsutDmhhM8reW+LdWizgNe1040J/8sDr2 njwGlVOjfSZrbTkWyIy228wcQJI848DGtBiQzKp5Sys+E47rJfn0Wig4HK0ks95OigxcBS PaNAPP5Xg9telvM8Romqh7Awo5ozD7E= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; spf=pass (imf29.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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=1700274790; 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=GmYiN9TS0AQydL26WGv49S3BZ4NGySUzvIrM955P+N0=; b=rfxuGAWFNqNoFNHjE4cSLIMZ9kQsho1caW3TZRb6MICGjt8ZacFWDoT0bLBgI9noKCoy9f yXjB9NePnLCf3gsPlYkgTOUSDSvaUW4uNVbSOglXF01yPhp7JgfBbp3xG+GMKW0kZCRIUf Tb4xwIYC5Acgb0CxzU4f0YPuw32zc7s= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SXHqc4BfCzvPrQ; Sat, 18 Nov 2023 10:32:44 +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; Sat, 18 Nov 2023 10:33:03 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , Sidhartha Kumar , Vishal Moola , Kefeng Wang Subject: [PATCH v3 2/5] mm: memory: use a folio in validate_page_before_insert() Date: Sat, 18 Nov 2023 10:32:29 +0800 Message-ID: <20231118023232.1409103-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231118023232.1409103-1-wangkefeng.wang@huawei.com> References: <20231118023232.1409103-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 66A55120003 X-Stat-Signature: jziaqxt18cuydhahwcty1956adyrc8ky X-HE-Tag: 1700274787-581131 X-HE-Meta: U2FsdGVkX1+qjXTvrESXUVERzIwqMw468Yaa0jZxoEDYP+guhq8kntU9i190JMAzmtmXqirwcXA2dag5Howc+R3yJtVYHveBjFzm7ckrjX64s8t5f9uhUPxoXT6NJ3tfl4df8a/ojgM9eKAY8H3mQwAd7kfpkYFJaPzQeRKA6Pg5JqdUh7dMq6R8CszypikGLAMTmKgeo6uLRGqg6Dj3uUwlH1A9jDy+B9/mtsnq2LV/csQKJO+dXAfxXz5T8dJNbME+AGRxOqI4vDP2zDJPksA++VAT2B9MnQvbLWxpcePIpyMQwMKjF8T0X7W4+16wQVKI5bpDXep+NiE1aDB0FRORoK1ESWnnKwrlBR9xhsTSkyAwT5Rx5MvcxQGsK0Rz2VPrVb4y7JLONcvu2pwOtoHS1OqtYD/Aa/wE+W0r80dbDfdHNm1I5VsypDs8shHGZUW3yWC60H2KZPg/XqalQqsfXdy9GKAqBVphxQBfoxFqUC45HHY+o3gXsrBeHMLkd+Kb69Wbm3bEQIfyphTtrnMZ4AwWLAN7KOGQwmI43ZR6SHom2Bm7zkyNfQttwbNM6ALghAYYsmBovvcq7s40daiNIcx8AQioN6D11vhexyK161vqRH5US1bfZQTpalpPvRJ6TOKMk/luLSvYBgalOfs+VK/0Zy45eoi0sx2FN1VK1UqviTDB72e3tIt5XcYuJzkcsC3ZHw7vfttKmLJgzgKlRajkSeFDJaXrsVqjiWLShUH9PEwku9gLi/LK3sIo0N8US65IHyULkt+EbaZ39FBXsbfihfx4Ox6ONx/jALiUAo5WvCzswBK9Txm+n0uX9XwRF+meMSJM0TOgTtfSkdqDNPIaJq8yVGPqpiaJ1oA5tZcG/pD+VYCUgLGu3pN9pAI1Y+NbunVXhNp4PwTPrfVunq+7wW1pdn2lxaBqnXNv9So6aCei7gFVjujCQzIy9Dg50ttd39NGi3uNuLG gsafw1EN 7PbwqBIRJc8ZeaKblOPKQXVrl6WgteD+tLs1J72elQxYqZkEBv20jG7yLJfTmoGXuQkNUqqbM12BrHk0BN/lWlbZs3jVkVk3a45TP+BNPb3OKhLqgAmYZnyid3/dPm1RBZjHOAuok1JkufQ3p/2irwum9BYnaq1UIaT2sTYbi0HJpq7QK4MaPQWMSokLYGXhwK/jEihW94U0I3B9D8d5sn3SGYogSTOB2Zov6KOPyQecffKxXglol8FEt7DSPHC+VvvGJ1YvXY1zvCDK1ZWkPoktZ3VN/8Gx440omxq8iEfOTt60mhzcrcrHZig== 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 --- mm/memory.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 4de9fa7d7073..dffd39c9b3af 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1839,9 +1839,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; }