Message ID | 20231113152222.3495908-3-wangkefeng.wang@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> 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 <rfc822;heyuhang3455@gmail.com> + 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; 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 <wangkefeng.wang@huawei.com> To: Andrew Morton <akpm@linux-foundation.org> CC: <linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>, Matthew Wilcox <willy@infradead.org>, David Hildenbrand <david@redhat.com>, Sidhartha Kumar <sidhartha.kumar@oracle.com>, Kefeng Wang <wangkefeng.wang@huawei.com> 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 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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: <linux-kernel.vger.kernel.org> 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 |
Series |
mm: cleanup and use more folio in page fault
|
|
Commit Message
Kefeng Wang
Nov. 13, 2023, 3:22 p.m. UTC
Use a folio in validate_page_before_insert() to save two compound_head() calls. Reviewed-by: Sidhartha Kumar <sidhartha.kumar@oracle.com> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> --- mm/memory.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
Comments
On Mon, Nov 13, 2023 at 11:22:18PM +0800, Kefeng Wang wrote: > Use a folio in validate_page_before_insert() to save two > compound_head() calls. > Reviewed-by: Vishal Moola (Oracle) <vishal.moola@gmail.com> > Reviewed-by: Sidhartha Kumar <sidhartha.kumar@oracle.com> > Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> > --- > 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; > } > > -- > 2.27.0
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; }