Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2516286rdb; Wed, 21 Feb 2024 09:55:33 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVWTVnUwBMWOnDpIUGV23CaylYSb7WghHv+kE3cLN6MPImKskXiB8Ie70i9KT6yqXrKTAeKt2/sxjJiCDYkr4VqeMvQ+kLRs+kMahND4Q== X-Google-Smtp-Source: AGHT+IHpHebfeEUoWkuEoeVbgxacmHbuSgsFUOVu2tDQjQSF82XYnIUChNDxwCU4gWhO98y8qYyf X-Received: by 2002:aa7:d984:0:b0:565:2082:20bd with SMTP id u4-20020aa7d984000000b00565208220bdmr435767eds.27.1708538133796; Wed, 21 Feb 2024 09:55:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708538133; cv=pass; d=google.com; s=arc-20160816; b=lOoX4ey2Dk2Wg4qG5H+xTg9hYX/DA0G6pNrQxqNmzn2Nus5hA2xASjKWxvf3mMS1U0 J1otuq1C7Tbx/tcFATSCbRo48FlPoY0wEfgzaGfayiBFPQpfWFYwUlUjhOViDxNqMJ16 U8vji9DmUUoFDKsByvzHKTxamMZHvZkEFp3mVXCXYUDQtjO+/vsymo2n4JlTwKgXicX1 j09fml0wPgahvED5OgrXNhomrcHiinPSAYo8wZWQySe9GqWimhVz23e5I25WTtv810Hu pI98SMO30D7wiWz7txfLGkkAwPqVmg0ml2MEHvTIuPT9tyNaBlhDWY8Mwrw71dY5qgT8 jYyQ== 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=wRp1w5Zyb5jyGjRVjFlb00/lPh/g4wKdCacDA3p0w8g=; fh=9LT7OASmA7DXBorlvv0DnSLNjqGVnk7cWb8tQ3LoeX4=; b=tVOpeCJBok6pZcJHxJDQc7rezXT6kSZQGd8CXjY5meu5ASXRMK1h5xTrK5eIhDNXjs +aFgC+eXwnJYUUB47XoAh7dmEQ2W+07/sAzfFf4mjw9F+6JZcKGRVESX5a4j5KZHdwmZ SkblTv7f2GSG+9JhqE7IZaRx47vX9qCFaJ0ItU9lbGS9toHzCk/+UIz0MuWuwwBwFm3S oFA/PBFKGOtItngFtYOk6mQJUfgtVSq1iPgyYT6GhBHmE2px99oe9fJq+fzGUZFfcCgz BHztGFUKIVcjt46g74dkhUZxzxeH+JsNjloFWmrgFE6qJSYJhasmsFub+UukVIN/DXyN wFUA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=UovlAaKW; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-75234-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75234-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id n20-20020a5099d4000000b00564566672b6si3344273edb.303.2024.02.21.09.55.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 09:55:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75234-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=UovlAaKW; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-75234-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75234-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 829CC1F23B2F for ; Wed, 21 Feb 2024 17:55:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EA36B84FCB; Wed, 21 Feb 2024 17:55:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="UovlAaKW" 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 F06F283CC7 for ; Wed, 21 Feb 2024 17:55:20 +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=1708538123; cv=none; b=H3VcDJfS++W/uGuGVsGZJyW2ag/oI+OfXdBHK2QclDY8oq8ls7zmxKwMtEsi9ixXABnFwboT42Vct7/IihnfrdKdtAawkBMZPcv8fV8JlXkHMGow3e4TnNfXYDDT0tf3K7nDc8swn1+v8Jpk4XHkAL5CI66eOszkayOaJZ0Ebqg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708538123; c=relaxed/simple; bh=WnozabPfgyLgQuSJlmU9bbQ6aXri5w7SUQ2o65f0ySM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FgV027EFzhGWqKnndzFd2mgHiMCzK+t3ExjZZ+MMatij2dRMN/0nWpI9H4FD3Qy49W+I+tErsnuuGGvAottvwy7ohcob9VSeitT2upY1z3SyN2qvEDmvkc5AkCZYgdts0klLdXYWUwQgptrNIBV72bIzjpij9caQwPzyo9HvawI= 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=UovlAaKW; 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=wRp1w5Zyb5jyGjRVjFlb00/lPh/g4wKdCacDA3p0w8g=; b=UovlAaKW6CTiINlkME0xjm1y/g 016q0sdMdEI9eGIVOzP13bTWo4rtMN3kwiwfvKS1b3JAacPz8zTuAioBslASuR3clZVqXVYYVImfP lPvHgEot5y1d0w2kiUe2SZtzCAhYAVQDHbGHztUaQBbUGFsaHYkfftJSVqvvInmFtV+qHqj0+fCiK dNw9dgVwOp3Wgc4K247DECSAhadEBSJ1HsFuxlbFkZEkQFmZRe1pqBmxumbMnkNvPXth416tI+Kno KZ+yz+geZhDXPZ6PYfhomxGQyqBhQLXIdpnEuue5dGy1o+Y6hAeWZFuX6lCLAkUUZb5IWcXL1fISe kgtXThPg==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcqoP-00000001KuE-3Xc7; Wed, 21 Feb 2024 17:55:17 +0000 Date: Wed, 21 Feb 2024 17:55:17 +0000 From: Matthew Wilcox To: Vishal Moola Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, muchun.song@linux.dev Subject: Re: [PATCH 2/3] hugetlb: Use vmf_anon_prepare() instead of anon_vma_prepare() Message-ID: References: <20240220231424.126600-1-vishal.moola@gmail.com> <20240220231424.126600-3-vishal.moola@gmail.com> 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: On Wed, Feb 21, 2024 at 09:15:51AM -0800, Vishal Moola wrote: > > > unsigned long haddr = address & huge_page_mask(h); > > > struct mmu_notifier_range range; > > > + struct vm_fault vmf = { > > > + .vma = vma, > > > + .address = haddr, > > > + .real_address = address, > > > + .flags = flags, > > > + }; > > > > We don't usually indent quite so far. One extra tab would be enough. > > > > Also, I thought we talked about creating the vmf in hugetlb_fault(), > > then passing it to hugetlb_wp() hugetlb_no_page() and handle_userfault()? > > Was there a reason to abandon that idea? > > No I haven't abandoned that idea, I intend to have a separate patchset to go > on top of this one - just keeping them separate since they are conceptually > different. I'm converting each function to use struct vm_fault first, then > shifting it to be passed throughout as an arguement while cleaning up the > excess variables laying around. In a sense working bottom-up instead > of top-down. I think you'll find it less work to create it in hugetlb_fault() first. ie patch 2 could be to hoist its creation from half-way down hugetlb_fault to the top of hugetlb_fault. Patch 3 could pass it through hugetlb_no_page() to hugetlb_handle_userfault() and remove its creation there. Now you've alreedy got it, and can make use of it in this patch which would be the new patch 4. If you want to do a cleanup patch afterwards, you could hoist the vmf creation all the way to handle_mm_fault() ;-)