From patchwork Thu Jan 27 08:56:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 12726422 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 240ECC433F5 for ; Thu, 27 Jan 2022 08:56:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B1B8D6B0075; Thu, 27 Jan 2022 03:56:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ACDD26B0078; Thu, 27 Jan 2022 03:56:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9BACF6B007B; Thu, 27 Jan 2022 03:56:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0057.hostedemail.com [216.40.44.57]) by kanga.kvack.org (Postfix) with ESMTP id 8C0D46B0075 for ; Thu, 27 Jan 2022 03:56:31 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 4EB38181C9B9B for ; Thu, 27 Jan 2022 08:56:31 +0000 (UTC) X-FDA: 79075460982.12.B229196 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf27.hostedemail.com (Postfix) with ESMTP id EF3D94000A for ; Thu, 27 Jan 2022 08:56:30 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3512E61B23; Thu, 27 Jan 2022 08:56:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0387EC340EF; Thu, 27 Jan 2022 08:56:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643273789; bh=CdUM/xw3G6lznVQt3NFsLntFbhnkWNalr2oPO1cWbtc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PdeB0IOjH7cl+p7r/DVrnXMzWGpLTAqd7OeqfmR5lN0cQswaE9TQ6aDaVI3nQVMWG XoHl9bO+SG272yKyOFDqISU2IJw45i5Pq/n+j/ppeWnbAzxPVYRLz/NWmQpY4kSMvB xUEOdmh4J1oeda569iz0hqKGdwsogExt4lJCnta6F7gS2WpvPBTmm98TirE4gY4pV9 ilrA1lVskayUfHi3CDPLv25yxIFGYn1H+WjpHtr3OmSeg6BB+NXpIg1xgEUBvsMt7R SbZATL97Cpcc10wh9AMIHkhf0kCazy/3u2l4zKjEo6pIl0BjvXau/bg5zp51XEUcwg bRq46RA7wqkFQ== From: Mike Rapoport To: linux-mm@kvack.org Cc: Andrew Morton , Andy Lutomirski , Dave Hansen , Ira Weiny , Kees Cook , Mike Rapoport , Mike Rapoport , Peter Zijlstra , Rick Edgecombe , Vlastimil Babka , linux-kernel@vger.kernel.org, x86@kernel.org Subject: [RFC PATCH 3/3] EXPERIMENTAL: x86/module: use __GFP_UNMAPPED in module_alloc Date: Thu, 27 Jan 2022 10:56:08 +0200 Message-Id: <20220127085608.306306-4-rppt@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220127085608.306306-1-rppt@kernel.org> References: <20220127085608.306306-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: EF3D94000A X-Stat-Signature: d3m9gqi4bagoixpgpocx5yy8wck64iy3 Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=PdeB0IOj; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf27.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org X-Rspam-User: nil X-HE-Tag: 1643273790-873803 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: From: Mike Rapoport The permissions of pages allocated by module_alloc() are frequently updated using set_memory and set_direct_map APIs. Such permission changes cause fragmentation of the direct map. Since module_alloc() essentially wraps vmalloc(), the memory allocated by it is mapped in the vmalloc area and it can be completely removed from the direct map. Use __GFP_UNMAPPED to utilize caching of unmapped pages done by the page allocator. Signed-off-by: Mike Rapoport --- arch/x86/kernel/module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c index 95fa745e310a..70aa6ec0cc16 100644 --- a/arch/x86/kernel/module.c +++ b/arch/x86/kernel/module.c @@ -75,7 +75,7 @@ void *module_alloc(unsigned long size) p = __vmalloc_node_range(size, MODULE_ALIGN, MODULES_VADDR + get_module_load_offset(), - MODULES_END, gfp_mask, + MODULES_END, gfp_mask | __GFP_UNMAPPED, PAGE_KERNEL, VM_DEFER_KMEMLEAK, NUMA_NO_NODE, __builtin_return_address(0)); if (p && (kasan_module_alloc(p, size, gfp_mask) < 0)) {