Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1606228pxa; Thu, 13 Aug 2020 12:24:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwl6Dgn881AoK0uzy0qTO27cOzb49gozMrNs2ACuOiGOaZFGVYMXMsWSn8zjkl23eAyKiZb X-Received: by 2002:a50:93a2:: with SMTP id o31mr6257132eda.203.1597346678956; Thu, 13 Aug 2020 12:24:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597346678; cv=none; d=google.com; s=arc-20160816; b=E54xeVwiRAyps2ZbnA+SZ+58dJd7OFpAnzZcJYZXMxRiQz14HrRI2nd75bD4lFLZKO KQ2EQUJRy14PX2yQipJnKsvQjjIA0IWRzO7o/psMgdU3x54UmbW7wX7wQVjeR9RZhB17 GzEaA9+zl0kWN/K9izQrhgeRO1dSOEiYGoDuHwlx117o3Oz82glNlrGYgAnRr+G4Xypp y4sKGCWiaOA+GoUG7gXU2dowH+lBFM5R9tAMTjffG4Df4AWc/KEscV981FGokOix+vUf YZF1iwpK3RBlLdbUVg7cudSdjGMQaK7JAnU7blmskiCl8rmFYhT3UktIzD9EUsFB2syg ovDw== 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=XVrQlhbY2LBFm8eHP/4vv+LthPgeA+gEbL08m7IjfDA=; b=amogqdi4i/7UW6AyFgeb8sM4FyzY/aNSRdpxDz9nr7aN8Xj7reQubAUivAHnDtfKBP sJJq9magqp5TluG3WflZx5GFkZZr1Umcqwrz7i+9MwkQ+vLHN98INZspAy84y8deqRB4 3E9V8uFJQdEuvkCby6B0pLoOPLm/ceqnTBnQ1R9b3dEICSi/Q9F2192Bi5ZFNJOcYejq 9Cx3dB7jgWwFpepshjuwfwYZ8nwokeyjI39Zf9cYw2CNhE70yyJf0W9tEM710sN+xmd8 ZDkYvjLYQ2eoaRb+GyNltk0rb/Yk+HDCF3gSxYvvpzLB6hR7yLjP1BoseHJ90RDJ8idn Zj/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=dFl7oWZF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rp21si3849526ejb.0.2020.08.13.12.24.14; Thu, 13 Aug 2020 12:24:38 -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=fail header.i=@gmail.com header.s=20161025 header.b=dFl7oWZF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726526AbgHMTVS (ORCPT + 99 others); Thu, 13 Aug 2020 15:21:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726244AbgHMTVR (ORCPT ); Thu, 13 Aug 2020 15:21:17 -0400 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D9ADC061757 for ; Thu, 13 Aug 2020 12:21:17 -0700 (PDT) Received: by mail-ej1-x641.google.com with SMTP id bo3so7354061ejb.11 for ; Thu, 13 Aug 2020 12:21:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=XVrQlhbY2LBFm8eHP/4vv+LthPgeA+gEbL08m7IjfDA=; b=dFl7oWZFR+WUBCcPOXjfJ3ft448yYTYqwF2qOidfjPsC1xtdhVVADigmDF3GxG9fFl TbzxunMt0NuLbOuobQ2aS+8kI40a0dZdQak9HqDE5HaI11NTOCCCssmQrTAJRIK1KaK1 7k4aim5YRDKz7Y5x6EbZ9JjjrIXlCc6GRfRN9mhHrTCOcRzfaRKnvvirs6vz9rh1cYIB iFpF61K5/O9xmgiAf7CFlPxMB0ZFAPsaks1KAfosSE3B4u8xzP/JpQ+9t+LvE+bIF+p3 C8hwP9t3fGRvbTxonruJU5+oPT1lBUzO8f9nT9gk6edreGFptjOX2yVlOZpPTbpkafC8 x3dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=XVrQlhbY2LBFm8eHP/4vv+LthPgeA+gEbL08m7IjfDA=; b=tlXfJ+21NgPkJpObb4NZ15pkYLVuG0/Ao0zx6+5yiSsJqXxKm8aqLBOQ9sbgo2ArF9 SnuU0/VmX75qJuzWumZm9s9X9wy3knClwPoJhjqxETpp49ycuMrXbKvk7m2WILKcq1gb 2LSUDVpyZSRXfx6Df7yFfAAuIyny0+R3MnCMQ6LEMTWqvGvd5pJK7udlWfV5Z6hYLDFf +z0DnSkLFNBva3p3/hekQRFwaEtw4HlKeYIc1RFvWj5DLU26VVkT81chs1eZuGgRpn+i qLUDQvEWH14+ETssLM5MjLZtf0oevHf0TNfgMpt1Ai6KfOUO8VOMFjfIPXny+49+YuUW jjWg== X-Gm-Message-State: AOAM533v0A0AnIfg8FH7sPGoqn1pecL1086Ccz0DQIW/rOURf7yIy5hU AqMb8oWck3OsIiMN0mklkdw= X-Received: by 2002:a17:906:2a04:: with SMTP id j4mr6566953eje.440.1597346476253; Thu, 13 Aug 2020 12:21:16 -0700 (PDT) Received: from gmail.com (54033286.catv.pool.telekom.hu. [84.3.50.134]) by smtp.gmail.com with ESMTPSA id t3sm4674617edq.26.2020.08.13.12.21.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Aug 2020 12:21:15 -0700 (PDT) Date: Thu, 13 Aug 2020 21:21:13 +0200 From: Ingo Molnar To: Mike Rapoport Cc: Dave Hansen , Joerg Roedel , x86@kernel.org, Andy Lutomirski , Peter Zijlstra , hpa@zytor.com, Joerg Roedel , Linus Torvalds , Jason@zx2c4.com, Andrew Morton , linux-kernel@vger.kernel.org, "Shutemov, Kirill" Subject: Re: [PATCH] x86/mm/64: Do not dereference non-present PGD entries Message-ID: <20200813192113.GA2338781@gmail.com> References: <20200807084013.7090-1-joro@8bytes.org> <165106f9-392f-9ca5-52c8-8d58c41c5f79@intel.com> <20200810155359.GV163101@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200810155359.GV163101@linux.ibm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Mike Rapoport wrote: > On Mon, Aug 10, 2020 at 07:27:33AM -0700, Dave Hansen wrote: > > ... adding Kirill > > > > On 8/7/20 1:40 AM, Joerg Roedel wrote: > > > + lvl = "p4d"; > > > + p4d = p4d_alloc(&init_mm, pgd, addr); > > > + if (!p4d) > > > + goto failed; > > > > > > + /* > > > + * With 5-level paging the P4D level is not folded. So the PGDs > > > + * are now populated and there is no need to walk down to the > > > + * PUD level. > > > + */ > > > if (pgtable_l5_enabled()) > > > continue; > > > > It's early and I'm a coffee or two short of awake, but I had to stare at > > the comment for a but to make sense of it. > > > > It feels wrong, I think, because the 5-level code usually ends up doing > > *more* allocations and in this case, it is _appearing_ to do fewer. > > Would something like this make sense? > > Unless I miss something, with 5 levels vmalloc mappings are shared at > p4d level, so allocating a p4d page would be enough. With 4 levels, > p4d_alloc() is a nop and pud is the first actually populated level below > pgd. > > > /* > > * The goal here is to allocate all possibly required > > * hardware page tables pointed to by the top hardware > > * level. > > * > > * On 4-level systems, the p4d layer is folded away and > > * the above code does no preallocation. Below, go down > > * to the pud _software_ level to ensure the second > > * hardware level is allocated. > > */ Would be nice to integrate all these explanations into the comment itself? Thanks, Ingo