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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB5DEC433EF for ; Tue, 14 Dec 2021 17:26:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6D7876B0073; Tue, 14 Dec 2021 12:26:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 687776B0074; Tue, 14 Dec 2021 12:26:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 551AB6B0075; Tue, 14 Dec 2021 12:26:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0198.hostedemail.com [216.40.44.198]) by kanga.kvack.org (Postfix) with ESMTP id 477C66B0073 for ; Tue, 14 Dec 2021 12:26:31 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 057B688CE2 for ; Tue, 14 Dec 2021 17:26:21 +0000 (UTC) X-FDA: 78917078562.24.DE336B2 Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) by imf15.hostedemail.com (Postfix) with ESMTP id A5D00A0011 for ; Tue, 14 Dec 2021 17:26:16 +0000 (UTC) Received: by mail-qt1-f173.google.com with SMTP id t11so19081982qtw.3 for ; Tue, 14 Dec 2021 09:26:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=826lo/OFrJk222r+sN9o+DWKehRdrydX6E4AepnaF0s=; b=IwvDyDAhFzTN/2kqd+8GOULtlqslwkBF0xnSRC3TOU/lsSOxhKa/KXJqEX+3ntr6im rvUhVUvh/qKdYX5TdopzduX9r7Aia69aGiYhXUZWcPUzz/xrofpUpPgPxvUsYsdnYhRN Fl2BZSL8IvoVuVChtSsCAu50+rKp5ABHCGkbaPHIAksbusurn+Tzjl14CH+eGjYya7hd 0b+87fFi6GQH8FjMmdMsEjnNZRrKfKFlwkZvYDqFAl322vVzKUliUHV56qWpHOTJEz2y R7KCO1NWweNvB+V8WYtz0opj+x+RVq5zbp42650li6Cb+U+pZQ5C+6TP8jb0Y7aB/Loc 3+Zg== X-Gm-Message-State: AOAM532uKW/pc/BVf32gGV2xG6bkn/B6kNe2EOdy2EKhMOc3J4MRpWTN vdTjEdhbscCXwu4bstE4dcI= X-Google-Smtp-Source: ABdhPJzssn55vxdoSsLT8NneKqIz7PCLs3RZ2yix4ovt3oIj6BFwXJ6bRiipof1/EM41W7TkUADNNQ== X-Received: by 2002:ac8:588e:: with SMTP id t14mr7408245qta.437.1639502778434; Tue, 14 Dec 2021 09:26:18 -0800 (PST) Received: from fedora (pool-173-68-57-129.nycmny.fios.verizon.net. [173.68.57.129]) by smtp.gmail.com with ESMTPSA id a16sm367167qta.94.2021.12.14.09.26.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Dec 2021 09:26:17 -0800 (PST) Date: Tue, 14 Dec 2021 12:26:16 -0500 From: Dennis Zhou To: Geert Uytterhoeven Cc: Vladimir Murzin , linux-arch-owner@vger.kernel.org, Linux MM , Tejun Heo , Christoph Lameter , Andrew Morton , Nicholas Piggin , Christoph Hellwig , Arnd Bergmann , Linux-sh list , Rich Felker , linux-riscv Subject: Re: [PATCH] percpu: km: ensure it is used with NOMMU (either UP or SMP) Message-ID: References: <20211130172954.129587-1-vladimir.murzin@arm.com> <20211130172954.129587-2-vladimir.murzin@arm.com> <8c2b4666-cf13-3735-be1e-b8a1c71df113@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Authentication-Results: imf15.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none); spf=pass (imf15.hostedemail.com: domain of dennisszhou@gmail.com designates 209.85.160.173 as permitted sender) smtp.mailfrom=dennisszhou@gmail.com X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: A5D00A0011 X-Stat-Signature: q4pn5hi95rtuiw4jjwausjdx7wwerto3 X-HE-Tag: 1639502776-578402 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: Hello, On Tue, Dec 14, 2021 at 05:29:22PM +0100, Geert Uytterhoeven wrote: > Hi Vladimir and Dennis, > > On Wed, Dec 1, 2021 at 12:53 PM Vladimir Murzin wrote: > > On 11/30/21 5:41 PM, Dennis Zhou wrote: > > > On Tue, Nov 30, 2021 at 05:29:54PM +0000, Vladimir Murzin wrote: > > >> Currently, NOMMU pull km allocator via !SMP dependency because most of > > >> them are UP, yet for SMP+NOMMU vm allocator gets pulled which: > > >> > > >> * may lead to broken build [1] > > >> * ...or not working runtime due to [2] > > >> > > >> It looks like SMP+NOMMU case was overlooked in bbddff054587 ("percpu: > > >> use percpu allocator on UP too") so restore that. > > >> > > >> [1] > > >> For ARM SMP+NOMMU (R-class cores) > > >> > > >> arm-none-linux-gnueabihf-ld: mm/percpu.o: in function `pcpu_post_unmap_tlb_flush': > > >> mm/percpu-vm.c:188: undefined reference to `flush_tlb_kernel_range' > > >> > > >> [2] > > >> static inline > > >> int vmap_pages_range_noflush(unsigned long addr, unsigned long end, > > >> pgprot_t prot, struct page **pages, unsigned int page_shift) > > >> { > > >> return -EINVAL; > > >> } > > >> > > >> Signed-off-by: Vladimir Murzin > > >> --- > > >> mm/Kconfig | 3 +-- > > >> 1 file changed, 1 insertion(+), 2 deletions(-) > > >> > > >> diff --git a/mm/Kconfig b/mm/Kconfig > > >> index d16ba92..66331e0 100644 > > >> --- a/mm/Kconfig > > >> +++ b/mm/Kconfig > > >> @@ -425,9 +425,8 @@ config THP_SWAP > > >> # UP and nommu archs use km based percpu allocator > > >> # > > >> config NEED_PER_CPU_KM > > >> - depends on !SMP > > >> bool > > >> - default y > > >> + default !SMP || !MMU > > >> > > > > > > Should this be `depends on !SMP || !MMU` with default yes? Because with > > > SMP && MMU, it shouldn't be an option to run with percpu-km. > > > > IIUC these are equivalent, truth table would not change if is under "depends" > > or "default" > > > > SMP MMU NEED_PER_CPU_KM > > y y !y || !y => n || n => n > > y n !y || !n => n || y => y > > n y !n || !y => y || n => y > > n n !n || !n => y || y => y > > > > > > > >> config CLEANCACHE > > >> bool "Enable cleancache driver to cache clean pages if tmem is present" > > >> -- > > >> 2.7.4 > > >> > > > > > > It's interesting to me that this is all coming up at once. Earlier this > > > month I had the same conversation with people involved with sh [1]. > > > > > > [1] https://lore.kernel.org/linux-sh/YY7tp5attRyK42Zk@fedora/ > > > > > > I can pull this shortly once I see whatever happened to linux-sh. > > > > Ahh, good to know! Adding SH folks here (start of discussion [0]). I see you came > > to the same conclusion, right? > > > > IIRC, RISC-V also have SMP+NOMMU, so adding them as well. > > I had seen the j-Core thread, but completely forgot about > Canaan K210 (RV64 SMP+NOMMU). > > This became commit 3583521aabac76e5 ("percpu: km: ensure it is used > with NOMMU (either UP or SMP)"). And now booting K210 prints: > > percpu: wasting 10 pages per chunk > > a) Is this bad? It's not great.. Can you share the line on boot with the following prefix: pcpu-alloc [1]. I'm a little surprised here because this means it's allocating not against the right atomic size. I don't necesarily think it's an issue of switching from percpu-vm to percpu-km. > b) What exactly was this fixing, and how would I trigger the bad case > on K210 before, if it was affected at all? > In v5.14, I merged Roman's request for percpu depopulation [2]. This required calls to flush the tlb. There is an abstraction layer: percpu-vm vs percpu-km. So if an architecture is using percpu-vm but doesn't have an MMU AND doesn't map out appropriately the tlb flush call, then it fails. This happened on arm + sh architectures. Now RV might be mapping it out appropriately so they never saw the issue. Now, there is also a bigger caveat with using percpu-vm without an MMU. In percpu-vm, we allocate pages on demand and map them in into pre-allocated vmas. This means there are 2 scenarios that I haven't looked into deeper. 1, the vma alloc maps to allocating physical pages. 2, we're lucky percpu allocates backwards in the vma so we haven't had a collision problem yet. [1] https://git.kernel.org/pub/scm/linux/kernel/git/dennis/percpu.git/tree/mm/percpu.c#n2507 [2] https://lore.kernel.org/lkml/20210419225047.3415425-1-dennis@kernel.org/ Thanks, Dennis > > > > [0] https://lore.kernel.org/linux-mm/20211130172954.129587-1-vladimir.murzin@arm.com/T/ > > 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