Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1415969pxk; Thu, 10 Sep 2020 15:01:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKxZ4JteJL1GYQpMaxxs/fvPGwJia5f9bm6vWsjbv+wI/HwZINWueY1XJe9j3Sy+RAzqCt X-Received: by 2002:a05:6402:1212:: with SMTP id c18mr11396482edw.344.1599775273419; Thu, 10 Sep 2020 15:01:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599775273; cv=none; d=google.com; s=arc-20160816; b=cPzM1F8ODIfUTuzpkkd+ifbX555movh/o51nfBcm35XGLGoZ8ODrVLoKmk/MmSx5Mc 9hCEioQi3056ue3j+b2eiTxsJoHDp53p34lEp3z2TA4mxRQM0t5kBPMovrPZ15jHdWNw tMiPucYQ0bL7t8jypVaIVA5er9K2vlgQz4MyJK1KIPCuJajFzZm1uJRaEW2N8iLeiw/d tLmeudbHuuFITqfDx8ntkiNuHhMKFzhlsuLnuwGitdQA3NzvmiQeeYKoQbL02Eqt7eIH 0BTCa6Yi4dcjE/z0GRg9Bwj9f7D/tN3Cki7C3JcjN+oExLA10cRHDNq4lk0LCk1vyPJV dKIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=RBvq+OOZpOHz7JVY1b9A66StBw0lh3lNMqv01GrhYLE=; b=ldhcINuKJk/ZFo4yYpd9ETMzWINw2iPQ5BOxHFrqHHYOehodilCQqrhIQwA+bx/X+M gNyIsMj5yABRAu4ZaqV+00NidlWBEpVxwsu0J96mkCIWT9yUU7BiRKVVUzdPps/2VqdG veVZr+GC2tW1HMRhi3vH6fMTAEVsmXJjhXBo5oETlxUW1WL6D0h/+2Z1jZDQSC5Y8oxy orfQwC7yhGSh4umcMDsjhRMBxPmekIWcJfPPurx6TXaEMD2a4tt1ksjOqDE1ckVoX8+t HtLd+yui4+fDH+dIQD/XcyfjUQHqR6Lgg8xjfl7bDMmhF6unChWNMFoSYypjzSBH47Et 9Dlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=XGa+1wti; 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 t4si4300854ejo.316.2020.09.10.15.00.50; Thu, 10 Sep 2020 15:01:13 -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=@ziepe.ca header.s=google header.b=XGa+1wti; 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 S1725881AbgIJV7k (ORCPT + 99 others); Thu, 10 Sep 2020 17:59:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725876AbgIJV7Y (ORCPT ); Thu, 10 Sep 2020 17:59:24 -0400 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D6D9C061757 for ; Thu, 10 Sep 2020 14:59:24 -0700 (PDT) Received: by mail-qk1-x743.google.com with SMTP id g72so7736837qke.8 for ; Thu, 10 Sep 2020 14:59:24 -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=RBvq+OOZpOHz7JVY1b9A66StBw0lh3lNMqv01GrhYLE=; b=XGa+1wtiJPkykbDWCfESpB/MvI1RBtyH5dvDVcm14/sCZlt15vU51OB/uvdf8x4ZQa kQYpCVOD4ExSpYHPDOteT1PnQSYpcVDio5gc9zCACzdojqAlh6SwMKMRY4M2jHdso8pC o1SCOD1e7CU5P94+lNcRXuJe4cmvhxIpYDyRzl6AlKYd1iDVs+vkgkgFbjeoHTVRj1ST 1yBIDBY0FM4tBgJQZxvv5cNNGM4bu8ROu2teyjXMmbtUrBhHsMF7QLWMp1o0b0abexEB POsgnb1rV2g2SN+GvDFk4nRwxlB7GR1NoIs/6jzxofpKRolvj4glG/Y8VK7FoDyzwgcR PZcQ== 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=RBvq+OOZpOHz7JVY1b9A66StBw0lh3lNMqv01GrhYLE=; b=WRZ3/7FSHSkKJ6meo6FE2lNIhqRVXCKI78jY1x2Zoj6Zdo2OuMFWbE2cfmhxWGb8cA xGhdOi/T2uSKyWJJ95Z1iLi9ZBEYps9Je/tGHQxdP+XcpnUESOnXOrbQadnJ3x/YHPOC CPFgyjoMQJoUY1hHPt9WnqyR/MjDvquiH25QXO6yFS/fRb9GI3aikBGIIxB0Twi7kq78 RHuMFoM8fwQXCRJTDNjcHl/zI9IlGFhs3bYucLmFkfR52KfK92AafFMS6K4MWzkNc5ZB KAApE6uhv8zlpJNNu18WXlsf7ba4JNX4CceLaZx8yllFLfcn/PfXecpBlsNI6Au5UZxi bsNg== X-Gm-Message-State: AOAM530+xlfSauh1dTMwkC069cAXPay5LKaEhIA6HrC8VaZymgnILvIf rAk8DsgH5mFDHtFP9qNNeIaFqw== X-Received: by 2002:ae9:c015:: with SMTP id u21mr10626371qkk.268.1599775163249; Thu, 10 Sep 2020 14:59:23 -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 j88sm32038qte.96.2020.09.10.14.59.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2020 14:59:22 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kGUbB-004RUb-H7; Thu, 10 Sep 2020 18:59:21 -0300 Date: Thu, 10 Sep 2020 18:59:21 -0300 From: Jason Gunthorpe To: Linus Torvalds Cc: Gerald Schaefer , Alexander Gordeev , 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 Subject: Re: [RFC PATCH v2 1/3] mm/gup: fix gup_fast with dynamic page table folding Message-ID: <20200910215921.GP87483@ziepe.ca> References: <20200909142904.00b72921@thinkpad> <20200909192534.442f8984@thinkpad> <20200909180324.GI87483@ziepe.ca> <20200910093925.GB29166@oc3871087118.ibm.com> <20200910181319.GO87483@ziepe.ca> <20200910211010.46d064a7@thinkpad> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 12:32:05PM -0700, Linus Torvalds wrote: > Yeah, I get hung up on naming sometimes. I don't tend to care much > about private local variables ("i" is a perfectly fine variable name), > but these kinds of somewhat subtle cross-architecture definitions I > feel matter. One of the first replys to this patch was to ask "when would I use _orig vs normal", so you are not alone. The name should convey it.. So, I suggest pXX_offset_unlocked() Since it is safe to call without the page table lock, while pXX_offset() requires the page table lock to be held as the internal *pXX is a data race otherwise. Patch 1 might be OK for a stable backport, but to get to a clear pXX_offset_unlocked() all the arches would want to be changed to implement that API and the generic code would provide the wrapper: #define pXX_offset(pXXp, address) pXX_offset_unlocked(pXXp, *(pXXp), address) Arches would not have a *pXX inside their code. Then we can talk about auditing call sites of pXX_offset and think about using the _unlocked version in places where the page table lock is not held. For instance mm/pagewalk.c should be changed. So should huge_pte_offset() and probably other places. These places might already be exsting data-race bugs. It is code-as-documentation indicating an unlocked page table walk. Now it is not just a S390 story but a change that makes the data concurrency much clearer, so I think I prefer this version to the addr_end one too. Regards, Jason