From patchwork Fri Nov 3 14:01:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 161327 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1088573vqu; Fri, 3 Nov 2023 07:47:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGZxoBMZ2YQpxt/0OAO+sj2Ah4ldk/Hy/gLRGgn9IYzmmGvX38rM+LzgI9e0qu48/rFexUz X-Received: by 2002:a17:90b:fc2:b0:27d:8ad:69f9 with SMTP id gd2-20020a17090b0fc200b0027d08ad69f9mr17978061pjb.2.1699022852965; Fri, 03 Nov 2023 07:47:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699022852; cv=none; d=google.com; s=arc-20160816; b=zmSaDfxN1l+GnmUQdC/YLJ/7WAJeEGAeLPEfU2dO3cXsQFC9AxHOTiEsSVfCFDLtiH TGJrtH7Vq97pk1vJr0kxG8rCF+3poKmwvwPxqlzD22I6jXEnNjGJkYvgKCXMkN/EP9Ib YhBlCVb4lkxFgGk10+hBmTWNplxuLofbfmS6wa9CPysnr2ZjO/8myvspvuq9GJfdh4JZ HsyP5zI0vb/VWtkOz7Ufkj0DQbpXMoMahxVQFqWC7OFnoVYhgecN2TLxviygLgEO92iR nvV27aGhdmu650JvcmJREKT/7pKnQurf3GwGT/vu1qh7pT6IV1fvGA7s8IwsO1XoShzZ ovHQ== 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 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 h5-20020a17090acf0500b0027d82c2b020si1644174pju.88.2023.11.03.07.47.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:47: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 B42BB80747A3; Fri, 3 Nov 2023 07:45:58 -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 S229531AbjKCOpz (ORCPT + 36 others); Fri, 3 Nov 2023 10:45:55 -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 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:45:58 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781554586983826959 X-GMAIL-MSGID: 1781554586983826959 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); /*