Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp532626lqp; Tue, 11 Jun 2024 11:22:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUAvMg4oNIv72xTG4MY5omFSyt/pHuNbNIRwO/MjqczrbxATiRWfjPei+VjTdC5kvJx0Y/Z3fCQP17I3bHy2EO5B3lxC1S1Gw9Qf9GQ1g== X-Google-Smtp-Source: AGHT+IG/YC+KQKQrEEfJ4OMd75FATyhrzt5QY/tg7FWi/xlMzR8QTat9kBTb5uIednkoJX126SmZ X-Received: by 2002:a05:6830:1008:b0:6f9:9fad:159c with SMTP id 46e09a7af769-6f99fad16e4mr7239723a34.33.1718130144364; Tue, 11 Jun 2024 11:22:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718130144; cv=pass; d=google.com; s=arc-20160816; b=Cvb6Ge8jUXpXvr8e9+BoVIS55CI5GvEJNbWpY6yTERiRq9JIIZxbjcyj2hNOQVJTva MiJJiCJJUtjyDkfQSnMo8gT6RnCF1BrLNAtX8L42NZcCCgyZbj0StPCCEtfh0lkTSfJg mbmrSJ0/hV779pwzeGf+Bcw0mBChoXdABiqOIGomMT0HIJsAwNZ4ExG20CyZH4Ti/mdg inIN+L9ccS5HG6eXKBB/nxrfWtlf/cJic3DWtp5FtVOqmbby23dpIG5uagXIy6N//ZNF FRpWpEZRChS6wls5y/v6oeG++tis38H1MW0AeaEUKmN50+UvrhGfo81O9TRitNcXQ1hy zk6g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=v+biT19hMk3zmDJ0JM4Tlgb3u1aCfIc9jRZYIonIyMw=; fh=PQvYBxqAWnZpuUbVHzLWCytCx5flVauJTD5HKb8uM34=; b=w7qJuQHOBm5Pbbl0OKAjNNy4RamTP2cX1SPw4C1C/4FGteY9IfptG+KRBusDP6gtz4 Wezx+SaSwzbHA64bNIR8vJCp4/NF0w3CWlx0xlpPe4ZJGNmWyAQF2JgiVtqHS7iaRx9j gYQhJqK94tPxjkq7kXWBnvEqQqT6/yqGEFyPGIeUPmzEmJfucuHkvAsNnNne+IPlnyl7 sW1hubILLb+SHhkPpeFhZExwEQNcidDFSiIxx0qZ+4IWlIJq1h/2oGcSDnEnB1ZonD2K QDdb20njLuPFi/YyyMQ8D4YN/aOVHQomn1JORzOlKRGycIdj8dOrpPPAOOL75JdRB1F2 MGRw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=G+EiwD4G; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-210418-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210418-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-797b9278f17si362943285a.702.2024.06.11.11.22.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 11:22:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-210418-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=G+EiwD4G; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-210418-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210418-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 8D8D91C22D7E for ; Tue, 11 Jun 2024 18:22:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5240973473; Tue, 11 Jun 2024 18:22:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="G+EiwD4G" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C539A376E9 for ; Tue, 11 Jun 2024 18:22:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718130127; cv=none; b=d+BXq1omxR6dyOFvL7WbtJ1IZ3+WDHjuuODSaPNazQeiIEbWhZrfwd+c0x55VeSY0yolSKWsOQ9khuCpS5LqklxgO+/VPqhsUO36cgEXtJNtxuXp4CIirhkmYyC0YvdEW9J3wnlgydHOofVaqY6AnF2gL0GvGYPrVCwax8wlQsU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718130127; c=relaxed/simple; bh=aZIw2wIw6HZncUZ9BiHGTY56QThK53FOhX5SS3cSeC8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=lW9t6WEzQpctRHfuPeeRlhdNm5x/E4ArhjM7A1drc+d25F03UyUEreqCKmrOlBASKTUMRqk/bEcLF/MjdaxOFUkYetQAwfMVVzYN9jiARoiW2bFX0UZLZdbe5gqXnj6S24s8L8MsAVPELVkKgYIAArHoGlOqy/DH5Lqx+e2/v5I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=G+EiwD4G; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=v+biT19hMk3zmDJ0JM4Tlgb3u1aCfIc9jRZYIonIyMw=; b=G+EiwD4GDC9cHvXeCq1YHv7ti/ IlYTLigKWg5uv1EP0m2ybhYhGX9h/GnK3Hq5lwa2LxVKZDbmMrx+ifr/gJD1jXzUu9Nn7REYTzNJz CIeTPq+SURoWmu7zjSItVG/hbpeDrAbHF6GgqvufLdPYB+c9PHtctRqIcjYqPf/xD8YBKpt03+b65 VS1AwqXwbhM4Az0f0HjF68guIUL4sj11S3+ONs2WpSLuPfRvgAPR3KptfXUYnvicH+oYupZhxnEk5 JtdTIvo2npekB4qU11ivs6xb9vLohXCzoj/vAbxDoXiWdmfu20hjbIlQhpIFf8JoO4djRr0qnPRdj R5zIZyjg==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sH68B-0000000Dwm0-2FcS; Tue, 11 Jun 2024 18:22:03 +0000 Date: Tue, 11 Jun 2024 19:22:03 +0100 From: Matthew Wilcox To: Andrew Morton Cc: David Hildenbrand , Andrew Bresticker , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mm/memory: Don't require head page for do_set_pmd() Message-ID: References: <20240611153216.2794513-1-abrestic@rivosinc.com> <8040793f-e9e9-4a2e-807c-afcb310a48f5@redhat.com> <20240611110622.8e9892e92618ddc36bca11b7@linux-foundation.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240611110622.8e9892e92618ddc36bca11b7@linux-foundation.org> On Tue, Jun 11, 2024 at 11:06:22AM -0700, Andrew Morton wrote: > On Tue, 11 Jun 2024 17:33:17 +0200 David Hildenbrand wrote: > > > On 11.06.24 17:32, Andrew Bresticker wrote: > > > The requirement that the head page be passed to do_set_pmd() was added > > > in commit ef37b2ea08ac ("mm/memory: page_add_file_rmap() -> > > > folio_add_file_rmap_[pte|pmd]()") and prevents pmd-mapping in the > > > finish_fault() and filemap_map_pages() paths if the page to be inserted > > > is anything but the head page for an otherwise suitable vma and pmd-sized > > > page. > > > > > > Fixes: ef37b2ea08ac ("mm/memory: page_add_file_rmap() -> folio_add_file_rmap_[pte|pmd]()") > > > Signed-off-by: Andrew Bresticker > > > --- > > > mm/memory.c | 3 ++- > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > diff --git a/mm/memory.c b/mm/memory.c > > > index 0f47a533014e..a1fce5ddacb3 100644 > > > --- a/mm/memory.c > > > +++ b/mm/memory.c > > > @@ -4614,8 +4614,9 @@ vm_fault_t do_set_pmd(struct vm_fault *vmf, struct page *page) > > > if (!thp_vma_suitable_order(vma, haddr, PMD_ORDER)) > > > return ret; > > > > > > - if (page != &folio->page || folio_order(folio) != HPAGE_PMD_ORDER) > > > + if (folio_order(folio) != HPAGE_PMD_ORDER) > > > return ret; > > > + page = &folio->page; > > > > > > /* > > > * Just backoff if any subpage of a THP is corrupted otherwise > > > > Acked-by: David Hildenbrand > > You know what I'm going to ask ;) I'm assuming that the runtime effects > are "small performance optimization" and that "should we backport the > fix" is "no". We're going to stop using PMDs to map large folios unless the fault is within the first 4KiB of the PMD. No idea how many workloads that affects, but it only needs to be backported as far as v6.8, so we may as well backport it.