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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7C0F5C3DA63 for ; Tue, 23 Jul 2024 21:22:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=g2K985F+JisyaO1P/JvvQtZwZa+DhsuE69ZrR+fszhY=; b=BrCJLkTDSBA9HynRDLdJkSsLqP 0OSeHmjx0TtRjVq7Bc2ukRxR5b7XIHHetNYAZWcxcz70D3NSu/RjcYSVcL3c1550U35AK/WYp4AbJ qRtJVvX67KsE9zJHhoUP+9Yd4xHwk+hkI4M0Dtbd3UbsvbUnpF8ZvUxVWIdi7j1c5oPBdY9iBzXEZ /8ULgPH4xXBzNp8o2KXl2soYVJ0JwZI09cVZPmuOkRBvqoEdvACNOHqCS4J+uh2nTFN/sFpsezcIB +29eF+w+WMuN0MtJQ0hlBnRfIgIuvcDHxigAwXj53Hi0UxZH+JAd0YT8gslSCTfgARRPyx2oCQTVN yuItVk6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sWMxv-0000000DYl1-0WfL; Tue, 23 Jul 2024 21:22:35 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sWMxW-0000000DYeC-1xjy for linux-arm-kernel@lists.infradead.org; Tue, 23 Jul 2024 21:22:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721769728; h=from:from: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:autocrypt:autocrypt; bh=g2K985F+JisyaO1P/JvvQtZwZa+DhsuE69ZrR+fszhY=; b=InApUyoWubpTOPkXmpYCIQDoUzOdCnLpgldKamTpRJ4e8tOjfasFxaBU6GFqxMSOZDb6EK PmBdd4VrnaoW0ByomKZ1YWUTw23ASGhd1g4AtTyR6Q34n/Ly2dBs16bIC9leYjDBPsHGu2 LGDeD4V3RM5xSHDgMzWFocgGDd476NE= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-539-vd6SvT7yOTONAqPnxXSEhw-1; Tue, 23 Jul 2024 17:22:06 -0400 X-MC-Unique: vd6SvT7yOTONAqPnxXSEhw-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-36863648335so3608477f8f.0 for ; Tue, 23 Jul 2024 14:22:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721769725; x=1722374525; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:from:references:cc:to:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=g2K985F+JisyaO1P/JvvQtZwZa+DhsuE69ZrR+fszhY=; b=ej0BPuzn6bFeaH/6FcLOrHFK1UCAFFycgAX5ZJnLmznH+RWDCWsUH2eCj1xpPSbw2N dt9W4CQ8oHmk6fR1Cpkp360Yrr2Hr+X+VN6IlcOvojLiJM8OtppvS0y3YcN9E6RgXbxI trNHcc3ivb0TAjl5P14l9DiPXyRmI1XcHifdtxFHr5bSDTfc+9y5onKsmyAdsZjP2p0+ wCiHaJAMq9dqaN9EnzbBqU1K/rnk+UUGLXmLkHQyom7i/g7PFKoysXoX4jY8Iuvd7LBv 6YrHSI4qzVgz0PeqqvZz+x3aIdSJSVOG9rGAH6fCkBTn5dGazTeNlvFHGCVqFhL5PvwK horw== X-Forwarded-Encrypted: i=1; AJvYcCUp7B9aVlqqaJM+BjkOJxcmvWAOSEN8CDSB3ws8+UlO+N8e+rGo1HZ15g2geUxSUAxrtniE1adNwGl1Tr6JVMR1TsEOuWraxFb7Wit17Fc5deCw7pI= X-Gm-Message-State: AOJu0Yx+oSKjbKetMUyL2DhBSeLR18dsQh7u3Stn+gJKS9niHsr3Wdfp C0tQlwsRSaYblsFdmDXnSGsZv0PEjJxIXOEqaRzvNW4SbRSxloxCkwAEWTTZ7oBp07/25I0NZ8W UTE37ghKZhuwEyalZGEp5JSTKx1RZuYRBXRE1IEEnFKj2d2wliFd1jJTlHHr748v+JPfu+cgW X-Received: by 2002:a5d:64a8:0:b0:367:94b8:1df1 with SMTP id ffacd0b85a97d-369bae97e75mr7352131f8f.55.1721769725077; Tue, 23 Jul 2024 14:22:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEZpJY61ZWZsVtUXIZgPXhIWFxqPYeKoLxP8USF6rP/yxwg/LgUFS9ATMnvRHeV1H1e/zaoew== X-Received: by 2002:a5d:64a8:0:b0:367:94b8:1df1 with SMTP id ffacd0b85a97d-369bae97e75mr7352118f8f.55.1721769724633; Tue, 23 Jul 2024 14:22:04 -0700 (PDT) Received: from ?IPV6:2003:cb:c72f:ed00:9dc2:1adb:d133:4434? (p200300cbc72fed009dc21adbd1334434.dip0.t-ipconnect.de. [2003:cb:c72f:ed00:9dc2:1adb:d133:4434]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36878684839sm12529422f8f.22.2024.07.23.14.22.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Jul 2024 14:22:04 -0700 (PDT) Message-ID: <263e4414-24c0-4245-9c6d-7799c7bb9f77@redhat.com> Date: Tue, 23 Jul 2024 23:22:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RFC 0/6] mm: THP-agnostic refactor on huge mappings To: Peter Xu Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Vlastimil Babka , Oscar Salvador , linux-s390@vger.kernel.org, Andrew Morton , Matthew Wilcox , Dan Williams , Michal Hocko , linux-riscv@lists.infradead.org, sparclinux@vger.kernel.org, Alex Williamson , Jason Gunthorpe , x86@kernel.org, Alistair Popple , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, Ryan Roberts , Hugh Dickins , Axel Rasmussen References: <20240717220219.3743374-1-peterx@redhat.com> From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8NJgW0k/D1RyKCwaTsgRdwuK Kx/Y91XuSBdz0uOyU/S8kM1+ag0wvsGlpBVxRR/xw/E8M7TEwuCZQArqqTCmkG6HGcXFT0V9 PXFNNgV5jXMQRwU0O/ztJIQqsE5LsUomE//bLwzj9IVsaQpKDqW6TAPjcdBDPLHvriq7kGjt WhVhdl0qEYB8lkBEU7V2Yb+SYhmhpDrti9Fq1EsmhiHSkxJcGREoMK/63r9WLZYI3+4W2rAc U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EPeu59Y5vSJOx/z6OUImD/GhX7Xvkt3kq Er5KTrJz3++B6SH9pum9PuoE/k+nntJkNMmQpR4MCBaV/J9gIOPGodDKnjdng+mXliF3Ptu6 3oxc2RCyGzTlxyMwuc2U5Q7KtUNTdDe8T0uE+9b8BLMVQDDfJjqY0VVqSUwImzTDLX9S4g/8 kC4HRcclk8hpyhY2jKGluZO0awwTIMgVEzmTyBphDg/Gx7dZU1Xf8HFuE+UZ5UDHDTnwgv7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240723_142210_627834_0519CDD4 X-CRM114-Status: GOOD ( 26.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 23.07.24 23:04, Peter Xu wrote: > On Tue, Jul 23, 2024 at 10:18:37AM +0200, David Hildenbrand wrote: >> On 22.07.24 17:31, Peter Xu wrote: >>> On Mon, Jul 22, 2024 at 03:29:43PM +0200, David Hildenbrand wrote: >>>> On 18.07.24 00:02, Peter Xu wrote: >>>>> This is an RFC series, so not yet for merging. Please don't be scared by >>>>> the code changes: most of them are code movements only. >>>>> >>>>> This series is based on the dax mprotect fix series here (while that one is >>>>> based on mm-unstable): >>>>> >>>>> [PATCH v3 0/8] mm/mprotect: Fix dax puds >>>>> https://lore.kernel.org/r/20240715192142.3241557-1-peterx@redhat.com >>>>> >>>>> Overview >>>>> ======== >>>>> >>>>> This series doesn't provide any feature change. The only goal of this >>>>> series is to start decoupling two ideas: "THP" and "huge mapping". We >>>>> already started with having PGTABLE_HAS_HUGE_LEAVES config option, and this >>>>> one extends that idea into the code. >>>>> >>>>> The issue is that we have so many functions that only compile with >>>>> CONFIG_THP=on, even though they're about huge mappings, and huge mapping is >>>>> a pretty common concept, which can apply to many things besides THPs >>>>> nowadays. The major THP file is mm/huge_memory.c as of now. >>>>> >>>>> The first example of such huge mapping users will be hugetlb. We lived >>>>> until now with no problem simply because Linux almost duplicated all the >>>>> logics there in the "THP" files into hugetlb APIs. If we want to get rid >>>>> of hugetlb specific APIs and paths, this _might_ be the first thing we want >>>>> to do, because we want to be able to e.g., zapping a hugetlb pmd entry even >>>>> if !CONFIG_THP. >>>>> >>>>> Then consider other things like dax / pfnmaps. Dax can depend on THP, then >>>>> it'll naturally be able to use pmd/pud helpers, that's okay. However is it >>>>> a must? Do we also want to have every new pmd/pud mappings in the future >>>>> to depend on THP (like PFNMAP)? My answer is no, but I'm open to opinions. >>>>> >>>>> If anyone agrees with me that "huge mapping" (aka, PMD/PUD mappings that >>>>> are larger than PAGE_SIZE) is a more generic concept than THP, then I think >>>>> at some point we need to move the generic code out of THP code into a >>>>> common code base. >>>>> >>>>> This is what this series does as a start. >>>> >>>> Hi Peter! >>>> >>>> From a quick glimpse, patch #1-#4 do make sense independent of patch #5. >>>> >>>> I am not so sure about all of the code movement in patch #5. If large folios >>>> are the future, then likely huge_memory.c should simply be the home for all >>>> that logic. >>>> >>>> Maybe the goal should better be to compile huge_memory.c not only for THP, >>>> but also for other use cases that require that logic, and fence off all THP >>>> specific stuff using #ifdef? >>>> >>>> Not sure, though. But a lot of this code movements/churn might be avoidable. >>> >>> I'm fine using ifdefs in the current fine, but IMHO it's a matter of >>> whether we want to keep huge_memory.c growing into even larger file, and >>> keep all large folio logics only in that file. Currently it's ~4000 LOCs. >> >> Depends on "how much" for sure. huge_memory.c is currently on place 12 of >> the biggest files in mm/. So there might not be immediate cause for action >> ... just yet :) [guess which file is on #2 :) ] > > 7821, hugetlb.c > 7602, vmscan.c > 7275, slub.c > 7072, page_alloc.c > 6673, memory.c > 5402, memcontrol.c > 5239, shmem.c > 5155, vmalloc.c > 4419, filemap.c > 4060, mmap.c > 3882, huge_memory.c > > IMHO a split is normally better than keeping everything in one file, but > yeah I'd confess THP file isn't that bad comparing to others.. And I'm > definitely surprised it's even out of top ten. It's always interesting looking at the numbers here. For v6.10 we had: 8521 mm/memcontrol.c 7813 mm/hugetlb.c 7550 mm/vmscan.c 7266 mm/slub.c 7018 mm/page_alloc.c 6468 mm/memory.c 5154 mm/vmalloc.c 5002 mm/shmem.c 4419 mm/filemap.c 4019 mm/mmap.c 3954 mm/ksm.c 3740 mm/swapfile.c 3730 mm/huge_memory.c 3689 mm/gup.c 3542 mm/mempolicy.c I suspect memcontrol.c shrunk because of the v1 split-off, leaving hugetlb.c now at #1 :) -- Cheers, David / dhildenb