Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp727089lqe; Sun, 7 Apr 2024 00:37:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVsPe/xn78SJPaiS/xZdVIqAABxQSB6tCRIF9n2mTNXkrCt9dAnaACmQ1rgf2BaltWoQxNV95dNAx/277WJ2af0QJpiH1J6CbZmAi+LvA== X-Google-Smtp-Source: AGHT+IE4O75ZhcEh+81x3aqUN0MG9S3/D45wvXAg5XQ5SKsOYSViorNw+Jq+9LSbymgg9rj79p6B X-Received: by 2002:a05:6e02:9b:b0:369:c0a3:2ad2 with SMTP id bc27-20020a056e02009b00b00369c0a32ad2mr8332438ilb.16.1712475444518; Sun, 07 Apr 2024 00:37:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712475444; cv=pass; d=google.com; s=arc-20160816; b=EWV74pYrF+87CM2R+q8MvTrAJMS29GGYv6X5+AROeuOeyqmqJ5WrCCDIkHeprI+fbV jgQ+FRMgdHEgkWB4QX8WN6FdfLsL9z8LgTwOB3tE0zEGb93BqjTKcc/QCA9KppKcGzN2 mTTkICggQ9ZrtOkJ3DWpjMBYgYKXLlvLQpNkyiYnZHsHFsTkR5etttIuKpmVMw1Sv5xh jKdfx6SCOirf3f0D9DK0ExXrGvdqGBfjkKc0iVhPCRB6ztE+wWjOVFuu/rOJA+9+92Z6 CEwMXQHtqBLvtr3JDoYxdwwZxjLq8tATfoFT1GKTxlHj0n+2XhDwyxzK5YSQdHP93K4j 82lA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=0Bahn4KQkeBpv/q05dP0qudxz14FvAOhzQLd0ktghZo=; fh=xzgbVgykbOZqFbUfbEPcvtAkPM2SJQlvWQyez4SMqCk=; b=Zcw7nQQMW6J1W5Jh31l8avYJpiRnwhX/dXr80cjd2QdNIOBrz46711iBTpxr6znBeD aM/2FdUSMiauqhLkOCv1ycsyIR95w+c6IaM3bLkUYT0xulwLFAzxidx1FCwTS/3KL6eQ b08BHFjSi96VIoTwlEN5hbiWtgJgNaxCStTY2SbWuKke9QNSSQFra77Fuac9uAAD6hBr 5ZuWNxbGfgToLd9AcD3YJtUMhmL6mCzGnTna5yqXnGCXYS3K5TNNfQkyoLtTzmxjsS10 HhumLLu8rNm1mFpIT2dyte+RHdY/RdQqaNbBsF0TM9Rl4QKzv3a07LML7RndiXBLXEYV TBHw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=dNt3tV3X; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-134226-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134226-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id h12-20020a63c00c000000b005d8b2b582dfsi4232361pgg.837.2024.04.07.00.37.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Apr 2024 00:37:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-134226-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=dNt3tV3X; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-134226-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134226-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 2944C283CDE for ; Sun, 7 Apr 2024 07:37:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 54EC7E56A; Sun, 7 Apr 2024 07:37:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="dNt3tV3X" Received: from out-187.mta0.migadu.com (out-187.mta0.migadu.com [91.218.175.187]) (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 E1CB17483 for ; Sun, 7 Apr 2024 07:37:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712475439; cv=none; b=AT8+VQSpL/yezrIXhKaggAUfmzEgOHcrIVCvLprbe29SIFVCM2mxJuEhUUL6HZubaQf2V8Rk3pU884NhARn1tIo6rGka17e4B897dUFKtkFrkjw7xpMbJ01tSPC5nzdJ7Z9cAWAeFI0cGJZv94W8OVhCO7bIJWdJWLOycPXsdg0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712475439; c=relaxed/simple; bh=ifvSm+8K5bMmWjHLvREuVwcxQRti83HpgGfPaXqTGSs=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=em8POCu/4wDUvIaiQLM48jqaA762JNQFR7Yx1asfUMziQpSkM3DQ/l5LzxkbYxTuteVTLaXBf1nXYx/Hsmc7M1rLfwdZa2mulE7PRWsOug8HOunCGdhEbiwYGQjDXLy6HYAS9h1G3VeMCYs+xA61MGKk5xah7BMoBYXQRBm6PgY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=dNt3tV3X; arc=none smtp.client-ip=91.218.175.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Content-Type: text/plain; charset=utf-8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1712475434; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0Bahn4KQkeBpv/q05dP0qudxz14FvAOhzQLd0ktghZo=; b=dNt3tV3X/x1eFdBkdX9rtEbIxNSBBvklJ9jTVTQMJBQbW0XgXfH2oqZlTeJOMjcan7QjRi yM+MxrtNmgsKHnvPgTlCs6QpZ4aJ6HEvOOkUOQtMkYlJkfw60fwDjulqvo/rrBoi18nYDC zwGnXXkMgQGBWyJtt7dBxR51t8rMHiE= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.500.171.1.1\)) Subject: Re: [PATCH v2 1/3] hugetlb: Convert hugetlb_fault() to use struct vm_fault X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: Date: Sun, 7 Apr 2024 15:36:39 +0800 Cc: Oscar Salvador , Linux-MM , LKML , Andrew Morton , "Matthew Wilcox (Oracle)" Content-Transfer-Encoding: quoted-printable Message-Id: References: <20240401202651.31440-1-vishal.moola@gmail.com> <20240401202651.31440-2-vishal.moola@gmail.com> To: Vishal Moola X-Migadu-Flow: FLOW_OUT > On Apr 5, 2024, at 03:32, Vishal Moola wrote: >=20 > On Thu, Apr 4, 2024 at 5:26=E2=80=AFAM Oscar Salvador = wrote: >>=20 >> On Mon, Apr 01, 2024 at 01:26:49PM -0700, Vishal Moola (Oracle) = wrote: >>> Now that hugetlb_fault() has a vm_fault available for fault = tracking, use >>> it throughout. This cleans up the code by removing 2 variables, and >>> prepares hugetlb_fault() to take in a struct vm_fault argument. >>>=20 >>> Signed-off-by: Vishal Moola (Oracle) >>=20 >> Reviewed-by: Oscar Salvador >>=20 >> A question below: >>=20 >>> mm/hugetlb.c | 84 = +++++++++++++++++++++++++--------------------------- >>> 1 file changed, 41 insertions(+), 43 deletions(-) >>>=20 >>> diff --git a/mm/hugetlb.c b/mm/hugetlb.c >>> index 8267e221ca5d..360b82374a89 100644 >>> --- a/mm/hugetlb.c >>> +++ b/mm/hugetlb.c >> ... >>> /* >>> - * entry could be a migration/hwpoison entry at this point, so = this >>> - * check prevents the kernel from going below assuming that we = have >>> - * an active hugepage in pagecache. This goto expects the 2nd = page >>> - * fault, and is_hugetlb_entry_(migration|hwpoisoned) check = will >>> - * properly handle it. >>> + * vmf.orig_pte could be a migration/hwpoison vmf.orig_pte at = this >>=20 >> "vmf.orig_pte could be a migration/hwpoison entry at ..." >>=20 >>> - entry =3D pte_mkyoung(entry); >>> - if (huge_ptep_set_access_flags(vma, haddr, ptep, entry, >>> + vmf.orig_pte =3D pte_mkyoung(vmf.orig_pte); >>> + if (huge_ptep_set_access_flags(vma, vmf.address, vmf.pte, = vmf.orig_pte, >>> flags & = FAULT_FLAG_WRITE)) >>=20 >> Would it make sense to teach = huge_ptep_set_access_flags/set_huge_pte_at() to use >> vm_fault struct as well? All info we are passing is stored there. >> Maybe it is not worth the trouble though, just asking. >=20 > Yeah, it makes sense. There are actually many function calls in the > hugetlb_fault() and > __handle_mm_fault() pathways that could make use of vm_fault to clean > up the stack. >=20 > It's not particularly complicated either, aside from reorganizing some > variables for every > implementation of each function. I'm not really sure if it's worth > dedicated effort > and churn though (at least I'm not focused on that for now). Not all the users of set_huge_pte_at() have a vmf structure. So I do not think it is a good idea to change it. And huge_ptep_set_access_flags() = is a variant of ptep_set_access_flags(), it's better to keep consistent. Otherwise, I think both of them should be adapted if you want cleanup. My tendency is to remain unchanged. Muchun, Thanks.