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: 164544 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1276329vqg; Mon, 13 Nov 2023 07:22:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IFMfQ7SPCFXiYlp5MmGidYs8mnCC4WgtH9KM71AIbwWoo0tNda1mE1ob+DnGnF/LXWXI5U1 X-Received: by 2002:a05:6a20:3d01:b0:159:dccb:8bb4 with SMTP id y1-20020a056a203d0100b00159dccb8bb4mr5416884pzi.23.1699888967280; Mon, 13 Nov 2023 07:22:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699888967; cv=none; d=google.com; s=arc-20160816; b=t+d95M6pRsXXLOYQsVnyx166w/aYnwowwNjiHxQOx1eqc6R2UVX/C568dmCue/rTf6 DfV4DujbL0AB9jqiBzs8djPBcTwXodiFUFNee/JdjUVC1x20mwaXDYPnwvztpwcnRqO4 nIz/vLNjZN0bTZht9t/fsHMmskBxmHXNDOsiIKKHJrdsUv3ywK05VfXbc9A30qCug2s/ Ezn6oDSw8dmpatnKf6btYmIMsSVndOjujUmOGMi8unSW3C2W1bwJq3J0djvhsd8chfMn PF4sIOSOZWUPBcOVp4XQi/4yrffXmeVYH7gWwIS6gTzbGGxUZIjxNxbeP1p5QLv4l9xO Q6Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=rr/e7Pgw+PsllWM48hvVrGsg9ztVLWWIS7ydQNjBaFM=; fh=XlEU0c7GtD3y3c6Cq42Wb1IF2okvB16VXiKMJsE5Xwg=; b=TWnhEeGhE6zi1NAAraIJJHsa26qRcH7f3pX6zy37ywR+JOIvIzPiCZYgO2Zt3zORjx xAMzp7/6+qjssgVaBwMYfbDuplZEhRCi1sSHqE2gNDGRbon1okqAGJqL7eLxUAEpHVj2 A0NCQiUvqkDH/33VbRMl8GeTZ7WVkFQmHvNV+zHErFpXcQK2pUY5UFsP43ymDA54mO2B o3B1sagVHOYheemngIRgcl9I6ie1iGMFPr4Sb/4GGrFKl5600mmro19Bf29w3wRkpzrP OL6SNP0HlQI/WOsmNR2GHXu159ApnD7DHRmAZpJlNzBtmy3BjL/o66NN9Nlg+t9TlgAn UeDA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id o12-20020a170902bccc00b001b84335fb90si5584197pls.286.2023.11.13.07.22.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 07:22:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 984CF802B071; Mon, 13 Nov 2023 07:22:45 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231597AbjKMPWi (ORCPT + 29 others); Mon, 13 Nov 2023 10:22:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231218AbjKMPWe (ORCPT ); Mon, 13 Nov 2023 10:22:34 -0500 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F1EED69 for ; Mon, 13 Nov 2023 07:22:31 -0800 (PST) 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 13 Nov 2023 07:22:45 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782462773814451282 X-GMAIL-MSGID: 1782462773814451282 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; }