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=-11.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 E4D36C433E0 for ; Thu, 4 Jun 2020 16:58:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B7AC6207DF for ; Thu, 4 Jun 2020 16:58:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="INbAqWsa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730012AbgFDQ6n (ORCPT ); Thu, 4 Jun 2020 12:58:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729907AbgFDQ6m (ORCPT ); Thu, 4 Jun 2020 12:58:42 -0400 Received: from mail-il1-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67D3CC08C5C0; Thu, 4 Jun 2020 09:58:42 -0700 (PDT) Received: by mail-il1-x143.google.com with SMTP id d1so6750761ila.8; Thu, 04 Jun 2020 09:58:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=V0PNBpoMs08sQd4e2o2SoGg1Svcltptif4I91AoTlvg=; b=INbAqWsakbJzK4ZSEEFe429oBmTHcyH/9fRe64K2yh4y2wJGs9smE/e7f9S9PpL5bs Ei3AuQd5J5QASo5h1K5IKhrn7HBM9jIJsQRkdX5VKKmmq9Iv24Nvs3ORCfG/4sFmSM3L IilNtaVFyoUbQ7lJ0xJbyK4mMrpfgu0p+EHbg5L7sMGwDnaQ3HmUoz91WAWyAhp99of5 dXsZCy80rDdj0rr8jk/YobGwpMdvWpus6/V4eNk8sEtY4ihPOAWfI35LqNXZrGT0AtIx +d83hsXhaf7SLFXwpM3UJJ20FguuXVWDyctqM7VjuEdflMMpwhRIjBKBqytpwGwoGoxk k9/g== 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:reply-to :from:date:message-id:subject:to:cc; bh=V0PNBpoMs08sQd4e2o2SoGg1Svcltptif4I91AoTlvg=; b=I5jBkQacxmwyf6mdj++LyHfFfQBB4eI93Bnjewd0jYtyDJXHUAUG07xI15tneN3aiK YQbj5Oo4hlZ+AOhtqIutlTFQwbEmEhAuWd77lzAMSkLVz1RzA+fDNamVCZMZnJExgdrH 37pRlIKtRsCtFbxKdmFW75ChvV0qq+mgX9+jEOzSG/UR1wDxCteEUyEptZXm6IjiwxMy 123iN4E+V2h/wFCrcUhOrck5APFCuFatzn1HBdO6iwcXEiDyp72tVbDG2scC3SN8xgDb cmAW7GtlapeUtUI9Bg9SROqwN6BV/sAdr557//q9doo5kMaebvN8cZvW3EZVtGWIgNcR gliw== X-Gm-Message-State: AOAM530ScT79WOyzsRQ/bC5CLsuZrUFaKE88kZ8ndmIwZ7MOqgh/sqTx A4W5Lo/d9vdNMwjiUZ8E9xQ3PVB3hIuBA/Dbyp0= X-Google-Smtp-Source: ABdhPJwMMOV4ROUKfkRri2iYpXGV3bCFo31xQIsOQpa//uvPw9wXVjqQALsY3dAdNGtINNjfGPr6il3/Rr6FaC+T8Bk= X-Received: by 2002:a92:9603:: with SMTP id g3mr5099315ilh.204.1591289921631; Thu, 04 Jun 2020 09:58:41 -0700 (PDT) MIME-Version: 1.0 References: <20200604074446.23944-1-joro@8bytes.org> <20200604164814.GA7600@kernel.org> In-Reply-To: <20200604164814.GA7600@kernel.org> Reply-To: sedat.dilek@gmail.com From: Sedat Dilek Date: Thu, 4 Jun 2020 18:58:29 +0200 Message-ID: Subject: Re: [PATCH] mm: Fix pud_alloc_track() To: Mike Rapoport Cc: Joerg Roedel , Andrew Morton , peterz@infradead.org, jroedel@suse.de, Andy Lutomirski , Abdul Haleem , Satheesh Rajendran , Stephen Rothwell , manvanth@linux.vnet.ibm.com, linux-next@vger.kernel.org, Steven Rostedt , linuxppc-dev@lists.ozlabs.org, hch@lst.de, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org 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 Thu, Jun 4, 2020 at 6:49 PM Mike Rapoport wrote: > > On Thu, Jun 04, 2020 at 09:44:46AM +0200, Joerg Roedel wrote: > > From: Joerg Roedel > > > > The pud_alloc_track() needs to do different checks based on whether > > __ARCH_HAS_5LEVEL_HACK is defined, like it already does in > > pud_alloc(). Otherwise it causes boot failures on PowerPC. > > > > Provide the correct implementations for both possible settings of > > __ARCH_HAS_5LEVEL_HACK to fix the boot problems. > > There is a patch in mmotm [1] that completely removes > __ARCH_HAS_5LEVEL_HACK which is a part of the series [2] that updates > p4d folding accross architectures. This should fix boot on PowerPC and > the addition of pXd_alloc_track() for __ARCH_HAS_5LEVEL_HACK wouldn't be > necessary. > > > [1] https://github.com/hnaz/linux-mm/commit/cfae68792af3731ac902ea6ba5ed8df5a0f6bd2f > [2] https://lore.kernel.org/kvmarm/20200414153455.21744-1-rppt@kernel.org/ > That link shows an overview of v4 and is easily downloadable as a single mbox file. See " Series = mm: remove __ARCH_HAS_5LEVEL_HACK" - Sedat - [1] https://lore.kernel.org/patchwork/project/lkml/list/?series=438627 > > Reported-by: Abdul Haleem > > Tested-by: Abdul Haleem > > Tested-by: Satheesh Rajendran > > Fixes: d8626138009b ("mm: add functions to track page directory modifications") > > Signed-off-by: Joerg Roedel > > --- > > include/asm-generic/5level-fixup.h | 5 +++++ > > include/linux/mm.h | 26 +++++++++++++------------- > > 2 files changed, 18 insertions(+), 13 deletions(-) > > > > diff --git a/include/asm-generic/5level-fixup.h b/include/asm-generic/5level-fixup.h > > index 58046ddc08d0..afbab31fbd7e 100644 > > --- a/include/asm-generic/5level-fixup.h > > +++ b/include/asm-generic/5level-fixup.h > > @@ -17,6 +17,11 @@ > > ((unlikely(pgd_none(*(p4d))) && __pud_alloc(mm, p4d, address)) ? \ > > NULL : pud_offset(p4d, address)) > > > > +#define pud_alloc_track(mm, p4d, address, mask) \ > > + ((unlikely(pgd_none(*(p4d))) && \ > > + (__pud_alloc(mm, p4d, address) || ({*(mask)|=PGTBL_P4D_MODIFIED;0;})))? \ > > + NULL : pud_offset(p4d, address)) > > + > > #define p4d_alloc(mm, pgd, address) (pgd) > > #define p4d_alloc_track(mm, pgd, address, mask) (pgd) > > #define p4d_offset(pgd, start) (pgd) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > > index 66e0977f970a..ad3b31c5bcc3 100644 > > --- a/include/linux/mm.h > > +++ b/include/linux/mm.h > > @@ -2088,35 +2088,35 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, p4d_t *p4d, > > NULL : pud_offset(p4d, address); > > } > > > > -static inline p4d_t *p4d_alloc_track(struct mm_struct *mm, pgd_t *pgd, > > +static inline pud_t *pud_alloc_track(struct mm_struct *mm, p4d_t *p4d, > > unsigned long address, > > pgtbl_mod_mask *mod_mask) > > - > > { > > - if (unlikely(pgd_none(*pgd))) { > > - if (__p4d_alloc(mm, pgd, address)) > > + if (unlikely(p4d_none(*p4d))) { > > + if (__pud_alloc(mm, p4d, address)) > > return NULL; > > - *mod_mask |= PGTBL_PGD_MODIFIED; > > + *mod_mask |= PGTBL_P4D_MODIFIED; > > } > > > > - return p4d_offset(pgd, address); > > + return pud_offset(p4d, address); > > } > > > > -#endif /* !__ARCH_HAS_5LEVEL_HACK */ > > - > > -static inline pud_t *pud_alloc_track(struct mm_struct *mm, p4d_t *p4d, > > +static inline p4d_t *p4d_alloc_track(struct mm_struct *mm, pgd_t *pgd, > > unsigned long address, > > pgtbl_mod_mask *mod_mask) > > + > > { > > - if (unlikely(p4d_none(*p4d))) { > > - if (__pud_alloc(mm, p4d, address)) > > + if (unlikely(pgd_none(*pgd))) { > > + if (__p4d_alloc(mm, pgd, address)) > > return NULL; > > - *mod_mask |= PGTBL_P4D_MODIFIED; > > + *mod_mask |= PGTBL_PGD_MODIFIED; > > } > > > > - return pud_offset(p4d, address); > > + return p4d_offset(pgd, address); > > } > > > > +#endif /* !__ARCH_HAS_5LEVEL_HACK */ > > + > > static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address) > > { > > return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))? > > -- > > 2.26.2 > > > > -- > Sincerely yours, > Mike. 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=-11.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 64EDCC433DF for ; Thu, 4 Jun 2020 16:58:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 11B16207D8 for ; Thu, 4 Jun 2020 16:58:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="INbAqWsa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 11B16207D8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9DBC280007; Thu, 4 Jun 2020 12:58:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 98CD68E0006; Thu, 4 Jun 2020 12:58:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A19A80007; Thu, 4 Jun 2020 12:58:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0164.hostedemail.com [216.40.44.164]) by kanga.kvack.org (Postfix) with ESMTP id 689F08E0006 for ; Thu, 4 Jun 2020 12:58:43 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 23906171BBC for ; Thu, 4 Jun 2020 16:58:43 +0000 (UTC) X-FDA: 76892138526.16.peace45_863e7135adb00 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id F1A3A103CE090 for ; Thu, 4 Jun 2020 16:58:42 +0000 (UTC) X-HE-Tag: peace45_863e7135adb00 X-Filterd-Recvd-Size: 7860 Received: from mail-il1-f193.google.com (mail-il1-f193.google.com [209.85.166.193]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Thu, 4 Jun 2020 16:58:42 +0000 (UTC) Received: by mail-il1-f193.google.com with SMTP id a13so6785669ilh.3 for ; Thu, 04 Jun 2020 09:58:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=V0PNBpoMs08sQd4e2o2SoGg1Svcltptif4I91AoTlvg=; b=INbAqWsakbJzK4ZSEEFe429oBmTHcyH/9fRe64K2yh4y2wJGs9smE/e7f9S9PpL5bs Ei3AuQd5J5QASo5h1K5IKhrn7HBM9jIJsQRkdX5VKKmmq9Iv24Nvs3ORCfG/4sFmSM3L IilNtaVFyoUbQ7lJ0xJbyK4mMrpfgu0p+EHbg5L7sMGwDnaQ3HmUoz91WAWyAhp99of5 dXsZCy80rDdj0rr8jk/YobGwpMdvWpus6/V4eNk8sEtY4ihPOAWfI35LqNXZrGT0AtIx +d83hsXhaf7SLFXwpM3UJJ20FguuXVWDyctqM7VjuEdflMMpwhRIjBKBqytpwGwoGoxk k9/g== 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:reply-to :from:date:message-id:subject:to:cc; bh=V0PNBpoMs08sQd4e2o2SoGg1Svcltptif4I91AoTlvg=; b=OUVA+yUbayqyS6MaTDUMkwZW49RvRD7zHakhTuswrrCUm9XuK4Ucw0dHDNJCgTAxBs yeOVIYbbo4Mtm33Qczs6Nr3qlcdw0tvYBvxVgvZIxEXKR8JRAga3hpUFhZ1/C1WzAIHn g1r3FrmkaXLnK972YyqMe01RB2XcYTJwR3eZmO0C0OUAvoYjoAFesWtwFoVDGnJY2T2z iYp733r3LmS4eYPuJhDNfop5iAc9/7tkC+NXdyKIrY4XZYSDFuPRak8fEC+/XHBjulCd d3VuF+OLJeSh1iH7ui985LLwkHBLM5pjryxQ3IflKty9EOR2o31W6FeWxHIM/GGgJQ+a 7AkQ== X-Gm-Message-State: AOAM532aD1U4jzRv7rWYlRDqd6Gnd46WXSXx3+sBsPMsBDS8oIl2KF+Z gL4euHfD7ulKp5JpLLAg1sLIMIswsuF/QxpFXCs= X-Google-Smtp-Source: ABdhPJwMMOV4ROUKfkRri2iYpXGV3bCFo31xQIsOQpa//uvPw9wXVjqQALsY3dAdNGtINNjfGPr6il3/Rr6FaC+T8Bk= X-Received: by 2002:a92:9603:: with SMTP id g3mr5099315ilh.204.1591289921631; Thu, 04 Jun 2020 09:58:41 -0700 (PDT) MIME-Version: 1.0 References: <20200604074446.23944-1-joro@8bytes.org> <20200604164814.GA7600@kernel.org> In-Reply-To: <20200604164814.GA7600@kernel.org> Reply-To: sedat.dilek@gmail.com From: Sedat Dilek Date: Thu, 4 Jun 2020 18:58:29 +0200 Message-ID: Subject: Re: [PATCH] mm: Fix pud_alloc_track() To: Mike Rapoport Cc: Joerg Roedel , Andrew Morton , peterz@infradead.org, jroedel@suse.de, Andy Lutomirski , Abdul Haleem , Satheesh Rajendran , Stephen Rothwell , manvanth@linux.vnet.ibm.com, linux-next@vger.kernel.org, Steven Rostedt , linuxppc-dev@lists.ozlabs.org, hch@lst.de, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: F1A3A103CE090 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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 Thu, Jun 4, 2020 at 6:49 PM Mike Rapoport wrote: > > On Thu, Jun 04, 2020 at 09:44:46AM +0200, Joerg Roedel wrote: > > From: Joerg Roedel > > > > The pud_alloc_track() needs to do different checks based on whether > > __ARCH_HAS_5LEVEL_HACK is defined, like it already does in > > pud_alloc(). Otherwise it causes boot failures on PowerPC. > > > > Provide the correct implementations for both possible settings of > > __ARCH_HAS_5LEVEL_HACK to fix the boot problems. > > There is a patch in mmotm [1] that completely removes > __ARCH_HAS_5LEVEL_HACK which is a part of the series [2] that updates > p4d folding accross architectures. This should fix boot on PowerPC and > the addition of pXd_alloc_track() for __ARCH_HAS_5LEVEL_HACK wouldn't be > necessary. > > > [1] https://github.com/hnaz/linux-mm/commit/cfae68792af3731ac902ea6ba5ed8df5a0f6bd2f > [2] https://lore.kernel.org/kvmarm/20200414153455.21744-1-rppt@kernel.org/ > That link shows an overview of v4 and is easily downloadable as a single mbox file. See " Series = mm: remove __ARCH_HAS_5LEVEL_HACK" - Sedat - [1] https://lore.kernel.org/patchwork/project/lkml/list/?series=438627 > > Reported-by: Abdul Haleem > > Tested-by: Abdul Haleem > > Tested-by: Satheesh Rajendran > > Fixes: d8626138009b ("mm: add functions to track page directory modifications") > > Signed-off-by: Joerg Roedel > > --- > > include/asm-generic/5level-fixup.h | 5 +++++ > > include/linux/mm.h | 26 +++++++++++++------------- > > 2 files changed, 18 insertions(+), 13 deletions(-) > > > > diff --git a/include/asm-generic/5level-fixup.h b/include/asm-generic/5level-fixup.h > > index 58046ddc08d0..afbab31fbd7e 100644 > > --- a/include/asm-generic/5level-fixup.h > > +++ b/include/asm-generic/5level-fixup.h > > @@ -17,6 +17,11 @@ > > ((unlikely(pgd_none(*(p4d))) && __pud_alloc(mm, p4d, address)) ? \ > > NULL : pud_offset(p4d, address)) > > > > +#define pud_alloc_track(mm, p4d, address, mask) \ > > + ((unlikely(pgd_none(*(p4d))) && \ > > + (__pud_alloc(mm, p4d, address) || ({*(mask)|=PGTBL_P4D_MODIFIED;0;})))? \ > > + NULL : pud_offset(p4d, address)) > > + > > #define p4d_alloc(mm, pgd, address) (pgd) > > #define p4d_alloc_track(mm, pgd, address, mask) (pgd) > > #define p4d_offset(pgd, start) (pgd) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > > index 66e0977f970a..ad3b31c5bcc3 100644 > > --- a/include/linux/mm.h > > +++ b/include/linux/mm.h > > @@ -2088,35 +2088,35 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, p4d_t *p4d, > > NULL : pud_offset(p4d, address); > > } > > > > -static inline p4d_t *p4d_alloc_track(struct mm_struct *mm, pgd_t *pgd, > > +static inline pud_t *pud_alloc_track(struct mm_struct *mm, p4d_t *p4d, > > unsigned long address, > > pgtbl_mod_mask *mod_mask) > > - > > { > > - if (unlikely(pgd_none(*pgd))) { > > - if (__p4d_alloc(mm, pgd, address)) > > + if (unlikely(p4d_none(*p4d))) { > > + if (__pud_alloc(mm, p4d, address)) > > return NULL; > > - *mod_mask |= PGTBL_PGD_MODIFIED; > > + *mod_mask |= PGTBL_P4D_MODIFIED; > > } > > > > - return p4d_offset(pgd, address); > > + return pud_offset(p4d, address); > > } > > > > -#endif /* !__ARCH_HAS_5LEVEL_HACK */ > > - > > -static inline pud_t *pud_alloc_track(struct mm_struct *mm, p4d_t *p4d, > > +static inline p4d_t *p4d_alloc_track(struct mm_struct *mm, pgd_t *pgd, > > unsigned long address, > > pgtbl_mod_mask *mod_mask) > > + > > { > > - if (unlikely(p4d_none(*p4d))) { > > - if (__pud_alloc(mm, p4d, address)) > > + if (unlikely(pgd_none(*pgd))) { > > + if (__p4d_alloc(mm, pgd, address)) > > return NULL; > > - *mod_mask |= PGTBL_P4D_MODIFIED; > > + *mod_mask |= PGTBL_PGD_MODIFIED; > > } > > > > - return pud_offset(p4d, address); > > + return p4d_offset(pgd, address); > > } > > > > +#endif /* !__ARCH_HAS_5LEVEL_HACK */ > > + > > static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address) > > { > > return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))? > > -- > > 2.26.2 > > > > -- > Sincerely yours, > Mike. 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=-11.3 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 10440C433E3 for ; Thu, 4 Jun 2020 17:02:03 +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 AD0C320738 for ; Thu, 4 Jun 2020 17:02:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="INbAqWsa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AD0C320738 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com 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 49dBs44hfwzDqBg for ; Fri, 5 Jun 2020 03:02:00 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::144; helo=mail-il1-x144.google.com; envelope-from=sedat.dilek@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=INbAqWsa; dkim-atps=neutral Received: from mail-il1-x144.google.com (mail-il1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) (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 49dBnS4R58zDqrZ for ; Fri, 5 Jun 2020 02:58:46 +1000 (AEST) Received: by mail-il1-x144.google.com with SMTP id 9so6726577ilg.12 for ; Thu, 04 Jun 2020 09:58:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=V0PNBpoMs08sQd4e2o2SoGg1Svcltptif4I91AoTlvg=; b=INbAqWsakbJzK4ZSEEFe429oBmTHcyH/9fRe64K2yh4y2wJGs9smE/e7f9S9PpL5bs Ei3AuQd5J5QASo5h1K5IKhrn7HBM9jIJsQRkdX5VKKmmq9Iv24Nvs3ORCfG/4sFmSM3L IilNtaVFyoUbQ7lJ0xJbyK4mMrpfgu0p+EHbg5L7sMGwDnaQ3HmUoz91WAWyAhp99of5 dXsZCy80rDdj0rr8jk/YobGwpMdvWpus6/V4eNk8sEtY4ihPOAWfI35LqNXZrGT0AtIx +d83hsXhaf7SLFXwpM3UJJ20FguuXVWDyctqM7VjuEdflMMpwhRIjBKBqytpwGwoGoxk k9/g== 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:reply-to :from:date:message-id:subject:to:cc; bh=V0PNBpoMs08sQd4e2o2SoGg1Svcltptif4I91AoTlvg=; b=iUG0A1fjqbaCwy+bN5/2PQfthBHQKfRlq5xkDrgZOBRCdFFjlAs58ZQc1ZmGbM3eKW We7m/kQxae1rsEa//sqTgbho0WZE15G9e5f3CECIW+289CWrCXeNLRJ6uM3MbAssj4iW S2AC1ttEPe5ON0Uzl6/XGSM32jRpKsuqhRHTPyxg16pjaYs63yFOq/NnD3nJREM9GqF+ sYAnekq36fMOxxNYhRH4cI5ewPRSKLgYLYZKbTemw+xupKJ1QPhHK3dErLZpUSmV5n6a c6ZuRBvJD7DD92/6G24mqFuyiluJan+k8g/G4NDKnoOrFZUAnZ8bR3Fb7AFqxgGrICQ2 bQlA== X-Gm-Message-State: AOAM5308iSzF+TSK89xjLRadYKpwJNp5L0lry6wwbrjkGJrI2aZWZtS2 6Ku++515nhsIKWXxhziBXteOjsv7ZFF27c1WuQs= X-Google-Smtp-Source: ABdhPJwMMOV4ROUKfkRri2iYpXGV3bCFo31xQIsOQpa//uvPw9wXVjqQALsY3dAdNGtINNjfGPr6il3/Rr6FaC+T8Bk= X-Received: by 2002:a92:9603:: with SMTP id g3mr5099315ilh.204.1591289921631; Thu, 04 Jun 2020 09:58:41 -0700 (PDT) MIME-Version: 1.0 References: <20200604074446.23944-1-joro@8bytes.org> <20200604164814.GA7600@kernel.org> In-Reply-To: <20200604164814.GA7600@kernel.org> From: Sedat Dilek Date: Thu, 4 Jun 2020 18:58:29 +0200 Message-ID: Subject: Re: [PATCH] mm: Fix pud_alloc_track() To: Mike Rapoport 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: , Reply-To: sedat.dilek@gmail.com Cc: linux-arch@vger.kernel.org, Stephen Rothwell , jroedel@suse.de, linux-mm@kvack.org, peterz@infradead.org, linuxppc-dev@lists.ozlabs.org, Joerg Roedel , linux-kernel@vger.kernel.org, Steven Rostedt , Abdul Haleem , linux-next@vger.kernel.org, Satheesh Rajendran , Andy Lutomirski , Andrew Morton , manvanth@linux.vnet.ibm.com, hch@lst.de Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Thu, Jun 4, 2020 at 6:49 PM Mike Rapoport wrote: > > On Thu, Jun 04, 2020 at 09:44:46AM +0200, Joerg Roedel wrote: > > From: Joerg Roedel > > > > The pud_alloc_track() needs to do different checks based on whether > > __ARCH_HAS_5LEVEL_HACK is defined, like it already does in > > pud_alloc(). Otherwise it causes boot failures on PowerPC. > > > > Provide the correct implementations for both possible settings of > > __ARCH_HAS_5LEVEL_HACK to fix the boot problems. > > There is a patch in mmotm [1] that completely removes > __ARCH_HAS_5LEVEL_HACK which is a part of the series [2] that updates > p4d folding accross architectures. This should fix boot on PowerPC and > the addition of pXd_alloc_track() for __ARCH_HAS_5LEVEL_HACK wouldn't be > necessary. > > > [1] https://github.com/hnaz/linux-mm/commit/cfae68792af3731ac902ea6ba5ed8df5a0f6bd2f > [2] https://lore.kernel.org/kvmarm/20200414153455.21744-1-rppt@kernel.org/ > That link shows an overview of v4 and is easily downloadable as a single mbox file. See " Series = mm: remove __ARCH_HAS_5LEVEL_HACK" - Sedat - [1] https://lore.kernel.org/patchwork/project/lkml/list/?series=438627 > > Reported-by: Abdul Haleem > > Tested-by: Abdul Haleem > > Tested-by: Satheesh Rajendran > > Fixes: d8626138009b ("mm: add functions to track page directory modifications") > > Signed-off-by: Joerg Roedel > > --- > > include/asm-generic/5level-fixup.h | 5 +++++ > > include/linux/mm.h | 26 +++++++++++++------------- > > 2 files changed, 18 insertions(+), 13 deletions(-) > > > > diff --git a/include/asm-generic/5level-fixup.h b/include/asm-generic/5level-fixup.h > > index 58046ddc08d0..afbab31fbd7e 100644 > > --- a/include/asm-generic/5level-fixup.h > > +++ b/include/asm-generic/5level-fixup.h > > @@ -17,6 +17,11 @@ > > ((unlikely(pgd_none(*(p4d))) && __pud_alloc(mm, p4d, address)) ? \ > > NULL : pud_offset(p4d, address)) > > > > +#define pud_alloc_track(mm, p4d, address, mask) \ > > + ((unlikely(pgd_none(*(p4d))) && \ > > + (__pud_alloc(mm, p4d, address) || ({*(mask)|=PGTBL_P4D_MODIFIED;0;})))? \ > > + NULL : pud_offset(p4d, address)) > > + > > #define p4d_alloc(mm, pgd, address) (pgd) > > #define p4d_alloc_track(mm, pgd, address, mask) (pgd) > > #define p4d_offset(pgd, start) (pgd) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > > index 66e0977f970a..ad3b31c5bcc3 100644 > > --- a/include/linux/mm.h > > +++ b/include/linux/mm.h > > @@ -2088,35 +2088,35 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, p4d_t *p4d, > > NULL : pud_offset(p4d, address); > > } > > > > -static inline p4d_t *p4d_alloc_track(struct mm_struct *mm, pgd_t *pgd, > > +static inline pud_t *pud_alloc_track(struct mm_struct *mm, p4d_t *p4d, > > unsigned long address, > > pgtbl_mod_mask *mod_mask) > > - > > { > > - if (unlikely(pgd_none(*pgd))) { > > - if (__p4d_alloc(mm, pgd, address)) > > + if (unlikely(p4d_none(*p4d))) { > > + if (__pud_alloc(mm, p4d, address)) > > return NULL; > > - *mod_mask |= PGTBL_PGD_MODIFIED; > > + *mod_mask |= PGTBL_P4D_MODIFIED; > > } > > > > - return p4d_offset(pgd, address); > > + return pud_offset(p4d, address); > > } > > > > -#endif /* !__ARCH_HAS_5LEVEL_HACK */ > > - > > -static inline pud_t *pud_alloc_track(struct mm_struct *mm, p4d_t *p4d, > > +static inline p4d_t *p4d_alloc_track(struct mm_struct *mm, pgd_t *pgd, > > unsigned long address, > > pgtbl_mod_mask *mod_mask) > > + > > { > > - if (unlikely(p4d_none(*p4d))) { > > - if (__pud_alloc(mm, p4d, address)) > > + if (unlikely(pgd_none(*pgd))) { > > + if (__p4d_alloc(mm, pgd, address)) > > return NULL; > > - *mod_mask |= PGTBL_P4D_MODIFIED; > > + *mod_mask |= PGTBL_PGD_MODIFIED; > > } > > > > - return pud_offset(p4d, address); > > + return p4d_offset(pgd, address); > > } > > > > +#endif /* !__ARCH_HAS_5LEVEL_HACK */ > > + > > static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address) > > { > > return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))? > > -- > > 2.26.2 > > > > -- > Sincerely yours, > Mike.