Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7521875rwb; Mon, 12 Dec 2022 16:09:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf4cCrYgqa3fddV1rk6LPLVAiYPepBE4I9upvxVB4xBvajWTwD/kuUd6J+flNHY6CKGQwk8n X-Received: by 2002:a05:6a20:a681:b0:ac:1266:bda with SMTP id ba1-20020a056a20a68100b000ac12660bdamr24416974pzb.7.1670890194486; Mon, 12 Dec 2022 16:09:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670890194; cv=none; d=google.com; s=arc-20160816; b=pcSxJTlFqBJ1Wb/zBLglio9Kozee6c0HVjRgpn/u/hkD0RWE7jD3X5Xr+5l7wtzF39 gzyqqC4bs1LaGlxTaFbtdSSShkDwISzP+WYu0upqg3nx7mzMzNKaNHQqx7koY2MOybl8 tP6m7dbfogoMxRXVbtMSzpxT4kCMc3rOxPcwvQ9hcsmBMIe2Ejv51qgLkVpykailGkF9 sm4aEuixzGO6JU12HdKUdZ39vkZyb/YuewBsqacGxehw6au9RuK0VCLca0R+PboFdNPB /jVCzTmDF71NyQxJQuDxSG+xpkikT4bAi0hE49LJdqgUOa7iNiC1LwIjDDKMQiE7Lk1D hKMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=d2D3szGCb9Vg2ywxzAo8nNWdIMuiqqy33S8+OxWxWj8=; b=TT0IoZhujU9lRKmhA7JbhrVNpjrao6Wm1fV/QBQzuKeEseyjx4tF9RlbmeL2qyTaVt o2q1D5b8uwzkr9OLvDlOoVPRPwxGPfAt7Q6hSVDDV3NK5gNYk3k537Zkjan/O76beqss r5uGMTknccQMPqLriBLO5oo6cSghRNV1oM0latNzZ7y07m+5YFYxcw6COgA1k/rQE7eR v4AqfR9zqTJCjHw3O2z9xtu6ys1Bk3eAl1QS1wG45jXCcEnzxwhde6IEoehhdYx6jAm1 iW76/dOJzWtqP/lIqnx4psQiBJDM1L1urWyG01rGCqMfR/FYR9xwJI15Wi39rXXcHNlk DFwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LCqSz2Y5; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oj7-20020a17090b4d8700b00213dc988b24si11437776pjb.13.2022.12.12.16.09.42; Mon, 12 Dec 2022 16:09:54 -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=@gmail.com header.s=20210112 header.b=LCqSz2Y5; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233827AbiLLXTU (ORCPT + 74 others); Mon, 12 Dec 2022 18:19:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229944AbiLLXTQ (ORCPT ); Mon, 12 Dec 2022 18:19:16 -0500 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EC471C136 for ; Mon, 12 Dec 2022 15:19:14 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id y16so13934589wrm.2 for ; Mon, 12 Dec 2022 15:19:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=d2D3szGCb9Vg2ywxzAo8nNWdIMuiqqy33S8+OxWxWj8=; b=LCqSz2Y5qcjBfH7iD0GZiRb9FoHwH7kdToub9Er9PErtfhHz6XBINd7RRN1Iye6Yzb gYrqyS9JQwmC4uivOMIquAnjKxFP26ILfZP7sJSnTHkSpEcAhfnjQvBAL6p3l7eN6z/y PAPzYMGKDYsi+hb/RCRjYpk4anTFNvIjCwbxDIUQ3+K6RwjZaQa+S3uQYwnTnih7YbMj npd9wlmd4S7hXuLiGNTwtfZAARoKCTywEXTWYIGSudDWzDInhkhvr2NtyNuYGUTQprYl vbtqhPxPtBKjVeg+JTjgBBDur2iT2UtNf6FktLNQmWT/LjuON3ZVIG4/1UhZg/40GJSu n1PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d2D3szGCb9Vg2ywxzAo8nNWdIMuiqqy33S8+OxWxWj8=; b=hiX/7Kvub31PPT9YGOqNNVdrrn2encPJw0eq+16kVmA3hYlD2+37hrUt85njwShcUl F6Me6yrrLeqLWSwxqfMnY9ZXCpmv1YPHL4zmtCe/G3VnYoTcNZ50b9cGpph0E60jFM/7 ZCs+nZvjXC9FpsteStqEd6JO1WvHKuWAs6QUOb3F81nrrh55IpmiGZz2c+1312wqXNdk FzKpVvFGkhMkVhsA/LOPZEX/yqis+xnw4PrV9HGtzJWJIq1h0a8MDMV4qtsp0wvvLKpU pyEs/uIGZT6Pj4V3xjXyuNiATcK4nayhE0cSUIjLYKT7NGPqB/Fwq5M5pDjXPdbRG7LP iKXA== X-Gm-Message-State: ANoB5pmGYcYutN8kTusr/6njpZFdMYnaDVNtatXqPvkX8QEnfZrxWVPA /R5QhwXI65ujmKdR4llLY6M= X-Received: by 2002:a05:6000:50f:b0:236:c62f:eb70 with SMTP id a15-20020a056000050f00b00236c62feb70mr11424280wrf.13.1670887152833; Mon, 12 Dec 2022 15:19:12 -0800 (PST) Received: from localhost.localdomain (host-79-41-27-125.retail.telecomitalia.it. [79.41.27.125]) by smtp.gmail.com with ESMTPSA id v3-20020a5d6103000000b002423edd7e50sm9964304wrt.32.2022.12.12.15.19.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 15:19:11 -0800 (PST) From: "Fabio M. De Francesco" To: Evgeniy Dushistov , Al Viro , Ira Weiny , linux-kernel@vger.kernel.org Cc: "Fabio M. De Francesco" Subject: [PATCH v2 0/3] fs/ufs: replace kmap() with kmap_local_page Date: Tue, 13 Dec 2022 00:19:03 +0100 Message-Id: <20221212231906.19424-1-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 kmap() is 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/ufs is safe everywhere, it should be preferred. Therefore, replace kmap() with kmap_local_page() in fs/ufs. kunmap_local() requires the mapping address, so return that address from ufs_get_page() to be used in ufs_put_page(). This series could have not been ever made because nothing prevented the previous patch from working properly but Al Viro made a long series of very appreciated comments about how many unnecessary and redundant lines of code I could have removed. He could see things I was entirely unable to notice. Furthermore, he also provided solutions and details about how I could decompose a single patch into a small series of three independent units.[1][2][3] I want to thank him so much for the patience, kindness and the time he decided to spend to provide those analysis and write three messages full of interesting insights.[1][2][3] Changes from v1 1/3: No changes. 2/3: Restore the return of "err" that was mistakenly deleted together with the removal of the "out" label in ufs_add_link(). Thanks to Al Viro.[4] Return the address of the kmap()'ed page instead of a pointer to a pointer to the mapped page; a page_address() had been overlooked in ufs_get_page(). Thanks to Al Viro.[5] 3/3: Return the kernel virtual address got from the call to kmap_local_page() after conversion from kmap(). Again thanks to Al Viro.[6] [1] https://lore.kernel.org/lkml/Y4E++JERgUMoqfjG@ZenIV/ [2] https://lore.kernel.org/lkml/Y4FG0O7VWTTng5yh@ZenIV/ [3] https://lore.kernel.org/lkml/Y4ONIFJatIGsVNpf@ZenIV/ [4] https://lore.kernel.org/lkml/Y5Zc0qZ3+zsI74OZ@ZenIV/ [5] https://lore.kernel.org/lkml/Y5ZZy23FFAnQDR3C@ZenIV/ [6] https://lore.kernel.org/lkml/Y5ZcMPzPG9h6C9eh@ZenIV/ The cover letter of the v1 is at https://lore.kernel.org/lkml/20221211213111.30085-1-fmdefrancesco@gmail.com/ Fabio M. De Francesco (3): fs/ufs: Use the offset_in_page() helper fs/ufs: Change the signature of ufs_get_page() fs/ufs: Replace kmap() with kmap_local_page() fs/ufs/dir.c | 138 +++++++++++++++++++++++++++------------------------ 1 file changed, 72 insertions(+), 66 deletions(-) -- 2.38.1