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=-3.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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 6AD25C43461 for ; Fri, 11 Sep 2020 16:54:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 21981221E7 for ; Fri, 11 Sep 2020 16:54:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599843257; bh=NbvToiHOOUTFRHguitKjzPQuxQrLRbG1KBWiN/Cstx8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=gF9qivQBs0/y1UPyHkVXyVRc2p8TCHfXljvg4XysAsZ/UiD4B3JKEn5DkdWant+Lb ZsPsTY/NnAMCRDtmNuNZG7u/olCX93Zx/euhPO3Ox4euB4cqtBzpYHzWm2vV1E9enj OqkPVnjlL50UKo5FbkTjONaQHt5euTcgw854rtpc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726080AbgIKQyM (ORCPT ); Fri, 11 Sep 2020 12:54:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725832AbgIKQwi (ORCPT ); Fri, 11 Sep 2020 12:52:38 -0400 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24FC5C061573 for ; Fri, 11 Sep 2020 09:52:38 -0700 (PDT) Received: by mail-ed1-x543.google.com with SMTP id w1so10736758edr.3 for ; Fri, 11 Sep 2020 09:52: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=ymUunqCLw2vPuQ1VbXcUDi5LPgcqHOLwtMhV+h1hP00=; b=LzixW8IE64pueJHPc4pkVfB4hu8uL7V9KR6+6qOQDiBrSui1M4vSI9xeqysgklBESL 0IQ4jxvW89dAuyt0txhLnLuupNLcl3TzUTNbKM8yk1mUHFyRH5GgOM7DPBaXlmnovHXl RwxBgeTE5qnMUevVAeinQ8lEe8Rzs7ehh51xA= 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=ymUunqCLw2vPuQ1VbXcUDi5LPgcqHOLwtMhV+h1hP00=; b=mIZR6go7yWwuAPRtew6AIv+3tNih3WJXyNfenJ3dvTf4rGZZcwGamxJIgEDOQE9EV7 Z1Szc3lgvzlF1+ZMEcY1Rj91fC40/dnpAmfEWokkMiXXhJt6BKE5l6jfwt60LYNpJ2zT 9PDCeVTuhxCRi3JCu+cZKFP0IKi9lOcMYh2z8KXoxHtj/nla72CJLM9rqyiclzY5auEG leKCP8B3PfLHc+1ccER++8GToxo7JEyDFjOAfK+DPZ1d72vS7ldNKE8tE33mJODZYBbV dTunaMWFcILJiiDSs2jAZEYPZMhKCuePUd+ZgfEHDYNfvkZEJNRbjUzyvqXZyfB6xjFj WbvA== X-Gm-Message-State: AOAM533g9G6zJFqN+yP65u7YAfji6YNs0uToyMjLB1qWUbzNNcZNK0Tj vr3Gt1KWHW2y/CwzX5zpsLmVT/YI+atbQg== X-Google-Smtp-Source: ABdhPJzIschmatwsKv7WibHbeyrPClZkmL6rD7YNx8Dk6wtgMo4xngHPke2CwLhqTcgGofX+c5SQ4A== X-Received: by 2002:a50:ed94:: with SMTP id h20mr3111973edr.184.1599843156568; Fri, 11 Sep 2020 09:52:36 -0700 (PDT) Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com. [209.85.221.45]) by smtp.gmail.com with ESMTPSA id z21sm1928786eja.72.2020.09.11.09.52.36 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Sep 2020 09:52:36 -0700 (PDT) Received: by mail-wr1-f45.google.com with SMTP id a17so12149320wrn.6 for ; Fri, 11 Sep 2020 09:52:36 -0700 (PDT) X-Received: by 2002:ac2:5594:: with SMTP id v20mr585120lfg.344.1599842749970; Fri, 11 Sep 2020 09:45:49 -0700 (PDT) MIME-Version: 1.0 References: <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> <0c9bcb54-914b-e582-dd6d-3861267b6c94@nvidia.com> <20200910221116.GQ87483@ziepe.ca> <20200911121955.GA10250@oc3871087118.ibm.com> In-Reply-To: <20200911121955.GA10250@oc3871087118.ibm.com> From: Linus Torvalds Date: Fri, 11 Sep 2020 09:45:33 -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: Alexander Gordeev Cc: Jason Gunthorpe , John Hubbard , Gerald Schaefer , Dave Hansen , 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 Fri, Sep 11, 2020 at 5:20 AM Alexander Gordeev wrote: > > What if the entry is still pud_present, but got remapped after > READ_ONCE(*pudp)? IOW, it is still valid, but points elsewhere? That can't happen. The GUP walk doesn't hold any locks, but it *is* done with interrupts disabled, and anybody who is modifying the page tables needs to do the TLB flush, and/or RCU-free them. The interrupt disable means that on architectures where the TLB flush involves an IPI, it will be delayed until afterwards, but it also acts as a big RCU read lock hammer. So the page tables can get modified under us, but the old pages won't be released and re-used. Linus From mboxrd@z Thu Jan 1 00:00:00 1970 From: Linus Torvalds Date: Fri, 11 Sep 2020 16:45:33 +0000 Subject: Re: [RFC PATCH v2 1/3] mm/gup: fix gup_fast with dynamic page table folding Message-Id: List-Id: References: <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> <0c9bcb54-914b-e582-dd6d-3861267b6c94@nvidia.com> <20200910221116.GQ87483@ziepe.ca> <20200911121955.GA10250@oc3871087118.ibm.com> In-Reply-To: <20200911121955.GA10250@oc3871087118.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Alexander Gordeev Cc: Jason Gunthorpe , John Hubbard , Gerald Schaefer , Dave Hansen , 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 On Fri, Sep 11, 2020 at 5:20 AM Alexander Gordeev wrote: > > What if the entry is still pud_present, but got remapped after > READ_ONCE(*pudp)? IOW, it is still valid, but points elsewhere? That can't happen. The GUP walk doesn't hold any locks, but it *is* done with interrupts disabled, and anybody who is modifying the page tables needs to do the TLB flush, and/or RCU-free them. The interrupt disable means that on architectures where the TLB flush involves an IPI, it will be delayed until afterwards, but it also acts as a big RCU read lock hammer. So the page tables can get modified under us, but the old pages won't be released and re-used. Linus 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=-3.9 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 D1B13C43461 for ; Fri, 11 Sep 2020 16:45:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 25E1020732 for ; Fri, 11 Sep 2020 16:45:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="LzixW8IE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 25E1020732 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 523FD6B0002; Fri, 11 Sep 2020 12:45:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4AC0D6B005A; Fri, 11 Sep 2020 12:45:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 34C5F6B005C; Fri, 11 Sep 2020 12:45:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0161.hostedemail.com [216.40.44.161]) by kanga.kvack.org (Postfix) with ESMTP id 1C04B6B0002 for ; Fri, 11 Sep 2020 12:45:55 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id D1A3B180AD807 for ; Fri, 11 Sep 2020 16:45:54 +0000 (UTC) X-FDA: 77251357428.14.jump62_31038ed270f0 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id A6E0118229835 for ; Fri, 11 Sep 2020 16:45:54 +0000 (UTC) X-HE-Tag: jump62_31038ed270f0 X-Filterd-Recvd-Size: 5598 Received: from mail-lf1-f66.google.com (mail-lf1-f66.google.com [209.85.167.66]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Fri, 11 Sep 2020 16:45:54 +0000 (UTC) Received: by mail-lf1-f66.google.com with SMTP id y2so6481880lfy.10 for ; Fri, 11 Sep 2020 09:45:54 -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=ymUunqCLw2vPuQ1VbXcUDi5LPgcqHOLwtMhV+h1hP00=; b=LzixW8IE64pueJHPc4pkVfB4hu8uL7V9KR6+6qOQDiBrSui1M4vSI9xeqysgklBESL 0IQ4jxvW89dAuyt0txhLnLuupNLcl3TzUTNbKM8yk1mUHFyRH5GgOM7DPBaXlmnovHXl RwxBgeTE5qnMUevVAeinQ8lEe8Rzs7ehh51xA= 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=ymUunqCLw2vPuQ1VbXcUDi5LPgcqHOLwtMhV+h1hP00=; b=Ov+oiOP+xHa7v7AmwtkkgqcYl+Xfvd/bicFzFm7hvau2pCSZJsr3dbUh0JToDsl7Y4 vBugZLULFfKX739ifh9pgk9elylY/KRMZHjEWHPo1ziPM5Wodb9qC1X3lnK05QqByOYI RqmpqZHMiABL2CBVN50PgZ/f9vrAhRmDki4UGpOzPlQKLrJ+2Mm2TUIOXX2SzEClrNZU 02Us+1ln5IOlOSVFXbfaLEhsWyEBcjHidTRY7cvyVqhyLFMpvDVSFBMfHgNwcmnfI85y sGARDgA/pXyflHr4CfiYM9Yu+Nvdh9BJ3x06IAbZelsG8AGaqgShKuF3w0w/ZUbu9Uwg 8fuQ== X-Gm-Message-State: AOAM5314FFZWuQaNffYIkP0yHp83suOkiOh3E5pu1eH4j8x92EmYrz5R V1BxsU/pg0Y+bRQIyi3lwS/ksCqQKLIZHw== X-Google-Smtp-Source: ABdhPJw95WsnLWGroPR4/oY9aHgDwrYrFWr+J82WOtWTFowF3D1vaOb4KA5Sql6beCWiB0WcZJRXYA== X-Received: by 2002:a19:1c8:: with SMTP id 191mr512467lfb.585.1599842752031; Fri, 11 Sep 2020 09:45:52 -0700 (PDT) Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com. [209.85.167.47]) by smtp.gmail.com with ESMTPSA id h13sm580819lji.134.2020.09.11.09.45.50 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Sep 2020 09:45:50 -0700 (PDT) Received: by mail-lf1-f47.google.com with SMTP id b12so6484633lfp.9 for ; Fri, 11 Sep 2020 09:45:50 -0700 (PDT) X-Received: by 2002:ac2:5594:: with SMTP id v20mr585120lfg.344.1599842749970; Fri, 11 Sep 2020 09:45:49 -0700 (PDT) MIME-Version: 1.0 References: <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> <0c9bcb54-914b-e582-dd6d-3861267b6c94@nvidia.com> <20200910221116.GQ87483@ziepe.ca> <20200911121955.GA10250@oc3871087118.ibm.com> In-Reply-To: <20200911121955.GA10250@oc3871087118.ibm.com> From: Linus Torvalds Date: Fri, 11 Sep 2020 09:45:33 -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: Alexander Gordeev Cc: Jason Gunthorpe , John Hubbard , Gerald Schaefer , Dave Hansen , 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" X-Rspamd-Queue-Id: A6E0118229835 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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 Fri, Sep 11, 2020 at 5:20 AM Alexander Gordeev wrote: > > What if the entry is still pud_present, but got remapped after > READ_ONCE(*pudp)? IOW, it is still valid, but points elsewhere? That can't happen. The GUP walk doesn't hold any locks, but it *is* done with interrupts disabled, and anybody who is modifying the page tables needs to do the TLB flush, and/or RCU-free them. The interrupt disable means that on architectures where the TLB flush involves an IPI, it will be delayed until afterwards, but it also acts as a big RCU read lock hammer. So the page tables can get modified under us, but the old pages won't be released and re-used. Linus 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=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 5CAD9C2BC11 for ; Fri, 11 Sep 2020 16:53:28 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8F431221E7 for ; Fri, 11 Sep 2020 16:53:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="LzixW8IE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8F431221E7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4Bp1zS6wKtzDqsW for ; Sat, 12 Sep 2020 02:53:24 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linuxfoundation.org (client-ip=2a00:1450:4864:20::642; helo=mail-ej1-x642.google.com; envelope-from=torvalds@linuxfoundation.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=google header.b=LzixW8IE; dkim-atps=neutral Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Bp1x50141zDqq5 for ; Sat, 12 Sep 2020 02:51:19 +1000 (AEST) Received: by mail-ej1-x642.google.com with SMTP id j11so14717061ejk.0 for ; Fri, 11 Sep 2020 09:51:18 -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=ymUunqCLw2vPuQ1VbXcUDi5LPgcqHOLwtMhV+h1hP00=; b=LzixW8IE64pueJHPc4pkVfB4hu8uL7V9KR6+6qOQDiBrSui1M4vSI9xeqysgklBESL 0IQ4jxvW89dAuyt0txhLnLuupNLcl3TzUTNbKM8yk1mUHFyRH5GgOM7DPBaXlmnovHXl RwxBgeTE5qnMUevVAeinQ8lEe8Rzs7ehh51xA= 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=ymUunqCLw2vPuQ1VbXcUDi5LPgcqHOLwtMhV+h1hP00=; b=iof1/c6n3DTL2B7ywUqbFCmMFaIuefqaVbQL3RDP5zYpqBxxVeqwzkHhU39+dsymtT 2Z4pPeR//FsL8zqC12aFPQXPnJkPJrvdO0mlvJHhNW35FPjdULOGefCs6kF8P3V5MsAo bQb7Hz3F3S3KmPTiBjHsJrf5YaA7RSHJCcouI+dZ84CpdJgWEKeVSyryRxwtWsy0ycBP aXmbkijvyDBVeIhU2aBsYRvNp445KW3kObE0vyvN0HY9g2A6BG4tIoWY8rdU/FoJNyne tNFpWKyNbia2hqWvU5RW+bzVoMRQvk3ZG7Rf54e38s81Xomx6Eh5DMqIMXtTeirIskQN fjgg== X-Gm-Message-State: AOAM532FQndOouh9THXSQvv4Y8yHjWmjurp4T3WwpNx9b8lfww5Ca/v1 19OXvBHTpgs3uiC2K58y+L70oCGJbpf6QA== X-Google-Smtp-Source: ABdhPJzXCarie7apBd06s/G0LMTE2TAclSk9USgvfsd1lmReiPVOs7/nq+NrrQ8K7kigY0HfD5vEqg== X-Received: by 2002:a17:906:1691:: with SMTP id s17mr3056145ejd.458.1599843070332; Fri, 11 Sep 2020 09:51:10 -0700 (PDT) Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com. [209.85.221.43]) by smtp.gmail.com with ESMTPSA id k25sm1927850ejk.3.2020.09.11.09.51.09 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Sep 2020 09:51:10 -0700 (PDT) Received: by mail-wr1-f43.google.com with SMTP id k15so12126772wrn.10 for ; Fri, 11 Sep 2020 09:51:09 -0700 (PDT) X-Received: by 2002:ac2:5594:: with SMTP id v20mr585120lfg.344.1599842749970; Fri, 11 Sep 2020 09:45:49 -0700 (PDT) MIME-Version: 1.0 References: <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> <0c9bcb54-914b-e582-dd6d-3861267b6c94@nvidia.com> <20200910221116.GQ87483@ziepe.ca> <20200911121955.GA10250@oc3871087118.ibm.com> In-Reply-To: <20200911121955.GA10250@oc3871087118.ibm.com> From: Linus Torvalds Date: Fri, 11 Sep 2020 09:45:33 -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: Alexander Gordeev Content-Type: text/plain; charset="UTF-8" X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Zijlstra , Dave Hansen , Dave Hansen , Paul Mackerras , linux-sparc , Claudio Imbrenda , Will Deacon , linux-arch , linux-s390 , Vasily Gorbik , Christian Borntraeger , Richard Weinberger , linux-x86 , Russell King , Jason Gunthorpe , Ingo Molnar , Catalin Marinas , Andrey Ryabinin , Gerald Schaefer , Heiko Carstens , Arnd Bergmann , John Hubbard , Jeff Dike , linux-um , Borislav Petkov , Andy Lutomirski , Thomas Gleixner , linux-arm , linux-mm , LKML , Andrew Morton , linux-power , Mike Rapoport Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Fri, Sep 11, 2020 at 5:20 AM Alexander Gordeev wrote: > > What if the entry is still pud_present, but got remapped after > READ_ONCE(*pudp)? IOW, it is still valid, but points elsewhere? That can't happen. The GUP walk doesn't hold any locks, but it *is* done with interrupts disabled, and anybody who is modifying the page tables needs to do the TLB flush, and/or RCU-free them. The interrupt disable means that on architectures where the TLB flush involves an IPI, it will be delayed until afterwards, but it also acts as a big RCU read lock hammer. So the page tables can get modified under us, but the old pages won't be released and re-used. Linus 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=-3.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 2072EC433E2 for ; Fri, 11 Sep 2020 16:47:22 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AD109206A2 for ; Fri, 11 Sep 2020 16:47:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="XQmOLpb3"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="LzixW8IE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AD109206A2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=K0m+FeiI3ypdVbvpahwdagT8pujf8fqOag9vWKrWM2s=; b=XQmOLpb3ofrxfQIyIBqQFZBRI aaHcgGbN9JTFVEdjxzYB+6uWJMugWCnKliYI0ouwU3mpPYXldy6qkHQQcSDDVknSvM0Ks5X5rQI8S SBNbsBPxqqEw+1tVCHs5OAil3mEw4uhA8NscE73G0/UNcB4/QJ+ZRTy+NDRr2GRXMJ4oHNimiCEqH ehgxPYsJvOPsK31apOTCz5/bPbu2NOmVSDQOOMUjNrrfUrOa+4BEeDh5AkybP+Yzmk2PRPlgaSmZy wJ9bLGXOlA1WRTS1wvZPORlmfPyaCdKhFJzzxYWVrIRL8dF+NeMDXwVysjeyVJTfC42Eqdo2YZ23M wMO4L91yg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGmBS-00023C-Uz; Fri, 11 Sep 2020 16:45:59 +0000 Received: from mail-ej1-x643.google.com ([2a00:1450:4864:20::643]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGmBO-00021S-RX for linux-arm-kernel@lists.infradead.org; Fri, 11 Sep 2020 16:45:56 +0000 Received: by mail-ej1-x643.google.com with SMTP id o8so14637582ejb.10 for ; Fri, 11 Sep 2020 09:45:54 -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=ymUunqCLw2vPuQ1VbXcUDi5LPgcqHOLwtMhV+h1hP00=; b=LzixW8IE64pueJHPc4pkVfB4hu8uL7V9KR6+6qOQDiBrSui1M4vSI9xeqysgklBESL 0IQ4jxvW89dAuyt0txhLnLuupNLcl3TzUTNbKM8yk1mUHFyRH5GgOM7DPBaXlmnovHXl RwxBgeTE5qnMUevVAeinQ8lEe8Rzs7ehh51xA= 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=ymUunqCLw2vPuQ1VbXcUDi5LPgcqHOLwtMhV+h1hP00=; b=b8xh3YXGgFdo8lkZk4ZL7+XKNE6DclMt+FN8C73agnPnPhdaLZ+cvVE+YNqVfPUKFU x14InHaLznEOm3h4+udVt70iK7xQGt5o5wC3CGMz7sbdY6OWjShDg6Xqbtn1pbP5MWDM 7nzod2prAhdOWWz95lFZPPn9Ro4IDk/F63XI2w2fPTgmupQlwbsVx9O/RB3B242V3SIb WuZarcYWz19RLdRskg2eyTYXIkkfvtMYh6yYjbXLpgNBhQka/Tk4i/COZgGWCzlgdd/X 0XlugMd47kZ33H7wIEIjxC+XgQydssrxpNQxP1s3QAq+q/6OBKGbqFcCQ8PYY2ivCX0p nYkA== X-Gm-Message-State: AOAM532WJZ37nwG16ge7PfzK3ppzh6nY36jop/QX+p4RPGKq0yAi1MjV aIKhIMzub1zTXojSUgZR1HXQZuY2rgeaiQ== X-Google-Smtp-Source: ABdhPJys1CJs739KBwkaHjNgcAjBhjElAHwQ/jiIEC1NTM2hFIO5n8I1cQDeh/7YjJ2BOD6fwfrQUA== X-Received: by 2002:a17:906:ae8f:: with SMTP id md15mr2752635ejb.131.1599842753211; Fri, 11 Sep 2020 09:45:53 -0700 (PDT) Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com. [209.85.208.45]) by smtp.gmail.com with ESMTPSA id h10sm1877956ejt.93.2020.09.11.09.45.51 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Sep 2020 09:45:52 -0700 (PDT) Received: by mail-ed1-f45.google.com with SMTP id e22so150723edq.6 for ; Fri, 11 Sep 2020 09:45:51 -0700 (PDT) X-Received: by 2002:ac2:5594:: with SMTP id v20mr585120lfg.344.1599842749970; Fri, 11 Sep 2020 09:45:49 -0700 (PDT) MIME-Version: 1.0 References: <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> <0c9bcb54-914b-e582-dd6d-3861267b6c94@nvidia.com> <20200910221116.GQ87483@ziepe.ca> <20200911121955.GA10250@oc3871087118.ibm.com> In-Reply-To: <20200911121955.GA10250@oc3871087118.ibm.com> From: Linus Torvalds Date: Fri, 11 Sep 2020 09:45:33 -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: Alexander Gordeev X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200911_124554_932488_AF8CE2A4 X-CRM114-Status: GOOD ( 15.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Zijlstra , Benjamin Herrenschmidt , Dave Hansen , Dave Hansen , Paul Mackerras , linux-sparc , Claudio Imbrenda , Will Deacon , linux-arch , linux-s390 , Vasily Gorbik , Christian Borntraeger , Richard Weinberger , linux-x86 , Russell King , Jason Gunthorpe , Ingo Molnar , Catalin Marinas , Andrey Ryabinin , Gerald Schaefer , Heiko Carstens , Arnd Bergmann , John Hubbard , Jeff Dike , linux-um , Borislav Petkov , Andy Lutomirski , Thomas Gleixner , linux-arm , linux-mm , LKML , Michael Ellerman , Andrew Morton , linux-power , Mike Rapoport Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Sep 11, 2020 at 5:20 AM Alexander Gordeev wrote: > > What if the entry is still pud_present, but got remapped after > READ_ONCE(*pudp)? IOW, it is still valid, but points elsewhere? That can't happen. The GUP walk doesn't hold any locks, but it *is* done with interrupts disabled, and anybody who is modifying the page tables needs to do the TLB flush, and/or RCU-free them. The interrupt disable means that on architectures where the TLB flush involves an IPI, it will be delayed until afterwards, but it also acts as a big RCU read lock hammer. So the page tables can get modified under us, but the old pages won't be released and re-used. Linus _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel