Received: by 2002:a17:90a:c8b:0:0:0:0 with SMTP id v11csp2298273pja; Fri, 19 Apr 2019 11:31:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqzMArPO2l+8NJXTs7Gb3/QRL4tQSOtc1W6qkj+EZVF8+fn3iRhPhG9lCnacGNgRUtXbLd3N X-Received: by 2002:a17:902:8349:: with SMTP id z9mr5223111pln.144.1555698684384; Fri, 19 Apr 2019 11:31:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555698684; cv=none; d=google.com; s=arc-20160816; b=DE0fcT9qt7ISisGqgWj/MTESfWLzXX0VUnbEXb1sgRoBglBzgTENozqFIUS69YczhD gcSgontIUPssF1Kd9mmB+PJSYngPdsQUnWe4OfO7jbwCBapBfEtZWYo92FOkHZ/Gi4e2 5l8ktcByoi0iDfyrbjTgVbbL6VWREviloxY5CETkI0bdfNGZZuiL1X28P4tH1/zkKnHb SePT2hldi/xFci/ZYZApk7/Rn7bm881oKp92tVXWLNEIhgXfCbXFMVWIGu+fkVytAYYU joBErH81jl8pb6O60ZYW5oXCF+qqtFFFQWYxGHhHVNnZjQfOduKl8LWJSXEBcECIY51/ 5UUw== 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=j4Pa6AaD11YFWbmWnx+oyTpQprnUAPqORvuUTpM5Xuw=; b=cKaO/wzSoopWgT1TFYcq4SULRfX6oNSAcs+tCk/RuM342RDVHQrhuf4MZUBUxnCQAl uWqdmpjMR14vZvBYafW4KNr0KdB5PVsh33SXwlUyuOVVeT1jc58tVqzlr05lYOAMUJTz WCnuVUqQnou4ZQ+Mtkd5EJQkcg585dUp5CLuawgvDvpMExEB0XzApPfWGCzT57XlHWdJ bs5mQr9onD/OhARNtbYkUxKfkdkyBmuQ/E54HApCz4/KUnjnqGabqcV6LTh31gGk29en ByFLrvQXGNuomQuXpPKVQG7Gw46zqB04UWPsCeS8spw5XRTgNNJDwPS+hoZ5vp/EtL7A ASlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=O6Q5+GrA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l68si6131227pfb.248.2019.04.19.11.31.09; Fri, 19 Apr 2019 11:31:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=O6Q5+GrA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728039AbfDSS34 (ORCPT + 99 others); Fri, 19 Apr 2019 14:29:56 -0400 Received: from mail-lf1-f48.google.com ([209.85.167.48]:45176 "EHLO mail-lf1-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726976AbfDSS3z (ORCPT ); Fri, 19 Apr 2019 14:29:55 -0400 Received: by mail-lf1-f48.google.com with SMTP id t11so4571643lfl.12 for ; Fri, 19 Apr 2019 11:29: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=j4Pa6AaD11YFWbmWnx+oyTpQprnUAPqORvuUTpM5Xuw=; b=O6Q5+GrAK7AxKAU6R3bcr5tL2B2L81VIjsIgmsOOhsZVD8iJ86wAGcqox7QC0zGGm1 W9L53HaLy/EVleG8CNrqtDGYiTHd8nr/LevmYFsuM9BgGpzLymCavDN+bBC9M/z6DcVF g3axT4iMKotCNYPdxBtlwANC2CxFrlsBybWog= 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=j4Pa6AaD11YFWbmWnx+oyTpQprnUAPqORvuUTpM5Xuw=; b=mXmRq9UDnq6KqGSVM7OqTUcyZSQLYHV+wghcnzBTUxMXBllz99yvJ61oRT3DByCo80 gVtcFMBswBNPZHbnfTaJRHX4f0QkfFXnfGMoQq4G55zVIB5BQzXKxhkq4G3PZDhdfBhq kfUoFu1E5DeA14M7PSTSe04xHQpgx0op7Or5h3BUApSd9QTa9MBWiJmfBqT2Guy7QgB4 eIqwRU3QyZx3Xa9yFuiRYb+6jRrnnOiBec1UPLxIsGnht+0oHryeVRGUfph4QiMthbAm +hjH9q4iIaYrVtdbw26ECF7cR67cO+Cm6CmiFmaj5ztZuzRk5TcGb5tS817GJL7Cu2Y6 PD3g== X-Gm-Message-State: APjAAAV1+Ex/i/zp2GMfZ5L23Cq3/rGV7vT5b0t0depABx+wpL9DHvce ESRVjxI/QzmdJ4ABEy+SXJFBF3src0Q= X-Received: by 2002:a19:f24c:: with SMTP id d12mr2866824lfk.163.1555694855894; Fri, 19 Apr 2019 10:27:35 -0700 (PDT) Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com. [209.85.208.171]) by smtp.gmail.com with ESMTPSA id c5sm1330546ljd.18.2019.04.19.10.27.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Apr 2019 10:27:34 -0700 (PDT) Received: by mail-lj1-f171.google.com with SMTP id h16so5177155ljg.11 for ; Fri, 19 Apr 2019 10:27:34 -0700 (PDT) X-Received: by 2002:a2e:3e0e:: with SMTP id l14mr2872561lja.125.1555694853846; Fri, 19 Apr 2019 10:27:33 -0700 (PDT) MIME-Version: 1.0 References: <20190415051919.GA31481@infradead.org> <20190416110906.6c773aff@mschwideX1> <20190416140658.2cb73a3f@mschwideX1> <20190417094637.51ad4c67@mschwideX1> <20190417100244.42e29736@mschwideX1> <20190418100218.0a4afd51@mschwideX1> <20190418204144.16adf2a0@mschwideX1> <20190419153307.4f2911b5@mschwideX1> In-Reply-To: <20190419153307.4f2911b5@mschwideX1> From: Linus Torvalds Date: Fri, 19 Apr 2019 10:27:17 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Linux 5.1-rc5 To: Martin Schwidefsky Cc: Christoph Hellwig , Linux List Kernel Mailing , Michael Ellerman , linuxppc-dev@lists.ozlabs.org, linux-s390 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, Apr 19, 2019 at 6:33 AM Martin Schwidefsky wrote: > > That problem got stuck in my head and I thought more about it. Why not > emulate the static folding sequence in the s390 page table code? So this model seems much closer to what x86 does in its folding, where the pattern is basically > static inline pX-1d_t *pXd_offset(pXd_t *pXd, unsigned long address) > { > if (pXd_folded(pXd) > return (pX-1d_t *) pXd; > return (pX-1d_t *) pXd_deref(*pXd) + pXd_index(address); > } which is really how the code is designed to work (ie the folded entry doesn't actually do anything to the page directory pointer, it just says "ok, we'll use this exact page directory pointer for the next lower level instead". And that's very much what allows the generic gup code to load the entry once, and use a temporary, and as you walk down the chain, if it is folded it just then uses that (previous) temporary value for the next level instead. IOW, the lower level page table is hidden inside the upper level one, and folding just means "don't do any offsets, don't change any values, just use the entry as-is for the next lower level". So I think that's the right thing to do. Looking at the s390 code, it seems to fold things the other way, conceptually hiding the upper level inside the lower one, and always doing the offset thing (but just avoiding the dereference). Maybe there's some reason why the s390 code does it that way, but I think your new model is the right one, and hopefully means you can use the generic page table walking more easily. Of course, the s390 folding is very different from the x86 one (or the generic fixed 3-level of 4-level cases). The x86 folding doesn't depend on the contents of the page tables, it's just entirely static (well, the 5th level is conditional, but it's conditional on a static key, not on what is in the page tables). So maybe the old model of s390 made more sense in that context, but I look at your new suggested pXd_offset() functions and I go "yeah, that's the way it's supposed to work". Linus