Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp5891200imw; Wed, 20 Jul 2022 15:01:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u+Q194rHWqrPOphe0T2Im4eYIvG/0y+DthnSBG3WXGqCuyRhaCnePXVnR2o5MH9gUmGOwz X-Received: by 2002:a17:906:49d4:b0:6d6:e5ec:9a23 with SMTP id w20-20020a17090649d400b006d6e5ec9a23mr38471506ejv.79.1658354461317; Wed, 20 Jul 2022 15:01:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658354461; cv=none; d=google.com; s=arc-20160816; b=M2c8UGAhMpEQjks4ppLQe7qiq27s5Yl0Wjh8MXGN9ZpJtkPdOVLwA11dJC6ubRtGL1 5jE0doG2vKVxMgr3nyFYrqAyQf3VJLaXhopAuaY6UtGjK9k14cPDlRVPd9H87LMh9B6Z agdmQtSzJF/5v2IH6IAr9QY/7Q9wc3iCdy3XTfh8F4lZkZkwfKtBLQg/ifqJYt7xCLHh VgoNsUJBLMf1uUFn2xQCNDk6xj/R+zR+Zp9mhylAwH3R9hzoYjukqHA36tQeekad9/fM ZBcpy/XCwTNsdjwbrZWHM15ntJVttFv4CHFfGREqFPdNglXXzFjWVCLz3ohYd9mU66hY lkBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=TdqfPLZDQqoiJgcJ8XR8R3y1mXk+yPYhV3rFEr0vWdM=; b=S7UvrGuiP0ieU2nk1dj7cj5q/C2fzvNamC4bG2iwwmynKzvdYiE+sjTiAbnW1i9u+n Nub/PcrRu0pnFO2JZCfoCdUC2GM4uZXmbUfdvK6aMTejW37xujL+MYIy0Q1zlpjY9d2N F7b8EhmvQV7IJQxd2jvIxqekqBMVNEjaKaCmASzFH9Du4rvulB8734Hs9uNAbVe6ANoi vrc9LQub6I2rr9K8lRP22GDpV0dVs+DtWnu0cx727dVL6Pa1xIRtGnTmNbxvO4im8mX4 ZcsS0ykL97GMUUyTYztyiqHjA3WCujIpyXkz+EKToV9StdUSW1u6cZIIl+eeY3DrqVCm xCbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=EyyBW+Gh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k20-20020a1709063e1400b0072b474f829dsi247236eji.970.2022.07.20.15.00.35; Wed, 20 Jul 2022 15:01:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=EyyBW+Gh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229972AbiGTVaC (ORCPT + 99 others); Wed, 20 Jul 2022 17:30:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229550AbiGTVaB (ORCPT ); Wed, 20 Jul 2022 17:30:01 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 844F7599E5; Wed, 20 Jul 2022 14:29:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:In-Reply-To: Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description; bh=TdqfPLZDQqoiJgcJ8XR8R3y1mXk+yPYhV3rFEr0vWdM=; b=EyyBW+GhbfCjbZGYNdYdMxe8Bv Cal32LM+2FxIqx8X4DVss81RIwwhRntKO+e0TUd/4ZIMszdyoDt6tSjrFMiaJbo5sQBrEFV+fywE1 vQ4w7nx1rwbz5aboLityf7hx6YnJKYig79eNMx64FV7TJHcTjKVKnec63+1sm4u9zFC7b7y+GrFWz jZ82iNN77Ntt0X964bEa9fAn/PzQmxbd1CHe8oDKSb/SRl058hsSSpb42a5vOEw3m1OXUrD5nBjIJ W0qkFBuxtTYunmRoeWug9mkOodKEhhk2iUxyDApJ0YLbJEDsBGTxG2oTw5/gjzXqtjt2AjUSURIGS fOO3xLjQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oEHGH-00BSfp-6C; Wed, 20 Jul 2022 21:29:41 +0000 Date: Wed, 20 Jul 2022 14:29:41 -0700 From: Luis Chamberlain To: "Fabio M. De Francesco" Cc: Matthew Wilcox , Ira Weiny , linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, Song Liu , Takashi Iwai , Adam Manzanares , Davidlohr Bueso , Matthew Wilcox Subject: Re: [PATCH v2] module: Replace kmap() with kmap_local_page() Message-ID: References: <20220720161932.9567-1-fmdefrancesco@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220720161932.9567-1-fmdefrancesco@gmail.com> Sender: Luis Chamberlain X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 20, 2022 at 06:19:32PM +0200, Fabio M. De Francesco wrote: > kmap() is being deprecated in favor of kmap_local_page(). > > Two main problems with kmap(): (1) It comes with an overhead as mapping > space is restricted and protected by a global lock for synchronization and > (2) it also requires global TLB invalidation when the kmap’s pool wraps > and it might block when the mapping space is fully utilized until a slot > becomes available. > > With kmap_local_page() the mappings are per thread, CPU local, can take > page faults, and can be called from any context (including interrupts). > Tasks can be preempted and, when scheduled to run again, the kernel > virtual addresses are restored and still valid. > > kmap_local_page() is faster than kmap() in kernels with HIGHMEM enabled. > > Since the use of kmap_local_page() in module_gzip_decompress() and in > module_xz_decompress() is safe (i.e., it does not break the strict rules > of use), it should be preferred over kmap(). > > Therefore, replace kmap() with kmap_local_page(). > > Tested on a QEMU/KVM x86_32 VM with 4GB RAM, booting kernels with > HIGHMEM64GB enabled. Modules compressed with XZ or GZIP decompress > properly. > > Cc: Matthew Wilcox > Suggested-by: Ira Weiny > Signed-off-by: Fabio M. De Francesco Thanks for the enhanced commit log! Queued onto modules-testing, if that doesn't blow something up I'll move to modules-next afterwards. Luis