From patchwork Tue Dec 12 21:34:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Ghiti X-Patchwork-Id: 13490010 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 9C277C4332F for ; Tue, 12 Dec 2023 21:37:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2FA518D0005; Tue, 12 Dec 2023 16:37:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A8AA8D0001; Tue, 12 Dec 2023 16:37:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1494F8D0005; Tue, 12 Dec 2023 16:37:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 00E9D8D0001 for ; Tue, 12 Dec 2023 16:37:04 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id CE5A31A0A9B for ; Tue, 12 Dec 2023 21:37:04 +0000 (UTC) X-FDA: 81559476768.25.54D8095 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by imf01.hostedemail.com (Postfix) with ESMTP id F01A340028 for ; Tue, 12 Dec 2023 21:37:02 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=VtzUvGmb; spf=pass (imf01.hostedemail.com: domain of alexghiti@rivosinc.com designates 209.85.128.46 as permitted sender) smtp.mailfrom=alexghiti@rivosinc.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702417023; 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=qCOh69caXbVfDD+nz3SkSSNJ4LOnzQLxIG6SJxHDatw=; b=mxN2YXYt5Pf7jjwEv/ohwi5oaXCT/IO3thKfvb2LFePz2hYTeoQAnBjBo/J4A4wRWzQmuk zjMQYQbU+QRWiDCJZ3kvmZb1ebNGrXmr0o/IRKloxB6VZSwZ9HaKQeDh880fuYS3WY9A9D YkY+9V6j0KWKsmEHwlIt7iuxB52k4hM= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=VtzUvGmb; spf=pass (imf01.hostedemail.com: domain of alexghiti@rivosinc.com designates 209.85.128.46 as permitted sender) smtp.mailfrom=alexghiti@rivosinc.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702417023; a=rsa-sha256; cv=none; b=U+1wanvT12HyJU6NlIIjP2K6uzySZ+Qb9ybl/NJwdBVRg5/qs4rE1bnWU3Es6GRIcRQvL2 Pk5BAowQA8gC/zZPrBBwCU9QSZCzlmGorHuWLWdF2oVnRMJs0sbiZzzMOLMDxQmdN6lVIf X/i+osS4JvoetBmkecBARuZOnMlhUsI= Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-40c2bb872e2so58038935e9.3 for ; Tue, 12 Dec 2023 13:37:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1702417021; x=1703021821; 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=qCOh69caXbVfDD+nz3SkSSNJ4LOnzQLxIG6SJxHDatw=; b=VtzUvGmbV5FDawSGrZujQz1ei4mqJFJrD9rbOn1wm0lDDfTLK8Vjo7/ypm53V5Lzww 4pbXCLjwvYgxslq1OMclup0t+DuQHMeKw3qjKoP9x34J08z3xlfYsBom6w83MpfaKUL0 bzzWQ+ciSJU4GDjjZhIZnOiA89E5jrx0OgGVnexmkB3yP4K5fNe4fV0l3M2w/eKGTQAI Nz1TNuUVo1YI0ChbYO6wZVmWeTd0OSeKeGDy38XfWfn9OKob3E0xY4uMfx+xLlHzbsHt ajQCBXJwRbaXPWdDNFFpkyLkI4f3BWOSSSODZITXPVzOYvDeJaTKNc4fJaTR1BjlG02L Gt+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702417021; x=1703021821; 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=qCOh69caXbVfDD+nz3SkSSNJ4LOnzQLxIG6SJxHDatw=; b=wbSZAmV5IhSJ11LmOWRKlaasoNEoaWf4GACGXEA2PYZLXhhdvsciioQOeeGz5afewy 7dX7nuUBE7oe9T/AzuqTkbqL5xebJH2+mPDpRI8UprWfKxgE8kMiUaUhwK79ZElvi28n L+TtqIBO/CL2oNNMPOAdyLuv3dtMdFas2YWveHe9dYnqePo5V1nHxaCWIaUIQylEWXzs oH46RYjAKgVx+fbhvrkoySu+Ajw6/2s+QmmqDyrUpUiLENl7m6PArk37U0V+dT55GgDt 3GU4LvIYy/5FNxFgd5LhKlJYmE5DNUXr7lduv2oeniI6TAaYlJRMYT/B1A45y+wiaYHg 5oWQ== X-Gm-Message-State: AOJu0Yxn5JODN2uowodtucZELleC/9hTiMcaTAh7/18BaTALOao7xlzG zEoloQyVpF8VSpWakVqs78Wksw== X-Google-Smtp-Source: AGHT+IFqqgEgVUuuLcp/jxl4AbRQVAxPSPDTSvhp/ckLGpwai+H0FWmy2ZTFwQBh1m466TRnZ7G6vg== X-Received: by 2002:a05:600c:2814:b0:40b:5f03:b43f with SMTP id m20-20020a05600c281400b0040b5f03b43fmr1885174wmb.353.1702417021655; Tue, 12 Dec 2023 13:37:01 -0800 (PST) Received: from alex-rivos.ba.rivosinc.com (amontpellier-656-1-456-62.w92-145.abo.wanadoo.fr. [92.145.124.62]) by smtp.gmail.com with ESMTPSA id ay35-20020a05600c1e2300b0040b2b38a1fasm17954734wmb.4.2023.12.12.13.37.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 13:37:01 -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 v2 2/2] riscv: Enable pcpu page first chunk allocator Date: Tue, 12 Dec 2023 22:34:57 +0100 Message-Id: <20231212213457.132605-3-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231212213457.132605-1-alexghiti@rivosinc.com> References: <20231212213457.132605-1-alexghiti@rivosinc.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: F01A340028 X-Rspam-User: X-Stat-Signature: 9mcxumrraasss1fcqcibnt6fsb1z3gx5 X-Rspamd-Server: rspam01 X-HE-Tag: 1702417022-811886 X-HE-Meta: U2FsdGVkX19R6Se01LTQjxx5JAU8tZj8Jq8tmAbeF6Gz08F2/UTtRx6p2fY0pQJO5ORqNG/WybGpeqRTCWhP429K3GSQo7wBMLMrh4WD1aox+q5URxPOoCrDJqpuiB2aTGpBwx77UhAuKTjL3b5luhZOpvOo5jrwILCN/Jipw5Ebk8GUhA/jkFgjTHs2n2R3h6aU8BwwuD61/MkD3cuIGyAPMFu5vj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ud6/kABuLxZRQbLDoKqdlTfz99233BK5qfFfrXp+qBLAlVl4CQZN02ouDSfToVu0Rw52VMvxDJZrAN7rePQ7FHzk8vthMnsxSPHBGGwjXmZ0y5cj+6uJF+UHbVgamC03kbfo03M1PgAs+5W/IMoJjf01k4KSEZ/RJdTYzjOEFRDpTUvtCxUDVkCe+1R5xDvbB5DMHQ2+8bVRtNu/jqS9jGYNXoxdQyFtVFr2+L5wBri0ggU6/ZFYkIw== 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 7603bd8ab333..8ba4a63e0ae5 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -415,7 +415,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;