Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp5201795ybb; Tue, 24 Mar 2020 12:48:09 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvydSr4jiUORwAKDoaKgsF9dIA/bqtIrYyp+sa+HYXdQCZyQ9vt2vKqpRTWA7aXnb26PNLk X-Received: by 2002:a9d:708a:: with SMTP id l10mr24402025otj.152.1585079289731; Tue, 24 Mar 2020 12:48:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585079289; cv=none; d=google.com; s=arc-20160816; b=YD6x+HbmfCEf1/Vl9ZbwYwtDWpq6eE7CPGXLDKGY46+peYbJ79VPrndo/2AY8Xx1u0 TLiMnhmdpvmotA7MjxPX1doH4lyVPzjTxBuoKa0AhX3sDGK9rccLiKSq7XG/+EhtkzEI jIlD5RrjDpN30e34dmPKz29gthp0G2krN7IwrzUK0R5y8gmNU9uO8yuyrFnBCUM1PEZ1 wmZDKqffdppr5hu/92tnGeJu3+vei8NRdhz/Z11Q6knO3c2YMAFmXZie9QmDgbUotyy0 vOB6R1BXVyoBrtTWVEdipEkS7JW9EzFfMnMsuA5lM3WBJMxQYdjaKWMX/GnYdn3w7o2k o6Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=aH2gS92pizO8Ui8+GY3Utx9mk0wsuhwC71eXWonUlwo=; b=YR29/Gm7VhPj1Z43O0TYv5gYRntPcESZBBn5EWcAK57zHSp7VniCEtOFGtfFD4NG+V ef0As/IRVEZSNHg7ABIT9YjAEbsCpYpckdOVJ73SL7JfD8nHgdfPwaF36YnCu1Sdqa0n DLi8sRZWVhdhhR0tacdPsLqrgx9IX1rfyWw4PSF8PacqN4jn5+aXKnSrAGFM8WivZWm8 C5E+NxWstt4uwALa73SClzAQLfvo5e/F5XqafPLVGytOX1QwjTuBhQWM9j1zGBprybtk evREhzawqZggKHG8IRKu9+8Hiz+cX3k+/NGOvCf7X0aglB0zsxDWKUozyn/GHeNE5aj2 JXsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=pC0tAQKy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y206si4420060oig.253.2020.03.24.12.47.56; Tue, 24 Mar 2020 12:48:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=pC0tAQKy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727088AbgCXTr0 (ORCPT + 99 others); Tue, 24 Mar 2020 15:47:26 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:41980 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725835AbgCXTr0 (ORCPT ); Tue, 24 Mar 2020 15:47:26 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02OJiGco030029; Tue, 24 Mar 2020 19:47:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=aH2gS92pizO8Ui8+GY3Utx9mk0wsuhwC71eXWonUlwo=; b=pC0tAQKy3mtbwgPKbDSmmFZYlsI+uBsK4T+u8zgUBplY9RZEfsJFKBCXYddayy9Qrjwh K9it2225dQPjjmnbjnxmVnwR9BIuPuHNYIki0TW2tdUhhoBUKqq77Gl31UQP2j+DZImJ SxUyEF/GshfoRMuRyoTGd0t3NvvmRT6hICW4mM+UkPHDOJGvsZTXxvxJgXWTsZl/nWhU hVcb8qj+2vVPkZKWkIqC+2DY/pmLGudj1qXcjT1pwK5fOI6qQg4KQPZxkld7HjYxp4n8 nmKsUTIiuCWvP05WBV0E8EdACdR9fy7688Jflu+2DrzPiL6EBqjukdLSD9aPzLRwBG/+ gQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2yx8ac3avv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 24 Mar 2020 19:47:12 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02OJgLR3050472; Tue, 24 Mar 2020 19:47:12 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 2yxw4px6ya-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 24 Mar 2020 19:47:12 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 02OJl8qZ008773; Tue, 24 Mar 2020 19:47:08 GMT Received: from [192.168.1.206] (/71.63.128.209) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 24 Mar 2020 12:47:08 -0700 Subject: Re: [PATCH v2] mm/hugetlb: fix a addressing exception caused by huge_pte_offset() To: Jason Gunthorpe Cc: "Longpeng (Mike, Cloud Infrastructure Service Product Dept.)" , akpm@linux-foundation.org, kirill.shutemov@linux.intel.com, linux-kernel@vger.kernel.org, arei.gonglei@huawei.com, weidong.huang@huawei.com, weifuqiang@huawei.com, kvm@vger.kernel.org, linux-mm@kvack.org, Matthew Wilcox , Sean Christopherson , stable@vger.kernel.org References: <20200323160955.GY20941@ziepe.ca> <69055395-e7e5-a8e2-7f3e-f61607149318@oracle.com> <20200323180706.GC20941@ziepe.ca> <88698dd7-eb87-4b0b-7ba7-44ef6eab6a6c@oracle.com> <20200323225225.GF20941@ziepe.ca> <20200324115541.GH20941@ziepe.ca> <98d35563-8af0-2693-7e76-e6435da0bbee@oracle.com> <20200324155552.GK20941@ziepe.ca> <66583587-ca4f-9847-c173-4a3d7938fec6@oracle.com> <20200324175918.GL20941@ziepe.ca> From: Mike Kravetz Message-ID: Date: Tue, 24 Mar 2020 12:47:05 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200324175918.GL20941@ziepe.ca> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9570 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 spamscore=0 mlxlogscore=952 adultscore=0 phishscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003240097 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9570 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 mlxscore=0 adultscore=0 phishscore=0 impostorscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003240097 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/24/20 10:59 AM, Jason Gunthorpe wrote: > On Tue, Mar 24, 2020 at 09:19:29AM -0700, Mike Kravetz wrote: >> On 3/24/20 8:55 AM, Jason Gunthorpe wrote: >>> On Tue, Mar 24, 2020 at 08:25:09AM -0700, Mike Kravetz wrote: >>>> On 3/24/20 4:55 AM, Jason Gunthorpe wrote: >>>>> Also, since CH moved all the get_user_pages_fast code out of the >>>>> arch's many/all archs can drop their arch specific version of this >>>>> routine. This is really just a specialized version of gup_fast's >>>>> algorithm.. >>>>> >>>>> (also the arch versions seem different, why do some return actual >>>>> ptes, not null?) >>>> >>>> Not sure I understand that last question. The return value should be >>>> a *pte or null. >>> >>> I mean the common code ends like this: >>> >>> pmd = pmd_offset(pud, addr); >>> if (sz != PMD_SIZE && pmd_none(*pmd)) >>> return NULL; >>> /* hugepage or swap? */ >>> if (pmd_huge(*pmd) || !pmd_present(*pmd)) >>> return (pte_t *)pmd; >>> >>> return NULL; >>> >>> So it always returns a pointer into a PUD or PMD, while say, ppc >>> in __find_linux_pte() ends like: >>> >>> return pte_offset_kernel(&pmd, ea); >>> >>> Which is pointing to a PTE >> >> Ok, now I understand the question. huge_pte_offset will/should only be >> called for addresses that are in a vma backed by hugetlb pages. So, >> pte_offset_kernel() will only return page table type (PUD/PMD/etc) associated >> with a huge page supported by the particular arch. > > I thought pte_offset_kernel always returns PTEs (ie the 4k entries on > x86), I suppose what you are saying is that since the caller knows > this is always a PUD or PMD due to the VMA the pte_offset is dead code. Yes, for x86 the address will correspond to a PUD or PMD or NULL. For huge page mappings/vmas on x86, there are no corresponding PTEs. -- Mike Kravetz