Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2496177rdb; Wed, 21 Feb 2024 09:16:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXgeJCrX3ojBUh53vBe1izDYbDgWxvY+pjbpvcnwhgNylR9zxsTuNdScdw/UvP14qisNG3hhCZ5j9UvVhxJv61czdD5+isefIa3djTFXA== X-Google-Smtp-Source: AGHT+IGcpH2KAnBdHDVpw7dKHgfGQ6lF6Zh5tukxlPfVdFwr6YCyHIuTQWUB5bsPRI1R0DyDd77w X-Received: by 2002:ad4:5c6c:0:b0:68f:8977:3bd1 with SMTP id i12-20020ad45c6c000000b0068f89773bd1mr9579881qvh.30.1708535797324; Wed, 21 Feb 2024 09:16:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708535797; cv=pass; d=google.com; s=arc-20160816; b=T21iyiVlBEEOG3WjMUOx/W74hZdK51FDCVlruO5tzZNy1b7mLT8Vh7RwfxMsWaxQZ2 19lLxCt/Ibs8BCyK3frrESd4pOKQBtybfY57WlR/1sPa0ay7wmgQnmupouQuSwqlvnrP zsMC1Fnx6oGqzcoR7oS6ukOffBZkCM/jxW9zQDEWe1H0hVHS6LlqHOdD9Xj+hSnx62vE NjtRfP+aCE5V1lF/P5q0i7zxJhiZYF2LrLCIEWP9dzE2dbTMHlt+3cvRmKg3CDuAjpZi aSOLGlZBhpWYHgY1MtEZ8vvzUbzZsfy4Y6xxKnVxRjqxlr7CnyrdXGWYAbhIhGGIChHZ RUYA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=SJQdC7idwulVMBcihj7Q1mmstXpwh/b+WQal363i4yI=; fh=xsTh0Z14mt2zr9Pmw0Ud8xZAHuxp516tNQUiRyeoVWs=; b=se4FSS+ScB6x+0p9LQHNEhEFV7mVWPVKNudDnkCe/gB5cHq4V4QmtJAksGibnlDsCf rDzs1B/fl7nMOrdFw0dR9nW5aC/UcBXGvT0vbXES2yHVnrlLjxkW3OzMCRa7I/gsyp7X b7rRv1xPeT8Bb+Pgdr3kuhhC90NvNRPwiJVrf0G4otelGrY9tIvOX6Fs3NWAl/w1RcoT h3MSZmjPGqxMnEkE1fENFQ2KyP+YtpAs00g21G5ZCn1jWftgMkaPFsO0bFXA5nU99zmy maPW2DT5cgmbRy4Umo8cJRK7NHNbumjf6xgVCREe9EoxdKZUBm3NijbP+PkVrTcESYg5 BhQw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=COE6zeRD; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-75176-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75176-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id h1-20020a0562140da100b0068f57389198si9182157qvh.496.2024.02.21.09.16.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 09:16:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75176-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=@gmail.com header.s=20230601 header.b=COE6zeRD; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-75176-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75176-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 0AF2D1C22C09 for ; Wed, 21 Feb 2024 17:16:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 03A1E83CA3; Wed, 21 Feb 2024 17:16:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="COE6zeRD" Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9DBFE81737 for ; Wed, 21 Feb 2024 17:16:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708535765; cv=none; b=h2Vjz/zQTptRqCVqjyDH2L8KdSDAobcbRMoOgSDEpOxeeEGpFHR0UHFlmZ3h3HIrV2rHBmx0PhC+S71wQSeU48sAxLb3zGcAw+2MUgr1RUtdcg+ytPs8vbFm1ZLN1dhdJ0/erv7SxwqcoKoFOXEMsEMMETp3JRlvLztfCELyAlQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708535765; c=relaxed/simple; bh=RXmp5LBrNh470eyA/9PolaZXtxVx5YgBsg7qcaw0eTA=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=e7rDfVwjkGUOGBiBjRgst6wcwTo86Hgz5WH46hbEMlr/NLo06oW+9+fMhlUMwscWOW7HNFwlwA0SEFOctkEvGnO2Z1fHFpwLANmZbST573kx3TbzY1OVk/rImAiJpv0yVSiHEho+ZwvINc+gUs6WsFP2YTAXGjY3EYh6MUwDdCc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=COE6zeRD; arc=none smtp.client-ip=209.85.128.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-607f8482b88so53066637b3.0 for ; Wed, 21 Feb 2024 09:16:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708535762; x=1709140562; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=SJQdC7idwulVMBcihj7Q1mmstXpwh/b+WQal363i4yI=; b=COE6zeRDvNsWRujldSS4UYvKgTAEMrutNC7PPDX6tYxOKMAIuv4ihyd7wPfGJsPVYr RySAvhv2R67iVDWZucm0gxOEKFyD9603O1IPwc+keRdD4GSMI56PKf7cu9RKD9Q5YJNO fAzSLRAiaQ0ef4LQ7JDVoUoKot4oHaE30ufEumWmQWIUg4NTPROsg3WG5txp22iuJvwd PtRpDruQFpe5xLMTjFnxT5cvFZWw11FyVtEldSPyOEs0EAJuS7i2iHGA9OWlP7wkIyiQ /HF52mE6dDlHvlDcNA6/zs3qySgFdYVLTbQXH5gxHsFmS3PdWZR916JnwVNdLRq76unA KB5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708535762; x=1709140562; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SJQdC7idwulVMBcihj7Q1mmstXpwh/b+WQal363i4yI=; b=FVkSsJWJZHudUNaEpex4/Jmdi7MQDoQTZeJmNtGrgsxgYhG7/nFakoSDeKMNuHO3XC B2jOcdjm0lmbKPbMJRLoteDXk+a62ZXtIDK0r/pK1MBACyohWUmN1L9m3i+PkGvUn8zr UyNKD9yO2vs3OS+kxHX6jpaJHZzlX4fOpTwXmpe4CqyZYzvvm0U4UJu8CsfS+TGF5cwp U+doJ8l+jcY0nJOJSthIBi+elXj2s9PK8qIXeeu+SepjcLEqXs4S8Nch2YWIPbOQgr8/ 0RPlwf5CCuPdkCMBHKjzywvjxyySX6CDsDmCfP2tKRVzGY31jpLRerETP+09Y6ti7ImW nATQ== X-Forwarded-Encrypted: i=1; AJvYcCVFx6u5qbctwQ+nqPHQSYRMB8fKueDo6QlbO2bZ/1o4qMfwXhllVoU2QbEIw/y2O/uN4ryx6V7T5NYYYkwNRznABnFBXiAhroxgwSsv X-Gm-Message-State: AOJu0YxzyUso/VwQYSLuYo13wkB32nXgOSRi7hLgrvB9Eqk1mHL/1/pp LvDGGMGeSnBpRQUhCIEoGTmFwFOItm7/KlO8hBFpcjo2vt5AAU25H4H+b2T+7zu4kKIAgHTsk/J p9JMOW2AaKJW6301JCcf4cGGSL3dUZ0mE X-Received: by 2002:a81:a103:0:b0:607:9d63:1a85 with SMTP id y3-20020a81a103000000b006079d631a85mr17916533ywg.44.1708535762484; Wed, 21 Feb 2024 09:16:02 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240220231424.126600-1-vishal.moola@gmail.com> <20240220231424.126600-3-vishal.moola@gmail.com> In-Reply-To: From: Vishal Moola Date: Wed, 21 Feb 2024 09:15:51 -0800 Message-ID: Subject: Re: [PATCH 2/3] hugetlb: Use vmf_anon_prepare() instead of anon_vma_prepare() To: Matthew Wilcox Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, muchun.song@linux.dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Feb 20, 2024 at 7:46=E2=80=AFPM Matthew Wilcox wrote: > > On Tue, Feb 20, 2024 at 03:14:23PM -0800, Vishal Moola (Oracle) wrote: > > +++ b/mm/hugetlb.c > > @@ -5834,9 +5834,15 @@ static vm_fault_t hugetlb_wp(struct mm_struct *m= m, struct vm_area_struct *vma, > > struct folio *old_folio; > > struct folio *new_folio; > > int outside_reserve =3D 0; > > - vm_fault_t ret =3D 0; > > + vm_fault_t ret =3D 0, anon_ret =3D 0; > > Do we need a second variable here? Seems to me like we could > unconditionally assign to ret: Hmm, looks like we can directly assign to ret without any problems in both functions, I'll change that for v2. > > - if (unlikely(anon_vma_prepare(vma))) { > > - ret =3D VM_FAULT_OOM; > > + anon_ret =3D vmf_anon_prepare(&vmf); > > + if (unlikely(anon_ret)) { > > + ret =3D anon_ret; > > > > > unsigned long haddr =3D address & huge_page_mask(h); > > struct mmu_notifier_range range; > > + struct vm_fault vmf =3D { > > + .vma =3D vma, > > + .address =3D haddr, > > + .real_address =3D address, > > + .flags =3D 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 g= o 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.