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 C8B48ECAAD1 for ; Thu, 1 Sep 2022 06:59:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 708886B0072; Thu, 1 Sep 2022 02:59:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B85F6B0073; Thu, 1 Sep 2022 02:59:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5AA738D0001; Thu, 1 Sep 2022 02:59:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 4BEB66B0072 for ; Thu, 1 Sep 2022 02:59:53 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 1C56F120CB7 for ; Thu, 1 Sep 2022 06:59:53 +0000 (UTC) X-FDA: 79862616666.25.EF028C1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf06.hostedemail.com (Postfix) with ESMTP id C2A25180046 for ; Thu, 1 Sep 2022 06:59:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662015591; 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=KutrrOGNshk1JY+KNnymRzeyn0LVovbCCf72jYJxCGQ=; b=PVLNrSImv4Mt3SrX+ucleQ69oJ3t3u/9w4ZZGID/rHSyUpRAEqNSbn4q6I42JzypAA4n3g I602mi490WOyXkN0AZj3zkJqEnr4axHmsH9JvC8V7740WMgIrlmFBHsnV4BZyKkHIVXiJL taGUMYO4RzG2zFYC5jsZR75gvzK7je0= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-563-j87Mut4qOpGbhCoNPW3sSQ-1; Thu, 01 Sep 2022 02:59:50 -0400 X-MC-Unique: j87Mut4qOpGbhCoNPW3sSQ-1 Received: by mail-wr1-f72.google.com with SMTP id x3-20020adfbb43000000b002258c0751c2so2809310wrg.16 for ; Wed, 31 Aug 2022 23:59:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc; bh=KutrrOGNshk1JY+KNnymRzeyn0LVovbCCf72jYJxCGQ=; b=tuGMvBc2JvZPra5qFr4Np/h3HKLgoHkU7aY8iTwNx6aqSgmI8tqnR6zFWSixHO0STS Lmeo9Qt/HU6PKiT4q1t2qbm750JXTBZT1NkC8Ujng32yF8oS29fRXNwX+vijTNqV8Lwt +PHXrPeV+rMv4JsldNtfEzrDjx+NR6zcdnIvNQVmSh3k9pvsDdMjnJFo9qTuF6oZ//Ur s+hyFgGwX/DP5vJR2b93fkl1fJQP28mRbphMYJkvSqXZmc/LmO0XHksMxvgeKsNDfR1I fUZhdzr456yaD98U6znHBgFmoWA/DAMwK6JzjZR1sc+egvMe0pqDqxFnodWa4lp7eYRK jSvA== X-Gm-Message-State: ACgBeo3J8mwHSUzS4p8IBZc9fpu4B35cXUKqI8PkTK1miV3kGT1tC3gS xpnqG/GMEa8iA/7M9yUeoh2n4Wd1SqG46M9YpR+/lDaHW7LJdhy3JRG9T1UPpj1vPHHTpjzXiXd YcNpfPet7Im8= X-Received: by 2002:a5d:5963:0:b0:226:dff7:adbe with SMTP id e35-20020a5d5963000000b00226dff7adbemr7898424wri.568.1662015589136; Wed, 31 Aug 2022 23:59:49 -0700 (PDT) X-Google-Smtp-Source: AA6agR5m7cRVGCRrdQO37krM0xY2Mf0J7OCDD2pnsNFgIDdRbjKsEjIYNlKU/VsHPl1xPTx1IzQE+g== X-Received: by 2002:a5d:5963:0:b0:226:dff7:adbe with SMTP id e35-20020a5d5963000000b00226dff7adbemr7898405wri.568.1662015588841; Wed, 31 Aug 2022 23:59:48 -0700 (PDT) Received: from ?IPV6:2003:cb:c707:9e00:fec0:7e96:15cb:742? (p200300cbc7079e00fec07e9615cb0742.dip0.t-ipconnect.de. [2003:cb:c707:9e00:fec0:7e96:15cb:742]) by smtp.gmail.com with ESMTPSA id f9-20020a05600c154900b003a60ff7c082sm4693019wmg.15.2022.08.31.23.59.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 31 Aug 2022 23:59:48 -0700 (PDT) Message-ID: <02209dba-532d-a033-2dba-077ed26c8c6a@redhat.com> Date: Thu, 1 Sep 2022 08:59:47 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH] hugetlb: simplify hugetlb handling in follow_page_mask To: Baolin Wang , 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> From: David Hildenbrand Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PVLNrSIm; spf=pass (imf06.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662015592; a=rsa-sha256; cv=none; b=yeuZZuLqpjvG6NgXWPunPIhjLSlq+/viKe8y8ZGaHjLc1tA/upMy01mfKix3nqDsb91HR/ NbxasVs3yk5vHoRn9v15tcKhggw0wEG19ipBWojiV+UT1dar0GyeuUPKfxWJJs+e3kKAHm 4E2Anm3KZsEvNgexkAk1AsdxuHHeVq0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662015592; 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:dkim-signature; bh=KutrrOGNshk1JY+KNnymRzeyn0LVovbCCf72jYJxCGQ=; b=2tanoi1sG3/T6cam/NyYtBfKUlqoTwv+vDeAaro3C9XNpD/IUku2oXweYGQNOlcoUKneaO BoNGP5ayG6Eg7qDfWnaG9xWrDjStojFCd3+A9Lvo7u/ewxbDL2GheukJCPpcMa3VgSyAIy uZH9f057gtlriuHKOHivFzvtM0Q11Ss= Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PVLNrSIm; spf=pass (imf06.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspam-User: X-Stat-Signature: naqiqzc1p9jan57a4fksuxseir51kpwt X-Rspamd-Queue-Id: C2A25180046 X-Rspamd-Server: rspam09 X-HE-Tag: 1662015591-689757 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 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. -- Thanks, David / dhildenb