From patchwork Thu Jun 4 03:54:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Jordan X-Patchwork-Id: 11586891 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DC8C2913 for ; Thu, 4 Jun 2020 03:55:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9355220756 for ; Thu, 4 Jun 2020 03:55:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="h2Mvt9jh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9355220756 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9542C8000F; Wed, 3 Jun 2020 23:55:03 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 904BA8000E; Wed, 3 Jun 2020 23:55:03 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F2D58000F; Wed, 3 Jun 2020 23:55:03 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 652448000E for ; Wed, 3 Jun 2020 23:55:03 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 24602180AD80F for ; Thu, 4 Jun 2020 03:55:03 +0000 (UTC) X-FDA: 76890163686.25.stew33_8357acb457330 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id 04D301804E3A0 for ; Thu, 4 Jun 2020 03:55:03 +0000 (UTC) X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,daniel.m.jordan@oracle.com,,RULES_HIT:30054:30064:30080,0,RBL:156.151.31.86:@oracle.com:.lbl8.mailshell.net-62.18.0.100 64.10.201.10,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: stew33_8357acb457330 X-Filterd-Recvd-Size: 5553 Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Thu, 4 Jun 2020 03:55:02 +0000 (UTC) Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0543qUMV129253; Thu, 4 Jun 2020 03:54:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=Z6Q9Wq0yQ9bYp+C/bSDjX1Q1JFM5hLt2P2p/aVt1ixU=; b=h2Mvt9jhAjmuJDQf5LnGjf46WdYyN920Yi6mmXKJiQzn0dRY1fnmYxrAfEQ8xvVraODM FCaR3RGaHPuMiNLN3V3UMpILWWXjH+5QkzOod+P0JGhRUX82gnFmmfahYH9Tz4KIvF21 rwwsVmgzGkDO6c0ywQ0iADNxEkSyXwEQOWouXghyNpTwNfWG8ghtrFRFfALjKy1JZuAK YQ4t5CX7k2lLgdPi8kyXpcQQ7GIcX39wJl1bfi4+RIbMFKqwAk1qw2o1nsIqewJNjWPv 2/I2LMkqT/lHdqaBfsff4vriYFWITse67cL/U7YMoc3DaSOnm8Qvg/i/4jCAJJQeQ/Cg hA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 31bewr4eqy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 04 Jun 2020 03:54:51 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0543rTBt168559; Thu, 4 Jun 2020 03:54:51 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 31ej0ysgp8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Jun 2020 03:54:51 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0543snsW032028; Thu, 4 Jun 2020 03:54:49 GMT Received: from localhost.localdomain (/98.229.125.203) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 03 Jun 2020 20:54:48 -0700 From: Daniel Jordan To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Andrew Morton , Andy Lutomirski , Dave Hansen , David Hildenbrand , Michal Hocko , Pavel Tatashin , Peter Zijlstra , Steven Sistare , Daniel Jordan Subject: [PATCH] x86/mm: use max memory block size with unaligned memory end Date: Wed, 3 Jun 2020 23:54:43 -0400 Message-Id: <20200604035443.3267046-1-daniel.m.jordan@oracle.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9641 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006040022 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9641 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 bulkscore=0 phishscore=0 suspectscore=0 impostorscore=0 cotscore=-2147483648 lowpriorityscore=0 mlxscore=0 adultscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006040022 X-Rspamd-Queue-Id: 04D301804E3A0 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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: Some of our servers spend 14 out of the 21 seconds of kernel boot initializing memory block sysfs directories and then creating symlinks between them and the corresponding nodes. The slowness happens because the machines get stuck with the smallest supported memory block size on x86 (128M), which results in 16,288 directories to cover the 2T of installed RAM, and each of these paths does a linear search of the memory blocks for every block id, with atomic ops at each step. Commit 078eb6aa50dc ("x86/mm/memory_hotplug: determine block size based on the end of boot memory") chooses the block size based on alignment with memory end. That addresses hotplug failures in qemu guests, but for bare metal systems whose memory end isn't aligned to the smallest size, it leaves them at 128M. For such systems, use the largest supported size (2G) to minimize overhead on big machines. That saves nearly all of the 14 seconds so the kernel boots 3x faster. There are some simple ways to avoid the linear searches, but for now it makes no difference with a 2G block. Signed-off-by: Daniel Jordan --- arch/x86/mm/init_64.c | 9 +++++++++ 1 file changed, 9 insertions(+) base-commit: 3d77e6a8804abcc0504c904bd6e5cdf3a5cf8162 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index 8b5f73f5e207c..d388127d1b519 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -1390,6 +1390,15 @@ static unsigned long probe_memory_block_size(void) goto done; } + /* + * Memory end isn't aligned to any allowed block size, so default to + * the largest to minimize overhead on large memory systems. + */ + if (!IS_ALIGNED(boot_mem_end, MIN_MEMORY_BLOCK_SIZE)) { + bz = MAX_BLOCK_SIZE; + goto done; + } + /* Find the largest allowed block size that aligns to memory end */ for (bz = MAX_BLOCK_SIZE; bz > MIN_MEMORY_BLOCK_SIZE; bz >>= 1) { if (IS_ALIGNED(boot_mem_end, bz))