From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C6D12D7DF2 for ; Sat, 21 Mar 2026 14:21:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774102894; cv=none; b=Tjauv+1t4w0hGzvxkQZjs5E2ltuJ7z7LxtwywJfK7swrRLyJbisKT42AFjDCA4mC8EgAv9XYOiJCXY0Tfy5/1rpZOU1rh9U9rQIn2dr+Kb4NH4KdXQZoe6GHgXpy0wh51gPL6HsMcIuNYnVIa/CgWmUdLU72On2hwiBennfz+Xo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774102894; c=relaxed/simple; bh=PQ5/BK7Vy3rri50nCJ76meVM/jGmLWEkIlBnXqDTyEk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SeTwm6sVv2GeueHnC4UBlQGSxN35L4KxJZqcbVyUu1mOpItdq5p0h5SpX+r4ZmyxvP+BTxfTcqulr3KhyIMe6ZlT5HuhxgRgF8HUAxlnUaCMMsXX/s+z4LZDkoTPxrw08zqSuuOYViUlA3boSZ12PGUBvF7oTOOUj2CDRb2xgfI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hev.cc; spf=pass smtp.mailfrom=hev.cc; dkim=pass (2048-bit key) header.d=hev-cc.20230601.gappssmtp.com header.i=@hev-cc.20230601.gappssmtp.com header.b=xSBHa5ao; arc=none smtp.client-ip=209.85.214.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hev.cc Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hev.cc Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=hev-cc.20230601.gappssmtp.com header.i=@hev-cc.20230601.gappssmtp.com header.b="xSBHa5ao" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-2ad617d5b80so18578355ad.1 for ; Sat, 21 Mar 2026 07:21:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hev-cc.20230601.gappssmtp.com; s=20230601; t=1774102892; x=1774707692; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FFdEgLKBQwl/qBMdiHVw8eCe65OPPezRSACDbsiut88=; b=xSBHa5aoXw1aaMMcF+QSsD6/ehCU5YCDRpXvyeIvu7cAYYCgWWzB5Rk1C4nWg3O0Mb UDXtghkV987NWAUyJM+IdKiBpdpFHAK+64oi4yIcTLC3QBngeOT0FyJRW4dEVghwRDvn pmfUlQwXlX8C6zd0bmoibsw9cILE7/jmL9M88wn7RtfkLGVuF0M731QDjvJHujTZiXp9 c0/H/VS3epK3mBg9ejzXYw4ha285qr/S20qu31xH3Vwbaz997NfGMdIIO8Y1bfoCQa2y IUVj0TzGTFYJ+0pW4M7rY2TvCMrihE0RKBDCHvPDpomwPF1qJZM2FsN6YboYFSoJBHvH yG5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774102892; x=1774707692; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=FFdEgLKBQwl/qBMdiHVw8eCe65OPPezRSACDbsiut88=; b=KUyZANqKNNC830O3VsmfOkoTJYBURDGeVZUFF76GzRzxWW+ZkLbaNk7j7ETvyGBiCw M498IHl+Z3jQaapyVptlxjTFj7m8neZim/G4Uvux6nlP1qkGzOlyBU3UfgiRrNQibAPu 3laFyoW0GQo6f0WY8HDEDWegl40RHWvgW2AVXW2d/LLpi0Ax+H4Aau7w0I04dcBpZS84 UhmLBm/5Jub3KG+sIMVGBNY8iKI4Auje3kB1M7b50kF4wZyBRlC122bQrwobs7UGGboU rXssYD973LTRxAN6Nm+PfUHCCep79AJ4EKLZoTt5YgNnCJQKwli8/bOmOeKHD73oz/Nr 0ASw== X-Forwarded-Encrypted: i=1; AJvYcCUgLSlJXT3OwkOYsuhU6jNNYbLHbOJataYmAk5Psg8i20Eo+1acMsrUGYWUU2JIqr/LhcJDWwzWRlIxwvE=@vger.kernel.org X-Gm-Message-State: AOJu0Ywdvvy1S9Wx5CVtnRilFC+FlZFudbeDdDwn8aQIIM9Fy3uNszLU 8iEMMJPrqp6+01QbR02M3ktXzOCylMTo9Cf1jDJ3E8P9ZGVhyEOfIQ9uXm+5TtS8r3Qs3kVNcNj Wt+sbVv8= X-Gm-Gg: ATEYQzzlwFDGgJK2sVN8niqsAH35/opG102G+AKOnoqWRl5yx0fxYr2OVtgXKo7OZl3 UTLZ+Cr6QcltymJc5W/gBBVBq1ptGRw3fXwZIqEYtcEc93I2krXtEteS6H756BMrSBkXSBHjoB/ CGstnDwW/pE4Y8emrduyTHBj3HBP/YXg/CyEfYuGo1iPh4uvgXSoVcCvHRAc7qgXF/lkMfGS7Nz p+1u3zbUgygauFUJdKboXL44qp8Kw0FRoQbydRIOIlEORYle8vaIUUSrRgQ5D21NJvtiL3zM8Qi rfwswZZd9zZsD2y3r52XSlN0D9iUB9jWOV73gbkk3itGQrWceOP5FEw9PdSjw5VdIVIHIRJdakP r7ouqvW1uTPd0i34eKC7AO6ptxx2zl3Z5cSv9y2YOZLPJVvKp7INTc7xsUbp4ncdQ4ekZqoaMt1 Ix X-Received: by 2002:a17:902:eccb:b0:2b0:8106:f3ad with SMTP id d9443c01a7336-2b0827c7f52mr60674775ad.29.1774102892319; Sat, 21 Mar 2026 07:21:32 -0700 (PDT) Received: from gpc ([2400:8902:e002:ded5:78c1:8178:95c1:6ca3]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b083656df5sm70621765ad.44.2026.03.21.07.21.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Mar 2026 07:21:31 -0700 (PDT) From: WANG Rui To: david@kernel.org, usama.arif@linux.dev, willy@infradead.org, baolin.wang@linux.alibaba.com Cc: r@hev.cc, Liam.Howlett@oracle.com, ajd@linux.ibm.com, akpm@linux-foundation.org, apopple@nvidia.com, baohua@kernel.org, brauner@kernel.org, catalin.marinas@arm.com, dev.jain@arm.com, jack@suse.cz, kees@kernel.org, kevin.brodsky@arm.com, lance.yang@linux.dev, linux-arm-kernel@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, lorenzo.stoakes@oracle.com, mhocko@suse.com, npache@redhat.com, pasha.tatashin@soleen.com, rmclure@linux.ibm.com, rppt@kernel.org, ryan.roberts@arm.com, surenb@google.com, vbabka@kernel.org, viro@zeniv.linux.org.uk Subject: Re: [PATCH v5] binfmt_elf: Align eligible read-only PT_LOAD segments to PMD_SIZE for THP Date: Sat, 21 Mar 2026 22:21:19 +0800 Message-ID: <20260321142119.102525-1-r@hev.cc> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260320171115.93235-1-r@hev.cc> References: <20260320171115.93235-1-r@hev.cc> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit One clarification regarding my earlier comment about compatibility with cont-pte. What I meant there is that the alignment logic in my patch does work for systems with 4K and 16K base pages, where the PMD size remains within a practical range. In those configurations, providing PMD-level alignment already creates the conditions needed for both THP collapse and cont-pte coalescing. This does not fully extend to 64K base page systems. There the PMD size can be quite large (e.g. 512M), which exceeds the 32M cap used in my patch, so PMD-sized alignment may not be achievable in practice. One way to structure this could be to treat alignment in a layered manner. My patch focuses on establishing a reliable PMD-level alignment baseline so that THP has the opportunity to form large mappings where it is practical. On top of that, Usama's work can further improve behavior at smaller granularities, for example by enabling cont-pte mappings when PMD alignment is not feasible. /* skip non-power of two alignments as invalid */ if (!is_power_of_2(p_align)) continue; if (p_align < PMD_SIZE && should_align_to_pmd(&cmds[i])) p_align = PMD_SIZE; + else if (p_align < CONT_PTE_SIZE && should_align_to_cont_pte(&cmds[i])) + p_align = CONT_PTE_SIZE; alignment = max(alignment, p_align); } } With that separation of roles, the two approaches complement each other, and we can get the benefit of both without changing the core alignment policy in binfmt_elf. Thanks, Rui