From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387248; b=pl/qqkKeDOG5e+Uvmdm+Vy9Wymmx2Pr0T2iacrdfKEdv0Qq6vZKWNRV4mNNeLU/ge0C6 U/Q1NOfNEe97VKRzWBQ/6FA6Q8Du0s6FiGtj7KemkdBGep5DkGLcTD8ST2IBWh1eAPSd3 TurqCvqmOTkdEL1CWqp9qZdDuZ0Mee7xYKnAWsHtfeeNFsV3TVxyQh5LqaCcPmMrb4uWW PpPLqWqlb8qdsprWyJeNzQbSIzEkLmDolS8CfXeiC/LLOXT5pwSc/IMYhXPUvA9g5VETA yoFNsi0r0isX3nJvSiLouby+10u5yxl9HZ0zYs5nq6O3cbnsJdziZifEFuUgBi/qgEQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387248; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=Oc7wmoE5nIG5UdVHeOSmTJ/MayQokjVs3eXjC6zzglY=; b=yJeimmWUsLwflga4G+MYkFlqmWMNJ+AlHW0jNGH+NVy6rTjMcIcfCvcskC1ijcQBXBlq maCFD/0baVQAeL1/niJBI1r1QxFQz8sc8+Lv9LSRpvFBjb9VJTPc1vKg9oAQtCaRgNL8g YYGB6ufGoWAxshRdak/EZQvWxvN5I1nUjPkNJIU7kz9ZlIIPCeSjmyrCtgAEJDZZD+0Ai SlQjWNRNO5AYa/ELQ9uUPVLjiNldSGVpeQEBzh5I25vihNnV/trqKSQ1CBMUYU3RS1IX2 jYkuQE6PqVdbdWmSIvLmS6XgnGemwn9l/Pq/UEk0N/qLJLZeNiIalOOOlL5MjLHd4SQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=IJPK5UGN; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9BB7606A322; Fri, 4 Dec 2026 12:27:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=IJPK5UGN Received: by smtp.kernel.org (Postfix) with ESMTPSA id D44FC1F000C2; Fri, 4 Dec 2026 12:27:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387248; bh=Oc7wmoE5nIG5UdVHeOSmTJ/MayQokjVs3eXjC6zzglY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IJPK5UGNWkgFVHlqTZ7UtctpY/RQCnP3aRqgH/ZIuPlHcxJZf1tFmjkM9s7tpkmcC ZpZ90/6txwWQbHiC3j6au5+lkn8MRg65HUAqyqhpqT/H5IsgUvQbQS9ffB/qZSZxvq 3+2itegXfLkfHWTQqigEoDKlS4JcRaNMFbwR69Ys= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ira Weiny , "Fabio M. De Francesco" , Luis Chamberlain , Anna Schumaker , Sasha Levin Subject: [PATCH 6.1 0165/1059] fs/nfs: Replace kmap_atomic() with kmap_local_page() in dir.c Date: Fri, 4 Dec 2026 18:54:56 +0900 Message-ID: <20261204100648.508173062@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Fabio M. De Francesco [ Upstream commit 1683ed16ff1a51705f58e8083ed93a7428a543f2 ] kmap_atomic() is deprecated in favor of kmap_local_page(). With kmap_local_page() the mappings are per thread, CPU local, can take page-faults, and can be called from any context (including interrupts). Furthermore, the tasks can be preempted and, when they are scheduled to run again, the kernel virtual addresses are restored and still valid. kmap_atomic() is implemented like a kmap_local_page() which also disables page-faults and preemption (the latter only for !PREEMPT_RT kernels, otherwise it only disables migration). The code within the mappings/un-mappings in the functions of dir.c don't depend on the above-mentioned side effects of kmap_atomic(), so that mere replacements of the old API with the new one is all that is required (i.e., there is no need to explicitly add calls to pagefault_disable() and/or preempt_disable()). Therefore, replace kmap_atomic() with kmap_local_page() in fs/nfs/dir.c. Tested in a QEMU/KVM x86_32 VM, 6GB RAM, booting a kernel with HIGHMEM64GB enabled. Suggested-by: Ira Weiny Signed-off-by: Fabio M. De Francesco Reviewed-by: Luis Chamberlain Signed-off-by: Anna Schumaker Stable-dep-of: 89b91409b234 ("NFS: restore directory index when resuming readdir") Signed-off-by: Sasha Levin --- fs/nfs/dir.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 330d747856d10..261031ef7895e 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -203,14 +203,14 @@ static void nfs_readdir_page_init_array(struct page *page, u64 last_cookie, { struct nfs_cache_array *array; - array = kmap_atomic(page); + array = kmap_local_page(page); array->change_attr = change_attr; array->last_cookie = last_cookie; array->size = 0; array->page_full = 0; array->page_is_eof = 0; array->cookies_are_ordered = 1; - kunmap_atomic(array); + kunmap_local(array); } /* @@ -221,11 +221,11 @@ static void nfs_readdir_clear_array(struct page *page) struct nfs_cache_array *array; unsigned int i; - array = kmap_atomic(page); + array = kmap_local_page(page); for (i = 0; i < array->size; i++) kfree(array->array[i].name); array->size = 0; - kunmap_atomic(array); + kunmap_local(array); } static void nfs_readdir_free_folio(struct folio *folio) @@ -371,14 +371,14 @@ static pgoff_t nfs_readdir_page_cookie_hash(u64 cookie) static bool nfs_readdir_page_validate(struct page *page, u64 last_cookie, u64 change_attr) { - struct nfs_cache_array *array = kmap_atomic(page); + struct nfs_cache_array *array = kmap_local_page(page); int ret = true; if (array->change_attr != change_attr) ret = false; if (nfs_readdir_array_index_cookie(array) != last_cookie) ret = false; - kunmap_atomic(array); + kunmap_local(array); return ret; } @@ -418,9 +418,9 @@ static u64 nfs_readdir_page_last_cookie(struct page *page) struct nfs_cache_array *array; u64 ret; - array = kmap_atomic(page); + array = kmap_local_page(page); ret = array->last_cookie; - kunmap_atomic(array); + kunmap_local(array); return ret; } @@ -429,9 +429,9 @@ static bool nfs_readdir_page_needs_filling(struct page *page) struct nfs_cache_array *array; bool ret; - array = kmap_atomic(page); + array = kmap_local_page(page); ret = !nfs_readdir_array_is_full(array); - kunmap_atomic(array); + kunmap_local(array); return ret; } @@ -439,9 +439,9 @@ static void nfs_readdir_page_set_eof(struct page *page) { struct nfs_cache_array *array; - array = kmap_atomic(page); + array = kmap_local_page(page); nfs_readdir_array_set_eof(array); - kunmap_atomic(array); + kunmap_local(array); } static struct page *nfs_readdir_page_get_next(struct address_space *mapping, @@ -568,14 +568,14 @@ static int nfs_readdir_search_array(struct nfs_readdir_descriptor *desc) struct nfs_cache_array *array; int status; - array = kmap_atomic(desc->page); + array = kmap_local_page(desc->page); if (desc->dir_cookie == 0) status = nfs_readdir_search_for_pos(array, desc); else status = nfs_readdir_search_for_cookie(array, desc); - kunmap_atomic(array); + kunmap_local(array); return status; } -- 2.53.0