Message ID | Y8KuYwE9S3zLsqVl@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp286302wrn; Sat, 14 Jan 2023 05:37:12 -0800 (PST) X-Google-Smtp-Source: AMrXdXv/ucL7Rh87agL0kjaU2bFntEMb6PHZkYVdAcdYIzvQc+t6Gewx2jU4m73eBCd9BXXM8ygz X-Received: by 2002:a17:906:7188:b0:7c1:eb:b2a7 with SMTP id h8-20020a170906718800b007c100ebb2a7mr6146193ejk.13.1673703432590; Sat, 14 Jan 2023 05:37:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673703432; cv=none; d=google.com; s=arc-20160816; b=GVdtJm5bhgGB4Og4WE2qV3oLLjNcxO5x7XiHvkdfr51fBXF2DEYI+wBG3F/t2RGwnZ 8Dn7BMpI0YMqoQG1eldTeirVVr7iwB6Rv2B4LCShRmk7U1Zf6IIMmW5UuuryjG7YHYKr Uua1T5PaaXkw2gsH2s1d3fvROGjlwU5tDyOpEVwFL+q1X5vWfFUxyF6FCDr9kDqJBYfY o4zP0P+2lvqZb1be/0QmvNzTjlsqiQ6zwLRjJSq2F0sh0sDP/jLUWlKVJjn76yM5fIFP mN+RU9HrSV6qtYG9llgAzDwxB3m3K4c4N02+7zEXGIvR3zVtMky1L12pxFAD8GamhLnN nlNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=4AIwVyWl+wCRPMRO7sAJHr4lzR+ieDHcsxhu8Tt+Aa0=; b=MJXUHeEjpE/LPLMVRvN2DNpcP0+pI5yOBRVf3KgpdhLdKrCA3V/mx9mmyk955mu8GI xO3Z6tlPKnNeevYY3vLxZgPHXXHVKTqkAwlA2ysMieKlrfTYRB60Oz6B1kbXXS3JF49y kRjlUiEO7kWiuTs82Nr4qY+lvejVzrrdj+6/E+RO9mycVr83ZdNyzlwjI/uh/XqbnMZ4 l6emI0eSgA3+t9z6/7fodhD+lhi96Y2hopJdFhh1RLJAZUyN0pA5F4/JAiQwc0kBnVQ4 2t9JYmzMUoK9TH8LV9voA2TJZzksFwov1Vx+e7LKC/NjEpSRLJxZHv8Wt77My9Kh/uU4 d4Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mrKXKdj+; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s5-20020a17090699c500b0084ca4bdbc7bsi26153434ejn.799.2023.01.14.05.36.48; Sat, 14 Jan 2023 05:37:12 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mrKXKdj+; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229888AbjANNa2 (ORCPT <rfc822;limurcpp@gmail.com> + 99 others); Sat, 14 Jan 2023 08:30:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229535AbjANNa0 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 14 Jan 2023 08:30:26 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7856B5243 for <linux-kernel@vger.kernel.org>; Sat, 14 Jan 2023 05:30:25 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 35D63B8049B for <linux-kernel@vger.kernel.org>; Sat, 14 Jan 2023 13:30:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02559C433EF; Sat, 14 Jan 2023 13:30:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673703022; bh=cF7w2WUjmCAVcs3N4RrigyXBTZrsAH/r+Y+h/2zIfU4=; h=Date:From:To:Cc:Subject:From; b=mrKXKdj+3eVMbtpQIdnTLPEtzap8aSycMgtqXjM0xlGQqRzfOsh65Iz7b3JZLKvgM BfjtbumvOcatP1JoyrMkwNXItaL87LCJaIGlkdAWqTl6rYvdW9ysn7l25K/Mdhs1fg AuFZ5D7sogO+3BMM3A3/KZZsy5CBzyuMdVwY9bbAOOlfgh5LWYYfp7Wv1A0Njdp0xw gVDRq0Di2DIwV8vYYSOxZSaPe7kwerjVhlWlsNBsfvw0Ht8+PaykuetAVcxLXbYZIL Ue5AGIhB65FmDFLuxGw89jls2Dz4rO1It/zDQ6MyzzZQnDG9fOM0JR9me+SQUJ5uJx xV+kmElfJf5Dw== Date: Sat, 14 Jan 2023 15:30:11 +0200 From: Mike Rapoport <rppt@kernel.org> To: Linus Torvalds <torvalds@linux-foundation.org> Cc: Aaron Thompson <dev@aaront.org>, Mike Rapoport <rppt@kernel.org>, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [GIT PULL] memblock: fix release of deferred pages in memblock_free_late() Message-ID: <Y8KuYwE9S3zLsqVl@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755005250545429825?= X-GMAIL-MSGID: =?utf-8?q?1755005250545429825?= |
Series |
[GIT,PULL] memblock: fix release of deferred pages in memblock_free_late()
|
|
Pull-request
https://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock tags/fixes-2023-01-14Message
Mike Rapoport
Jan. 14, 2023, 1:30 p.m. UTC
Hi Linus, The following changes since commit fa81ab49bbe4e1ce756581c970486de0ddb14309: memblock: Fix doc for memblock_phys_free (2023-01-04 12:31:22 +0200) are available in the Git repository at: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock tags/fixes-2023-01-14 for you to fetch changes up to 115d9d77bb0f9152c60b6e8646369fa7f6167593: mm: Always release pages to the buddy allocator in memblock_free_late(). (2023-01-08 18:49:33 +0200) ---------------------------------------------------------------- memblock: always release pages to the buddy allocator in memblock_free_late() If CONFIG_DEFERRED_STRUCT_PAGE_INIT is enabled, memblock_free_pages() only releases pages to the buddy allocator if they are not in the deferred range. This is correct for free pages (as defined by for_each_free_mem_pfn_range_in_zone()) because free pages in the deferred range will be initialized and released as part of the deferred init process. memblock_free_pages() is called by memblock_free_late(), which is used to free reserved ranges after memblock_free_all() has run. All pages in reserved ranges have been initialized at that point, and accordingly, those pages are not touched by the deferred init process. This means that currently, if the pages that memblock_free_late() intends to release are in the deferred range, they will never be released to the buddy allocator. They will forever be reserved. In addition, memblock_free_pages() calls kmsan_memblock_free_pages(), which is also correct for free pages but is not correct for reserved pages. KMSAN metadata for reserved pages is initialized by kmsan_init_shadow(), which runs shortly before memblock_free_all(). For both of these reasons, memblock_free_pages() should only be called for free pages, and memblock_free_late() should call __free_pages_core() directly instead. One case where this issue can occur in the wild is EFI boot on x86_64. The x86 EFI code reserves all EFI boot services memory ranges via memblock_reserve() and frees them later via memblock_free_late() (efi_reserve_boot_services() and efi_free_boot_services(), respectively). If any of those ranges happens to fall within the deferred init range, the pages will not be released and that memory will be unavailable. For example, on an Amazon EC2 t3.micro VM (1 GB) booting via EFI: v6.2-rc2: Node 0, zone DMA spanned 4095 present 3999 managed 3840 Node 0, zone DMA32 spanned 246652 present 245868 managed 178867 v6.2-rc2 + patch: Node 0, zone DMA spanned 4095 present 3999 managed 3840 Node 0, zone DMA32 spanned 246652 present 245868 managed 222816 # +43,949 pages ---------------------------------------------------------------- Aaron Thompson (1): mm: Always release pages to the buddy allocator in memblock_free_late(). mm/memblock.c | 8 +++++++- tools/testing/memblock/internal.h | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-)
Comments
The pull request you sent on Sat, 14 Jan 2023 15:30:11 +0200:
> https://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock tags/fixes-2023-01-14
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/4f43ade45dc57fc3b4a5cb598a6f4916dcc418ba
Thank you!