Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp8200124rwr; Wed, 10 May 2023 20:16:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4aEPmoDU7zCwkDZvUpPYLSWs739yF5goTJ0g/3PWCTZ0Xok6Ev7Y54JlEMcRgJq9ka/kSo X-Received: by 2002:a17:902:db08:b0:1a6:b496:4053 with SMTP id m8-20020a170902db0800b001a6b4964053mr23148873plx.59.1683775018096; Wed, 10 May 2023 20:16:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683775018; cv=none; d=google.com; s=arc-20160816; b=PBgfyCblum5cpK7KT67ppcKG6+Hfw5CK4jQhs59+v5lDYruVqmukz7bEBMDgcQ8qPt Q5whyb8HBEf2o4ghrNwfp5Kv68fX07Ij/GGsrgXPLa6EP6DBMpqbiuG3iQO7CfVGZmun 66A30uISNCvZHVeQ9KKURx48PwhTh9mroc47EbHxypo4nMUYuJiofNUZDaFYQNXdudRN XCjm+It6pjEI7NEd+slo+Tn2za6PIvsYeR5D62Ykc5aI0L/AW2K35IZ3YiEl/we+c1iX h2hN2CRooOp5jpoZG5xWbQt3Nvc7HKSuZN8HkzxpgnaHWfmM0qG6iEska1Tvk1XBRkjI t66g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=VKY0MPg+ixVSR7jOZPK9uKssH+HTM4GRvqWKWUn/BFA=; b=ZiEC6l7EuwmmMZu7MYEhmnTBIVG6hcnA3n2jJKEBGg5k5uGrIzmuRZYOmJHiEi/MsU aQxMz8qEKKO1bO5++SnOZk2hPHkHktcPyi+KRrlgnaYtqZsDA0Q4Zhzg/rjRqO9eTlAJ Wcse6UQIe6kKUAkjeWAg7Jq4NbNjnm3snMWvKx85AueDLG1Ivd3kusg8jw9mlfcywESJ QhUJvjpwwypYnv+cLtSrn+KrkkEiwiaeJAC8T6SI7f0cBoJDsKa4xHJiai0Y6FKqupgX h3boPVOnrqhJShztyVSw5fa8A52rk0u2M+fHfd64YsPsVcBTLcSFbWsOL89OaaEl0r4c Wbgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="A/8Yl5mL"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k2-20020a17090a590200b002528f40700dsi407975pji.153.2023.05.10.20.16.43; Wed, 10 May 2023 20:16:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="A/8Yl5mL"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235540AbjEKC6C (ORCPT + 99 others); Wed, 10 May 2023 22:58:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233919AbjEKC6A (ORCPT ); Wed, 10 May 2023 22:58:00 -0400 Received: from mail-yw1-x1132.google.com (mail-yw1-x1132.google.com [IPv6:2607:f8b0:4864:20::1132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3CD4173A for ; Wed, 10 May 2023 19:57:58 -0700 (PDT) Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-55a14807e4cso143722077b3.1 for ; Wed, 10 May 2023 19:57:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683773878; x=1686365878; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=VKY0MPg+ixVSR7jOZPK9uKssH+HTM4GRvqWKWUn/BFA=; b=A/8Yl5mLDDyzpMzxH/65tVA6ZiqBtbA3d9RA8fCNCX4cspZ3FSeBdW0oUC/QrOwu05 JoxxoIZTWWZvG9sUA5Kt4j/mCk5PbrWXYCjVoAOE6DA24+iPz85mkYE73LNDr0oFWCdT rH/bRk56/wMHo6z0qHtG+YSqxp4dd4t3ZJ8DxDyJqTsMSx9i6fBtQEQ4PO2NHpeCsaUL CWzLaMlncwyqAXylxS2D1Zyo1qpYkgLrxXJlwsKj/b67fZ4WppqlP9S5HEb7GRAykDlw k/Vb5i8FWzhnGt6pe/zFYyUpDBBrPTmJLrRKIFY1WW7hoXogJGukSIZoffaAETEPY/4t xZVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683773878; x=1686365878; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=VKY0MPg+ixVSR7jOZPK9uKssH+HTM4GRvqWKWUn/BFA=; b=TWCvnhUadpWoQMOrCzBWqNM3yKdvF8WOLaKAKtBXTKxFrQMsHgt1nt9yLPFIyyE1qG dfRlPrbUR0fMRBHBKyffrTwY9dTo5QRvCwqevnqcqC8F1l+iQsHt3o2FC4d1AR2ZV0S0 Jd+/YAVuI4gyq9n9OyZHpoZDmFYM6kdL2ObNapPh2wIKy36gWsNbe+dAwHJmYyiMwA4W 1P5ibC4tnHjO/eETZDEirLGIsVSc2zGuOFzffWv/ONo5En6U66SM+rljOcmLvUbxLEtB 5sXruRDYJLtkDOQ5WLLNZwZlkOm+G5ej+KUycWnhpBK/LLfo0Oig5EDLTKDDafSHzhve Tv4w== X-Gm-Message-State: AC+VfDwoGS6szUfk7GIpbxMFEnGTZss/MTCprxifvjCfmCirYHbFGyry mJzrK0pG29Wig5BPM+Jn/2vPPQ== X-Received: by 2002:a81:d54b:0:b0:55a:2102:1699 with SMTP id l11-20020a81d54b000000b0055a21021699mr20828006ywj.11.1683773877637; Wed, 10 May 2023 19:57:57 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id q6-20020a0de706000000b0055a07e36659sm4496591ywe.145.2023.05.10.19.57.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 19:57:57 -0700 (PDT) Date: Wed, 10 May 2023 19:57:46 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Geert Uytterhoeven cc: Hugh Dickins , Andrew Morton , Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Russell King , Catalin Marinas , Will Deacon , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 05/23] m68k: allow pte_offset_map[_lock]() to fail In-Reply-To: Message-ID: References: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> <237c8410-ce61-94c-4260-7318ad6a4f3@google.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="-1463760895-840625160-1683773877=:9548" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---1463760895-840625160-1683773877=:9548 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE On Wed, 10 May 2023, Geert Uytterhoeven wrote: > Hi Hugh, >=20 > Thanks for your patch! And thank you for looking so quickly, Geert. >=20 > On Wed, May 10, 2023 at 6:48=E2=80=AFAM Hugh Dickins w= rote: > > In rare transient cases, not yet made possible, pte_offset_map() and > > pte_offset_map_lock() may not find a page table: handle appropriately. > > > > Restructure cf_tlb_miss() with a pte_unmap() (previously omitted) > > at label out, followed by one local_irq_restore() for all. >=20 > That's a bug fix, which should be a separate patch? No, that's not a bug fix for the current tree, since m68k does not offer CONFIG_HIGHPTE, so pte_unmap() is never anything but a no-op for m68k (see include/linux/pgtable.h). But I want to change pte_unmap() to do something even without CONFIG_HIGHPTE, so have to fix up any such previously harmless omissions in this series first. >=20 > > > > Signed-off-by: Hugh Dickins >=20 >=20 > > --- a/arch/m68k/include/asm/mmu_context.h > > +++ b/arch/m68k/include/asm/mmu_context.h > > @@ -99,7 +99,7 @@ static inline void load_ksp_mmu(struct task_struct *t= ask) > > p4d_t *p4d; > > pud_t *pud; > > pmd_t *pmd; > > - pte_t *pte; > > + pte_t *pte =3D NULL; > > unsigned long mmuar; > > > > local_irq_save(flags); > > @@ -139,7 +139,7 @@ static inline void load_ksp_mmu(struct task_struct = *task) > > > > pte =3D (mmuar >=3D PAGE_OFFSET) ? pte_offset_kernel(pmd, mmuar= ) > > : pte_offset_map(pmd, mmuar); > > - if (pte_none(*pte) || !pte_present(*pte)) > > + if (!pte || pte_none(*pte) || !pte_present(*pte)) > > goto bug; >=20 > If the absence of a pte is to become a non-abnormal case, it should > probably jump to "end" instead, to avoid spamming the kernel log. I don't think so (but of course it's hard for you to tell, without seeing all completed series of series). If pmd_none(*pmd) can safely goto bug just above, and pte_none(*pte) goto bug here, well, the !pte case is going to be stranger than either of those. My understanding of this function, load_ksp_mmu(), is that it's dealing at context switch with a part of userspace which very much needs to be present: whatever keeps that from being swapped out or migrated at present, will be sure to keep the !pte case away - we cannot steal its page table just at random (and a THP on m68k would be surprising too). Though there is one case I can think of which will cause !pte here, and so goto bug: if the pmd entry has got corrupted, and counts as pmd_bad(), which will be tested (and cleared) in pte_offset_map(). But it is okay to report a bug in that case. I can certainly change this to goto end instead if you still prefer, no problem; but I'd rather keep it as is, if only for me to be proved wrong by you actually seeing spam there. >=20 > > > > set_pte(pte, pte_mkyoung(*pte)); > > @@ -161,6 +161,8 @@ static inline void load_ksp_mmu(struct task_struct = *task) > > bug: > > pr_info("ksp load failed: mm=3D0x%p ksp=3D0x08%lx\n", mm, mmuar= ); > > end: > > + if (pte && mmuar < PAGE_OFFSET) > > + pte_unmap(pte); >=20 > Is this also a bugfix, not mentioned in the patch description? I'm not sure whether you're referring to the pte_unmap() which we already discussed above, or you're seeing something else in addition; but I don't think there's a bugfix here, just a rearrangement because we now want lots of cases to do the pte_unmap() and local_irq_restore(). Hugh >=20 > > local_irq_restore(flags); > > } > > >=20 > Gr{oetje,eeting}s, >=20 > Geert >=20 > --=20 > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m6= 8k.org >=20 > In personal conversations with technical people, I call myself a hacker. = But > when I'm talking to journalists I just say "programmer" or something like= that. > -- Linus Torvalds ---1463760895-840625160-1683773877=:9548--