Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp219726rdb; Thu, 2 Nov 2023 01:20:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFfBl2bt8fHilRHfGP5AxKIFRPpb1KWZ+2ltudwgoDEtf/GZYW3hhYobNLzeHEBR+kyLodp X-Received: by 2002:a05:6808:bc6:b0:3b2:ec66:d868 with SMTP id o6-20020a0568080bc600b003b2ec66d868mr23229822oik.41.1698913248165; Thu, 02 Nov 2023 01:20:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698913248; cv=none; d=google.com; s=arc-20160816; b=Qx5XIp2kzUhuhlS/7lDmM3GPesN78wk7DfqJP5uX6RxG3/8gT6qt6LwoEmUsX3/qmV rNApXuwnB5PUsiFomzBnr6LsxgN5xFF3fAGpdvznfuXjbp7hoPWI4HQIHesY99wRnyy9 gBbnMwptZFRqIH56SjQEPnTfGarjDE91hwGdwL+V3VBabVt4RUKGFUl0fe2F5hpRMU25 SZ7w8Yku2xWRQ2rrCrh1FcMK1gp08puKiX9QB7arkjubxgHZL+MoqT/cRf4BTz9uILJl Shj1zq7OJPtLTHbJwyQ1gerxOcD8bqdOXLFVhMHfmIuZ0Djtmsk0ekaBcyH3/o01gfYb 0Ocw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=xOlOPXtFC14sPmMq/gNPsGSMRG8MAsaEPYDXA9iMskI=; fh=m3WivHnu0YfsmOQIPqqYZXKuGM+WQX3QA1Go72xXAMA=; b=la6k7wuLMS53EfvaYFmh896G16pwBcfOX6EaEoMHj2lKnbmUwvbFdDPp6BEqCiNOOa tsfzbns5FXGYO8YGM2rlTKihQAuYrCoxBqSzaV+jDP5WaqPm5llwVjPZ5dx4embhMQnk 1EWIHZbJpjuwqn4jhAd9NEUvQdJpjU583sC41l5kE7TDLmiRoz50SeVli7M4BgIxjRse VX7GP10RAECMjDqq2XLXaJTjmLdzQyyVwaT8ey9bN09nNghBozKirMtPuy0MpIHLTVIo m+Qyqn8LSWi7sjE7IojGg7/W6UsvoaP8Ix8Nnm7mwvfsolq1XLLy5tbptp6tXVLrNfEI CjVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=XFM8ZEbd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id y26-20020aa7943a000000b0069026fd5a48si3024209pfo.34.2023.11.02.01.20.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 01:20:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=XFM8ZEbd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id EC2C3802A35A; Thu, 2 Nov 2023 01:20:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233218AbjKBIT0 (ORCPT + 99 others); Thu, 2 Nov 2023 04:19:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbjKBITZ (ORCPT ); Thu, 2 Nov 2023 04:19:25 -0400 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5F70128 for ; Thu, 2 Nov 2023 01:19:18 -0700 (PDT) Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 7D10B3FA95 for ; Thu, 2 Nov 2023 08:19:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1698913157; bh=xOlOPXtFC14sPmMq/gNPsGSMRG8MAsaEPYDXA9iMskI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:In-Reply-To; b=XFM8ZEbdjREn5zcnQZEiu0vvjMll9NoZtOFl/83AzBJIvhf9woTmKljMjI6o7PgJv 9OcFh1DgP7WzT+NtoZF2mvicXBARgVv7/SImHhg39JCRNwZ+jj6F+OxksQbQ53Qy18 IlmBQWS3e6CGpKMKk20XhNCIyvCt4GfMnFx9sUv4tD/HsF5tOFmCFzM4/hCUZkrVLU K5Uf3Kxzi5Ah9uFQ0qW40VyNiNMOxBaVuqfupd72IwQmD1wCZEwH9qwVwHOVqcYT4O DzDzghjT3M0L1RGaHCLVpsimWol5pCWXhrfuat6qqcppkkgDPJi+8iDGqVB3XYhuz+ YaqU88uj+sS7g== Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-9d2ab03a586so42428266b.0 for ; Thu, 02 Nov 2023 01:19:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698913156; x=1699517956; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=xOlOPXtFC14sPmMq/gNPsGSMRG8MAsaEPYDXA9iMskI=; b=IC/7YAvSJ9TB9QvUAwt5jvZtO+ujNF61x596kVt+Ak4bFP+/g0I3Z8eumnlbURsgOk 0JUOtSUE0DZFq7b+RiGjY4+64mGY6fUbVOYIDcIMihGvtltwcNoYmRMnuvQ+HauPaaDU zfjew4U7TlFxG6N+r2CQZAAMP+axxz19vTNjhCmOSJ9R2/WGao2urr4Xn2UTmLrTEZrx DNNcSQ68JlKuAKOsj5tr+6+cwLYFYraNwF00c34DnKp1LBzaxFcX2iyWWqfMJdnYvYQy DUNWGv38bCtTcVUXdKuJquY29t0iTCH+ahxOxCTRvY9Zk2pT920h5KLB3hBnbBZahMm4 6rXQ== X-Gm-Message-State: AOJu0Ywp3i7rz3T6QfHppYSHMxNyvxxFZKsMTc4tnKGqIhozAnz+qvyx iDvzukwgawAOMYRKN0q5y6ITyUfXhurN+oBVlkOEZzdFCfBca0f1PjgnhQpTSRQHQlMV9bYSLWT Edmtlrzg8BXziCWy5zQG40C4SRwcBgfl8k3FJLseQdR+DL/Rbdw== X-Received: by 2002:a17:906:1915:b0:9bd:a73a:7a0a with SMTP id a21-20020a170906191500b009bda73a7a0amr2841631eje.58.1698913156302; Thu, 02 Nov 2023 01:19:16 -0700 (PDT) X-Received: by 2002:a17:906:1915:b0:9bd:a73a:7a0a with SMTP id a21-20020a170906191500b009bda73a7a0amr2841622eje.58.1698913155904; Thu, 02 Nov 2023 01:19:15 -0700 (PDT) Received: from localhost (host-79-33-130-95.retail.telecomitalia.it. [79.33.130.95]) by smtp.gmail.com with ESMTPSA id pv21-20020a170907209500b0099c53c4407dsm824959ejb.78.2023.11.02.01.19.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 01:19:15 -0700 (PDT) Date: Thu, 2 Nov 2023 09:19:14 +0100 From: Andrea Righi To: Luis Chamberlain , Linus Torvalds Cc: linux-modules@vger.kernel.org, patches@lists.linux.dev, linux-kernel@vger.kernel.org, keescook@chromium.org, zhumao001@208suo.com, yangtiezhu@loongson.cn, ojeda@kernel.org Subject: Re: [GIT PULL] Modules changes for v6.7-rc1 Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 02 Nov 2023 01:20:42 -0700 (PDT) On Thu, Nov 02, 2023 at 08:29:17AM +0100, Andrea Righi wrote: > On Wed, Nov 01, 2023 at 09:21:09PM -1000, Linus Torvalds wrote: > > On Wed, 1 Nov 2023 at 21:02, Linus Torvalds > > wrote: > > > > > > kmalloc() isn't just about "use physically contiguous allocations". > > > It's also more memory-efficient, and a *lot* faster than vmalloc(), > > > which has to play VM tricks. > > > > I've pulled this, but I think you should do something like the > > attached (UNTESTED!) patch. > > > > Linus > > Looks good to me, I'll give it a try ASAP. > > -Andrea Just tested this both with zstd and gzip module compression, all good. You can add my: Tested-by: Andrea Righi Or if you need a proper paperwork: -- From: Andrea Righi Subject: [PATCH] module/decompress: use kvmalloc() consistently We consistently switched from kmalloc() to vmalloc() in module decompression to prevent potential memory allocation failures with large modules, however vmalloc() is not as memory-efficient and fast as kmalloc(). Since we don't know in general the size of the workspace required by the decompression algorithm, it is more reasonable to use kvmalloc() consistently, also considering that we don't have special memory requirements here. Signed-off-by: Linus Torvalds Tested-by: Andrea Righi Signed-off-by: Andrea Righi --- kernel/module/decompress.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/module/decompress.c b/kernel/module/decompress.c index 4156d59be440..474e68f0f063 100644 --- a/kernel/module/decompress.c +++ b/kernel/module/decompress.c @@ -100,7 +100,7 @@ static ssize_t module_gzip_decompress(struct load_info *info, s.next_in = buf + gzip_hdr_len; s.avail_in = size - gzip_hdr_len; - s.workspace = vmalloc(zlib_inflate_workspacesize()); + s.workspace = kvmalloc(zlib_inflate_workspacesize(), GFP_KERNEL); if (!s.workspace) return -ENOMEM; @@ -138,7 +138,7 @@ static ssize_t module_gzip_decompress(struct load_info *info, out_inflate_end: zlib_inflateEnd(&s); out: - vfree(s.workspace); + kvfree(s.workspace); return retval; } #elif defined(CONFIG_MODULE_COMPRESS_XZ) @@ -241,7 +241,7 @@ static ssize_t module_zstd_decompress(struct load_info *info, } wksp_size = zstd_dstream_workspace_bound(header.windowSize); - wksp = vmalloc(wksp_size); + wksp = kvmalloc(wksp_size, GFP_KERNEL); if (!wksp) { retval = -ENOMEM; goto out; @@ -284,7 +284,7 @@ static ssize_t module_zstd_decompress(struct load_info *info, retval = new_size; out: - vfree(wksp); + kvfree(wksp); return retval; } #else -- 2.40.1