From mboxrd@z Thu Jan 1 00:00:00 1970 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 043D8C369D9 for ; Wed, 30 Apr 2025 13:24:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 076866B00B9; Wed, 30 Apr 2025 09:24:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 024A36B00BB; Wed, 30 Apr 2025 09:24:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E2D036B00BC; Wed, 30 Apr 2025 09:24:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C70686B00B9 for ; Wed, 30 Apr 2025 09:24:08 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 01044C9FF2 for ; Wed, 30 Apr 2025 13:24:09 +0000 (UTC) X-FDA: 83390778660.24.E1F2C93 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf16.hostedemail.com (Postfix) with ESMTP id 45207180013 for ; Wed, 30 Apr 2025 13:24:08 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Vjd0LIB0; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf16.hostedemail.com: domain of da.gomez@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=da.gomez@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1746019448; a=rsa-sha256; cv=none; b=m6PNw1U1b8AMsSa+vUg2aYzf++BTYnu8yuPxM83PaFOjHS2jN3M4vPcNqcJcwNlxeXq9Q0 Nm474wqhslbarFrSD8FJfAxUEWsOkf1bOzvxDh8YaLM3GS8gYduoc/U0p2STkQosNvA5om ZWWlq3Rq/nV4kmlDM44hHDR2HWtzytA= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Vjd0LIB0; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf16.hostedemail.com: domain of da.gomez@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=da.gomez@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1746019448; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=FPwcjOTgEernZI7B/vE1qKo/CfT2zBkvPDqKNmCZxPI=; b=KJk+y5rrj0g1hd3elYvq8WRoHoIpSc9lGcnmS5i4aYj5dFkG4kzhvxZLa/Vub3cDx69fg7 Pwu4i4yGC32qc39aM7gERSgVFTwSw/KElSzFMOo4mtNoJDJzdpTYUl4+Z0Ofw1zQ8o3K1o BJ3Q5203GHzc4ccWrJ5gm8c0ueVRtMA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id EA17F5C4910; Wed, 30 Apr 2025 13:21:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40D40C4CEE9; Wed, 30 Apr 2025 13:24:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1746019446; bh=4Nc6GDztxDnf1w4KqVdi+LzpveRRgp4sfrwZ+0SHHS8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Vjd0LIB0sgnkdhpcz4kpRBtnO+wtfuCiN5i4BEnIynkhHoW8goJk9P83j2stkksMJ g3zYhaQhOeihgkEd6GcpZOV0jW/TB9ubFWPBi4caCRtCQpzXA2ONW9/it5zJkamFH3 phDIOZOi6HIXsOWDQa6wYWAAhd9z3A7+iUVgbNF7NDNyKOi/CQFWcjhg7TWDeuZeK3 rqfxQpJIZYfRYLcGYKbYDhlSPjfgvG6+LyZVfNIWKSvpMhFUbzPdP9N8UYqq51IKaM ZT+rLuVYi2BZHHU2K19J5ywKPO9w7pZxLKtvTGTqplHPDevcjuqhSmtlp9fmxM4TPJ Ux5DDc86qPSJg== Date: Wed, 30 Apr 2025 15:24:03 +0200 From: Daniel Gomez To: Ville =?utf-8?B?U3lyasOkbMOk?= Cc: Baolin Wang , akpm@linux-foundation.org, hughd@google.com, willy@infradead.org, david@redhat.com, wangkefeng.wang@huawei.com, 21cnbao@gmail.com, ryan.roberts@arm.com, ioworker0@gmail.com, da.gomez@samsung.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, regressions@lists.linux.dev, intel-gfx@lists.freedesktop.org, Eero Tamminen Subject: Re: [REGRESSION] Re: [PATCH v3 3/6] mm: shmem: add large folio support for tmpfs Message-ID: References: <035bf55fbdebeff65f5cb2cdb9907b7d632c3228.1732779148.git.baolin.wang@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 45207180013 X-Stat-Signature: ocukg5iuj6ude8p4ww34iz8h43tbd3pe X-HE-Tag: 1746019448-375420 X-HE-Meta: U2FsdGVkX19Ap52VvPIiykC5z+sfSjeYDVqHOhpwA0hSIXtMIK0LuZiloQCvLiWX4Hu3S/OwSw8RFxGM96DCZJKV+H44uYwLulc1rkI1kHS2qJSA6AkMq69FuvU++R7cnn0DQUABy/9OYhFKlx5gbKA/X5ridRup1/aS5uE+Of6OZVEMhVn5vArTUNZluxao+3RTdztAAl1IQVrVZb1IbSs1O9MLe7JSqEZrN4cs/LwWmBx7yogd5Hw1utjZ1pRs0GElcl0NpRPpdRs3gS2xKUyhoLAeBerIYfA67w+KbPWhMEqtdYA1JmoRWBYTsemd/eEJ6ssW5qfOozZrRbzYKX9vKObouGB2jcHxZ6bXSsLaiE+L8mrJcTocL4TduYyEsLBO/ZAtmDsrV+0PmleM/hQu1oHHfSLjrqW3brW/oqfj7CUrQ67y5O2uL0WgDOLWtxafbdqtso5YZawpVw9/ey0zmv0KdQ5Jp2+1eNJ/TJpbc08Ihcudg+RQvjSXpqkc9U/f8s9ZZjFRjnGrqrWs1pKBfw4pYnzm8txQXgtopJGNNyb0dmfIZw+EZaoVJBw7XwrFRaBG15dkbrPC25inbtB+TrcN5IMnSzwdzRZQ5hfuXUEEkUbBjuCdBKtE7OCLUDDJuISI1+uQu7zJy9Wq5fKUEAnTCnH+R/5+x/8AWZHwvC0GV2jkt1sX4FsxYM3VEkT7frXn4SmNZRv3CXd1/DmLJhao/1GCfWw/lSNK61eF/HX8Xp27+RLmce5ufH2AeZxZFz07zm8x/IlqM/l4caFpRtdx7ZS1pi51MR6EuWVA4GFkqwvntQolBdNcezxirEAHcoVflqQ3tpAApgmoqlVWJwbHRYzS95fI3VaZp6LacOP9c5Qmky9wQKffQ7E1azN8/0FylZYBTC70ecqurvv77K/dwlJabh65cHd1hU1WlA0F4h9L4MiPkGAu17SgrDPhfa+K5cWiFNyxb/Z babfAGqX IPZu9Gco/3Q13AobypkHZEkN7wByuqqTuCV5FO/IvP31B+NvLUHdKKb/S0YzxoL68DuiunVSSj/RY7Ngczro1aNoVR+hdKPtLSS13UBcGjwOKBLDbf9BFhcPJZuzMjp66SswWEMfRQnGtuee0jo+ovEIhfj/0KRx5saHiNNhl44Tw2UVOVHlhF2akWuPorRmwzUp8VdAigWIarWrYCA98DMkQPwTwsbY6jdxyoxhhvtu1/Vk= 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: On Wed, Apr 30, 2025 at 02:20:02PM +0100, Ville Syrjälä wrote: > On Wed, Apr 30, 2025 at 02:32:39PM +0800, Baolin Wang wrote: > > On 2025/4/30 01:44, Ville Syrjälä wrote: > > > On Thu, Nov 28, 2024 at 03:40:41PM +0800, Baolin Wang wrote: > > > Hi, > > > > > > This causes a huge regression in Intel iGPU texturing performance. > > > > Unfortunately, I don't have such platform to test it. > > > > > > > > I haven't had time to look at this in detail, but presumably the > > > problem is that we're no longer getting huge pages from our > > > private tmpfs mount (done in i915_gemfs_init()). > > > > IIUC, the i915 driver still limits the maximum write size to PAGE_SIZE > > in the shmem_pwrite(), > > pwrite is just one random way to write to objects, and probably > not something that's even used by current Mesa. > > > which prevents tmpfs from allocating large > > folios. As mentioned in the comments below, tmpfs like other file > > systems that support large folios, will allow getting a highest order > > hint based on the size of the write and fallocate paths, and then will > > attempt each allowable huge order. > > > > Therefore, I think the shmem_pwrite() function should be changed to > > remove the limitation that the write size cannot exceed PAGE_SIZE. To enable mTHP on tmpfs, the necessary knobs must first be enabled in sysfs as they are not enabled by default IIRC (only THP, PMD level). Ville, I see i915_gemfs the huge=within_size mount option is passed. Can you confirm if /sys/kernel/mm/transparent_hugepage/hugepages-*/enabled are also marked as 'always' when the regression is found? Even if these are enabled, the possible difference may be that before, i915 was using PMD pages (THP) always and now mTHP will be used, unless the file size is as big as the PMD page. I think the always mount option would also try to infer the size to actually give a proper order folio according to that size. Baolin, is that correct? And Ville, can you confirm if what i915 needs is to enable PMD-size allocations always?