Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1867439ybl; Thu, 5 Dec 2019 08:15:09 -0800 (PST) X-Google-Smtp-Source: APXvYqx3Eq5ipaxq7vvqFo6AoTXbB+ygd96g1Utvw5CdD3YhHHQeK8pym1wtSRLcSX4ReWwXCgAg X-Received: by 2002:aca:75d0:: with SMTP id q199mr8030441oic.121.1575562509700; Thu, 05 Dec 2019 08:15:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575562509; cv=none; d=google.com; s=arc-20160816; b=RPDXzjkF0gTZ9BV6lKS2U7d3QJNE2cVh8kZHDKAfEjCtANdddrk8w2dlLaSi7D5pWz RmlLSqQskwWlajUj07rO74aEThTpgLAqZ8Qq0txeqRng5zmYYhPdp+5ZaBZ69TM2BSIk TtEVUB7IcttFVl8ZODtkSF2OwFWCpz0L0+ZXfm/LD+1Y+hYWgZHt0geRUmbGvejPV/7P /+rMKP74yMHxMDKvNBpGi+LQq7rtvTAqPYIKbFQ16B2HSUUOZQHXY/gOEwi43nr7spM0 K/czF0qNMVuqN3Dm64XFFsOqFHWsPQOiiTyG4lDHYJvl8wGkDZ3UIoarZ/kUGzdPHlVq 3Ppg== 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; bh=BzeWlAHVU2HltvIFrP0fsFnUxdM4qbyfP8pavgfcc7w=; b=hpYjJ5suFdhkjOvp9P6KH/aMmEIJljwYBNTkgXrctUSWmQdzrnSUFow3mg7FMGuT3i qkGj/0SfvYMCXOI9wJEuwX1rp/4arcegGiYiuiiYg7M1+8UI/I9LS19jszHUF4WSOdA3 707O0ZPXeNPaGIFZ0XtronQXWvHGM3F8uH5w61AmxHWprWHba2RGijDZyVoIvh+nE3hU PqdTnHHQPNRcnknSkK6QrHfhlQGk78HHgPUzevy2BpqAvCUf5nqYC1Im+8fbmBB0Ss4R rlg4BJLjdpkqbPTo6TH5XeG8nLu2Mk9Wt00+twF/qgKyNCees4QhL3hfH/S5vLXLUdc+ aHSw== ARC-Authentication-Results: i=1; mx.google.com; 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 l20si5075672otd.292.2019.12.05.08.14.54; Thu, 05 Dec 2019 08:15:09 -0800 (PST) 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; 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 S1729703AbfLEP1K (ORCPT + 99 others); Thu, 5 Dec 2019 10:27:10 -0500 Received: from mail-ot1-f68.google.com ([209.85.210.68]:44650 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725909AbfLEP1K (ORCPT ); Thu, 5 Dec 2019 10:27:10 -0500 Received: by mail-ot1-f68.google.com with SMTP id x3so2876123oto.11; Thu, 05 Dec 2019 07:27:09 -0800 (PST) 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=BzeWlAHVU2HltvIFrP0fsFnUxdM4qbyfP8pavgfcc7w=; b=rAQvSKU3K8tKj0s5kNllYLui0AYu7uw0hsEXoaczmhFqiGIWmAwrq1CPWY4nYlUHra 3gmOZ4vvkuEOfPmIY0h9LWmUiVnmOvC1/o8vdpiCWOlN9HoRZCkyUht17tPyv7WQKmsZ 4W61py++43aGKPrNxL3Mv0W4qsE27R3VFDFrgwqTZPK2d3WShpp9u5JL0XcIdyIkDGWn j2TVOkDY8mBD8zBxhG72oJnYTjVvcZBhcv80Zp8jwLJ1hLV9j1Rp0Mh3owvQw68X4alZ Hlr+IxG9cKUB8AP3kcQAyOryl3kTTDlBGUjHeXi7vGZQk0cCOZmW2CZrdyUhLJBnUXhU T89w== X-Gm-Message-State: APjAAAWNm7s1GI1ZMFwRM6mrbg/kofCIE078fRAi2e49zX4GBsDHVZ1j yoEu4TU34WCe25mR3tTwBGjFQh4IF/L4J1ypapQ= X-Received: by 2002:a05:6830:91:: with SMTP id a17mr6542243oto.107.1575559629333; Thu, 05 Dec 2019 07:27:09 -0800 (PST) MIME-Version: 1.0 References: <20190219103148.192029670@infradead.org> <20190219103233.443069009@infradead.org> <20191204104733.GR2844@hirez.programming.kicks-ass.net> <20191204133454.GW2844@hirez.programming.kicks-ass.net> <20191204164143.GB2810@hirez.programming.kicks-ass.net> In-Reply-To: <20191204164143.GB2810@hirez.programming.kicks-ass.net> From: Geert Uytterhoeven Date: Thu, 5 Dec 2019 16:26:57 +0100 Message-ID: Subject: Re: [PATCH v6 10/18] sh/tlb: Convert SH to generic mmu_gather To: Peter Zijlstra Cc: Will Deacon , "Aneesh Kumar K.V" , Andrew Morton , Nicholas Piggin , Linux-Arch , Linux MM , Linux Kernel Mailing List , Russell King , Heiko Carstens , Rik van Riel , Yoshinori Sato , Rich Felker , Linux-sh list , Guenter Roeck 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 Hoi Peter, On Wed, Dec 4, 2019 at 5:42 PM Peter Zijlstra wrote: > On Wed, Dec 04, 2019 at 04:07:53PM +0100, Geert Uytterhoeven wrote: > > On Wed, Dec 4, 2019 at 2:35 PM Peter Zijlstra wrote: > > > Does this fare better? > > > > Yes. Migo-R is happy again. > > Tested-by: Geert Uytterhoeven > > > > > --- a/arch/sh/include/asm/pgalloc.h > > > +++ b/arch/sh/include/asm/pgalloc.h > > > @@ -36,9 +36,7 @@ do { \ > > > #if CONFIG_PGTABLE_LEVELS > 2 > > > #define __pmd_free_tlb(tlb, pmdp, addr) \ > > > do { \ > > > - struct page *page = virt_to_page(pmdp); \ > > > - pgtable_pmd_page_dtor(page); \ > > > - tlb_remove_page((tlb), page); \ > > > + pmd_free((tlb)->mm, (pmdp)); \ > > > } while (0); > > > #endif > > OK, so I was going to write a Changelog to go with that, but then I > realized that while this works and is similar to before the patch, I'm > not sure this is in fact correct. > > With this on (and also before) we're freeing the PMD before we've done > the TLB invalidate, that seems wrong! > > Looking at the size of that pmd_cache, that looks to be 30-(12+12-3)+3 > == 12, which is exactly 1 page, for PAGE_SIZE_4K, less for the larger > pages. > > I'm thinking perhaps we should do something like the below instead? Your advice is better when in close vicinity of an SH cross compiler, though ;-) > --- a/arch/sh/mm/pgtable.c > +++ b/arch/sh/mm/pgtable.c > @@ -5,9 +5,6 @@ > #define PGALLOC_GFP GFP_KERNEL | __GFP_ZERO > > static struct kmem_cache *pgd_cachep; > -#if PAGETABLE_LEVELS > 2 > -static struct kmem_cache *pmd_cachep; > -#endif > > void pgd_ctor(void *x) > { > @@ -23,11 +20,6 @@ void pgtable_cache_init(void) > pgd_cachep = kmem_cache_create("pgd_cache", > PTRS_PER_PGD * (1< PAGE_SIZE, SLAB_PANIC, pgd_ctor); > -#if PAGETABLE_LEVELS > 2 > - pmd_cachep = kmem_cache_create("pmd_cache", > - PTRS_PER_PMD * (1< - PAGE_SIZE, SLAB_PANIC, NULL); > -#endif > } > > pgd_t *pgd_alloc(struct mm_struct *mm) > @@ -48,11 +40,7 @@ void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd) > > pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address) > { > - return kmem_cache_alloc(pmd_cachep, PGALLOC_GFP); > -} > - > -void pmd_free(struct mm_struct *mm, pmd_t *pmd) mm/memory.o: In function `__pmd_alloc': memory.c:(.text+0x1d74): undefined reference to `pmd_free' > -{ > - kmem_cache_free(pmd_cachep, pmd); > + BUILD_BUG_ON(PTRS_PER_PMD * (1< PAGE_SIZE ? Else it triggers all the time. > + return (pmd_t *)__get_free_page(PGALLOC_GFP); > } > #endif /* PAGETABLE_LEVELS > 2 */ BTW, I'm still running Willy's fix that never made it upstream to kill an ugly boot warning, which also touches this code: https://patchwork.kernel.org/patch/10549883/#22166333 Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org 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