Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp66266pxk; Tue, 1 Sep 2020 16:25:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztt+68NQWDcH6ONm/n9KSsvalC9cD86cekSm1PyfruE/PUizlWoq7BxQv+c0raTV5yaxO/ X-Received: by 2002:a50:fd19:: with SMTP id i25mr4023456eds.142.1599002735455; Tue, 01 Sep 2020 16:25:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599002735; cv=none; d=google.com; s=arc-20160816; b=d9fOOepvKw/bGvic6qpDLIUjYeWwcJOv5gvP5J+5CgsUpAPVGUT3SMYGQQoCk8ugBN DkmJggNKqZgrBcu0ji1+SAyWn8kV0FbSlHwE8w/2RUY7J+x9X6n3wwF6WTS+LYcxPVEw WlF6UodBt0pCAUgOvaz4jymMNlu+A64Y7toz0EGCIRtCir2V6yYvK760kEFZfIMIysM6 86zkudwERzQiF98YqPZymdo2Wqo+pHt3gHRYgL0m/hFi6lnw/ViOZlF4toKSIgegzFgn eLOdimA3k+DJlu6A0x3uMG6mcVccxtESfDKKYMR6DidzNKN0BYnC68tca+1YjKMf/ePj 1ziw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=QvEpBawqMk10IWgyHYMp7W4/aQgWqCyGEhNMfoN1Ads=; b=q2RnNr5EZA+TK2hCSGiriJvU/NjCR/dX5Qfkkh5Nwf8L2DExiwZOpjnLZk5LnXYA05 boeBJ8naAIoW75Kx7X/erULGLqLyAZz3zDquU5Gle5z972Y9ns6XnRfD63mHUSY0W7NY RHLaJpO+ZRQZa+G+5rXvRBBalxvDXazqqmlGdO8BXgbQ7ZqhULNIOrQIyUgztnCS0oCt IP/yyj64UGtSrzklZ3RfctA9kQXuDVXUPDaJM9wZVU9t95jD3Uz1wEqqZd5zXkfn3hr4 El9vIA7+7RSlgKKZv8FQEXH+nq7DsouGNPrvvcEztu83/miD40bOrZoGs+46o9QnMxRC uiLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=dtNXtT3a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i19si1565167ejp.78.2020.09.01.16.25.07; Tue, 01 Sep 2020 16:25:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=dtNXtT3a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726124AbgIAXWZ (ORCPT + 99 others); Tue, 1 Sep 2020 19:22:25 -0400 Received: from hqnvemgate25.nvidia.com ([216.228.121.64]:12500 "EHLO hqnvemgate25.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725949AbgIAXWX (ORCPT ); Tue, 1 Sep 2020 19:22:23 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Tue, 01 Sep 2020 16:21:37 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Tue, 01 Sep 2020 16:22:23 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Tue, 01 Sep 2020 16:22:23 -0700 Received: from [10.2.63.6] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 1 Sep 2020 23:22:22 +0000 Subject: Re: [RFC PATCH 0/2] mm/gup: fix gup_fast with dynamic page table folding To: Gerald Schaefer , Andrew Morton CC: Christian Borntraeger , Linus Torvalds , linux-mm , LKML , Vasily Gorbik , Alexander Gordeev , , Heiko Carstens , Claudio Imbrenda , Jason Gunthorpe References: <20200828140314.8556-1-gerald.schaefer@linux.ibm.com> <9071c9fa-ba6a-90dc-2d7a-8b155141d890@de.ibm.com> <20200831121553.8be5dcdbdbc5256846ac513e@linux-foundation.org> <20200901194020.418da486@thinkpad> From: John Hubbard Message-ID: <91988792-069c-31a6-7840-0122357538c7@nvidia.com> Date: Tue, 1 Sep 2020 16:22:22 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200901194020.418da486@thinkpad> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1599002497; bh=QvEpBawqMk10IWgyHYMp7W4/aQgWqCyGEhNMfoN1Ads=; h=X-PGP-Universal:Subject:To:CC:References:From:Message-ID:Date: User-Agent:MIME-Version:In-Reply-To:X-Originating-IP: X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=dtNXtT3aM/7U29OmKL/4t8Db0SE3cimmEHykFmH8ItKI5gjmIXjUR+mnyPW8cVLmW mR70cVpyoxMhRq7H8uMqxWxh1dOTWdcUPLcOGdQ+e0IMh/lX7JCvEi/dBI1N+bqq32 KJSBbhWG1BbjoUjnjwfZvYCDFlDVqoCOinEAfmY+lvENy7k8E622R3tTzHx23Rj025 FQ8a6RdLHVnnpAIv0TQd4l4gsxdVApYlMiwGddrn7Pfgn7drA3ISqLenbW+r13xWDh Z34N7SoueSzam/8fHaBNW2nxZR3Uh2xr8EmQF2YNTqGcG3XYLFFVjNW5YqgQJqIHyB 4RR+4z/i8oHcQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/1/20 10:40 AM, Gerald Schaefer wrote: > On Mon, 31 Aug 2020 12:15:53 -0700 > Andrew Morton wrote: ... > diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h > index e8cbc2e795d5..43dacbce823f 100644 > --- a/include/linux/pgtable.h > +++ b/include/linux/pgtable.h > @@ -681,6 +681,38 @@ static inline int arch_unmap_one(struct mm_struct *mm, > }) > #endif > > +/* > + * With dynamic page table levels on s390, the static pXd_addr_end() functions > + * will not return corresponding dynamic boundaries. This is no problem as long > + * as only pXd pointers are passed down during page table walk, because > + * pXd_offset() will simply return the given pointer for folded levels, and the > + * pointer iteration over a range simply happens at the correct page table > + * level. > + * It is however a problem with gup_fast, or other places walking the page > + * tables w/o locks using READ_ONCE(), and passing down the pXd values instead > + * of pointers. In this case, the pointer given to pXd_offset() is a pointer to > + * a stack variable, which cannot be used for pointer iteration at the correct > + * level. Instead, the iteration then has to happen by going up to pgd level > + * again. To allow this, provide pXd_addr_end_folded() functions with an > + * additional pXd value parameter, which can be used on s390 to determine the > + * folding level and return the corresponding boundary. Ah OK, I finally see what you have in mind. And as Jason noted, if we just pass an additional parameter to pXd_addr_end() that's going to be cleaner. And doing so puts this in line with other page table abstractions that also carry more information than some architectures need. For example, on x86, set_pte_at() ignores the first two parameters: #define set_pte_at(mm, addr, ptep, pte) native_set_pte_at(mm, addr, ptep, pte) static inline void native_set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep , pte_t pte) { native_set_pte(ptep, pte); } This type of abstraction has worked out very well, IMHO. thanks, -- John Hubbard NVIDIA