Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1288787pxk; Thu, 10 Sep 2020 11:35:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpgKQrrP++oH258wETtpS7d4b0Y8OsBnAq9c41J/+NO9upECKotxqnPzegkqydQakxOqXs X-Received: by 2002:a17:906:2985:: with SMTP id x5mr10023123eje.136.1599762937803; Thu, 10 Sep 2020 11:35:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599762937; cv=none; d=google.com; s=arc-20160816; b=BMOpMi1cGF28KcFHlKNV+O68n4dF19eHvnOSqLGgrb3dEg2gpmV/6VChM1Whw6NR4i JnsOD5Bx2T4nsbCerqN8yJKIz3GTKhAhNgU403Wv9P0recAcb6boS0J9J/MSR7XYzqUJ ENdgViy0yq4AWYEXmURUGaKTgOsOqHc9K03d1jYaDz64o1cCdFKwYZGFTkymoybwfyKH MxxWomPm1YosielbNPvfBfD9hupIUa2xtCn53FgKOeBb2WXuESC5rKZIrRcSorqKuyb0 TENisGbRt3/FPEsyDdsP4Lm7D7RCee1ArjeJHXbCbaquY4JrU5slVcbP5CIYguY5FIm6 DqPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=qxUvMosCQmqJOT3+XnukK6QXCPsj7s8SUCtblFuQCtk=; b=Y4Paxy03VpoCW/7AvhZOwD1xwYKVlOIvV/SqStSWb3k10hcT87ALiy4RcPCgN3i+76 iRUghrt4IxasJYgUT/fr+nlfI9azXETVaWbhWdHta9r537SKUIkZia9HkM0G4XIgCNI6 9ypJFym40MO97+K5NE5bjCRPb23A96963+FtTUn9PvR137kDQQ4ascSh1D5dQ5s38c4A Hm87mKcejeXErJueOy/P/O9cC9CqTLv9CXxWPja+QDDcXUUGxPe8DIY/HHjje2i5WRMj TBrGiMiHCOD34m66VfITYW9jrZBppGjOdmq3shPpKdfo16PQ5Zw6FlGEQm8fwbN6Ry/z Y18g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=KlHKM3kh; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b23si4243481ejb.465.2020.09.10.11.35.15; Thu, 10 Sep 2020 11:35:37 -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=@linux-foundation.org header.s=google header.b=KlHKM3kh; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726474AbgIJSeb (ORCPT + 99 others); Thu, 10 Sep 2020 14:34:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726899AbgIJSdi (ORCPT ); Thu, 10 Sep 2020 14:33:38 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34922C0613ED for ; Thu, 10 Sep 2020 11:33:38 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id u4so9454515ljd.10 for ; Thu, 10 Sep 2020 11:33:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qxUvMosCQmqJOT3+XnukK6QXCPsj7s8SUCtblFuQCtk=; b=KlHKM3khaRQUhJpR9UdzFB5LWAQF17Brw1Ft7CKtiriIUBpvA7+djFgchHKossZjUO VhqJr4lFUYp9ylSJpdlZ0hFaIz/Ssta/iioJv0jWuQQR7zk9LpCYLPwRfEoZmfrs0FFc eJ9cpxyshw+kFNXrIvj9XAnDrbJSgUK0YSwsk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qxUvMosCQmqJOT3+XnukK6QXCPsj7s8SUCtblFuQCtk=; b=Sudkn3v1XH6YYqBgF1IqTdkIbI24XQuk/iExF4p68ziMANCYVq6nkkpf7GllAw6kOr DgEB2Z0ryzpKS/LHCX6vTc3DMm0m4r0een4B+NgVVC9jyHTEXhlyO14JLsLTg7TNQ4W6 9CsSRRHvBKPsMLVYp8cRcJX6vl3nHqCXFK0gcWo7Pgygg5mtpvSu0uURe/7vNw2blKXM 3eTacmu/dD245o5QNqcdiXpd7byLFpI5sj2935qbumjrVJpNP06BMJjEz/GR3xbxURME thvESio8XyLzFSardS2nSOyz9XnMFzC9CajNdtV3vGiytRikxwVBiYqZ03DdWbfuDzu2 NuHw== X-Gm-Message-State: AOAM533+nnRAnDuq9VkFqHFGMg9zFzdfEjtH+mqH6F9SZEYSUZLj6fBx WenHKPo7AWoq4w5jIFI3pKsG5l4ItwQvMQ== X-Received: by 2002:a05:651c:290:: with SMTP id b16mr4845804ljo.307.1599762815007; Thu, 10 Sep 2020 11:33:35 -0700 (PDT) Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com. [209.85.208.177]) by smtp.gmail.com with ESMTPSA id y4sm1789051ljk.61.2020.09.10.11.33.33 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Sep 2020 11:33:34 -0700 (PDT) Received: by mail-lj1-f177.google.com with SMTP id u21so9487403ljl.6 for ; Thu, 10 Sep 2020 11:33:33 -0700 (PDT) X-Received: by 2002:a05:651c:104c:: with SMTP id x12mr5572300ljm.285.1599762813344; Thu, 10 Sep 2020 11:33:33 -0700 (PDT) MIME-Version: 1.0 References: <20200907180058.64880-1-gerald.schaefer@linux.ibm.com> <20200907180058.64880-2-gerald.schaefer@linux.ibm.com> <0dbc6ec8-45ea-0853-4856-2bc1e661a5a5@intel.com> <20200909142904.00b72921@thinkpad> <20200909192534.442f8984@thinkpad> <20200909180324.GI87483@ziepe.ca> <20200910093925.GB29166@oc3871087118.ibm.com> <20200910181319.GO87483@ziepe.ca> In-Reply-To: <20200910181319.GO87483@ziepe.ca> From: Linus Torvalds Date: Thu, 10 Sep 2020 11:33:17 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH v2 1/3] mm/gup: fix gup_fast with dynamic page table folding To: Jason Gunthorpe Cc: Alexander Gordeev , Gerald Schaefer , Dave Hansen , John Hubbard , LKML , linux-mm , linux-arch , Andrew Morton , Russell King , Mike Rapoport , Catalin Marinas , Will Deacon , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Jeff Dike , Richard Weinberger , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Arnd Bergmann , Andrey Ryabinin , linux-x86 , linux-arm , linux-power , linux-sparc , linux-um , linux-s390 , Vasily Gorbik , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 10, 2020 at 11:13 AM Jason Gunthorpe wrote: > > So.. To change away from the stack option I think we'd have to pass > the READ_ONCE value to pXX_offset() as an extra argument instead of it > derefing the pointer internally. Yeah, but I think that would actually be the better model than passing an address to a random stack location. It's also effectively what we do in some other places, eg the whole logic with "orig" in the regular pte fault handling is basically doing unlocked loads of the pte, various decisions on that, and then doing a final "is this still the same pte" after it has gotten the page table lock. (And yes, those other pte fault handling cases are different, since they _do_ hold the mmap lock, so they know the page *tables* are stable, and it's only the last level that then gets re-checked against the pte once the pte itself has also been stabilized with the page table lock). So I think it would actually be a better conceptual match to make the page table walking interface be "here, this is the value I read once carefully, and this is the address, now give me the next address". The folded case would then just return the address it was given, and the non-folded case would return the inner page table based on the value. I dunno. I don't actually feel all that strongly about this, so whatever works, I guess. Linus