From patchwork Wed Feb 19 02:17:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 13981427 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 9C2D1C021AA for ; Wed, 19 Feb 2025 02:18:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 188716B00A3; Tue, 18 Feb 2025 21:18:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 139356B00A4; Tue, 18 Feb 2025 21:18:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F420B2801CA; Tue, 18 Feb 2025 21:18:21 -0500 (EST) 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 D77916B00A3 for ; Tue, 18 Feb 2025 21:18:21 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 76022140AAD for ; Wed, 19 Feb 2025 02:18:21 +0000 (UTC) X-FDA: 83135084802.23.7B449CE Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf10.hostedemail.com (Postfix) with ESMTP id CBA15C0006 for ; Wed, 19 Feb 2025 02:18:19 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="e/B8l2iX"; spf=pass (imf10.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=1739931499; 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=I/mn+nVqK2FRLw7VBAQJ/H349Ch26E3Rtf6ayDMSoXY=; b=pIVbbR6HDOY/B7ufmtsqrbL7zAcXtPUT+NOI6+JNZ3fl+ki0fG1azHIKf+wynFZH9Sj8Gs AZQj0iPUUh9bbEXw5zNrN6j6t2EqZCBjfyaBbsEsKZ5wE8fqApv+ATWlZzcriNe+AZhLTB Eq+TMQWeXcI4L9clJbZ23SMYhKkIYIk= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="e/B8l2iX"; spf=pass (imf10.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=1739931499; a=rsa-sha256; cv=none; b=5xvfVnsY5PyavSSsD2C8yfDCUewTukrxy0XZ2nPY6mMm8P+n6H3xfChbAPwUL5R9RAK99n wg3WyfeyyZ2xdNbEJp/BtuquBHycabOWqZ+HrSiES2hK1phwkgLVkH8DB2qTFM+aHs2GZK fC2epZOiUPdPrrB6TMbxR/ihvs9vZDQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739931499; 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=I/mn+nVqK2FRLw7VBAQJ/H349Ch26E3Rtf6ayDMSoXY=; b=e/B8l2iXMcyrw9a7lupBl6TdfLyIpCBOU2ZlRKfNMmI2asqy2x9aNOGoAvaSSJJOuzH7iL 9SvKPTezmTmQ2UXqRqMelDhYHXn8pWyvU+TMufKOJMAe8HMftGhSqDog9rhtJZO+dgPOmG AYjCCT/v92y6xJregGnV4JMQQxArvuI= Received: from mx-prod-mc-01.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-385-cD9dy8IXPDaf652OcGdbqg-1; Tue, 18 Feb 2025 21:18:14 -0500 X-MC-Unique: cD9dy8IXPDaf652OcGdbqg-1 X-Mimecast-MFC-AGG-ID: cD9dy8IXPDaf652OcGdbqg_1739931493 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 959811975AFC; Wed, 19 Feb 2025 02:18:12 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.65.50]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9D6D01956094; Wed, 19 Feb 2025 02:18:09 +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 0/4] mm: page_ext: Introduce new iteration API Date: Tue, 18 Feb 2025 21:17:46 -0500 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspam-User: X-Stat-Signature: 7siyc5gsoho7tcz5szxj35jhz8qf7ciu X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: CBA15C0006 X-HE-Tag: 1739931499-693925 X-HE-Meta: U2Fs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fMvGxGf7nS82T48+y3WY/G5e0Aa5Y7npUvBkg7b/mkNsEEqpa7+k30XqOLCl46OxaV6EvEwPy2cjeOOeAOApUpqYzLvAUMgtpP3crGDoaLCB9hk8QOnGI+ydphdKGAzxJem+agU88lNR7Ewwv35n1hWyFHC+PHs6jmBlILGl9x/4RZ6AHLYzYynsFHUgXpQneUTtgMKQBj74HcvcHMsLhfdlGu0I8lfGcVbVJf77BZCsD2QMD0kleqA== 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: Hi, [ 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. All details in patch 1. Also, this series is against Linus tree commit 2408a807bfc3f738850ef5ad5e3fd59d66168996 . 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 Luiz Capitulino (4): 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 mm: page_ext: make page_ext_next() private to page_ext include/linux/page_ext.h | 67 +++++++++++++++++++++++++++++++++++++--- mm/page_ext.c | 48 ++++++++++++++++++++++++++++ mm/page_owner.c | 61 +++++++++++++++++------------------- mm/page_table_check.c | 39 +++++++---------------- 4 files changed, 152 insertions(+), 63 deletions(-)