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=-7.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,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 1EE12C433DB for ; Sun, 24 Jan 2021 23:17:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A0AE5229C6 for ; Sun, 24 Jan 2021 23:17:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A0AE5229C6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DA7EA6B0005; Sun, 24 Jan 2021 18:17:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D56FD6B0007; Sun, 24 Jan 2021 18:17:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C6E546B0008; Sun, 24 Jan 2021 18:17:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0254.hostedemail.com [216.40.44.254]) by kanga.kvack.org (Postfix) with ESMTP id B1A316B0005 for ; Sun, 24 Jan 2021 18:17:37 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 6B7DF180ACEE9 for ; Sun, 24 Jan 2021 23:17:37 +0000 (UTC) X-FDA: 77742232554.01.touch00_0b09fa627581 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id 37AF810049F05 for ; Sun, 24 Jan 2021 23:17:37 +0000 (UTC) X-HE-Tag: touch00_0b09fa627581 X-Filterd-Recvd-Size: 6528 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Sun, 24 Jan 2021 23:17:36 +0000 (UTC) Received: by mail-pj1-f54.google.com with SMTP id j12so7212198pjy.5 for ; Sun, 24 Jan 2021 15:17:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:references:in-reply-to:mime-version :message-id:content-transfer-encoding; bh=vmIru6MfV60AorXtK81mK9wqaHb82tqsfwMpO7SPkgI=; b=K+U49/R9bHOeSIDkgGZanLLovgbgmh5uQMQVJNnno8FThvFwXybrHyFT1R0qJhL9GK K1z14NFcw8Tqbmru39dBz7taSSjxBTWys7rsL0OmtRPn95vN+d3PRTbM1dM386Q8o3NW ZE49oxL2QRa8FMV1zkeB4pVweM6cN0Tq37ApvBTDV/wUHnSWz3eB8Siv1aq6EDaIUxvk y3agWJFjQS6CACCLLpedCSp9CaUCa8JU1IiOXioY2cIn2r3WVWp8ZTeCKhd8ugm6CgOz +pSx4SP2x2g+/E2iZqd1FQYamEwSq1XLCNZ9sPvJ0B5GgaMWjXqggSIF09D7OVqoJAFB waYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:references:in-reply-to :mime-version:message-id:content-transfer-encoding; bh=vmIru6MfV60AorXtK81mK9wqaHb82tqsfwMpO7SPkgI=; b=iQN1F+ALtY+3jIQesXMOXIMiYFw3F9p+RENSzcMEYsmHmLzMQF3I1v24EixR4yzQ9f aM+/64dWGIEnhDRKEhWHhDaMmKLwi6/5b6ho+TwN9f2aruqSDPtOojbIj0IGuasLInDf F4R9+//xWvj5zLFHMJDY+AYKmZQgBy/uz6Fr2TAgMuGhjHWpkqjkY/kGVis0oQJODEgV BgP6SUxqamAbF1xmKaZIoot75A/AcIEhebk0yX+qaP5aiDvxBdZyFRn0OkcI23vUAGBe jecA/T5a8xF3eNmAOQYU9I3GSOdwgFymTdXrTT7mymKXYXH4uQr4EhLms9c/Hjb0blvS jxpw== X-Gm-Message-State: AOAM531TsHNdXg4Zh3+rII81aWrtH6h4vVIMC3tCzBETmdeoLhZNmVC1 EexyYe8n2xBNnRFa07XZToICWJNuqhI= X-Google-Smtp-Source: ABdhPJy2kG8tVAgVFmG9UnEo3wcKE3mHDXxXZlqFto7Q/Kp/s+THDx1kKu0L5cmF2uvncLYV9yvjIw== X-Received: by 2002:a17:902:c94d:b029:de:9b70:d886 with SMTP id i13-20020a170902c94db02900de9b70d886mr6340876pla.5.1611530255875; Sun, 24 Jan 2021 15:17:35 -0800 (PST) Received: from localhost ([124.170.13.62]) by smtp.gmail.com with ESMTPSA id gg6sm20043833pjb.2.2021.01.24.15.17.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Jan 2021 15:17:34 -0800 (PST) Date: Mon, 25 Jan 2021 09:17:18 +1000 From: Nicholas Piggin Subject: Re: [PATCH v10 11/12] mm/vmalloc: Hugepage vmalloc mappings To: Christoph Hellwig Cc: Andrew Morton , Christophe Leroy , Ding Tianhong , Jonathan Cameron , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Zefan Li , Rick Edgecombe , Randy Dunlap References: <20210124082230.2118861-1-npiggin@gmail.com> <20210124082230.2118861-12-npiggin@gmail.com> <20210124150729.GC733865@infradead.org> In-Reply-To: <20210124150729.GC733865@infradead.org> MIME-Version: 1.0 Message-Id: <1611529781.hxjbuadzrl.astroid@bobo.none> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: Excerpts from Christoph Hellwig's message of January 25, 2021 1:07 am: > On Sun, Jan 24, 2021 at 06:22:29PM +1000, Nicholas Piggin wrote: >> diff --git a/arch/Kconfig b/arch/Kconfig >> index 24862d15f3a3..f87feb616184 100644 >> --- a/arch/Kconfig >> +++ b/arch/Kconfig >> @@ -724,6 +724,16 @@ config HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD >> config HAVE_ARCH_HUGE_VMAP >> bool >> =20 >> +config HAVE_ARCH_HUGE_VMALLOC >> + depends on HAVE_ARCH_HUGE_VMAP >> + bool >> + help >> + Archs that select this would be capable of PMD-sized vmaps (i.e., >> + arch_vmap_pmd_supported() returns true), and they must make no >> + assumptions that vmalloc memory is mapped with PAGE_SIZE ptes. The >> + VM_NOHUGE flag can be used to prohibit arch-specific allocations fro= m >> + using hugepages to help with this (e.g., modules may require it). >=20 > help texts don't make sense for options that aren't user visible. Yeah it was supposed to just be a comment but if it was user visible=20 then similar kind of thing would not make sense in help text, so I'll just turn it into a real comment as per Randy's suggestion. > More importantly, is there any good reason to keep the option and not > just go the extra step and enable huge page vmalloc for arm64 and x86 > as well? Yes they need to ensure they exclude vmallocs that can't be huge one way or another (VM_ flag or prot arg). After they're converted we can fold it into HUGE_VMAP. >> +static inline bool is_vm_area_hugepages(const void *addr) >> +{ >> + /* >> + * This may not 100% tell if the area is mapped with > PAGE_SIZE >> + * page table entries, if for some reason the architecture indicates >> + * larger sizes are available but decides not to use them, nothing >> + * prevents that. This only indicates the size of the physical page >> + * allocated in the vmalloc layer. >> + */ >> + return (find_vm_area(addr)->page_order > 0); >=20 > No need for the braces here. >=20 >> } >> =20 >> +static int vmap_pages_range_noflush(unsigned long addr, unsigned long e= nd, >> + pgprot_t prot, struct page **pages, unsigned int page_shift) >> +{ >> + unsigned int i, nr =3D (end - addr) >> PAGE_SHIFT; >> + >> + WARN_ON(page_shift < PAGE_SHIFT); >> + >> + if (page_shift =3D=3D PAGE_SHIFT) >> + return vmap_small_pages_range_noflush(addr, end, prot, pages); >=20 > This begs for a IS_ENABLED check to disable the hugepage code for > architectures that don't need it. Yeah good point. >> +int map_kernel_range_noflush(unsigned long addr, unsigned long size, >> + pgprot_t prot, struct page **pages) >> +{ >> + return vmap_pages_range_noflush(addr, addr + size, prot, pages, PAGE_S= HIFT); >> +} >=20 > Please just kill off map_kernel_range_noflush and map_kernel_range > off entirely in favor of the vmap versions. I can do a cleanup patch on top of it. >> + for (i =3D 0; i < area->nr_pages; i +=3D 1U << area->page_order) { >=20 > Maybe using a helper that takes the vm_area_struct and either returns > area->page_order or always 0 based on IS_ENABLED? I'll see how it looks. Thanks, Nick