Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2896709rdb; Fri, 22 Sep 2023 11:15:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG5ydbyHTWEOGpcMQ0bD9Cr2t0CNrE+QlGcvv8uasfrVDN0HKXt1DUYZHoS0rJrjHJbWQ83 X-Received: by 2002:a05:6a20:7f9e:b0:15d:ccf3:93b4 with SMTP id d30-20020a056a207f9e00b0015dccf393b4mr290522pzj.53.1695406557654; Fri, 22 Sep 2023 11:15:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695406557; cv=none; d=google.com; s=arc-20160816; b=QX9vLGezPMHEaMy/yJb5COjIcT5VPvqMHK4X87r8cCqIyNZ3EjwPTFYjhI39LT9tgQ D4pQHx71y9fPwcUIWWZUTBbBPqTKWkXkKinjah7imwGYVEOVeq7CTOS9kcc7H/vMSuXp 7GgZ/NuElP7tGKjuqtfD7w1X2o/1XNLivJjkX8Kx901qiob7KoLAALYsK+D+np9KWQT4 mRa6l2clQqrzRpBIU/sv21tvUL6xYb7T5Z9Ec5olFutaMthjNlfxiK1ZD5r4jtLfuU4P Yk5t7rFOFsmo+PpNwa9KSWC/r6iXsEF8bPGgz2tMaLw1hdZVKmRgNJvWuBsc2Fpeq18k FDrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=q9o0eyPrPED08Whg4Z5ZxhQWffqyfOzmMnSHg2K2zdA=; fh=d+Qiyl7G1peQZArPyxcfy0cME/+OyalwbXjhQIgEzjM=; b=zLhnYEE7TKJ+TgYL2+eFYi2Vn6bspdk674HoOIybGKc/HyRfrMyh2VEi/S+hD9DuZJ Iclh7FKYvtmsgp/1KqM08bbeFL95n0v54vOWdxIdIMeiA65YudQZ6b72iguNDPbWPly6 7ofFXMvvGCmkWKuviYgaxPMVdbQuToXDnXDAI1x5jGbbD094DSzSMOYwNgYLzmasIPbd jFr7A0N3jfcDX5V67bCg42DvqXzMTBHT51OEPNvLo1ZXdeJrfxabhXPtbb4CV71gXVnP 5WOQrS6F6E3CHmogP+aFKyX62EVWvIUxuyLcTh8fKnAnjVjfdXxbc4irKtFOYcpWrwuU krcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=UpAwaXJT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id r3-20020a63fc43000000b00578b9757214si4229239pgk.163.2023.09.22.11.15.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 11:15:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=UpAwaXJT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id C073883CCA94; Fri, 22 Sep 2023 07:43:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231486AbjIVOn3 (ORCPT + 99 others); Fri, 22 Sep 2023 10:43:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231547AbjIVOn1 (ORCPT ); Fri, 22 Sep 2023 10:43:27 -0400 Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50E2B19C for ; Fri, 22 Sep 2023 07:43:21 -0700 (PDT) Received: by mail-qt1-x835.google.com with SMTP id d75a77b69052e-4142ca41b89so14308641cf.0 for ; Fri, 22 Sep 2023 07:43:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1695393800; x=1695998600; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=q9o0eyPrPED08Whg4Z5ZxhQWffqyfOzmMnSHg2K2zdA=; b=UpAwaXJT3I6vbqIg2skPxeCDHNTg0PmzslN/9+KecqqnVGXaWVja/gGBo3WYPuufp6 Q8ov6v/MgRAFoaH+6VwQtbT06snzR2mOfWiCFNyE/qfoUXxOg84CCJc+HSgA3h69RtIr AvuGgvSGCaQXvhf6qLt+WsoeA7we2plSkAJrXY6XPs8KCrn+iFpkkv0P7MhoPLYO8XaB c2cv6SZvphukvL4Bh+jX0AdQl9HAT7dO+/oPSsRewZMIHK+vIbluVMVEDgnbjSi5DW2Q Gv79cAZO91p9hQHOzDqRTeWXSqrZy7VPQpAv8XqThmtjTCxe7Bl1G/zqZYt1d6lEUV3T iJzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695393800; x=1695998600; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q9o0eyPrPED08Whg4Z5ZxhQWffqyfOzmMnSHg2K2zdA=; b=hL5dJluSK/1izOB0s978HMAGrna9qtZJE0n0oQBFFInhQMHCXgyL7GRWiVvILzhqoI IA7Q8xUd5PjQJJNhNIpZaYWnUVkflv0anrWfJOY5AwUIKDzEmn8o1z8Z6fIn0Ue4zD0c xFpdw5123vj1zJL4GMVRZB2x+wURZKel4FBgvCx79Fjp38HXtEkE4gJ6LNc/ePvbqyie bfnSgASkI95ZfRexWulNkKV7CZjWKwLe7a6Qkh4cBDArEQO25nsQtA2MulSZEPPFjFEw qR3GLVHTdX1gN0Z8rpxIyWOFuZho7jSUJQRL5r5ZzOUWpfkMz4vodwaMrEpLXgxfKKsw 5prw== X-Gm-Message-State: AOJu0YyphLPjG+5aWKLOCGusnB5Ru25f35W9jPkr5ZwPwnWiWEymwC/p H1D2YJGntftWk5dWTDGsgyPTU+jFadkUXQ7iUd4hpg== X-Received: by 2002:ac8:5a16:0:b0:40f:ef6d:1a31 with SMTP id n22-20020ac85a16000000b0040fef6d1a31mr10433299qta.13.1695393800409; Fri, 22 Sep 2023 07:43:20 -0700 (PDT) MIME-Version: 1.0 References: <20230906112605.2286994-1-usama.arif@bytedance.com> In-Reply-To: <20230906112605.2286994-1-usama.arif@bytedance.com> From: Pasha Tatashin Date: Fri, 22 Sep 2023 10:42:44 -0400 Message-ID: Subject: Re: [v4 0/4] mm: hugetlb: Skip initialization of gigantic tail struct pages if freed by HVO To: Usama Arif Cc: linux-mm@kvack.org, muchun.song@linux.dev, mike.kravetz@oracle.com, rppt@kernel.org, linux-kernel@vger.kernel.org, songmuchun@bytedance.com, fam.zheng@bytedance.com, liangma@liangbit.com, punit.agrawal@bytedance.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.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 (morse.vger.email [0.0.0.0]); Fri, 22 Sep 2023 07:43:29 -0700 (PDT) On Wed, Sep 6, 2023 at 7:26=E2=80=AFAM Usama Arif wrote: > > This series moves the boot time initialization of tail struct pages of a > gigantic page to later on in the boot. Only the > HUGETLB_VMEMMAP_RESERVE_SIZE / sizeof(struct page) - 1 tail struct pages > are initialized at the start. If HVO is successful, then no more tail str= uct > pages need to be initialized. For a 1G hugepage, this series avoid > initialization of 262144 - 63 =3D 262081 struct pages per hugepage. > > When tested on a 512G system (which can allocate max 500 1G hugepages), t= he > kexec-boot time with HVO and DEFERRED_STRUCT_PAGE_INIT enabled without th= is > patchseries to running init is 3.9 seconds. With this patch it is 1.2 sec= onds. > This represents an approximately 70% reduction in boot time and will > significantly reduce server downtime when using a large number of > gigantic pages. My use case is different, but this patch series benefits it. I have a virtual machines with a large number of hugetlb pages. The RSS size of the VM after boot is much smaller with this series: Before: 9G After: 600M The VM has 500 1G pages, and 512G total RAM. I would add this to the description, that this series can help reduce the VM overhead and boot performance for those who are using hugetlb pages in the VMs. Also, DEFERRED_STRUCT_PAGE_INIT is a requirement for this series to work, and should be added into documentation. Pasha > Thanks, > Usama > > [v3->v4]: > - rebase ontop of patch "hugetlb: set hugetlb page flag before optimizing= vmemmap". > - freeze head struct page ref count. > - Change order of operations to initialize head struct page -> initialize > the necessary tail struct pages -> attempt HVO -> initialize the rest of = the > tail struct pages if HVO fails. > - (Mike Rapoport and Muchun Song) remove "_vmemmap" suffix from memblock = reserve > noinit flags anf functions. > > [v2->v3]: > - (Muchun Song) skip prep of struct pages backing gigantic hugepages > at boot time only. > - (Muchun Song) move initialization of tail struct pages to after > HVO is attempted. > > [v1->v2]: > - (Mike Rapoport) Code quality improvements (function names, arguments, > comments). > > [RFC->v1]: > - (Mike Rapoport) Change from passing hugepage_size in > memblock_alloc_try_nid_raw for skipping struct page initialization to > using MEMBLOCK_RSRV_NOINIT flag > > Usama Arif (4): > mm: hugetlb_vmemmap: Use nid of the head page to reallocate it > memblock: pass memblock_type to memblock_setclr_flag > memblock: introduce MEMBLOCK_RSRV_NOINIT flag > mm: hugetlb: Skip initialization of gigantic tail struct pages if > freed by HVO > > include/linux/memblock.h | 9 ++++++ > mm/hugetlb.c | 61 ++++++++++++++++++++++++++++++++++------ > mm/hugetlb_vmemmap.c | 4 +-- > mm/hugetlb_vmemmap.h | 9 +++--- > mm/internal.h | 3 ++ > mm/memblock.c | 48 ++++++++++++++++++++++--------- > mm/mm_init.c | 2 +- > 7 files changed, 107 insertions(+), 29 deletions(-) > > -- > 2.25.1 > >