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 47A68C43461 for ; Tue, 8 Sep 2020 19:39:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 074372137B for ; Tue, 8 Sep 2020 19:39:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="Lf6G5poV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732370AbgIHTjP (ORCPT ); Tue, 8 Sep 2020 15:39:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730187AbgIHPzg (ORCPT ); Tue, 8 Sep 2020 11:55:36 -0400 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A499C061231 for ; Tue, 8 Sep 2020 06:26:12 -0700 (PDT) Received: by mail-qk1-x741.google.com with SMTP id q5so13009895qkc.2 for ; Tue, 08 Sep 2020 06:26:12 -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=0Bd9eUG3DnE6D+neFj9R3QfT/oWxBp+wzdY7i+GsBSw=; b=Lf6G5poVVU9DTO5y/Kk8H2Ke1/yuvwq44QRfLlgtzVksH3W4CflZYO6N1CS6Gkgf+O 36N3+8wD9pObYI1CMdwZYMYRu7HbXVUKEFPJ2AjNcK9X3BID5PsppQaFjSnqxa7JtCNT aY2EX4mu669m3AJgX7WT/I/zIn+qpP2LPn3ueNiUgo8NZRJ/0OvY6GqXffz02hp9ASt6 Kw7kagCQ12/ztkbDpZvauMGFhf/ti5rup7TXyfyR2MZlnoY6C7+c78nhZr2bXok7Z+TB z94051jMYxpI6fAzrkfx1CYHrWeWBF5AFFZLbShjEyTsCM8ydvp1pulj0ri7yDSPS5ma HXGQ== 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=0Bd9eUG3DnE6D+neFj9R3QfT/oWxBp+wzdY7i+GsBSw=; b=jPAgKV9ruffeTfdAxG6OebWSrmV6IDhP0X2UIfrDPuHAiaQw/p3EragU/C7hDoHC0Q hHli3pEdcGmiFFeYuqlqhSDNzKWvnx1AfMHm9YO23ig7+RSdEhmROUeQW1iRHWtClli2 cAWEKbwtogtLs6FKUv3So583dWmZ1bzmSGRjKYTlMEx1zV5CmUSAxbXXFzaZTDR8bVt5 OKEdp2wQowvxxIRToZvQ3HyJZVTZBAgjHUQ4iC8R6u3JZYDxL/9CUt4Sk2SdAftQf78d B6AjZbT52fRilaWgazhTAjqeMdzrf2DbtCgAjYAKuAQXZyCElFxaznonG4L/eiZIH4Nl apjw== X-Gm-Message-State: AOAM531b4fMZU2si5Su5Fd8WOBsVZ8l++rlf9IjDNTqLW6obnZQMDLxU +WW5OwfmnaKJMbBISNVn6irxeg== X-Google-Smtp-Source: ABdhPJytassnqIHgDUzIEWSN+bwEo6szoZotvnjMoppJpA+RAkN2BANjzTq153kTDs5DZf5N4KZr1w== X-Received: by 2002:a05:620a:6d9:: with SMTP id 25mr18567qky.269.1599571572011; Tue, 08 Sep 2020 06:26:12 -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 j8sm14658360qth.90.2020.09.08.06.26.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2020 06:26:11 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kFddS-002zaX-9j; Tue, 08 Sep 2020 10:26:10 -0300 Date: Tue, 8 Sep 2020 10:26:10 -0300 From: Jason Gunthorpe To: Gerald Schaefer Cc: John Hubbard , LKML , linux-mm , linux-arch , Andrew Morton , Linus Torvalds , 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 , Alexander Gordeev , Vasily Gorbik , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda Subject: Re: [RFC PATCH v2 2/3] mm: make pXd_addr_end() functions page-table entry aware Message-ID: <20200908132610.GB87483@ziepe.ca> References: <20200907180058.64880-1-gerald.schaefer@linux.ibm.com> <20200907180058.64880-3-gerald.schaefer@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200907180058.64880-3-gerald.schaefer@linux.ibm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 07, 2020 at 08:00:57PM +0200, Gerald Schaefer wrote: > From: Alexander Gordeev > > Unlike all other page-table abstractions pXd_addr_end() do not take > into account a particular table entry in which context the functions > are called. On architectures with dynamic page-tables folding that > might lead to lack of necessary information that is difficult to > obtain other than from the table entry itself. That already led to > a subtle memory corruption issue on s390. > > By letting pXd_addr_end() functions know about the page-table entry > we allow archs not only make extra checks, but also optimizations. > > As result of this change the pXd_addr_end_folded() functions used > in gup_fast traversal code become unnecessary and get replaced with > universal pXd_addr_end() variants. > > The arch-specific updates not only add dereferencing of page-table > entry pointers, but also small changes to the code flow to make those > dereferences possible, at least for x86 and powerpc. Also for arm64, > but in way that should not have any impact. > > So, even though the dereferenced page-table entries are not used on > archs other than s390, and are optimized out by the compiler, there > is a small change in kernel size and this is what bloat-o-meter reports: This looks pretty clean and straightfoward, only __munlock_pagevec_fill() had any real increased complexity. Thanks, Jason From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jason Gunthorpe Date: Tue, 08 Sep 2020 13:26:10 +0000 Subject: Re: [RFC PATCH v2 2/3] mm: make pXd_addr_end() functions page-table entry aware Message-Id: <20200908132610.GB87483@ziepe.ca> List-Id: References: <20200907180058.64880-1-gerald.schaefer@linux.ibm.com> <20200907180058.64880-3-gerald.schaefer@linux.ibm.com> In-Reply-To: <20200907180058.64880-3-gerald.schaefer@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Gerald Schaefer Cc: John Hubbard , LKML , linux-mm , linux-arch , Andrew Morton , Linus Torvalds , 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 , Alexander Gordeev , Vasily Gorbik , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda On Mon, Sep 07, 2020 at 08:00:57PM +0200, Gerald Schaefer wrote: > From: Alexander Gordeev > > Unlike all other page-table abstractions pXd_addr_end() do not take > into account a particular table entry in which context the functions > are called. On architectures with dynamic page-tables folding that > might lead to lack of necessary information that is difficult to > obtain other than from the table entry itself. That already led to > a subtle memory corruption issue on s390. > > By letting pXd_addr_end() functions know about the page-table entry > we allow archs not only make extra checks, but also optimizations. > > As result of this change the pXd_addr_end_folded() functions used > in gup_fast traversal code become unnecessary and get replaced with > universal pXd_addr_end() variants. > > The arch-specific updates not only add dereferencing of page-table > entry pointers, but also small changes to the code flow to make those > dereferences possible, at least for x86 and powerpc. Also for arm64, > but in way that should not have any impact. > > So, even though the dereferenced page-table entries are not used on > archs other than s390, and are optimized out by the compiler, there > is a small change in kernel size and this is what bloat-o-meter reports: This looks pretty clean and straightfoward, only __munlock_pagevec_fill() had any real increased complexity. Thanks, Jason 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.6 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 5CD6CC433E2 for ; Tue, 8 Sep 2020 13:28:40 +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 649F223C2D for ; Tue, 8 Sep 2020 13:28:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="Lf6G5poV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 649F223C2D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca 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 4Bm5ZW6LTxzDqN0 for ; Tue, 8 Sep 2020 23:28:35 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ziepe.ca (client-ip=2607:f8b0:4864:20::744; helo=mail-qk1-x744.google.com; envelope-from=jgg@ziepe.ca; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ziepe.ca header.i=@ziepe.ca header.a=rsa-sha256 header.s=google header.b=Lf6G5poV; dkim-atps=neutral Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) (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 4Bm5Wx4jBKzDqMb for ; Tue, 8 Sep 2020 23:26:15 +1000 (AEST) Received: by mail-qk1-x744.google.com with SMTP id n133so15148448qkn.11 for ; Tue, 08 Sep 2020 06:26:15 -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=0Bd9eUG3DnE6D+neFj9R3QfT/oWxBp+wzdY7i+GsBSw=; b=Lf6G5poVVU9DTO5y/Kk8H2Ke1/yuvwq44QRfLlgtzVksH3W4CflZYO6N1CS6Gkgf+O 36N3+8wD9pObYI1CMdwZYMYRu7HbXVUKEFPJ2AjNcK9X3BID5PsppQaFjSnqxa7JtCNT aY2EX4mu669m3AJgX7WT/I/zIn+qpP2LPn3ueNiUgo8NZRJ/0OvY6GqXffz02hp9ASt6 Kw7kagCQ12/ztkbDpZvauMGFhf/ti5rup7TXyfyR2MZlnoY6C7+c78nhZr2bXok7Z+TB z94051jMYxpI6fAzrkfx1CYHrWeWBF5AFFZLbShjEyTsCM8ydvp1pulj0ri7yDSPS5ma HXGQ== 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=0Bd9eUG3DnE6D+neFj9R3QfT/oWxBp+wzdY7i+GsBSw=; b=dzB+AVmDymk+MkeAlENckfXmCcrg+cXWWr+I5uST0GhO77rnXLJbE6VbtXuUqNrvv+ 5netf/mug++wNdD6f85lgLwBSwd7vExYV0QODJM/gWZ2fNIub9eDV0xalpw35V125GbZ P2vDsFlhbUVBDPoZc7FDtEQgJOLy+7FShHY/4s6Jf/CyPxanSGc2Se1RhoiLPznCtuMc xShnc+7/qdRXaGQ/XASq3RVGPksEjjv9DhwuFgal1I7OFv7JUjCy1GRh83GQ9JjZYgNC M3Rd7J9HIgSwN9u4iEhMRz8Ira0oAAMxruoJW9W1XJ2bPFwG2c5qo4MuwCKMnT0vu2d5 koNg== X-Gm-Message-State: AOAM5316L+CZ1ckBfIrbTuMRKg5kfN627acRZxzxzxlFVnH8gpHYjCps VeRxJAQPTGgouot2mNfV4CSSYg== X-Google-Smtp-Source: ABdhPJytassnqIHgDUzIEWSN+bwEo6szoZotvnjMoppJpA+RAkN2BANjzTq153kTDs5DZf5N4KZr1w== X-Received: by 2002:a05:620a:6d9:: with SMTP id 25mr18567qky.269.1599571572011; Tue, 08 Sep 2020 06:26:12 -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 j8sm14658360qth.90.2020.09.08.06.26.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2020 06:26:11 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kFddS-002zaX-9j; Tue, 08 Sep 2020 10:26:10 -0300 Date: Tue, 8 Sep 2020 10:26:10 -0300 From: Jason Gunthorpe To: Gerald Schaefer Subject: Re: [RFC PATCH v2 2/3] mm: make pXd_addr_end() functions page-table entry aware Message-ID: <20200908132610.GB87483@ziepe.ca> References: <20200907180058.64880-1-gerald.schaefer@linux.ibm.com> <20200907180058.64880-3-gerald.schaefer@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200907180058.64880-3-gerald.schaefer@linux.ibm.com> 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 , linux-mm , Paul Mackerras , linux-sparc , Alexander Gordeev , Claudio Imbrenda , Will Deacon , linux-arch , linux-s390 , Vasily Gorbik , Richard Weinberger , linux-x86 , Russell King , Christian Borntraeger , Ingo Molnar , Catalin Marinas , Andrey Ryabinin , Heiko Carstens , Arnd Bergmann , John Hubbard , Jeff Dike , linux-um , Borislav Petkov , Andy Lutomirski , Thomas Gleixner , linux-arm , linux-power , LKML , Andrew Morton , Linus Torvalds , Mike Rapoport Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Mon, Sep 07, 2020 at 08:00:57PM +0200, Gerald Schaefer wrote: > From: Alexander Gordeev > > Unlike all other page-table abstractions pXd_addr_end() do not take > into account a particular table entry in which context the functions > are called. On architectures with dynamic page-tables folding that > might lead to lack of necessary information that is difficult to > obtain other than from the table entry itself. That already led to > a subtle memory corruption issue on s390. > > By letting pXd_addr_end() functions know about the page-table entry > we allow archs not only make extra checks, but also optimizations. > > As result of this change the pXd_addr_end_folded() functions used > in gup_fast traversal code become unnecessary and get replaced with > universal pXd_addr_end() variants. > > The arch-specific updates not only add dereferencing of page-table > entry pointers, but also small changes to the code flow to make those > dereferences possible, at least for x86 and powerpc. Also for arm64, > but in way that should not have any impact. > > So, even though the dereferenced page-table entries are not used on > archs other than s390, and are optimized out by the compiler, there > is a small change in kernel size and this is what bloat-o-meter reports: This looks pretty clean and straightfoward, only __munlock_pagevec_fill() had any real increased complexity. Thanks, Jason 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,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 7892FC43461 for ; Tue, 8 Sep 2020 13:27:30 +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 2B5B523C2D for ; Tue, 8 Sep 2020 13:27:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="b+s7tBG3"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="Lf6G5poV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2B5B523C2D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca 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:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Gx6nnh+GAIdr7w1XfmL5x1CnC6Ux/VrybIXXsw8JM7U=; b=b+s7tBG3Srpf+tRuMrUhRP73y vMMwEb+EXzSJdfOv9gPypYVrkgALG+Y/+Z+EMsQplSpj4YfoTXeO67iiDdtLss/+LwtEnkINs4dJU W5EOZ8s5xt0H2H9hMUSXVLRByJuVieZG9VY6kxsLb/Emq9MpMTmH4JN+eqsNn/ar7dR/OF1wuVYsP rNiOv/tMudSs98k7NmxtXWryCpSCE1A0jmUYfFkrFCcT2DjubpbSjBP46/2i7rwc3HVODfjk03z5Z kfdDWPT4z8aGwbiWsMzH53kIYyamHzJ6TZ6yRdchTBAa51ndPUp5pLJofZZKmB4kYCfFKG6LTmAZk Pcq9e9rjQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFdda-0002U9-5V; Tue, 08 Sep 2020 13:26:18 +0000 Received: from mail-qk1-x743.google.com ([2607:f8b0:4864:20::743]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFddX-0002SW-PT for linux-arm-kernel@lists.infradead.org; Tue, 08 Sep 2020 13:26:16 +0000 Received: by mail-qk1-x743.google.com with SMTP id o16so5031247qkj.10 for ; Tue, 08 Sep 2020 06:26:13 -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=0Bd9eUG3DnE6D+neFj9R3QfT/oWxBp+wzdY7i+GsBSw=; b=Lf6G5poVVU9DTO5y/Kk8H2Ke1/yuvwq44QRfLlgtzVksH3W4CflZYO6N1CS6Gkgf+O 36N3+8wD9pObYI1CMdwZYMYRu7HbXVUKEFPJ2AjNcK9X3BID5PsppQaFjSnqxa7JtCNT aY2EX4mu669m3AJgX7WT/I/zIn+qpP2LPn3ueNiUgo8NZRJ/0OvY6GqXffz02hp9ASt6 Kw7kagCQ12/ztkbDpZvauMGFhf/ti5rup7TXyfyR2MZlnoY6C7+c78nhZr2bXok7Z+TB z94051jMYxpI6fAzrkfx1CYHrWeWBF5AFFZLbShjEyTsCM8ydvp1pulj0ri7yDSPS5ma HXGQ== 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=0Bd9eUG3DnE6D+neFj9R3QfT/oWxBp+wzdY7i+GsBSw=; b=dpZ/wzffT2Ye13Cwe5zL2VKhrMNyRFHaW0qBKBYZ3ubmKs4ih1ddk2ksCwgUCSjeQh URCozoSPE1z78dSf5Etqa1P1NgFazrO9jlPPNxzE7QhOa32DWbu/YTvvxk5GGXL7sjaR FH3BwZKbeMZuLIhdEu97XYqDKt5T72ZZZJJFSTeG0IfQEyBoM37jC5Wz1GpE1pLCGYP2 cnWsk05X/u3+pGVKvum037zPhLRuwrmQolYPEEFPinFg0tRSRTxi5gNtdWtuomEFognE 9Pgg5u0M6ZdRlwAY3oJnGD74huMjLWp2bnOJU7lJdJwLMhbfzF2AbrDMtk3VdKSLwvz3 rW5w== X-Gm-Message-State: AOAM531kBjsy87vP+76ElQVlWl4+NP48LC1G3dG/BP0wAFgdYfNR2K94 l9wH6XNXRWJIZaOxFSrFAu6s8w== X-Google-Smtp-Source: ABdhPJytassnqIHgDUzIEWSN+bwEo6szoZotvnjMoppJpA+RAkN2BANjzTq153kTDs5DZf5N4KZr1w== X-Received: by 2002:a05:620a:6d9:: with SMTP id 25mr18567qky.269.1599571572011; Tue, 08 Sep 2020 06:26:12 -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 j8sm14658360qth.90.2020.09.08.06.26.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2020 06:26:11 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kFddS-002zaX-9j; Tue, 08 Sep 2020 10:26:10 -0300 Date: Tue, 8 Sep 2020 10:26:10 -0300 From: Jason Gunthorpe To: Gerald Schaefer Subject: Re: [RFC PATCH v2 2/3] mm: make pXd_addr_end() functions page-table entry aware Message-ID: <20200908132610.GB87483@ziepe.ca> References: <20200907180058.64880-1-gerald.schaefer@linux.ibm.com> <20200907180058.64880-3-gerald.schaefer@linux.ibm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200907180058.64880-3-gerald.schaefer@linux.ibm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200908_092615_847073_123A42BF X-CRM114-Status: GOOD ( 23.06 ) 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 , linux-mm , Paul Mackerras , linux-sparc , Alexander Gordeev , Claudio Imbrenda , Will Deacon , linux-arch , linux-s390 , Vasily Gorbik , Richard Weinberger , linux-x86 , Russell King , Christian Borntraeger , Ingo Molnar , Catalin Marinas , Andrey Ryabinin , Heiko Carstens , Arnd Bergmann , John Hubbard , Jeff Dike , linux-um , Borislav Petkov , Andy Lutomirski , Thomas Gleixner , linux-arm , linux-power , LKML , Michael Ellerman , Andrew Morton , Linus Torvalds , 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 Mon, Sep 07, 2020 at 08:00:57PM +0200, Gerald Schaefer wrote: > From: Alexander Gordeev > > Unlike all other page-table abstractions pXd_addr_end() do not take > into account a particular table entry in which context the functions > are called. On architectures with dynamic page-tables folding that > might lead to lack of necessary information that is difficult to > obtain other than from the table entry itself. That already led to > a subtle memory corruption issue on s390. > > By letting pXd_addr_end() functions know about the page-table entry > we allow archs not only make extra checks, but also optimizations. > > As result of this change the pXd_addr_end_folded() functions used > in gup_fast traversal code become unnecessary and get replaced with > universal pXd_addr_end() variants. > > The arch-specific updates not only add dereferencing of page-table > entry pointers, but also small changes to the code flow to make those > dereferences possible, at least for x86 and powerpc. Also for arm64, > but in way that should not have any impact. > > So, even though the dereferenced page-table entries are not used on > archs other than s390, and are optimized out by the compiler, there > is a small change in kernel size and this is what bloat-o-meter reports: This looks pretty clean and straightfoward, only __munlock_pagevec_fill() had any real increased complexity. Thanks, Jason _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x741.google.com ([2607:f8b0:4864:20::741]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFddX-0002SU-OQ for linux-um@lists.infradead.org; Tue, 08 Sep 2020 13:26:16 +0000 Received: by mail-qk1-x741.google.com with SMTP id f2so15235961qkh.3 for ; Tue, 08 Sep 2020 06:26:13 -0700 (PDT) Date: Tue, 8 Sep 2020 10:26:10 -0300 From: Jason Gunthorpe Subject: Re: [RFC PATCH v2 2/3] mm: make pXd_addr_end() functions page-table entry aware Message-ID: <20200908132610.GB87483@ziepe.ca> References: <20200907180058.64880-1-gerald.schaefer@linux.ibm.com> <20200907180058.64880-3-gerald.schaefer@linux.ibm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200907180058.64880-3-gerald.schaefer@linux.ibm.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-um" Errors-To: linux-um-bounces+geert=linux-m68k.org@lists.infradead.org To: Gerald Schaefer Cc: Peter Zijlstra , Benjamin Herrenschmidt , Dave Hansen , linux-mm , Paul Mackerras , linux-sparc , Alexander Gordeev , Claudio Imbrenda , Will Deacon , linux-arch , linux-s390 , Vasily Gorbik , Richard Weinberger , linux-x86 , Russell King , Christian Borntraeger , Ingo Molnar , Catalin Marinas , Andrey Ryabinin , Heiko Carstens , Arnd Bergmann , John Hubbard , Jeff Dike , linux-um , Borislav Petkov , Andy Lutomirski , Thomas Gleixner , linux-arm , linux-power , LKML , Michael Ellerman , Andrew Morton , Linus Torvalds , Mike Rapoport On Mon, Sep 07, 2020 at 08:00:57PM +0200, Gerald Schaefer wrote: > From: Alexander Gordeev > > Unlike all other page-table abstractions pXd_addr_end() do not take > into account a particular table entry in which context the functions > are called. On architectures with dynamic page-tables folding that > might lead to lack of necessary information that is difficult to > obtain other than from the table entry itself. That already led to > a subtle memory corruption issue on s390. > > By letting pXd_addr_end() functions know about the page-table entry > we allow archs not only make extra checks, but also optimizations. > > As result of this change the pXd_addr_end_folded() functions used > in gup_fast traversal code become unnecessary and get replaced with > universal pXd_addr_end() variants. > > The arch-specific updates not only add dereferencing of page-table > entry pointers, but also small changes to the code flow to make those > dereferences possible, at least for x86 and powerpc. Also for arm64, > but in way that should not have any impact. > > So, even though the dereferenced page-table entries are not used on > archs other than s390, and are optimized out by the compiler, there > is a small change in kernel size and this is what bloat-o-meter reports: This looks pretty clean and straightfoward, only __munlock_pagevec_fill() had any real increased complexity. Thanks, Jason _______________________________________________ linux-um mailing list linux-um@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-um