From patchwork Fri Nov 10 14:07:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Ghiti X-Patchwork-Id: 13452444 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 296C7C4332F for ; Fri, 10 Nov 2023 14:09:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A1B66280028; Fri, 10 Nov 2023 09:09:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9A47F280022; Fri, 10 Nov 2023 09:09:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 81E20280028; Fri, 10 Nov 2023 09:09:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 6A602280022 for ; Fri, 10 Nov 2023 09:09:29 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 40B01B4C0A for ; Fri, 10 Nov 2023 14:09:29 +0000 (UTC) X-FDA: 81442227258.18.561AA92 Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) by imf06.hostedemail.com (Postfix) with ESMTP id 3FEA6180024 for ; Fri, 10 Nov 2023 14:09:26 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=jiXz5Fh0; dmarc=none; spf=pass (imf06.hostedemail.com: domain of alexghiti@rivosinc.com designates 209.85.208.173 as permitted sender) smtp.mailfrom=alexghiti@rivosinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699625367; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=TNncknImGYd0G7MADnDhbFKl7Y37Hs80keyCtMwuCbk=; b=1NJboyd366y4EIRBzYAM3yllKxlO3zCJippj0p0p5VfE94q/i+alZ0oPkupDIdPGJwX2+g FXQsE41GW27fVZcTXb5SCefrNXB693Fye9c+0mwQjtzW9AUHX3zKy0yZObTcOQMwoQZX3u Pwr1cVQPNc1r/py5Ial+OzpDoNcoifI= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=jiXz5Fh0; dmarc=none; spf=pass (imf06.hostedemail.com: domain of alexghiti@rivosinc.com designates 209.85.208.173 as permitted sender) smtp.mailfrom=alexghiti@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699625367; a=rsa-sha256; cv=none; b=JgM2hhGSaIwJ9XiIj4gMJ4KCBHidbt5hodmC013S+I+tyGhy/tRugC0MSiZmm+10Eh82SZ DxHgS2rmCIEVBKbXDJl106/eGOrAZea5tdnXswTmQQzRdCVN8SPd946fhcBgvyS/NRUpMO KjPEiidyvYUZG/7w4Zu5EXRNDriI9EU= Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-2c501bd6ff1so28348371fa.3 for ; Fri, 10 Nov 2023 06:09:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1699625365; x=1700230165; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TNncknImGYd0G7MADnDhbFKl7Y37Hs80keyCtMwuCbk=; b=jiXz5Fh0UUe0/KpSzjDXOyvFY8EtNoMXwGx9HhhHBUdFvg/M+SZ43tUCGQCTYU2DpE m8vgoVTrpWwzErtfCEUrTYKd2J1yDCUYhYtj20uKthcz1/QagNejRmKXZTrFYvO7cH8W 6RnQJdujrGbY+LFOwIc8InuKiqeECFSJczCndT4dzXy3TNGfOad3GTYsARHucRD/yHde kpGaVOx0/0YOHAT4pgJ62EIguhEuGWJy/Vml5xADzj8Ftmz6nZ0YDXQlA2p0xcJWTH8i WxEP8NkWfdLVMwWjzFPt+rKknRb+TcfqM8Zwj0UK53r81ngUx2B7Oq3YwPo7thZY636K Wftw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699625365; x=1700230165; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TNncknImGYd0G7MADnDhbFKl7Y37Hs80keyCtMwuCbk=; b=Qe0wQcqiHRgFRDv2MNob+cQ+r0L+BJldLvsvcr+c3m+7bnelfexzfzx0BQK4wkM4cl KerqbDkyxW9yi2JbZzQZgDDnncI0vAEq7wfbkmuN5WstW0bnSymWnvZGNNVIuKW6sSBc mP5qilqZDfyJdronaJYpVvqDCRTGVlLKegh6BCm8Bea0ujrbHaynjJ3ueKrybNVitbdq Li+N7ty4EhAiKsn+DVIpvFPVGhb/JQW2YlwlY7uhTA19tCbAhZOAxnAlmRmstVBLc+DM D0yUCJ2BYo+jIXrK/4FVPp7VmsG6AqTVbTxHmOdW2qYt7Wj5vpnd0jOXguiclBPGeCML DKIQ== X-Gm-Message-State: AOJu0YztGKPll5/OiYY2GkIVBxzA252aBIild7ZQ3KYqA/o++k4+duuI bI+mRxHfbRWG027PammjMu+33A== X-Google-Smtp-Source: AGHT+IFnc5DDn6eDvAmwHfvD11R9Doa6XtjEu4mYLiLBs82TOIbZPRsbYbDAWR9qLMG/ZVUIcvzhnw== X-Received: by 2002:a2e:2c15:0:b0:2c6:f51f:c96d with SMTP id s21-20020a2e2c15000000b002c6f51fc96dmr6506404ljs.13.1699625365568; Fri, 10 Nov 2023 06:09:25 -0800 (PST) Received: from alex-rivos.home (amontpellier-656-1-456-62.w92-145.abo.wanadoo.fr. [92.145.124.62]) by smtp.gmail.com with ESMTPSA id b12-20020a05600c150c00b004083a105f27sm5173099wmg.26.2023.11.10.06.09.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Nov 2023 06:09:25 -0800 (PST) From: Alexandre Ghiti To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Arnd Bergmann , Dennis Zhou , Tejun Heo , Christoph Lameter , Andrew Morton , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-mm@kvack.org Cc: Alexandre Ghiti Subject: [PATCH 2/2] riscv: Enable pcpu page first chunk allocator Date: Fri, 10 Nov 2023 15:07:21 +0100 Message-Id: <20231110140721.114235-3-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231110140721.114235-1-alexghiti@rivosinc.com> References: <20231110140721.114235-1-alexghiti@rivosinc.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 3FEA6180024 X-Stat-Signature: 46gj4pap6ypaczyiakbkicn3hjie1xpp X-Rspam-User: X-HE-Tag: 1699625366-170396 X-HE-Meta: U2FsdGVkX195/ANg+fvHuC0Di3fRye8KZBNEtDje6XRvVnhpxd3A/pnzt1kYyk6G+ICVzcygSGTq2sU4iZOGb75STNkKlbwKokD5zBBxSvdH0U7BnE4RqaimVWWInFoxCdf6D9DlEn7EPnfbNe8fzME2eGXmPMgpwjj4aVjBLQ4zRJc/x3se1A9j2mmgxZmwhWTQbD6C20biwvK025VfQuFyYdVXW9saPoEVac/nKttRuI/FrQqIsJAJfKBlDV94scYTcYSaKwzDlV9CGLfyif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XwcS3Bfl+WuPFXk2BB0FTGlFOWDQLntuB/ffzQS+RUGx7bcBcDAXWGxVDiU5VpPL6WsnF5SHKcXm0IZAgPtPv9xlYcJAlOToZlvb7qWi9MSiXEVxNJ7iEAzVkgu2J42b5/6CP7aguiUcO5G2EKy+QXFJ1E= 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: List-Subscribe: List-Unsubscribe: As explained in commit 6ea529a2037c ("percpu: make embedding first chunk allocator check vmalloc space size"), the embedding first chunk allocator needs the vmalloc space to be larger than the maximum distance between units which are grouped into NUMA nodes. On a very sparse NUMA configurations and a small vmalloc area (for example, it is 64GB in sv39), the allocation of dynamic percpu data in the vmalloc area could fail. So provide the pcpu page allocator as a fallback in case we fall into such a sparse configuration (which happened in arm64 as shown by commit 09cea6195073 ("arm64: support page mapping percpu first chunk allocator")). Signed-off-by: Alexandre Ghiti --- arch/riscv/Kconfig | 2 ++ arch/riscv/mm/kasan_init.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 5b1e61aca6cf..7b82d8301e42 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -416,7 +416,9 @@ config NUMA depends on SMP && MMU select ARCH_SUPPORTS_NUMA_BALANCING select GENERIC_ARCH_NUMA + select HAVE_SETUP_PER_CPU_AREA select NEED_PER_CPU_EMBED_FIRST_CHUNK + select NEED_PER_CPU_PAGE_FIRST_CHUNK select OF_NUMA select USE_PERCPU_NUMA_NODE_ID help diff --git a/arch/riscv/mm/kasan_init.c b/arch/riscv/mm/kasan_init.c index 5e39dcf23fdb..4c9a2c527f08 100644 --- a/arch/riscv/mm/kasan_init.c +++ b/arch/riscv/mm/kasan_init.c @@ -438,6 +438,14 @@ static void __init kasan_shallow_populate(void *start, void *end) kasan_shallow_populate_pgd(vaddr, vend); } +#ifdef CONFIG_KASAN_VMALLOC +void __init kasan_populate_early_vm_area_shadow(void *start, unsigned long size) +{ + kasan_populate(kasan_mem_to_shadow(start), + kasan_mem_to_shadow(start + size)); +} +#endif + static void __init create_tmp_mapping(void) { void *ptr;