From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A625AC43334 for ; Tue, 14 Jun 2022 10:33:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B1E46B00CC; Tue, 14 Jun 2022 06:33:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 161758D023A; Tue, 14 Jun 2022 06:33:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F1D768D0239; Tue, 14 Jun 2022 06:33:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E02C76B00CC for ; Tue, 14 Jun 2022 06:33:16 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id AD59821898 for ; Tue, 14 Jun 2022 10:33:16 +0000 (UTC) X-FDA: 79576479192.08.D63F9CC Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf05.hostedemail.com (Postfix) with ESMTP id 1EE5310008F for ; Tue, 14 Jun 2022 10:33:15 +0000 (UTC) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25E8sSrd016107; Tue, 14 Jun 2022 10:33:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=message-id : date : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding : mime-version; s=corp-2021-07-09; bh=JBlQy+ACEc+6Q3+8VDP9gTM03mBrBWFR07wj5D8Ed7s=; b=lfSgF0pi6nVxp94Ns8DRfqCtnV66spJVsqVSQun//guJ5/OKT3DjNskVMEUvUmaRxp95 ykpm+UIw4EV3A4wume6cwfFZJFm/YVjKuc7sf+PoCfl5uVJXWkfG6726SRN2hkPDeWEV kQbUvRoOuC8hAJ4RYqkh/gv9Wzw6REs+2vQgmeXzicbGimdmbIU0iff6UJDVYULBHzhB semoAQWsXOmuUlGCWbw8VaD/i/abCCYK3yVh6YQvP6hpv0HTJLRehGGCBP5kNT8yKJcX 6gzpawjcVRZfvblZ0pnP1+rGDjDOlpZZEm1OvYw1Tqm8qAQC5R+fxNgE63jmH0BJXEQB gw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gmkktdf4x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 Jun 2022 10:33:10 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 25EAQMGa036168; Tue, 14 Jun 2022 10:33:09 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2176.outbound.protection.outlook.com [104.47.55.176]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3gprbqgfrk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 Jun 2022 10:33:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IaudodZAymnZD/tjHMOiEFis6WdPHNJreqIByZCRTMGwiZ25HCg4Njmvn7ebvO4Trn2pr2oZ1WlDwhMQGkzCKfTqS8ZOovfeV6GXfK6fFfIR92eMtkBAgD9x816HSAVLXRokqk7PNGiGQxMBxNzjakK+fIz81KYGvq0k2iEnArdOtMzzcdR/3CTV/48RHkCUMK925Ui/7kihNzQqn2EcqpZFnM6OxyHm1yVskBgMaz2dhYhhzuU1HFGf5SGk72B470sAo1Mgpnbp7WeIAN3lkvIcklGUWtlpsqLVf5692pNfbo30JbQuBjPTTJeGxBAdlVtkH7UIYvBnDqnPkMoNWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JBlQy+ACEc+6Q3+8VDP9gTM03mBrBWFR07wj5D8Ed7s=; b=dqZvrKM8WszDPsQaKvH7sXI9KYcZCWuYR7QCqrZYdfto2Jb9z1dLHfHbWUwJpVFDlAjDviiRB26O66VGrqCmNpXJ5//ctVUNWJu3yyE0PWuqZyxADlTOPC5589694yo8FYQ2nSWUIDXtvFgUSXa0qQa9l0yG/C7irnotqXMGgYDRS4NDA/NfGaMpfAdvQmM6AUHPnUxV3kJnV9eIkpDgdN/7txVk1ueH8DW4Zw1YwW2xvViPqdjd6Chm73J7B76Rgt0CEnWvbStDOwD++3AqHugpUV/EKxkSrjO/VyWA11PM4KgUogOfau8oszlyXCit+qIRmFfA4po4skYv1SuC+A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JBlQy+ACEc+6Q3+8VDP9gTM03mBrBWFR07wj5D8Ed7s=; b=Zr1i5XeMKsnk6U26x7NxbVu0Q0Ugo2ulSIQ9a2flWgzUniYWgrqusgvGdZdIAjHIqNH5Nfa2UcKyCnrdEELWEztV0COJKkHTmF4hn3J9Z4WhR1u6HhllKTTAA0XiT4NwLe4ihXTasWAed7W9vrTzoV9sqOXCaul6Gu0rNc8tXCo= Received: from BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) by MWHPR10MB1566.namprd10.prod.outlook.com (2603:10b6:300:27::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.16; Tue, 14 Jun 2022 10:33:06 +0000 Received: from BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::b842:a301:806d:231e]) by BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::b842:a301:806d:231e%7]) with mapi id 15.20.5332.022; Tue, 14 Jun 2022 10:33:06 +0000 Message-ID: <17807dce-0894-08b9-d53a-55e3696d6c08@oracle.com> Date: Tue, 14 Jun 2022 11:33:01 +0100 Subject: Re: [PATCH v2] mm/page_alloc: minor clean up for memmap_init_compound() Content-Language: en-US To: Muchun Song , Miaohe Lin Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20220611021352.13529-1-linmiaohe@huawei.com> From: Joao Martins In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P123CA0448.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a9::21) To BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7dffbf19-94d8-4800-bea3-08da4df144da X-MS-TrafficTypeDiagnostic: MWHPR10MB1566:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8/Ukkdgmax6i3Ryn86zXJzWeZRr7MUr20ARJbJhogzSWz1rPWxrbdnl3xgmrX0e+WBS4kp/S2rPi0wmHwU2RqOOfYsmTmunlXUaCkWLzPYey2g4azrlgYA0NwYxSVp1xGFHEWBwi+ldWnbrpKtWHk5YvGGg+/xqq67k1OCZgkVY6v4MKaouWk80Ov8YT8BGfRP64iZR7xu6ahoGo1q5Qc/SuF1L0RNtJz3wrmWRVqUjXa1N/lUy/W00iBpZzOyZMejjpc4tlueyBl29t2ABUk9A/QUtGgtc3eZk2eRz2EsdPc1A5Pgj6+BN9zMJwtPSZVcRsb/Azz/ZdGhdOOId5qBKla5P1CH0l4JX/me7bv286iANdm09dA5cnXUKojlMb6qPkVKnziNEHfdAxheIvogq01zLqVMTltIDZKTOLQgJKE72FFHgWeA+yKYcLz4JtpuLM89U5+kwvFb4v1/xstqx5PivhuvGUBYbe3L8tLwEl1GF6p9W82yxL0NrONVhp1r5TjXDL7V/DuYROjprEn5zAHEmeLt/nlO3wEeI8zEkPnkiAyFs4FP4tjyF0mOjdTi6HY4cW4/Yn1MOOyJrPCiC7c4HG3E8VC2X+TJY1npZbgUqFs9b5CLwbNOF0OUGuWzd+81NFfmMHolt6p8oynnFsNcHuKQm3wQNxiKWh6n3VZ+D99E7LLnIcR7Ff0EcKA2nHWxnn/ao9A7/xZmOMXw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB4835.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(366004)(316002)(36756003)(66946007)(6666004)(6486002)(508600001)(8936002)(110136005)(31686004)(2616005)(4326008)(186003)(53546011)(5660300002)(6512007)(26005)(31696002)(66556008)(8676002)(66476007)(86362001)(6506007)(83380400001)(2906002)(38100700002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?cEVzZERORWVheXc2OFVMYnJ2NDUxc3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L3laREJxTkpOOXBCNFllNFp1cU9YUlpWVXRkMHNkcmVTUzZLc0dibFJu?= =?utf-8?B?eWM2UDR6QTdtZnpxZWZkblFLdWFMcThRWi9BYUlZU2g3dlZQbHBRRkZTVWJI?= =?utf-8?B?ZUJPcURyNTlvc1FqbkNOaGhSVlBqTnRSeTlrdEtTd29pK3AwdTJjRkZZdDYz?= =?utf-8?B?VWhsdUhzVG1CV2Z5bnpwYWg2UktWT2lxb1A4bjZoSzI5Y0hQVnBwdzU2QzJl?= =?utf-8?B?c3ozd3BuLzMyOC8vcjRCOW0veldobEY3L2d1cEp0MjZpVGZPMzdzWHVXMXlU?= =?utf-8?B?TWFQRXIxOTRFRzhDMXRQeXNTOTMwZmlDUWhOUFJyWUNDMURIYXU4Qy9aOXRy?= =?utf-8?B?am1OWHpVZ1NNOFh6bEpTQWF0RFZqZTc1U094RmRvK2hoZmtLckE0RXdybFZ0?= =?utf-8?B?S245SDhVak1VTlZYQVFEZW5ockh1WUFuVFlFaGVucm1jT2xCdngrOHQzblRj?= =?utf-8?B?WGFWQU9BemxhMURxdDczY2xKN2l2V1d6Qkx1OWRES0NKTUhBMW5STkZVQnF1?= =?utf-8?Q?luljmUoNPZhzWb08=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7dffbf19-94d8-4800-bea3-08da4df144da X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB4835.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2022 10:33:06.6645 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7a9fBLhu4PXBZQ0Db6SJamMYIHGGR6BGcLXExhErBulsZAGTW3uDRpb7TVDcAGzItd41hea/7wjHF+Czwdb9YjXUIIM0HFB5Rl3VYBsc2D8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1566 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517,18.0.874 definitions=2022-06-14_02:2022-06-13,2022-06-14 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 spamscore=0 phishscore=0 suspectscore=0 adultscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206140041 X-Proofpoint-GUID: 4W0OiuTZWXw3fnkOlafMztiuMLyAI9dd X-Proofpoint-ORIG-GUID: 4W0OiuTZWXw3fnkOlafMztiuMLyAI9dd ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655202796; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=JBlQy+ACEc+6Q3+8VDP9gTM03mBrBWFR07wj5D8Ed7s=; b=k99rZzUfKxVQX34qtLTsCiU4GSu07pq0F5thwDiCeONoDkQp+YO6RKmIiijhgrMno2GEQk 3ignI63hzHp8gJN+V3mBkWwdODrhFAn0fdgf8NxwtD8VCC+gy13//XbTufdQ8OXQcBdJSN 4V+crzwvAOkibYDVoEXcXceIZmu9jKU= ARC-Authentication-Results: i=2; imf05.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=lfSgF0pi; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Zr1i5XeM; dmarc=pass (policy=none) header.from=oracle.com; spf=none (imf05.hostedemail.com: domain of joao.m.martins@oracle.com has no SPF policy when checking 205.220.165.32) smtp.mailfrom=joao.m.martins@oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1655202796; a=rsa-sha256; cv=pass; b=YN+CRU7Ka5TyvaJkx+PweSnynmsANkYHQyKpXH4/6drdKlRMK40F4IdfBPtwWnhCzgyzu5 hjjMdamKkG8s+PqX4dENRw0tDuco3dp1bMdagfioyal0oP8E/+PFdkh8q0Uf5o48xQ9Eo2 eKYATWCBybGFkSP27XxLdv8UAG71ggM= X-Stat-Signature: ubjtoziskupobst85j4e31u3edmtuawj X-Rspamd-Queue-Id: 1EE5310008F X-Rspam-User: X-Rspamd-Server: rspam05 Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=lfSgF0pi; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Zr1i5XeM; dmarc=pass (policy=none) header.from=oracle.com; spf=none (imf05.hostedemail.com: domain of joao.m.martins@oracle.com has no SPF policy when checking 205.220.165.32) smtp.mailfrom=joao.m.martins@oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") X-HE-Tag: 1655202795-816582 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: [was out the past couple days, hence the late response] On 6/12/22 16:44, Muchun Song wrote: > On Sat, Jun 11, 2022 at 10:13:52AM +0800, Miaohe Lin wrote: >> 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); > > For me it is weird not to put this out of the loop. I saw the reason > is because of the caching suggested by Joao. But I think this is not > a hot path and putting it out of the loop may be more intuitive at least > for me. Maybe this optimization is unnecessary (maybe I am wrong). So, depending on your setup, this might actually sit in the boot path. Yes, it is at bringup/teardown of new memory, so it does not sit in a 'hot path' and struct pages are cold. But it is part of a function that initialiazes a whole DIMM worth of struct pages. And PMEM dimms can be denser than RAM ones IIRC. In my case we usually have 128G PMEM DIMMs in our servers. > And it will be consistent with prep_compound_page() (at least it does > not do the similar optimization) if we drop this optimization. > > Hi Joao, > > I am wondering is it a significant optimization for zone device memory? > I found this code existed from the 1st version you introduced. Not quite. It did not existed in the RFC. As a matter of fact the very first version was totally ignoring anything cache related (i.e. just calling prep_compound_page() in the loop for all struct pages after all the struct pages were inited) until Dan suggested I fix that part because people in the past have spent time optimizing it. > So > I suspect maybe you have some numbers, would you like to share with us? > 128G DIMMs /with struct pages placed in DRAM/ with 2M page size used to take around 250-400ms. Now once you placed the struct pages in PMEM those numbers go up to 4 secs all the way up to 8secs (there's a lot of high variance). Now imagine 12 dimms and those numbers can get in the ranges of 3 - 4.8secs for DRAM-struct-pages, and with PMEM-struct-pages to more than 48secs. Note that initializing as compound pages brought those numbers closer in the middle of the interval given that we need to do more work other than just initializing the raw struct page. With DRAM struct pages with the vmemmap deduplication trick (which is now default used) these got decreased down to 80-110ms per DIMM. But I actually got started with numbers in the order of ~180-190ms per pmem DIMM (ignore cache effects). I should note that I haven't measured /exactly/ the benefit of prep_compound_head() early calling. But the other numbers help gauging the cache effects in this path. Earlier (in v1) I merely expressed a minor concern. /Maybe/ this matters or maybe the cost of prep_compound_head() outweighs the cache-miss avoidance of the succeeding two tail page cache-lines per 2M page. Well, now it's one tail page. Nonetheless, I would expect that this is part of the testing the submitter performs, given that this is not one of those 'no functional change' patches as written in v1 commit message :( Should that be the case, then let's go with v1 as that certainly brings consistency with prep_compound_page().