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 05F71C3DA41 for ; Tue, 9 Jul 2024 15:57:07 +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-Type:In-Reply-To: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Xk2zHQ/YE20jgxtFEdO755E5YwPG0ZQdb2j69TcOV+0=; b=oMCGTDDkTokpIvgZzJc7/ecHzi +1C2LGFvhxpLydW9IuwV8u2IiGrU0yk+osgOqXiqICgomq8MfDMx3/h/6E2IDUkd7loiJCgBAOCCH D3asM7Xt/HhjFhntomW9pFr9GgX+30O9jCIYl0fal4tyX3tz5d8AAYGsqapKjMZfnv/djoYqRJ8bI +JiOThWYs/gSu6cc3tO9+4b9GXILWznyTzXImcBUz6ZOau4g7oW3pOP2miY6X3y1iGoK+AHnKjI6o IQQipj4ZyiBVltXJ2xv2hhPqjynaDGQSgQKaUDfwuiEZfnEC190Mf79fomFUlw5A6tLy+d3HiUegr +isrRltQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRDD6-00000007p4U-2Bab; Tue, 09 Jul 2024 15:56:56 +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 1sRDCp-00000007ovJ-00Mo for linux-arm-kernel@lists.infradead.org; Tue, 09 Jul 2024 15:56:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720540593; 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=Xk2zHQ/YE20jgxtFEdO755E5YwPG0ZQdb2j69TcOV+0=; b=OT0ccOUf39JqCVdRo/IeydRiancwBscvv9ei3s0fsW3U6GYu/w+4JVAZOnIf1sfafIs3Mn g8+1T0BG5Pq9b7DX8ZXcUQPeKa86duz50TAscXSbKK09eXdFmw0Ci2wEo5TVX8u1XZl0o2 2L2HTTSY5M4pDit5syRFLx+Cavylykw= Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-577--xc_rCRxMxGuA1Ot6PuOHA-1; Tue, 09 Jul 2024 11:56:31 -0400 X-MC-Unique: -xc_rCRxMxGuA1Ot6PuOHA-1 Received: by mail-oi1-f200.google.com with SMTP id 5614622812f47-3d92574d224so51375b6e.3 for ; Tue, 09 Jul 2024 08:56:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720540591; x=1721145391; 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=Xk2zHQ/YE20jgxtFEdO755E5YwPG0ZQdb2j69TcOV+0=; b=HWGJgtGSONxDUJ8aZM8AWsRp/hkvq+B7lzdBqxlnmJC8lG8mUOjoocNqvo7m95Kxz3 seSVFP4YLwqj0J2ZLxE70QI/mVZt92h6vKRX6pPGHT5UuyRHPSE+vr0mpV5G0VwH0MgR 7Vq6Xz9pdfxVURSyQGsvZYEkT9HQAAEm8S96l8fJXlI7+34LjKYH1dP1Nz8/kuN2I7Df hbhH+GpMF9pBoGmuNrLwRc3yfoShQ3DilZ1vXR1WRz5PlyNYx/iP15ELgXBcevCqqCbv wq+ZRbJOg9RH8tFfZSbVQrWa907ygYlxiDhIg5LAzlrfo0kJTRypXQh6g/iWgETpQY7x v/oQ== X-Forwarded-Encrypted: i=1; AJvYcCVsaE0So1HVhePc2498zIKmdv+YVTK909GTvm5rM8CVTePIQOt7D94QCElZ7ffKFCOw7i8O4U+omk47nUuqlvogcHDFCU8ey6MXptM0z91i2MyxAy8= X-Gm-Message-State: AOJu0YzwAHSmaLTI6CCMvy0z79yQxUV5holTsNFbpvsBgQq0ddpKNXV+ AFgCLXrbKHlq6IJKld8dFWrJnbpBGnXCjEuZoD8fShc/uEUVXhQBycZbCUbtcuQM/14O1x8MFk6 k/DsM4XUtRM73B/5Jj/BN0VAMCM+XeVEzdrchpdgh+9sgiOIr9iskeSZudPOzhZvY0v+cGKQ5 X-Received: by 2002:a05:6808:148b:b0:3d9:2e1d:2543 with SMTP id 5614622812f47-3d93c0fe45amr2848542b6e.5.1720540590687; Tue, 09 Jul 2024 08:56:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE1Ma1rQrmj4Xg5pyldsO8p97ImEEKrUWOUqeogODHc73Oz0DxK2TC+nXJTsvBMv1FTSng1jg== X-Received: by 2002:a05:6808:148b:b0:3d9:2e1d:2543 with SMTP id 5614622812f47-3d93c0fe45amr2848435b6e.5.1720540589482; Tue, 09 Jul 2024 08:56:29 -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 d75a77b69052e-447f9b26f7bsm11708091cf.6.2024.07.09.08.56.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jul 2024 08:56:29 -0700 (PDT) Date: Tue, 9 Jul 2024 11:56:25 -0400 From: Peter Xu To: Alistair Popple Cc: dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, logang@deltatee.com, bhelgaas@google.com, jack@suse.cz, jgg@ziepe.ca, catalin.marinas@arm.com, will@kernel.org, mpe@ellerman.id.au, npiggin@gmail.com, dave.hansen@linux.intel.com, ira.weiny@intel.com, willy@infradead.org, djwong@kernel.org, tytso@mit.edu, linmiaohe@huawei.com, david@redhat.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, jhubbard@nvidia.com, hch@lst.de, david@fromorbit.com, Alex Williamson Subject: Re: [PATCH 11/13] huge_memory: Remove dead vmf_insert_pXd code Message-ID: References: <400a4584f6f628998a7093aee49d9f86c592754b.1719386613.git-series.apopple@nvidia.com> <87zfqrw69i.fsf@nvdebian.thelocal> MIME-Version: 1.0 In-Reply-To: <87zfqrw69i.fsf@nvdebian.thelocal> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240709_085639_147873_76D69AEB X-CRM114-Status: GOOD ( 35.85 ) 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 Tue, Jul 09, 2024 at 02:07:31PM +1000, Alistair Popple wrote: > > Peter Xu writes: > > > Hi, Alistair, > > > > On Thu, Jun 27, 2024 at 10:54:26AM +1000, Alistair Popple wrote: > >> Now that DAX is managing page reference counts the same as normal > >> pages there are no callers for vmf_insert_pXd functions so remove > >> them. > >> > >> Signed-off-by: Alistair Popple > >> --- > >> include/linux/huge_mm.h | 2 +- > >> mm/huge_memory.c | 165 +----------------------------------------- > >> 2 files changed, 167 deletions(-) > >> > >> diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h > >> index 9207d8e..0fb6bff 100644 > >> --- a/include/linux/huge_mm.h > >> +++ b/include/linux/huge_mm.h > >> @@ -37,8 +37,6 @@ int change_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, > >> pmd_t *pmd, unsigned long addr, pgprot_t newprot, > >> unsigned long cp_flags); > >> > >> -vm_fault_t vmf_insert_pfn_pmd(struct vm_fault *vmf, pfn_t pfn, bool write); > >> -vm_fault_t vmf_insert_pfn_pud(struct vm_fault *vmf, pfn_t pfn, bool write); > >> vm_fault_t dax_insert_pfn_pmd(struct vm_fault *vmf, pfn_t pfn, bool write); > >> vm_fault_t dax_insert_pfn_pud(struct vm_fault *vmf, pfn_t pfn, bool write); > > > > There's a plan to support huge pfnmaps in VFIO, which may still make good > > use of these functions. I think it's fine to remove them but it may mean > > we'll need to add them back when supporting pfnmaps with no memmap. > > I'm ok with that. If we need them back in future it shouldn't be too > hard to add them back again. I just couldn't find any callers of them > once DAX stopped using them and the usual policy is to remove unused > functions. True. Currently the pmd/pud helpers are only used in dax. > > > Is it still possible to make the old API generic to both service the new > > dax refcount plan, but at the meantime working for pfn injections when > > there's no page struct? > > I don't think so - this new dax refcount plan relies on having a struct > page to take references on so I don't think it makes much sense to > combine it with something that doesn't have a struct page. It sounds > like the situation is the analogue of vm_insert_page() > vs. vmf_insert_pfn() - it's possible for both to exist but there's not > really anything that can be shared between the two APIs as one has a > page and the other is just a raw PFN. I still think most of the codes should be shared on e.g. most of sanity checks, pgtable injections, pgtable deposits (for pmd) and so on. To be explicit, I wonder whether something like below diff would be applicable on top of the patch "huge_memory: Allow mappings of PMD sized pages" in this series, which introduced dax_insert_pfn_pmd() for dax: $ diff origin new 1c1 < vm_fault_t dax_insert_pfn_pmd(struct vm_fault *vmf, pfn_t pfn, bool write) --- > vm_fault_t vmf_insert_pfn_pmd(struct vm_fault *vmf, pfn_t pfn, bool write) 55,58c55,60 < folio = page_folio(page); < folio_get(folio); < folio_add_file_rmap_pmd(folio, page, vma); < add_mm_counter(mm, mm_counter_file(folio), HPAGE_PMD_NR); --- > if (page) { > folio = page_folio(page); > folio_get(folio); > folio_add_file_rmap_pmd(folio, page, vma); > add_mm_counter(mm, mm_counter_file(folio), HPAGE_PMD_NR); > } As most of the rest look very similar to what pfn injections would need.. and in the PoC of ours we're using vmf_insert_pfn_pmd/pud(). That also reminds me on whether it'll be easier to implement the new dax support for page struct on top of vmf_insert_pfn_pmd/pud, rather than removing the 1st then adding the new one. Maybe it'll reduce code churns, and would that also make reviews easier? It's also possible I missed something important so the old function must be removed. Thanks, -- Peter Xu