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 BA328ECAAA1 for ; Wed, 31 Aug 2022 01:07:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BBC2A8D0001; Tue, 30 Aug 2022 21:07:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B6C106B0072; Tue, 30 Aug 2022 21:07:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A32AF8D0001; Tue, 30 Aug 2022 21:07:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 91FE46B0071 for ; Tue, 30 Aug 2022 21:07:21 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 57F3680167 for ; Wed, 31 Aug 2022 01:07:21 +0000 (UTC) X-FDA: 79858099482.04.E45CBC9 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by imf11.hostedemail.com (Postfix) with ESMTP id 5CA3740016 for ; Wed, 31 Aug 2022 01:07:18 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=11;SR=0;TI=SMTPD_---0VNo9O5p_1661908034; Received: from 30.97.48.45(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VNo9O5p_1661908034) by smtp.aliyun-inc.com; Wed, 31 Aug 2022 09:07:15 +0800 Message-ID: <0a8025eb-cf15-453a-7d7d-7c72d008889a@linux.alibaba.com> Date: Wed, 31 Aug 2022 09:07:28 +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: Mike Kravetz Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, inuxppc-dev@lists.ozlabs.org, linux-ia64@vger.kernel.org, David Hildenbrand , "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> From: Baolin Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661908041; a=rsa-sha256; cv=none; b=C5GxoClq1jLIH0VUCl0KOUFLPfD7APi57m+jozCQWhAb6sou9EBM8u2uFJMscIkVMYxAgz K76FFifMOrmewh+YJjbkeexZM5N27FHB/bw6VsbFlPvQMOe+qsK04VITuz4F3B3V9RIdRe NvRXjNLoWUGNU5izDfsobcdGzSy2alc= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf11.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.130 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661908041; 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=WD6ihNyz27jrulW97QXJ/M1WDjk76hqRRsKrPYeLkzE=; b=13r54953BnxbqnBoTCBg16nC5IXFOMVYz180IEl6IoSKq8BBpPhnJfnq04nrDIrupON8cP N5buQLnlPhvX92t4Eon2a0pXGGA2l4/0JFhMRehDQWG1orNGhcCFKcRlSw8M0gLJT/negi u54Twolg2ZO/gL0l9vneFbssZ2UnuRE= Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf11.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.130 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 5CA3740016 X-Stat-Signature: d885c4zddwi6obses4hp1zg84fdokdhr X-Rspam-User: X-HE-Tag: 1661908038-98072 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 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. [1] https://lore.kernel.org/all/cover.1661240170.git.baolin.wang@linux.alibaba.com/