Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp532825rdf; Fri, 3 Nov 2023 07:46:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFvWvGPEFfJ8k02K+JE8kDVdrEIO2RYjZ+0tR/7nstxJ3+9zg9YSPlSRZoSAjs8GHx2wrhu X-Received: by 2002:a17:90a:1a0b:b0:280:1022:f00e with SMTP id 11-20020a17090a1a0b00b002801022f00emr16495226pjk.29.1699022802166; Fri, 03 Nov 2023 07:46:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699022802; cv=none; d=google.com; s=arc-20160816; b=DuqtXHHKTHo89o9iyoS9izHwiuqGDrdo6jyM4oqpQlcrX3ow4tTrLgvCB9e7miaXkI Qy7qejCpM8GMeHC/W//3AJQ16NzvZ3FzdKpu2w6YcMGJhF0bbv79C4YfcnLFSqPDA3dr upejvHFsz/Or4HdPvZVlkgI6zUP2AC6ytiAlbOXLCm+WazsReUqsfqfg0xZiK7r28Wyl 0P9bVnL/sAk4+QH2PPTpdZCCSGmL5Sq5c/Uc5vdHib2QUGj4LO0fhcpSxyVjQjTndbci SPkHJ4Ys5Blv+TqEKK1WLk5V66zMHMl5l6ed+fi0d2GBgo+oB5nW5vBgh4X+tRx8divs 0N6w== 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=ylqQuVj5ksYS6g4LV1U9DLXWq/46sIERK97vnxuNUQw=; fh=kUj/5waaepfljbNx30rj2BALdV0u/mUCTaFWThlgquQ=; b=x0JLzyEiHldHYIQO96OzNrgx1ZgVFtchj7pfC75nEBiXBGajcHbYraUuUWPNyRBjur s1zo0pmmLKmhsM+x4TvcJjOI5wAZ4vboCRaOpHlL7dqk7NLNrK5zCU/uwSzUEX75eSnS GzDBbixrA32X3msn5lEd1mRUtqyGnuwJ+Md1EsBTQmkTuk3XbTV6sgYJHPORFBbC+qtM JlyeDDT0ZUP0Mq77S2YqNqm5w8Et1wt7iz+NRXU9Twm048dM7xYtLSn1TlyZPHF5SM8l 635gFeLAYeNGjbX+hneL9IkUSjR7NRxYAhK2+ilrSFYeXRGEKQFIJnZr5MMtsOg4nIhv 1RDA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id o17-20020a17090ac71100b00262f937bf93si1634252pjt.77.2023.11.03.07.46.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:46:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 553938303A1D; Fri, 3 Nov 2023 07:46:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229490AbjKCOpy (ORCPT + 99 others); Fri, 3 Nov 2023 10:45:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377812AbjKCODz (ORCPT ); Fri, 3 Nov 2023 10:03:55 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45563D60; Fri, 3 Nov 2023 07:03:51 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpP5yQNz1P7pR; Fri, 3 Nov 2023 22:00:45 +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:46 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 09/18] mm: memory: use a folio in do_set_pmd() Date: Fri, 3 Nov 2023 22:01:10 +0800 Message-ID: <20231103140119.2306578-10-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=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email 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 (groat.vger.email [0.0.0.0]); Fri, 03 Nov 2023 07:46:39 -0700 (PDT) Use a folio in do_set_pmd(), which save one compound_head() call. Signed-off-by: Kefeng Wang --- mm/memory.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 1f18ed4a5497..09009094a5f2 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4313,12 +4313,13 @@ vm_fault_t do_set_pmd(struct vm_fault *vmf, struct page *page) unsigned long haddr = vmf->address & HPAGE_PMD_MASK; pmd_t entry; vm_fault_t ret = VM_FAULT_FALLBACK; + struct folio *folio; if (!transhuge_vma_suitable(vma, haddr)) return ret; - page = compound_head(page); - if (compound_order(page) != HPAGE_PMD_ORDER) + folio = page_folio(page); + if (folio_order(folio) != HPAGE_PMD_ORDER) return ret; /* @@ -4350,7 +4351,7 @@ vm_fault_t do_set_pmd(struct vm_fault *vmf, struct page *page) if (write) entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma); - add_mm_counter(vma->vm_mm, mm_counter_file(page), HPAGE_PMD_NR); + add_mm_counter(vma->vm_mm, mm_counter_file_folio(folio), HPAGE_PMD_NR); page_add_file_rmap(page, vma, true); /* -- 2.27.0