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 13F3CC3ABAC for ; Tue, 6 May 2025 03:33:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A7EED6B000A; Mon, 5 May 2025 23:33:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A2ACC6B0082; Mon, 5 May 2025 23:33:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8CD4E6B0085; Mon, 5 May 2025 23:33:43 -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 6ADA26B000A for ; Mon, 5 May 2025 23:33:43 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 11F1DBE726 for ; Tue, 6 May 2025 03:33:44 +0000 (UTC) X-FDA: 83411063568.08.C4EE892 Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) by imf17.hostedemail.com (Postfix) with ESMTP id 09E8040007 for ; Tue, 6 May 2025 03:33:40 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=UzMbDMGn; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf17.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.100 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1746502422; a=rsa-sha256; cv=none; b=XW4/4NkFtE8Yy69MR32Aq8lRjBwzHxQF1vZz2KyoClQw7wC9SrPWoO4BQM5g2FG7y9vWzV G8MeuCI7gn88t4dfG2RVeac/XSF8rBbMGxV/89+e5wxWV+FvMkjONafF7gXcopQ1bWkGP+ ZfUHkb5CYixy4W+TXDILA15FALiIRNw= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=UzMbDMGn; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf17.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.100 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1746502422; 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=CUpvAXTG+sIqPcJVqAAskuK9yt70CbxZPTiboeMWKZE=; b=BoMdTSzWNznKaH7qtnRsJjhkXoqLFlwAsMX5jDLB5ASMfBsIez28gwkkzu81g7jX+NZXGt HWPq3aFaxowySQggIBsU1luwOojr+wU7EVYiyOEgFM6li6oiSKN9gaevwMJw1RzRrzwKOH 1eVO3VFPClKCT16fecLR4xH9BBPpm5w= DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1746502417; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=CUpvAXTG+sIqPcJVqAAskuK9yt70CbxZPTiboeMWKZE=; b=UzMbDMGnO/azUHRjN9HAyNmnbeJJlytiRLGdwufR+i8hAVo+JedGRT9f1kDaco/DZKCncVPUpgWaQIgU+ZHnyTd04g1OHVq9uFw71hlvf0+WX0PJ/zTl4VfAI34tABZWse3SWgzZ1XgYkFMOto4k1Tmtv7qtEOlQh3+aURSp388= Received: from 30.74.144.110(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WZJQtMn_1746502415 cluster:ay36) by smtp.aliyun-inc.com; Tue, 06 May 2025 11:33:35 +0800 Message-ID: Date: Tue, 6 May 2025 11:33:34 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [REGRESSION] Re: [PATCH v3 3/6] mm: shmem: add large folio support for tmpfs To: David Hildenbrand , Daniel Gomez Cc: =?UTF-8?B?VmlsbGUgU3lyasOkbMOk?= , akpm@linux-foundation.org, hughd@google.com, willy@infradead.org, 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 References: <035bf55fbdebeff65f5cb2cdb9907b7d632c3228.1732779148.git.baolin.wang@linux.alibaba.com> <57dc4929-268b-4f3f-a0f8-43d6ec85974f@linux.alibaba.com> <72978e3a-ee67-47d4-b06d-e911bc5d57ff@redhat.com> From: Baolin Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 09E8040007 X-Stat-Signature: jotee9re9hdatpwyekkj41ms6ffp6f6g X-Rspam-User: X-HE-Tag: 1746502420-195425 X-HE-Meta: U2FsdGVkX18KInL16mn4atZMNHQttaF8ahF0J0iViAqGQfIammsODAxWNgb9yZXOMgXq3WAizVZHD8yJZjvWpzmDC63mlOhlgdTRaRuThdCXmgPlRPXJh9QM7iozcTXORwfywJuq1VNYs0rYJWDl0/Qp/ypGrRXvcY88uzpIsE8rg0xkzfK2Li0rqdBclDctbCFdOpp67jDMudsG0Ueo5grQZO+pyqmpBCaT633FHnA+iCQjROkw/oVBwcgPEYmi6d6YfHeAtFOkm6ZsfMroVvPCLXD8Ap3F9OrclTv0mzhSjxjJaW8KZzXKtUweKO4tif0ej+Oibh1L9uc/PeF/69gGkBTNHzWsmRLP+/wsmB34zykBhZmXJGw1pVkI7AsnVcRru+IeUTP53UguKDGHV3dSlSu2H6ULdcKbZlgGab/F12JQnmwCq+oDvsXp+K1aq/c0PmXMfhwclomNwHAn1Vpk4hKa9TFfuBOHvkJvBwylWP9fWqYk+GbXmwJlINsS/koyVK4JiIPHXuzqQLIO+5TCkIhkEriLNzUP/hhXbGnauKSTX+3VEQfb8jAOGczKRcsKNUOGRQcj3Hk5hPwnveoOE8fjchDp3L05HY7z1nL/YT3w4LKrW+GoGlzKmckDNE/n6SqJcWiDKshj1EfsCjTbeaeA1VaLJrxys0dV9PLM0FLBuPnUrQRA6K4u/daStZkkCekKJxk8EXuRWbuprxqPNsYSmI7vuDu3O3966sjp7XPNKHnSW1F7tkGzmHMFHw3pBEKLJA50vr8cjCfyqPEHmXnu0BPkP0nEQKFLmOyO+EslO8KPfvDFMwxZRB3tH6GRUVbQ8uLTMvzZ6JZGRMtMY7Qo3DQWK6bPIyElFr8xNQ1j/A0DFI69EvQJGWLnP0dKybQplHMFO/rVsP4l1uJdD0V5rDhtkLboVzrhhvcD11CCt6+kGdyihRuw+Eb2YmWQIShDinka1nd9xga VzVVsMt+ V3Gne/oNPibhWtJflClkZbVgkDkVAyilj/Z7JIBGiWAe/S8NLmEwkQEy3VUCgZNtU7c+QDICTytG2zaeWzXDD1qyfSPoyRxqzdEQtz3NnPaZmoCsof1UZaEjGWRpxWUAJS5yv6CLUh4/BTeyCuYG+jk4gqiOJg16j84mhOLfjDmmrVJWM81UU4WLahsSnETQvmkapQu06zb6Vf6lakDOoVlvG47bsRY69b3sDedkr2veHIwFPxXcAZB8iiziL7z+pSbPzqyRGzWPhjNOY6a6l3yWtZB1tsQXh/CNxeGdtERr6m/6sjtBt4Qufri8H/s2nVfju 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 2025/5/2 23:31, David Hildenbrand wrote: > On 02.05.25 15:10, Daniel Gomez wrote: >> On Fri, May 02, 2025 at 09:18:41AM +0100, David Hildenbrand wrote: >>> On 02.05.25 03:02, Baolin Wang wrote: >>>> >>>> >>>> On 2025/4/30 21:24, Daniel Gomez wrote: >>>>> 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? >>>> >>>> The tmpfs mount will not be controlled by >>>> '/sys/kernel/mm/transparent_hugepage/hugepages-*Kb/enabled' (except for >>>> the debugging options 'deny' and 'force'). >>> >>> Right, IIRC as requested by Willy, it should behave like other FSes >>> where >>> there is no control over the folio size to be used. >> >> Thanks for reminding me. I forgot we finally changed it. >> >> Could the performance drop be due to the driver no longer using >> PMD-level pages? > > I suspect that the faulting logic will now go to a smaller order first, > indeed. > > ... trying to digest shmem_allowable_huge_orders() and > shmem_huge_global_enabled(), having a hard time trying to isolate the > tmpfs case: especially, if we run here into the vma vs. !vma case. > > Without a VMA, I think we should have "mpfs will allow getting a highest > order hint based on and fallocate paths, then will try each allowable > order". > > With a VMA (no access hint), "we still use PMD-sized order to locate > huge pages due to lack of a write size hint." > > So if we get a fallocate()/write() that is, say, 1 MiB, we'd now > allocate an 1 MiB folio instead of a 2 MiB one. Right. So I asked Ville how the shmem folios are allocated in the i915 driver, and to see if we can make some improvements.