From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDC2DECAAD3 for ; Thu, 1 Sep 2022 10:40:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 820DC6B0073; Thu, 1 Sep 2022 06:40:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7CFA76B0074; Thu, 1 Sep 2022 06:40:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6978D8D0001; Thu, 1 Sep 2022 06:40:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 5A8ED6B0073 for ; Thu, 1 Sep 2022 06:40:21 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 309F740881 for ; Thu, 1 Sep 2022 10:40:21 +0000 (UTC) X-FDA: 79863172242.19.E82472B Received: from out199-1.us.a.mail.aliyun.com (out199-1.us.a.mail.aliyun.com [47.90.199.1]) by imf26.hostedemail.com (Postfix) with ESMTP id 3FE2114006F for ; Thu, 1 Sep 2022 10:40:18 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R981e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046056;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=11;SR=0;TI=SMTPD_---0VO01loO_1662028813; Received: from 30.97.48.53(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VO01loO_1662028813) by smtp.aliyun-inc.com; Thu, 01 Sep 2022 18:40:14 +0800 Message-ID: <3ade5518-ef08-c353-1333-73a26ca28102@linux.alibaba.com> Date: Thu, 1 Sep 2022 18:40:26 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: Re: [PATCH] hugetlb: simplify hugetlb handling in follow_page_mask To: David Hildenbrand , Mike Kravetz Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, inuxppc-dev@lists.ozlabs.org, linux-ia64@vger.kernel.org, "Aneesh Kumar K . V" , Naoya Horiguchi , Michael Ellerman , Muchun Song , Andrew Morton References: <20220829234053.159158-1-mike.kravetz@oracle.com> <57c8f032-e48a-bacb-7922-3e2cc10dc0d2@linux.alibaba.com> <0a8025eb-cf15-453a-7d7d-7c72d008889a@linux.alibaba.com> <02209dba-532d-a033-2dba-077ed26c8c6a@redhat.com> From: Baolin Wang In-Reply-To: <02209dba-532d-a033-2dba-077ed26c8c6a@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662028820; a=rsa-sha256; cv=none; b=cFh2y6+RRz5jgN4w97H6VVIdA8WSlLOaPLY8h5NpLSiPR5czjIKIQMJERJwFrM5Y3kDKhL nPuYy43gBfuei+72ba9j/lGYPfEEH80Lrj9f9//MkclkZWEu8S4iEdwhZmFGjhVw12fA1U a+dnZncLKzjs080L8d2zExGbDEfpeRs= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 47.90.199.1 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662028820; h=from:from:sender: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=JBuAu6NrRKo7vAEoSFfUCnycWq7MfnuDEybiqtgH8DM=; b=MIfBdtOGIlM5iNG1jzzII63XuU/txvv1jockStmn4XFnNiH9nkWDGC9tjozC0MUpxMa258 v//01ZtqDvHBi5BNfZMWBq84ztw46lTJgSCiKIMtotOEPdxoaMC3W1Ooxq05WtefyOYSyZ ZT1NyBb5XCNagMnBZPKR/U574i78fTI= X-Rspamd-Queue-Id: 3FE2114006F Authentication-Results: imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 47.90.199.1 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-Rspam-User: X-Rspamd-Server: rspam01 X-Stat-Signature: dh83cit67xc5qor3ypj4nkkgbirrq9im X-HE-Tag: 1662028818-300844 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 9/1/2022 2:59 PM, David Hildenbrand wrote: > On 01.09.22 03:24, Baolin Wang wrote: >> >> >> On 9/1/2022 8:00 AM, Mike Kravetz wrote: >>> On 08/31/22 09:07, Baolin Wang wrote: >>>> >>>> >>>> On 8/31/2022 2:39 AM, Mike Kravetz wrote: >>>>> On 08/30/22 09:44, Mike Kravetz wrote: >>>>>> On 08/30/22 09:06, Baolin Wang wrote: >>>>>>> Hi Mike, >>>>>>> >>>>>>> On 8/30/2022 7:40 AM, Mike Kravetz wrote: >>>>>>>> During discussions of this series [1], it was suggested that hugetlb >>>>>>>> handling code in follow_page_mask could be simplified. At the beginning >>>>>>>> of follow_page_mask, there currently is a call to follow_huge_addr which >>>>>>>> 'may' handle hugetlb pages. ia64 is the only architecture which provides >>>>>>>> a follow_huge_addr routine that does not return error. Instead, at each >>>>>>>> level of the page table a check is made for a hugetlb entry. If a hugetlb >>>>>>>> entry is found, a call to a routine associated with that entry is made. >>>>>>>> >>>>>>>> Currently, there are two checks for hugetlb entries at each page table >>>>>>>> level. The first check is of the form: >>>>>>>> if (p?d_huge()) >>>>>>>> page = follow_huge_p?d(); >>>>>>>> the second check is of the form: >>>>>>>> if (is_hugepd()) >>>>>>>> page = follow_huge_pd(). >>>>>>>> >>>>>>>> We can replace these checks, as well as the special handling routines >>>>>>>> such as follow_huge_p?d() and follow_huge_pd() with a single routine to >>>>>>>> handle hugetlb vmas. >>>>>>>> >>>>>>>> A new routine hugetlb_follow_page_mask is called for hugetlb vmas at the >>>>>>>> beginning of follow_page_mask. hugetlb_follow_page_mask will use the >>>>>>>> existing routine huge_pte_offset to walk page tables looking for hugetlb >>>>>>>> entries. huge_pte_offset can be overwritten by architectures, and already >>>>>>>> handles special cases such as hugepd entries. >>>>>>> >>>>>>> Could you also mention that this patch will fix the lock issue for >>>>>>> CONT-PTE/PMD hugetlb by changing to use huge_pte_lock()? which will help >>>>>>> people to understand the issue. >>>>>> >>>>>> Will update message in v2. Thanks for taking a look! >>>>>> >>>>> >>>>> One additional thought, we 'may' need a separate patch to fix the locking >>>>> issues that can be easily backported. Not sure this 'simplification' is >>>>> a good backport candidate. >>>> >>>> Yes, that was my thought before, but David did not like adding more >>>> make-legacy-cruft-happy code. >>>> >>>> So how about creating a series that contains 3 patches: picking up patch 1 >>>> and patch 3 of my previous series [1], and your current patch? That means >>>> patch 1 and patch 2 in this series can fix the lock issue explicitly and be >>>> suitable to backport, meanwhile patch 3 (which is your current patch) will >>>> cleanup the legacy code. >>>> >>> >>> When I looked at patch 3, I was thinking the update follow_huge_pmd routine >>> would work for the PTE level with a few more modifications. Perhaps, this is >>> too ugly but it is a smaller set of changes for backport. >>> >>> Of course, this would be followed up with the simplification patch which >>> removes all this code. >> >> Yes, looks more simple. I can send you a formal patch with your >> suggestion, which can be added into your cleanup series. Thanks. > > As an alternative, we can have a stable-only version that does that. But from stable-kernel-rules, we should follow "It or an equivalent fix must already exist in Linus' tree (upstream)."