Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1608960rdb; Tue, 20 Feb 2024 01:08:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXsqwf8UZCVjGbP2PsK0Y84fEjafqR1gfaZ8c3MjpUy4vY+UsFSxVilKvRaR9OzUFE9qecy2GOcRpd9CaCHgJAyx2t63eTi6OQ7aLEiKg== X-Google-Smtp-Source: AGHT+IFb4spW7n3UH22nYb/JmcQDzchQG36pu6mvhBxjZmwJN+g+ElEseBOKZf4+fKpC3DsOKzQn X-Received: by 2002:a05:620a:575:b0:787:7604:9450 with SMTP id p21-20020a05620a057500b0078776049450mr1407962qkp.2.1708420116195; Tue, 20 Feb 2024 01:08:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708420116; cv=pass; d=google.com; s=arc-20160816; b=OtEphtJWafHmlIvqec64ViysEv1TxtfDmwFe/27e0wBiQooFJbNnpwRnwM/f7sJ9Ln CWVg8ZUNBziTLL59Kq0E/bMlBp0S9BlDfhEOccPQbdwCAZ0bs/e1dJ5g/fceB7J4nws6 o+Ovtvn1Lz+nfNlx3x8DbpvxJji7ydRlW4jNeswby7sU5FvD0vjxQ4NCQmVYvdspknzj YJjldKGaOyzY7TTfgKcIel6uxs/tkwjT8bW1w9KPLB3eg3aEipoW6A4Zi8t5mOrboRTm b7wSFnwVaW0HUDC1c/yisNB8xmUeK7JOtMpMC1+DMSj1/ZGxE5+0yZrHuiEFepbEGafn mLMQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:cc:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=Z/9qAJRbr+IjD7DqBzC1cp1ZRpZNaDoD2Bb8K2RbsXU=; fh=rT1XAkbInxrT1zG8dr8hVoF1oKbPvBYRLPOdTrTYKfo=; b=PiUNDoAwm22S51pzPdPaVbqDb2LhMrhEwTEFv7glpJ0OHLDutDQqideGZ6i4KC4x9D CGHoS6SNTEi4FioaNb4vKfReed43H4bLTJKVpYr8Mb1IVe2CWNDpzgE8JAKn52zDZDaw smP9EB6vAzOiHToP3eg6jE8kqf4hF5/4kcrHZCiZoq9YbBCDGX33HOlXbb2yk9zjlKEj RmKw4c2QESOobjH8zon3JkrsT1fMBYNyEGrQ1r0cgo3QY6U5UMDDl3WWpGQWckfds9Fn NkqKNHxkcsY4Nh+FgmTJgXl3XgOHrkPyeb0ZB1AEW5ckjoFKpdxyJdyVlbzn9p9McDlH 1H6Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-72651-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72651-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.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 d17-20020a05620a137100b007877462270asi1699879qkl.528.2024.02.20.01.08.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 01:08:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-72651-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; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-72651-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72651-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.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 E693D1C23EB1 for ; Tue, 20 Feb 2024 09:08:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 94EFD62178; Tue, 20 Feb 2024 09:06:43 +0000 (UTC) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) (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 A1267612FE for ; Tue, 20 Feb 2024 09:06:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.189 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708420003; cv=none; b=cS/XLZ0Mo0XWNcHI6v9l+OoRSzNK/ZXqFZnZ3mCERob1vKHnrvjGyCjE+YMwjkjVG295dRTnIuKlyTJ8pJoZtfU6GhQxQJcL/OWsFDgdxQ1W3V1O5JuG2NeHCRRqQatJPtUT/M/33DB7aMWyA9L9WgnhzSmflgb+li4DSmFhTKY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708420003; c=relaxed/simple; bh=BgDdgeT23PH+yWwPYSF9gJbEqkYMbmFf4IwbU1QNQWk=; h=Message-ID:Date:MIME-Version:CC:Subject:To:References:From: In-Reply-To:Content-Type; b=l8/9RofhFfTjrW9W/Nvaf6maYnHboAgx2wDmJaX6kLcGkoK9LAxENpBr7iB9ztq3B7FzJb2oqCJWOrgLHm1P/25iDkX477+jsXBxXohqFEJNrHOqy6mYVBNvcjABRLzQkAhopVcXJjgWxqX9VsBqszbdW/LpgBFX/M4aN9pLnRU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.189 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4TfD511Fd2zNlnc; Tue, 20 Feb 2024 17:05:09 +0800 (CST) Received: from dggpemd200001.china.huawei.com (unknown [7.185.36.224]) by mail.maildlp.com (Postfix) with ESMTPS id 0EE3818005E; Tue, 20 Feb 2024 17:06:31 +0800 (CST) Received: from [10.174.178.120] (10.174.178.120) by dggpemd200001.china.huawei.com (7.185.36.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1258.28; Tue, 20 Feb 2024 17:06:30 +0800 Message-ID: <1f98fd3a-9a2c-437e-8e86-8c5f575917df@huawei.com> Date: Tue, 20 Feb 2024 17:06:30 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird CC: , , , , , , , Subject: Re: [PATCH v4 0/3] Cleanup for PAT To: , , , , , , References: <20240220034835.507022-1-mawupeng1@huawei.com> <07d43633-d707-415d-a662-ecd3a50b12ae@zytor.com> Content-Language: en-US From: mawupeng In-Reply-To: <07d43633-d707-415d-a662-ecd3a50b12ae@zytor.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemd200001.china.huawei.com (7.185.36.224) On 2024/2/20 16:37, Xin Li wrote: > On 2/19/2024 7:48 PM, Wupeng Ma wrote: >> From: Ma Wupeng >> > > This patch set is all about follow_phys() cleanups, so "Cleanup for PAT" > seems too generic. > >> Patch #1 move follow_phys to memtype.c since only pat use this. >> Patch #2 cleanup parameter in follow_phys. >> Patch #3 drop the unnecessary WARN_ON_ONCE if follow_phys fails. > > I'm more curious why follow_phys() ended up this way? > > follow_phys() was introduced in commit 28b2ee20c7cba ("access_process_vm > device memory infrastructure") in 2008 for getting a physical page address > for a virtual address, and used in generic_access_phys(). And later it's > used in x86 PAT code. > > Commit 03668a4debf4f ("mm: use generic follow_pte() in follow_phys()") made > follow_phys() more of a wrapper of follow_pte(), and commit 96667f8a4382d > ("mm: Close race in generic_access_phys") replaced follow_phys() with > follow_pte() in generic_access_phys(). And the end result is that > follow_phys() is used in x86 PAT code only. Thanks for the explanation. I have a better understanding of the history of this function. > > As follow_phys() in untrack_pfn() can be replaced with follow_pfn(), then Yes, this can be replaced with follow_pfn(). > maybe we don't have to keep follow_phys(), and just use follow_pte() in > track_pfn_copy()? As follow_phys() will return unsigned long *prot which is need in track_pfn_copy(), we need to do something with this. Can we replace follow_pfn with follow_phys()? Thanks! Ma > > Thanks! >     Xin > >> >> Changelog since v3: >> - rebase to latest linux >> - fix compile warnings >> >> Changelog since v2: >> - rebase to latest linux >> >> Changelog since v1: >> - split patch #1 into two patches based on Boris's advise >> >> Ma Wupeng (3): >>    x86/mm/pat: Move follow_phys to pat-related file >>    x86/mm/pat: Cleanup unused parameter in follow_phys >>    x86/mm/pat: Remove WARN_ON_ONCE if follow_phys fails >> >>   arch/x86/mm/pat/memtype.c | 32 ++++++++++++++++++++++++++------ >>   include/linux/mm.h        |  2 -- >>   mm/memory.c               | 28 ---------------------------- >>   3 files changed, 26 insertions(+), 36 deletions(-) >> > >