Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp45505iol; Fri, 10 Jun 2022 20:59:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYwpzOmUO6pI4+UyeIXl1fDuRGWTW722hdSj45SeKxms+uvg4cEPYL0q9IzlYXpe2bYu6l X-Received: by 2002:a05:6a00:1a08:b0:510:a1db:1a91 with SMTP id g8-20020a056a001a0800b00510a1db1a91mr49123170pfv.69.1654919947690; Fri, 10 Jun 2022 20:59:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654919947; cv=none; d=google.com; s=arc-20160816; b=nqjPZ1OjnP3dLQn0Bcw0sbNrd/poDmC1UxV0ylKbBjkbbgp4U65spHn1l51DLxT531 QZYknnvJHxtHL9bDb4o5qR2mXvSa27VJxxmT2NVPSB/SxjhnnskVrxhplk0uoDwL6Ice j0LOQdGC4ZAH05vUGZRg2rgbIZCxKbd1U+JGZ4vZJ+BA3XDYwpJazWedYfN6U2ykTBEU b6Svc77r7I8cELJMvKLStA4WdsvcXPhhMMj6kUesyz2NPT6IxtbHFaYpENTmWydRzbKT SNiCxB54k30TXlC+BM5JfFWo+I7v5Fra+/Tfc3c/u+hd/Dbl0A+Ko49GofPuZZXO6nJM bAVA== 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 :message-id:date:subject:cc:to:from; bh=SMNlBnxMaOrji6qJDW++SzcVZBhf2jC4zqdPqgbWYTs=; b=n4mT0uNHgAhFdLv4/b+j+fWfaVXmI3l6KP3zY+ieAoDYbP7ReLqNfOn4rIbEqsze2Q UZsByCMJ8JUviDXbRg4yWQrenfRSJiWg4kQ4IONqDj9GC+ohkY6QLcYdlCPA9RMIPcoc GxKgZq/6/6YxzekZZCFVE3+8Z3RE4vpa366fpac8OAlC3Z7d3QdsODwiycnaJVt6nGoa BdRIuT4+vF7gVC1N5mXywlk+XcmEJIEjMxX1aj3U4EzytF4Yl/zRHhMo8pmHvvAT4pxj wqvKMsNyHHG6fE0pdRbxXZDw2fEBZb1DjlnKnMJJ9NT5nTVti+eBgr3Ll5rcvUWEh88n g2KQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o9-20020a056a0015c900b0051b98c3d62asi810507pfu.233.2022.06.10.20.58.28; Fri, 10 Jun 2022 20:59:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346797AbiFKCOA (ORCPT + 99 others); Fri, 10 Jun 2022 22:14:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229693AbiFKCN7 (ORCPT ); Fri, 10 Jun 2022 22:13:59 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 154A7240A9 for ; Fri, 10 Jun 2022 19:13:58 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LKhBT220kzRhrQ; Sat, 11 Jun 2022 10:10:41 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sat, 11 Jun 2022 10:13:49 +0800 From: Miaohe Lin To: CC: , , , Subject: [PATCH v2] mm/page_alloc: minor clean up for memmap_init_compound() Date: Sat, 11 Jun 2022 10:13:52 +0800 Message-ID: <20220611021352.13529-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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 Since commit 5232c63f46fd ("mm: Make compound_pincount always available"), compound_pincount_ptr is stored at first tail page now. So we should call prep_compound_head() after the first tail page is initialized to take advantage of the likelihood of that tail struct page being cached given that we will read them right after in prep_compound_head(). Signed-off-by: Miaohe Lin Cc: Joao Martins --- v2: Don't move prep_compound_head() outside loop per Joao. --- mm/page_alloc.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 4c7d99ee58b4..048df5d78add 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6771,13 +6771,18 @@ static void __ref memmap_init_compound(struct page *head, set_page_count(page, 0); /* - * The first tail page stores compound_mapcount_ptr() and - * compound_order() and the second tail page stores - * compound_pincount_ptr(). Call prep_compound_head() after - * the first and second tail pages have been initialized to - * not have the data overwritten. + * The first tail page stores compound_mapcount_ptr(), + * compound_order() and compound_pincount_ptr(). Call + * prep_compound_head() after the first tail page have + * been initialized to not have the data overwritten. + * + * Note the idea to make this right after we initialize + * the offending tail pages is trying to take advantage + * of the likelihood of those tail struct pages being + * cached given that we will read them right after in + * prep_compound_head(). */ - if (pfn == head_pfn + 2) + if (unlikely(pfn == head_pfn + 1)) prep_compound_head(head, order); } } -- 2.23.0