From patchwork Mon Feb 24 21:59:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 13989003 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 1A879C021A4 for ; Mon, 24 Feb 2025 21:59:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A39F528000E; Mon, 24 Feb 2025 16:59:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9E98628000D; Mon, 24 Feb 2025 16:59:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 88ABA28000E; Mon, 24 Feb 2025 16:59:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 69BAA28000D for ; Mon, 24 Feb 2025 16:59:26 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 31C864A02F for ; Mon, 24 Feb 2025 21:59:26 +0000 (UTC) X-FDA: 83156205132.08.1AD9640 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf04.hostedemail.com (Postfix) with ESMTP id 7D7E840003 for ; Mon, 24 Feb 2025 21:59:24 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=b98OtZAa; spf=pass (imf04.hostedemail.com: domain of luizcap@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=luizcap@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1740434364; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=vDPhXGlAvceGOH95ueyoy89QBaIskHOY83k25VR+vSA=; b=R2CqRTdkUMP8E2b6W+IgLV3m9mUeQusng1OdvTy3pG1ojsYK5FnZrynIlCLBoDyut8YsxT qepyamoBOh1I1f0jbWqGNgZte6Ld+KHlKngRYR5xM64rNcozor5tyhcHOZhG6Y+309rG4I fLyliAWVzDHv/vpdoppk1/Wga0j4CYo= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=b98OtZAa; spf=pass (imf04.hostedemail.com: domain of luizcap@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=luizcap@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1740434364; a=rsa-sha256; cv=none; b=2Lmdp39EK6AQxjXYhZVpL1UfaIVwjYmU2vyPokpHaXCQSray2iqZ6Iz3Cyt6k7ZnclpXfn ukGuZOm7lSCPqe0VOy59PjW+bunzDiCyW0baIZw7DmHU6mtBFncdhxk+WmjwJD2pWhikPd mP/lOnGOqOGui93Y9xt1l8e1lzmg72U= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1740434363; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=vDPhXGlAvceGOH95ueyoy89QBaIskHOY83k25VR+vSA=; b=b98OtZAac1ngfYsi2BlHuakGd6OWWVjDcf4q+cLlKz4qm15SrHfnownk+h+rftwvE/jJD9 rSssjB82z52V6HtPsT0tSi3UllMGa56pTJ2qREJh2VVxIJZ6T5QbAaa5N5KdcTFPdA/VW8 k2Dn6bTsO1l26YQRFb+u0G5NThfqq5Q= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-435-5iTqhX9aPhi37YB8mR_nIA-1; Mon, 24 Feb 2025 16:59:20 -0500 X-MC-Unique: 5iTqhX9aPhi37YB8mR_nIA-1 X-Mimecast-MFC-AGG-ID: 5iTqhX9aPhi37YB8mR_nIA_1740434358 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 21BAC18EB2C9; Mon, 24 Feb 2025 21:59:18 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.65.50]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A161F180035F; Mon, 24 Feb 2025 21:59:15 +0000 (UTC) From: Luiz Capitulino To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@redhat.com, yuzhao@google.com, pasha.tatashin@soleen.com Cc: akpm@linux-foundation.org, hannes@cmpxchg.org, muchun.song@linux.dev, luizcap@redhat.com Subject: [PATCH v2 0/4] mm: page_ext: Introduce new iteration API Date: Mon, 24 Feb 2025 16:59:04 -0500 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Rspamd-Queue-Id: 7D7E840003 X-Stat-Signature: tbh3bid3rphqt5qw4iq5hsog8rpec5gr X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1740434364-520456 X-HE-Meta: U2FsdGVkX1+KfavhKoUrnqbxc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Q66WpxawVwaDgBXXq84lYFgwqBtcfaPtxko3dgpU5+WyVNvLOY1QnligsszS1cv3awv7xvHvMXbYYTJD6YaSGJqJNLFulNF3k8LYHS/ygfpMaR3QxFtQ71JJyfOOU0HhqOW3tE1QFmzwNlGdmaL3E9ElFwHMA8uLgKzkdQiuoC5twFUMO+UEKqexZROiL78olh8sMEIWOl/558kQjxoshc3cFe0eW/b9qUIUmgCdOOXbc33DlS6+hQ== 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: List-Subscribe: List-Unsubscribe: This series is against v6.14-rc4. The introduction is after the changelog. v1 -> v2 ======== - Drop for_each_page_ext_order() (David) - Make page_ext_iter_begin() and page_ext_iter_next() inline functions (David) - Move loop logic into page_ext_iter_begin() and page_ext_iter_next() (David) RFC -> v1 ========= - Revamped the API by introducing for_each_page_ext macros - Implemented various suggestions from David Hildenbrand, including page_ext lookup optimization - Fixed changelogs Introduction ============ [ Thanks to David Hildenbrand for identifying the root cause of this issue and proving guidance on how to fix it. The new API idea, bugs and misconceptions are all mine though ] Currently, trying to reserve 1G pages with page_owner=on and sparsemem causes a crash. The reproducer is very simple: 1. Build the kernel with CONFIG_SPARSEMEM=y and the table extensions 2. Pass 'default_hugepagesz=1 page_owner=on' in the kernel command-line 3. Reserve one 1G page at run-time, this should crash (see patch 1 for backtrace) [ A crash with page_table_check is also possible, but harder to trigger ] Apparently, starting with commit cf54f310d0d3 ("mm/hugetlb: use __GFP_COMP for gigantic folios") we now pass the full allocation order to page extension clients and the page extension implementation assumes that all PFNs of an allocation range will be stored in the same memory section (which is not true for 1G pages). To fix this, this series introduces a new iteration API for page extension objects. The API checks if the next page extension object can be retrieved from the current section or if it needs to look up for it in another section. Please, find all details in patch 2. Luiz Capitulino (4): mm: page_ext: make lookup_page_ext() public mm: page_ext: add an iteration API for page extensions mm: page_table_check: use new iteration API mm: page_owner: use new iteration API include/linux/page_ext.h | 93 ++++++++++++++++++++++++++++++++++++++++ mm/page_ext.c | 4 +- mm/page_owner.c | 61 +++++++++++++------------- mm/page_table_check.c | 39 ++++++----------- 4 files changed, 136 insertions(+), 61 deletions(-)