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 X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94DA9C433E6 for ; Tue, 1 Sep 2020 18:14:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 541D9206FA for ; Tue, 1 Sep 2020 18:14:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="EHILGkhV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 541D9206FA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DF3BB6B00BB; Tue, 1 Sep 2020 14:14:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D7C1C6B00BC; Tue, 1 Sep 2020 14:14:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C44EA6B00C4; Tue, 1 Sep 2020 14:14:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0026.hostedemail.com [216.40.44.26]) by kanga.kvack.org (Postfix) with ESMTP id A39E16B00BB for ; Tue, 1 Sep 2020 14:14:15 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 69B9E82499B9 for ; Tue, 1 Sep 2020 18:14:15 +0000 (UTC) X-FDA: 77215292070.13.goose78_3811b492709a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id 2745118140B67 for ; Tue, 1 Sep 2020 18:14:15 +0000 (UTC) X-HE-Tag: goose78_3811b492709a X-Filterd-Recvd-Size: 5600 Received: from mail-qv1-f68.google.com (mail-qv1-f68.google.com [209.85.219.68]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Tue, 1 Sep 2020 18:14:14 +0000 (UTC) Received: by mail-qv1-f68.google.com with SMTP id cv8so958409qvb.12 for ; Tue, 01 Sep 2020 11:14:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=4A3hPsjtdOjipSjaJeT1UcVHO23/CVQ2IpCQthxyHBw=; b=EHILGkhVsKeiCP6z45SoutVPM+jA7upQKYGslQ7Q4Dl4PucwRSZxe8vXQm+WQenWUd mQH48T5ue18fETXWnvjz5Wx0qyCBTup2nDgxleJXbZo+Gp/0QMb/oeHF9KTRl+obxy9+ 76Ku0JMrTeKENh3LuA26FCgW1oHIGGaZn86M+d9Lj2t7QXL0eKKAVFeU0KfW7EigDtGa 7SybFavuEQT2XuvcQP+IuEFMkDijuHfAvhOCkdeTLAE7kS3scSIiw2qWpojyKJNsfGOM SsqTw9tAVuVs9EWnojQQ4pE/OF+CFPhdx0hQd9wicX/GuziDiMMdwW8ueGdHcY189NSK lz1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=4A3hPsjtdOjipSjaJeT1UcVHO23/CVQ2IpCQthxyHBw=; b=jBnTbQ8bMbYk9Tn82IsfqZwZuZAsPPuWMrla9TWYwR8qZi5eJVFMvsSGmyfuWhXf35 f1wO2koKV3V1ReVEepSUrKeCcTDSp+Sp8YCXQme983f+PJ7JR+Acc4RZa7x+GCUaI1+5 q/rZ5/1HAgMvsygyCZFP+SecL65rTqrEkZYRgl8E9KzM69W4VL6C8ulFXKYxd/kqtbM4 ozVbwk7v/86gPkcfYttfQL/GX5DPPj/uD1Fn5+4CsFa2dscUIhXoogR/z1KBzvWhc77Q iM/beWR0rdtubdQ9UrEQ35mQ7PQrvE0E1tHfXS5S1PfPMGRsLmLh986eGkG8ptfIM0GR jb+g== X-Gm-Message-State: AOAM5325jqxHaUmwi7KS/Y7WzafEw8b3GBMOUPCgJzkAOosoc+3KxkjR cPvxw2d6ZAvN8APvm0VBGbxDFw== X-Google-Smtp-Source: ABdhPJyS7IcgtYtB2wNGX+Xo0eMaeBEI0j+77VrEcdnZRuTRVP0UtmztL9vqX9/MJnXvw4b2RGS8aw== X-Received: by 2002:a0c:e783:: with SMTP id x3mr3317618qvn.114.1598984054019; Tue, 01 Sep 2020 11:14:14 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-156-34-48-30.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.48.30]) by smtp.gmail.com with ESMTPSA id k185sm2420678qkd.94.2020.09.01.11.14.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 11:14:13 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kDAnM-004ex1-GH; Tue, 01 Sep 2020 15:14:12 -0300 Date: Tue, 1 Sep 2020 15:14:12 -0300 From: Jason Gunthorpe To: Gerald Schaefer Cc: Andrew Morton , Christian Borntraeger , Linus Torvalds , linux-mm , LKML , Vasily Gorbik , Alexander Gordeev , linux-s390@vger.kernel.org, Heiko Carstens , Claudio Imbrenda , John Hubbard Subject: Re: [RFC PATCH 0/2] mm/gup: fix gup_fast with dynamic page table folding Message-ID: <20200901181412.GE24045@ziepe.ca> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200901194020.418da486@thinkpad> X-Rspamd-Queue-Id: 2745118140B67 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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 Tue, Sep 01, 2020 at 07:40:20PM +0200, Gerald Schaefer wrote: > +/* > + * 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. > + */ > +#ifndef pgd_addr_end_folded > +#define pgd_addr_end_folded(pgd, addr, end) pgd_addr_end(addr, end) > +#endif > + > +#ifndef p4d_addr_end_folded > +#define p4d_addr_end_folded(p4d, addr, end) p4d_addr_end(addr, end) > +#endif > + > +#ifndef pud_addr_end_folded > +#define pud_addr_end_folded(pud, addr, end) pud_addr_end(addr, end) > +#endif > + > +#ifndef pmd_addr_end_folded > +#define pmd_addr_end_folded(pmd, addr, end) pmd_addr_end(addr, end) > +#endif Feels like it would be cleaner to globally change pmd_addr_end() /etc to require the extra pmd input rather that introduce this special rule when *_folded needs to be used? NOP on all arches execpt s390.. There are not so many call sites that it seems too scary, and I wouldn't be surprised if there are going to be more cases beyond GUP that *should* be using the READ_ONCE trick. Jason