Received: by 2002:ac8:1418:0:b0:3ab:920c:4c8b with SMTP id k24csp436856qtj; Thu, 19 Jan 2023 08:09:30 -0800 (PST) X-Google-Smtp-Source: AMrXdXuQJRWV172Q1Ay1yxL7nurvNZBeC6pKKU3cUDopQz/xtRNWnR2/9UczBhXoCksKo2MnBItG X-Received: by 2002:a05:6a20:d045:b0:b8:aca6:b655 with SMTP id hv5-20020a056a20d04500b000b8aca6b655mr13471501pzb.31.1674144570579; Thu, 19 Jan 2023 08:09:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674144570; cv=none; d=google.com; s=arc-20160816; b=puZ/CD3X9kzAXfU/nj5pQZpOyn0r/kotywaEMXwvRmgOhFY8Uq/BIkw74xv1fr03ut HvAX8wY3b/fZxD72BsDyJdrtkG9xh9SJkl2KbMkUGqwC+xro7xNRnxB/UxpIzxe80Uij P+ZUC+vmVLUSncJcGd1tO42j7H4TvvSElcC4g1cl55UeDz22VwxnYCxTCotvvZ95gUaL xBEwdW9BTRSJhoIRwFnun7AXY/hQP3k9Anws2HO6qH4uRhFuaBO5mX/5v8hTgNg+sH36 FRk6WK7GynHS1V0W4GUmE2ZchVf+byEHrCerMZvDDcekppE7EXSi4oWb3VQylGdEUmcx QtRA== 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=FT7eqe6MLyQ7xafND32p75X/BdvWAVCLwDSIWMtedok=; b=TUQB1gel5jUzTAkOc7OXABUsZBMwDxSZa9i8nnMdCAZCep5NsY5jWxGELHYBqNKBeh WDKx8NmsFG8+gVzxFr4pK5QrKkwB4c8v+3CvbviGKEFnb/+fqsG83AxUlhi8XCbeKpfP PGbocFv4cA7DXHDln7EGzBZSVP77yRwUmeMQ2IlhUxF+7RZoaguExeafvzJEJEUvtEIb +SGacYkvh8wURZEA1kIDpaOFa7ZXCtBLcFv0Z3GY6L+Ue3I0Dib7+7FJeyObbIJYHDRv Bw3qt8HDFBpsAFz5pn4k4P/6JhALQSPZHr6syhEacH7+HFWM0yLC7iQylD39aiqE40aM QWLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="nR/M009m"; 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 t190-20020a6381c7000000b004cff4e7799dsi6939374pgd.813.2023.01.19.08.09.23; Thu, 19 Jan 2023 08:09: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="nR/M009m"; 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 S230507AbjASPco (ORCPT + 45 others); Thu, 19 Jan 2023 10:32:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230491AbjASPcm (ORCPT ); Thu, 19 Jan 2023 10:32:42 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66C8582D49; Thu, 19 Jan 2023 07:32:38 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id iv8-20020a05600c548800b003db04a0a46bso3205512wmb.0; Thu, 19 Jan 2023 07:32:38 -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=FT7eqe6MLyQ7xafND32p75X/BdvWAVCLwDSIWMtedok=; b=nR/M009m99yjBn6j3srQMHQ1GEe7IlYMEC7ENOxGqa3DunGT0VbAxm+1RuYB+doZT2 UjWojMZ4Lx4cEcirgWCWW4ubUIL8AYR0fTy3KKX+tmdS5umtgJwU81WCglRyjP8D5ue/ wCu6dUJfgpZ+18SHJcVeem+XjOqNwgw/iYf1eD+hzy/x4PfTGFo6MkJAQlOVX0ciM7W3 lnEunBXQZgrfOlfn7wsByvBI8yqivRbCDAXLRK/jOMpp7uDl22J0MihsHSlNd66XfweP +PmH/2v0iblBd13TkQMKhQMXVDA3FujQTPRwMGvrgKx0mwp6ozlqin/7Rgfw7LAnjWbs cZCA== 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=FT7eqe6MLyQ7xafND32p75X/BdvWAVCLwDSIWMtedok=; b=gROALywG1b30hjfX8/O3vz2vfCFO02CjTKq0MJIDj5PI05dnXPG2LXHOoqeBWyneef TNLemWIMWI4LXyCfzq31WAxY5U+y9dFU22bjgjh84ktFCpNKpQZswfxJezQn6BMDIREN 62tCX3/4zBMwH8c+5IUhLERKl2Jf4VKaRuK373XAfPoBmlfUzX4qzhsq3/Gci8027mi8 iUeGTpndMELkVseiIAlARLvyWcMn43qTHaJWsY7BAzeDXvCaWkz/7jlesrjk1P/m7eZc bzHkJiQvj3A7M6QomkKD1RVL5HzfHMUVmS7mAEdlu+6ZE0rc8tmrxNnX67jht7k0zfz4 /scg== X-Gm-Message-State: AFqh2kq11e89NihHG6tzOL1DoGsbXnglUmR44413v06zb+dNCxlIIMz+ 2uVnUO+24ofllDC5fwzHaDc= X-Received: by 2002:a05:600c:3c86:b0:3da:2a59:8a4f with SMTP id bg6-20020a05600c3c8600b003da2a598a4fmr10698010wmb.38.1674142356754; Thu, 19 Jan 2023 07:32:36 -0800 (PST) Received: from localhost.localdomain (host-82-55-106-56.retail.telecomitalia.it. [82.55.106.56]) by smtp.gmail.com with ESMTPSA id k34-20020a05600c1ca200b003cfd4e6400csm5827815wms.19.2023.01.19.07.32.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 07:32:36 -0800 (PST) From: "Fabio M. De Francesco" To: Christoph Hellwig , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Al Viro , Ira Weiny Cc: "Fabio M. De Francesco" Subject: [PATCH v3 0/4] fs/sysv: Replace kmap() with kmap_local_page() Date: Thu, 19 Jan 2023 16:32:28 +0100 Message-Id: <20230119153232.29750-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] Changes from v1:[5] 1/4 - No changes. 2/4 - Delete an unnecessary assignment (thanks to Dan Carpenter). 3/4 - No changes. 4/4 - No changes. Changes from v2:[6] 1/4 - No changes. 2/4 - Remove a redundant assignment in sysv_dotdot() and add a comment (thanks to Al Viro for both suggestions). 3/4 - No changes. 4/4 - No changes. [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 [5] https://lore.kernel.org/lkml/20221231075717.10258-1-fmdefrancesco@gmail.com/ [6] https://lore.kernel.org/lkml/20230109170639.19757-1-fmdefrancesco@gmail.com/ 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 | 120 +++++++++++++++++++++++++++--------------------- fs/sysv/namei.c | 9 ++-- fs/sysv/sysv.h | 1 + 3 files changed, 71 insertions(+), 59 deletions(-) -- 2.39.0