Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp782630rwb; Thu, 19 Jan 2023 02:36:49 -0800 (PST) X-Google-Smtp-Source: AMrXdXun9VDE6nxGAbxLmaq09pDERB3qC3NnkU0PMA+OGlsJENvML4O5fNTPzNxeSDOteK9wOlva X-Received: by 2002:a17:90a:b702:b0:219:7f29:3152 with SMTP id l2-20020a17090ab70200b002197f293152mr10056598pjr.39.1674124609682; Thu, 19 Jan 2023 02:36:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674124609; cv=none; d=google.com; s=arc-20160816; b=m2idpGwMIE8DVhTDXFgPl8pwY/gJU7O+GoDvXmrZLndWlBuUPR5/zJFDatW1zN6IPu ol5DaJoyHYRL4Ls9EOKqClVRzELuUZprbN7fW3HxKElY8DBV23SLVkMRKYjhfgPr+U0m 007sf81ERx+B1x14ytzvJ8+953sCC/aNchwsK2N2YbCdSuPUniNUVWYM6wIWH/TjeM9u eTNYjOsIip3IbzT1GtZw1gHrXWVmo2orGPEGjUvKmQkCDZVWKxAnD7oquT/KzBQBKR10 R7zfWBMT82gKKcvcYovLgWPUqBr0JubtYYxL/gyLLBU1qoIvSDJ8qQ92BI7mTYS2Cjrj g6dQ== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:dkim-signature:date; bh=rUe7Jkojk2oaxll/dmHbgXg519+vydqtLcAsij+B87Y=; b=Dhtza3VPb51R8IdnQVS82KvEW7wfgwYIDBmjBNy5NUVx9kEYrYn2G8gnenL9CYNALX 4tA2EdXxAGOUyB2jbvUXiSWFdGm8uQvhKdngYYBn+sekz1hekLxNEitsvjYbAp6bNl/w BvXK2riXClVnR2FfwXcEyPA7lhVmRPenacGInrZ3AVgag2yMdO2UWO7Y8/RIxLCmoWdr usOKFIRVA7Vu/0EpYDh01n9ZqyIclAJez3aD0dn/Gnb581rexoJdvHafiaGG+Y3d7h42 KI7HWfbI6XVjxCibTD42nL29Pfn4dJn516MJlP4r8ovNmpXs/zPf1ANgUGvc87aHFRDs MnrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="ZMIt/hBI"; 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=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nn8-20020a17090b38c800b00225eb9af940si4812990pjb.183.2023.01.19.02.36.40; Thu, 19 Jan 2023 02:36:49 -0800 (PST) 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=@linux.dev header.s=key1 header.b="ZMIt/hBI"; 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=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229862AbjASJta (ORCPT + 44 others); Thu, 19 Jan 2023 04:49:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229576AbjASJt3 (ORCPT ); Thu, 19 Jan 2023 04:49:29 -0500 X-Greylist: delayed 491 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 19 Jan 2023 01:49:27 PST Received: from out-87.mta0.migadu.com (out-87.mta0.migadu.com [91.218.175.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30EDB6EA1 for ; Thu, 19 Jan 2023 01:49:26 -0800 (PST) Date: Thu, 19 Jan 2023 04:41:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1674121271; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rUe7Jkojk2oaxll/dmHbgXg519+vydqtLcAsij+B87Y=; b=ZMIt/hBIr+ut/k0D3f08qLXybt/n/lJBrsn2bNQG87AocIzCyGAJ+3/kd2GTFutCR6W+ZU 2sCLRg7RFZntRo95ih49u/llg55AdtZfheae9mbYGQhuB89+yQo7n+GAaIVHkJk+DLL3Ws /6h22U865gYGvxnVmFaIKDNhjRBJqbs= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: "Fabio M. De Francesco" Cc: Alexander Viro , Benjamin LaHaise , linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, linux-kernel@vger.kernel.org, "Venkataramanan, Anirudh" , Ira Weiny Subject: Re: [RESEND PATCH] fs/aio: Replace kmap{,_atomic}() with kmap_local_page() Message-ID: References: <20221016150656.5803-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: <20221016150656.5803-1-fmdefrancesco@gmail.com> X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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 Sun, Oct 16, 2022 at 05:06:56PM +0200, Fabio M. De Francesco wrote: > The use of kmap() and kmap_atomic() are being deprecated in favor of > kmap_local_page(). > > There are two main problems with kmap(): (1) It comes with an overhead as > the 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). > It is faster than kmap() in kernels with HIGHMEM enabled. Furthermore, > the tasks can be preempted and, when they are scheduled to run again, the > kernel virtual addresses are restored and still valid. > > Since its use in fs/aio.c is safe everywhere, it should be preferred. > > Therefore, replace kmap() and kmap_atomic() with kmap_local_page() in > fs/aio.c. > > Tested with xfstests on a QEMU/KVM x86_32 VM, 6GB RAM, booting a kernel > with HIGHMEM64GB enabled. I was just looking over this code and made the same kmap -> kmap_local change, but you've done a more complete version - nice. For context, I was the one who added the kmap() call, because copy_to_user() can sleep - anything else at the time would've been more awkward, and highmem machines were already on the way out. But kmap_local is perfect here :) Reviewed-by: Kent Overstreet