Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp503224rdf; Fri, 3 Nov 2023 07:04:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEnSQvcd6soKd95mBeh77oOuMATRHR4imO4ENPEEKTl8yXwRfgVRA+LfeZKSRO7qI9EPrXB X-Received: by 2002:a05:6870:312:b0:1e9:b025:cf88 with SMTP id m18-20020a056870031200b001e9b025cf88mr28729500oaf.36.1699020272427; Fri, 03 Nov 2023 07:04:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699020272; cv=none; d=google.com; s=arc-20160816; b=t588/jQvPuRbL0cUzWV/5t6vaMUMnRpXpoWoCz+5swZLv44Zg8w4KL7VaGc9b29jk3 8XjFJJfkVop0mkJ/tmu5VFxoJ8riEJq7VilxGUWuerWlzCMIY1kQvA9LJpyqEQToriVo O8Ku33HYsygJ6Y+gQF5+plAuhEUKivvvbktPYj/kA0JaYRhrqZvZC8fwXg/o3HjFmHML NoDGR5BWuobk28ZyQayAi3nGIxEg9CqOfgUdu3Ku5Ork+9lx2RW5GcBcYO6SeafTNIHc OqzBWKbg0rdHyHIl7PtwWOVEuNR70LcKFKtJSLEIE6QygPl5lDLc92Qebx4TjB9zSjb0 GBwA== 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=MdhMIc9GunfmcgvY7/8IJnElK+TVJK6hHFkN45VneUA=; fh=kUj/5waaepfljbNx30rj2BALdV0u/mUCTaFWThlgquQ=; b=h6Z7jHjPczcGr2pGR8Ijx7zF5d0679+zqk9cbf5sBQF7RT0B/WOzC67WdOvq5I5n/N hgMwgEcCcaRKvVknUYvyHX4s5WbA18NPgiPTr63DJ0uMNh24WnK+90iWAPrJzGx543p0 e4MQE7f0H4fWCGsT3ssQiQ4ZTrmGBqOAv3i8e0YoBU+o5LzasZ3Xjw8eMc7vqAnEragl Cc+ENdcWe52vso8HinoW6DENjM2J+dbJQc7UpXFB1WPjNZbiHCqrpJ6kGjTHmbTNwFIV 6u4cVbT91qhR2xoh05HMtMf+H3foyu44qOLARhZo10owN0SYBwHOFhzpp33ih7Q9UBzP gzcg== 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 Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id n1-20020a056870240100b001efcb64d109si690941oap.139.2023.11.03.07.04.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:04:32 -0700 (PDT) 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 0F84B82B6F60; Fri, 3 Nov 2023 07:04:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377907AbjKCOEO (ORCPT + 99 others); Fri, 3 Nov 2023 10:04:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377848AbjKCOEC (ORCPT ); Fri, 3 Nov 2023 10:04:02 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EEE8D4D; Fri, 3 Nov 2023 07:03:55 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpQ12P0z1P7pT; Fri, 3 Nov 2023 22:00:46 +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; Fri, 3 Nov 2023 22:03:48 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 13/18] mm: memory: use a folio in insert_page_into_pte_locked() Date: Fri, 3 Nov 2023 22:01:14 +0800 Message-ID: <20231103140119.2306578-14-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-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: dggems706-chm.china.huawei.com (10.3.19.183) 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]); Fri, 03 Nov 2023 07:04:30 -0700 (PDT) Use mm_counter_file_folio() to save one compound_head() call in insert_page_into_pte_locked(). 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 2d90da70a1c8..584fe9a550b9 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1845,11 +1845,14 @@ static int validate_page_before_insert(struct page *page) static int insert_page_into_pte_locked(struct vm_area_struct *vma, pte_t *pte, unsigned long addr, struct page *page, pgprot_t prot) { + struct folio *folio; + if (!pte_none(ptep_get(pte))) return -EBUSY; + folio = page_folio(page); /* Ok, finally just insert the thing.. */ - get_page(page); - inc_mm_counter(vma->vm_mm, mm_counter_file(page)); + folio_get(folio); + inc_mm_counter(vma->vm_mm, mm_counter_file_folio(folio)); page_add_file_rmap(page, vma, false); set_pte_at(vma->vm_mm, addr, pte, mk_pte(page, prot)); return 0; -- 2.27.0