Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp8156748rwl; Sat, 31 Dec 2022 00:11:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXv6qz9Y8JnqhmElXkD/Pmmsv5q3mXioeVNkKLzsDw9MSBTZ0tlrogj4qesraw2Q4JaB38ib X-Received: by 2002:a17:906:3084:b0:7c1:5ee1:4c57 with SMTP id 4-20020a170906308400b007c15ee14c57mr29322610ejv.8.1672474277116; Sat, 31 Dec 2022 00:11:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672474277; cv=none; d=google.com; s=arc-20160816; b=fEJLAPokrfBPJtyR0qFAWMLG8DQnvIgCqy5bjkS33dj6WmIcF5r/vVQy0FSPHXmM8H eobJMI0Zwjx62UB1rOkfugoS9FDfLAaTurSkYD/dsg3dOYkmW+zQDwIBJ4/e1bkQ2w+L U5wTQbeXozc5sdmZewoqYoTKgYssdKbmBN1TM7EKk2Gj7xJ8EkVf5qWt/0Ak4yEPDWlr 2MhS0uYGTO2Kw383hqAliz0ttsfUYlxDRGnM9Iv8H4rn1nl4752tQoG4Q/Sqt7Grttac gos6TMstHZq1hQERhKng9SLL/zN9v1cNlAZQDcE2yw4XMlPOVXrZsV+/MZJ4OKndRljf Ljew== 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=kckosCj7pS5VlSv2D9XB8a7P6gG7tisCAhaL+kMfg8Q=; b=ZXcFE0Ib5x0JH2eE+BE2kXelpiKhDSYvYpGqYlU2dzMGQhCqammwAn0eHVppkw2684 1FfLkhjXXADc0uOoltZPqRb2kP937ZNY6+j3b97C+5WCJRzE+mQpU1yPQc4devDyQUzJ mslfBbXTuAIawHZHnrnD00fKRmmGp6VQD79fRQgYEBCpFzklS5oZ/3A2OQOvVCMezXPH Yl1CjNut7A3tQOtFT0/n+6V/uRFEqNnlilwSWAbigJYcBAfmhuTL6yu7/C3rIXaXqHvO PYvyuVp7pwwVm54t+iHl3xuEXhUHkfg3EOcHDALQnlAPmw0Lu6QeSJk5AuKG8E+QDiQc HccQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HlUdlkkY; 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 be5-20020a1709070a4500b007c1479b6a89si16995101ejc.823.2022.12.31.00.11.01; Sat, 31 Dec 2022 00:11:17 -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=HlUdlkkY; 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 S229975AbiLaH51 (ORCPT + 63 others); Sat, 31 Dec 2022 02:57:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229536AbiLaH5Z (ORCPT ); Sat, 31 Dec 2022 02:57:25 -0500 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C84A033F; Fri, 30 Dec 2022 23:57:23 -0800 (PST) Received: by mail-wm1-x329.google.com with SMTP id m3so7895995wmq.0; Fri, 30 Dec 2022 23:57:23 -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=kckosCj7pS5VlSv2D9XB8a7P6gG7tisCAhaL+kMfg8Q=; b=HlUdlkkYBD1VrxQRDfo1VaZXwBxEhqFntD0ER6wxsm9EPnpFBodFw6lecFIvjXyuIR NvlJ+xTT8t5F/CFGZO9yoHc4nShURA0oe928dBFywR+fuk2LacZRyP5xOi1S8f09QeOw atnvqpN+T60933kWUqTyILbW1GvjmMweIsr16n9Ge0QBUBgCn8xgVhjOaPbBENfxh4gB NYicAYWQ/nElKqI/kXLdxKxwvWyKS/OprnFp6ejkj4kCZX3HhcV0CI7PyUZHVb81lIOU wbppN/+NbT9RUXKTXaJ+dluuRsgiP7nJ05RDYrLpbYwbMSzD3B+8qWafZu78UsSje+jj EZmQ== 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=kckosCj7pS5VlSv2D9XB8a7P6gG7tisCAhaL+kMfg8Q=; b=clkMb0TNWR9WFAm4GC0nDXre9XX5im+fATJrauXSCm3et5GHiWjIozZIdfh2RVxdYO EYCwrnmBJx7duxt13zoflMiWSlr1YFc3t8EZqYQCU+WbubN90UqOzVSi2KEX2/HXnwYN 3B9dTuyUHVbSQ3tqA2rcrwoYCA9906Np6J0XtnrS+GVYFHELjC0MaCLfqyKYra/QAwwd lPUidvuH72z0kx2FRJWu0w9bcOHgXCDOSM4Li2vlVIOPmVucXTmDT7UFS/0OSluK6LzR CL3xPATWfGIW0Ksi5p226EU28bHmupUNAZCk3OwUO5txkaXB2Nil1dpfKJeqfqlMj3Kd q0aw== X-Gm-Message-State: AFqh2krn8SBa7mMh0/TxwgEYfMIM1BdI2kxpo5rcS6N0/aYbpC1s1dIc QxUtnTI9p/UPZCLB9N4JtCE= X-Received: by 2002:a05:600c:154b:b0:3cf:674a:aefe with SMTP id f11-20020a05600c154b00b003cf674aaefemr24413674wmg.22.1672473442218; Fri, 30 Dec 2022 23:57:22 -0800 (PST) Received: from localhost.localdomain (host-79-56-217-20.retail.telecomitalia.it. [79.56.217.20]) by smtp.gmail.com with ESMTPSA id l42-20020a05600c1d2a00b003d23928b654sm39389232wms.11.2022.12.30.23.57.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Dec 2022 23:57:21 -0800 (PST) From: "Fabio M. De Francesco" To: Christoph Hellwig , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: "Fabio M. De Francesco" , Al Viro , Ira Weiny Subject: [PATCH 0/4] fs/sysv: Replace kmap() with kmap_local_page() Date: Sat, 31 Dec 2022 08:57:13 +0100 Message-Id: <20221231075717.10258-1-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.39.0 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 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. kmap_local_page() in fs/sysv does not violate any of the strict rules of its use, therefore it should be preferred. Therefore, replace kmap() with kmap_local_page() in fs/sysv. kunmap_local() requires the mapping address, so return that address from dir_get_page() to be used in dir_put_page(). I had submitted a patch with the same purpose but it has been replaced by this series.[1] This is based on a long series of very appreciated comments and suggestions kindly provided by Al Viro (again thanks!).[2][3][4] Since this is a very different thing, versioning restarts from scratch. [1] https://lore.kernel.org/lkml/20221016164636.8696-1-fmdefrancesco@gmail.com/ [2] https://lore.kernel.org/lkml/Y4E++JERgUMoqfjG@ZenIV/#t [3] https://lore.kernel.org/lkml/Y4FG0O7VWTTng5yh@ZenIV/#t [4] https://lore.kernel.org/lkml/Y4ONIFJatIGsVNpf@ZenIV/#t Cc: Al Viro Cc: Ira Weiny Signed-off-by: Fabio M. De Francesco Fabio M. De Francesco (4): fs/sysv: Use the offset_in_page() helper fs/sysv: Change the signature of dir_get_page() fs/sysv: Use dir_put_page() in sysv_rename() fs/sysv: Replace kmap() with kmap_local_page() fs/sysv/dir.c | 117 +++++++++++++++++++++++++++--------------------- fs/sysv/namei.c | 9 ++-- fs/sysv/sysv.h | 1 + 3 files changed, 71 insertions(+), 56 deletions(-) -- 2.39.0