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 6433CC3DA5D for ; Mon, 22 Jul 2024 15:31:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0071F6B0092; Mon, 22 Jul 2024 11:31:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EF8C06B0093; Mon, 22 Jul 2024 11:31:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D99766B0095; Mon, 22 Jul 2024 11:31:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id B67AE6B0092 for ; Mon, 22 Jul 2024 11:31:58 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 3412B1A175C for ; Mon, 22 Jul 2024 15:31:58 +0000 (UTC) X-FDA: 82367779116.04.2A70F74 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf28.hostedemail.com (Postfix) with ESMTP id AD484C0007 for ; Mon, 22 Jul 2024 15:31:55 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=T+Dn4v7S; spf=pass (imf28.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@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=1721662270; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Jy2hKoepXG/rD4fs1gDu/NkLXDQ0MSD+ICWqPzfOpkw=; b=NsjS+6Lxca68Y4w+nIsb4YmghcBEQpiejEsEXdZRdIQxVE9gjJ9VejlYTyYo4BJlWHDRn1 xpjV6vJxgU/c67pUkvwnmRshqtxjzHKeR6lR3XSkq51CSKX7vgj088e0yjpkEOpzM1mvWz eFpkHk0hUCjIA7I6ayHipF7F3SJ3WcM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721662270; a=rsa-sha256; cv=none; b=sMA21+GHbmAf12vtbOOnYO6tjLQste4dk1oTvDs3THOuh4+pKSq3P+tebWNPGnLBUoEyth TYDx95x5B4zgYFl48UwRDvyNuvQo/EapX7DjS3sSUDLZiQkRLSRZCmeQAF+UpZH5A8OuYC HDCzcwFluSsti1VPWI+xBrBlWzAl7bo= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=T+Dn4v7S; spf=pass (imf28.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721662314; 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: in-reply-to:in-reply-to:references:references; bh=Jy2hKoepXG/rD4fs1gDu/NkLXDQ0MSD+ICWqPzfOpkw=; b=T+Dn4v7SbpLL5u5mlQYCPeYPbGJe8NS62iw+6OztSmSdEUjhqoj4UWRkSqxKhqRY59UgnO FhvXHgOTx3GLu5qfjys7a0b+36wM77ZHq7BkUQ1DAETUfJk7+BXOVZ9PJdwOIMgtt0jdKU joxacJgBNjCcwlWNOd7SFOt6X3unF58= Received: from mail-yw1-f200.google.com (mail-yw1-f200.google.com [209.85.128.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-96-dXRiM7ZzPpmArrbFAKz52w-1; Mon, 22 Jul 2024 11:31:52 -0400 X-MC-Unique: dXRiM7ZzPpmArrbFAKz52w-1 Received: by mail-yw1-f200.google.com with SMTP id 00721157ae682-6657a405603so10591257b3.1 for ; Mon, 22 Jul 2024 08:31:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721662312; x=1722267112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Jy2hKoepXG/rD4fs1gDu/NkLXDQ0MSD+ICWqPzfOpkw=; b=iSYRCu5SNz4vOEMBhImXc0RwyG319lYcr1rkQSsbFV8QfkHA0Ix+fbuI4ckba1txpz UbgesoossjGNgVoccftTY1i28n63wIZZdnD5zkd1TX5TXlwcP2MFEkYkBHN6qMcd/weJ HW3lcxxfPgugFtY32saOpnU96cv1o33iWTt14CjIblb2vv2TY811ll+hjHuk//U+ynfl zNVytlG8RwPSXL5Gze9OsH8skRJah07NHA1eIX0mPQ4uStoYwi4MbdSgrIQGr4TiDr3T bmuFgh7F8cw03S3yNTYVy28zVDJuhtNNwRh3OjbKdY52UiaC1V9ta+X9Gsn01rKskc7q RK3w== X-Forwarded-Encrypted: i=1; AJvYcCW0IAAUIa4Yugo7tw2OBjSSEX7QQDlb0mE17QPQzEuJcYr/v4ZbsFfHTPNk+hhgv4MjgRs2W8dEQRWhIpgZciuTQLU= X-Gm-Message-State: AOJu0YxElA4Nifgr1+z1yj1X03KzOA/KaZew6CR/Mm5+eGD6VsyF02k6 DWEcVWFfzUv26Btzbp2LlToj1qfPM8dnrJGqAasCmMNPvBBme1nXLdqh3MY9dKCtfiueKt1ct6h 1TCl5dEUiqQfE8Z9xsWhMqzk+8Xd8EFphAxNq9ffqLLafQ929 X-Received: by 2002:a05:690c:12:b0:62f:7951:fe4d with SMTP id 00721157ae682-66a6645377bmr38047557b3.4.1721662311579; Mon, 22 Jul 2024 08:31:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEjAYBMqsJOtNPwFqnMhMAJ/HDPRITSVBivrOVSPNdHxvmNPnz6ZnQiqjkhPkHbmoLpOWtDQA== X-Received: by 2002:a05:690c:12:b0:62f:7951:fe4d with SMTP id 00721157ae682-66a6645377bmr38047287b3.4.1721662311092; Mon, 22 Jul 2024 08:31:51 -0700 (PDT) Received: from x1n (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a198fba6efsm372071285a.41.2024.07.22.08.31.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 08:31:50 -0700 (PDT) Date: Mon, 22 Jul 2024 11:31:48 -0400 From: Peter Xu To: David Hildenbrand 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 Subject: Re: [PATCH RFC 0/6] mm: THP-agnostic refactor on huge mappings Message-ID: References: <20240717220219.3743374-1-peterx@redhat.com> MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Stat-Signature: 1gmr745rioyn1rhue19rzzu6ejbk5s56 X-Rspamd-Queue-Id: AD484C0007 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1721662315-219402 X-HE-Meta: U2FsdGVkX1/pDvMBWozm6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dVl2aUd6aph3BYqk9wfbtZdmtBqJGeDOguMKJAFq8FMtluGMl63pC/MDBOUrxaaQLSwWZ3IjqMuHKj1fC5npz2Ydvt9fYbFbR05id8EzYrvJfODoghjiTWklLayrLoEGGRkk4ZEv8PNqwwp6wVPf0Up3VrGhAJQQJg4tPrRUtUnvcfVoA6h9+q76IwwPmuPaxltQUldBPSzZGEMi7KNd0HIYXdkZ0B/IVUM2oP/wFqEH7ssgvE08y3l/3pJK8FXuNaVQFEaz79irw1OPHJqYL1n9OSbP8J8tP1hhOISTtA/j+m2eyoHDNit2fWYO7MPjcGlB5Rgw== 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 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. Nornally I don't see this as much of a "code churn" category, because it doesn't changes the code itself but only move things. I personally also prefer without code churns, but only in the case where there'll be tiny little functional changes here and there without real benefit. It's pretty unavoidable to me when one file grows too large and we'll need to split, and in this case git doesn't have a good way to track such movement.. Irrelevant of this, just to mention I think there's still one option that I at least can make the huge pfnmap depends on THP again which shouldn't be a huge deal (I don't have any use case that needs huge pfnmap but disable THP, anyway..), so this series isn't an immediate concern to me for that route. But for a hugetlb rework this might be something we need to do, because we simplly can't make CONFIG_HUGETLB rely on CONFIG_THP.. Thanks, -- Peter Xu