Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5845198rwb; Sun, 11 Dec 2022 13:51:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf5hnHXRXN9/Gx5MoCbPBu1R9w3vJxjyEFsfWcd+Yu60QzqcfmfQVWBEo0l4FlPW1eXP1X+p X-Received: by 2002:a17:902:ab0b:b0:189:5f5c:da1e with SMTP id ik11-20020a170902ab0b00b001895f5cda1emr14374706plb.27.1670795490343; Sun, 11 Dec 2022 13:51:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670795490; cv=none; d=google.com; s=arc-20160816; b=AV2NA7vkgbLU0Gsy5FssK9WsxbX7vV5BQ1pfGXHNSs01Q50tmzsiVaP70DL2WnjYmF ivf79ibYXgqv2ZBi8a1jhe6zJHVssAiSVk10A+4EY/Y4QiwNw0T1GXvs23neMXsVNiUW 5KheqpFGCN6Vf1jVkb42XcIgW+Ky9VclcHz5lNUrmX6rBa02JZJgM92zOpdFAtb5fW6C 735dwODjrti3BkF2sjsz5qQ8xo6lZF6N1FBTgayPOal2WreHlJyjMo3kg0W1Q4CL89Qz rBqXqsU1xbxnrPQxdCuu6RxWggUo1/H845Qj+n7pu2OkBiO0PeI/FngcV2uLpATXxS0b CHRw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=5FG9XFAhH1aAKNSCD7KXenAoQ7QCTJVpi7jZDxdnhI0=; b=z6LNAOrOoQKMDAdW/tRBEpuKApS5bfHdIcbmrkMy+FPi3cAEEq6hzxD7psxiWmI+CR ug0xpJZ2DxIEyaYoQUd/34ijZTc8bco2mlE7dDcMbtl3lFrB54VPMW8zP1ccYYxQyvoI Yyt6Pr+TCIMqIW1cuhzSS++8GsKCKZu17VlOC6HhfwrYLsoHC1EZ+X/VFk+OrfXy3Hqi nUqMfDBz7OC+OYkpDD6Harg0yOY74818w0YS+AzUzqLKkXI3QvsAors7tpkZkP7fEKJz 46LMgZekEaEbJTmox3Y0sVCfBSko5fCn0mBxMVY1AVShDEBO8trealU5dOcCl/+INRXn 2IfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=OC9FRQ5b; 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 h6-20020a170902f54600b00189b421fff1si8305517plf.432.2022.12.11.13.51.20; Sun, 11 Dec 2022 13:51:30 -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=OC9FRQ5b; 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 S230328AbiLKVb2 (ORCPT + 75 others); Sun, 11 Dec 2022 16:31:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229471AbiLKVbW (ORCPT ); Sun, 11 Dec 2022 16:31:22 -0500 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC178BC99; Sun, 11 Dec 2022 13:31:19 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id c65-20020a1c3544000000b003cfffd00fc0so3671253wma.1; Sun, 11 Dec 2022 13:31:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=5FG9XFAhH1aAKNSCD7KXenAoQ7QCTJVpi7jZDxdnhI0=; b=OC9FRQ5bdKmv3sGgoo1ZJg56K0vI4WY55htBKLsFGzk9o84vSEI5/l7nQi1LQ8Y9DI h9uxsFWD7cqUr7Mq/8K4p+o4GN6cu7f5w2Uztm1feVVXrXD7ikwr/+KyoFvWfWaq+IPm VVy4rkih1SoVMvYIwF/E/ID551LMhkPf2CutaMfzrefL+sGeuU24EB2sgCU2vLzAWCyQ 0rEHv+/E8UFMF1kbbRg976lsWYQ0fpLkADUr7jAbaZ5Nsg0Lbg4jgTnwomURdModQfpN oJphnSwkiX7U3EqmpQX89N65d0HJmWfU+BnjS7+yDopegOF3zkclfr+jxbYLVni8NGk3 CFBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5FG9XFAhH1aAKNSCD7KXenAoQ7QCTJVpi7jZDxdnhI0=; b=7oxMFvtpLa1hZ6PrQ0XnLzhwnBv0Cyg+z75XJH0+ZkXduSN1bzFzAiTePxr0ruP6m3 4MWSMZIYsQljpV90IfSi/sflzDTr8e96xJRJmuor74QMsO6EO4qEh8yqhCpbJWr8UHhq cWhdqiwvSoVTE9ALeBljd1VhOKLbazGBl0+sJesVw3N57ABJJn2jFY+13tgn1O4W0Z+/ 42CFKvX9TUak+rDjCbUU4QhrEKosCMgt9ZAquVH63nZJxOaKRqH1iWRATPkWuMuL7mOZ 5xCA/Ap/V1VG015bqMcYCqWGUHH8UJnI00pwAbXfuSEoRQzqC5DAJsmUw2dh1HZlzB9h k6xw== X-Gm-Message-State: ANoB5pl/1eoRF98Fvkl7jiqJO2ulE7QNpI6/EhT1OTATV1V7VnFyady3 /FKTi7fg+jmARyp6vOomgIaFd9GkNR0= X-Received: by 2002:a05:600c:991:b0:3cf:aa48:23d4 with SMTP id w17-20020a05600c099100b003cfaa4823d4mr10965839wmp.25.1670794278133; Sun, 11 Dec 2022 13:31:18 -0800 (PST) Received: from localhost.localdomain (host-95-247-100-134.retail.telecomitalia.it. [95.247.100.134]) by smtp.gmail.com with ESMTPSA id m127-20020a1c2685000000b003d1d5a83b2esm6866350wmm.35.2022.12.11.13.31.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Dec 2022 13:31:17 -0800 (PST) From: "Fabio M. De Francesco" To: Evgeniy Dushistov , Al Viro , Ira Weiny , linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: "Fabio M. De Francesco" , "Fabio M . De Francesco" Subject: [PATCH 0/3] fs/ufs: replace kmap() with kmap_local_page() Date: Sun, 11 Dec 2022 22:31:08 +0100 Message-Id: <20221211213111.30085-1-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.38.1 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. I hope to have not misunderstood too many things, however I'm pretty sure that I made many mistakes due to my scarce knowledge of filesystem and, above all, lack of experience :-) I decided to get rid of the previous numbers and start from scratch (i.e., version 1) because this series has too little to share with the design of the previous patch.[4] [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/20221016163855.8173-1-fmdefrancesco@gmail.com/ Cc: Ira Weiny Suggested-by: Al Viro Signed-off-by: Fabio M. De Francesco 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 | 140 +++++++++++++++++++++++++++------------------------ 1 file changed, 73 insertions(+), 67 deletions(-) -- 2.38.1