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=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 97F28C2D0BF for ; Thu, 5 Dec 2019 15:27:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B1F9E2464E for ; Thu, 5 Dec 2019 15:27:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B1F9E2464E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3F0A36B10D9; Thu, 5 Dec 2019 10:27:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 37B156B10DA; Thu, 5 Dec 2019 10:27:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 21C046B10DB; Thu, 5 Dec 2019 10:27:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0142.hostedemail.com [216.40.44.142]) by kanga.kvack.org (Postfix) with ESMTP id 08B5B6B10D9 for ; Thu, 5 Dec 2019 10:27:11 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id B2BF482DF889 for ; Thu, 5 Dec 2019 15:27:10 +0000 (UTC) X-FDA: 76231466220.12.skate22_5bb351f559e20 X-HE-Tag: skate22_5bb351f559e20 X-Filterd-Recvd-Size: 6568 Received: from mail-ot1-f65.google.com (mail-ot1-f65.google.com [209.85.210.65]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Thu, 5 Dec 2019 15:27:10 +0000 (UTC) Received: by mail-ot1-f65.google.com with SMTP id g18so2864132otj.13 for ; 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=GJ6zKQKDobifUzMJ3zk6Lek2nv5NwY8SYaewMTF2ZL96JW/Kv0YUFseVx6oobYz1Sc NvStb83W3O2ydijOC8SrHIWKkpTObSlXn7wBfq/JmqW2GnHyaFkFWq3zTZdSBDWQqKyE ujW/5dFjNCgN62Ri7TfwEw7+Lo6pBd8SGouIQgaeq+/hZLCcELrdp8IFia4N52jGANQK qt9rgse6lGKRFZdKQQuuqgJfUBYKFYmc3F7Jw8GoLWWzMuMHnGurI4OHM3ONho9Vr4ea jIFO2gEen9cdUPDTRfuaWoxHRJt6uGd7jOFo+Af2XIXU8BJm7gO/2NT2qm/ZgnjVkJgg ps7A== X-Gm-Message-State: APjAAAX3PtQ/ULOFQJToW6yv5eeOcLe3hRy2nOugdYY4+/6zZV0b7gmA LRS+9MrjdCUBmzg3uu1kumzsVc0dKxwMwUZfY2A= X-Google-Smtp-Source: APXvYqwHCmPlfMrZYZj+ql/m9hWI+YZzgBndE9T9km42bN1m86N9jZu3XfoBgpqFZvcdKfpjvilVI7g5aPfn4CHsDqQ= 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" 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: 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