From nobody Fri Apr 17 21:03:54 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40497C433EF for ; Thu, 21 Jul 2022 21:02:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233678AbiGUVCW (ORCPT ); Thu, 21 Jul 2022 17:02:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233567AbiGUVCU (ORCPT ); Thu, 21 Jul 2022 17:02:20 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CEBF904F4; Thu, 21 Jul 2022 14:02:19 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id m17so3672576wrw.7; Thu, 21 Jul 2022 14:02:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fS/nZXfCzoIrkQnCoo3AKoB3vg26TXpmf/4Iq1CbbwA=; b=fhutAQ2zFDM3pgiuPJuierDP9xD/G9Hhm9W5NL/hgw3wuzzhJ+QIJRyKxrcRJ4JYf9 hS6Aeh3UygJ+nZd/McuqlbliJ+KGVavJwOGCmEv1/1gr/lQgq+Ke6vPuLMd/h5c5ER1S R5DNzZJiEVWvOLIK+PS5fc5yuLGnvIoVjy4FaB6GxhJL+U9oVEAWl20+Gciy0Zmj6A8h 7ChboDDTZhwYAlJz41gfuUGRXovqooWnO7aMB56mUCmG5BIEpsFfIEdBU+4qMMf2vQrY pL1TbNUeebs1pCgvjO0YSKItN1VpNE79fGI2zdKPm3nZEzopN+tUSad4KjVX7LlzRMaC 5pjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fS/nZXfCzoIrkQnCoo3AKoB3vg26TXpmf/4Iq1CbbwA=; b=g00hgBUTb8mNaQZLF5wvmdYlNkfI5ERqkGI5zqAZTe9MJ2pbzeU9h0bHRh55Sgrbet UGJamoQsKtkFkGKidb6NS4CRSN5GQprXZtgJHH2yd7UPxfV/kPwYZeehsDQOHA+wl8Dm eaXda8QtFvEpCWCsYtAkADfOmPbOCYgBZuoIdGJzTyNQUWqsmI/IbZ854AlArtThoZiK kNyIU5ZcvmtoIh5SxO6ysaK1FOgSe90dX3iSMPMTlR/r0BMAndNmXs05OSNfeB2xeXL/ b/PHIKowruzJRn1VyqTnESkANk+rdabkRi7ykeL1oz4tVfaqp/oyfY5jL6ALEdVzCuvG 4eGw== X-Gm-Message-State: AJIora+EwcgZKGSA2AePGeW1hvyI99uSJF7W2OTjL3n9Ec+QT8DSyuLW VdnVvqzgV/gDftDOuDFa1W3ixzWap3M= X-Google-Smtp-Source: AGRyM1vjJX4rqvk86cxrkuq/sx8bdX1cg1BHM7BBE/bgoHMZGYxwJmOp6R2i5Qxdb2xGhRl4WHKdfw== X-Received: by 2002:adf:d1c8:0:b0:21d:a082:9290 with SMTP id b8-20020adfd1c8000000b0021da0829290mr210993wrd.246.1658437337651; Thu, 21 Jul 2022 14:02:17 -0700 (PDT) Received: from localhost.localdomain (host-95-235-102-55.retail.telecomitalia.it. [95.235.102.55]) by smtp.gmail.com with ESMTPSA id d12-20020adffbcc000000b0021b8c554196sm2884383wrs.29.2022.07.21.14.02.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jul 2022 14:02:16 -0700 (PDT) From: "Fabio M. De Francesco" To: Ira Weiny , Andrew Morton , Catalin Marinas , "Matthew Wilcox (Oracle)" , Will Deacon , Peter Collingbourne , Vlastimil Babka , Sebastian Andrzej Siewior , Jonathan Corbet , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: "Fabio M. De Francesco" , Mike Rapoport , Thomas Gleixner Subject: [PATCH 1/7] highmem: Remove unneeded spaces in kmap_local_page() kdocs Date: Thu, 21 Jul 2022 23:02:00 +0200 Message-Id: <20220721210206.13774-2-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220721210206.13774-1-fmdefrancesco@gmail.com> References: <20220721210206.13774-1-fmdefrancesco@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In the kdocs of kmap_local_page(), the description of @page starts after several unnecessary spaces. Therefore, remove those spaces. Cc: Andrew Morton Cc: Matthew Wilcox (Oracle) Cc: Mike Rapoport Cc: Sebastian Andrzej Siewior Cc: Thomas Gleixner Suggested-by: Ira Weiny Reviewed-by: Ira Weiny Signed-off-by: Fabio M. De Francesco --- include/linux/highmem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/highmem.h b/include/linux/highmem.h index 158a3a2907dc..accd286a6af5 100644 --- a/include/linux/highmem.h +++ b/include/linux/highmem.h @@ -60,7 +60,7 @@ static inline void kmap_flush_unused(void); =20 /** * kmap_local_page - Map a page for temporary usage - * @page: Pointer to the page to be mapped + * @page: Pointer to the page to be mapped * * Returns: The virtual address of the mapping * --=20 2.37.1 From nobody Fri Apr 17 21:03:54 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58D83C43334 for ; Thu, 21 Jul 2022 21:02:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233711AbiGUVC2 (ORCPT ); Thu, 21 Jul 2022 17:02:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbiGUVCX (ORCPT ); Thu, 21 Jul 2022 17:02:23 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF0F9904F0; Thu, 21 Jul 2022 14:02:21 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id d8so3935162wrp.6; Thu, 21 Jul 2022 14:02:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2Wa6yLMGc2WRkmaEKpyRFxQSUgk0ChF0sgc7hNeYrTc=; b=FQKt/UIgTZ8Mch9n4Dh2bjtUdG/NT2Vdmagpsj+j5I/ekpOhL5Wn31K9uLxuZnVuJP 1QTpIyeIIN3mFG89ZVqIWGlO4EMSss3Ewcf0tpCq2gI49dbPVxO57VDoipBcctctvcEM 95WxxUvGsD8Usb5qFThKBywL6hIg3FrhsFgakwK7xcP9/r3itdOYFXVRoRSjEiav1xxO rWjb1unrYcW2s13yUiFX6w/853b86XzWqR620N/UJ6tvdkk1+gFFO8Nin+TElVlzuZUO FZMYDfQJJo0M2E6ex+Sd/hHOKLvB+mNBDBTA/sZYxTuXshdVSa1XMJ7gqgi7LzjXmIXo XCbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2Wa6yLMGc2WRkmaEKpyRFxQSUgk0ChF0sgc7hNeYrTc=; b=ABJzWqTDtsK/aEHSmIUd2vEtV8JWtjfpZ/SnQBQGpEwU3XND3SVQBmrVnqcxO3h9IJ cLW5R/KWqmUpO5gqILR4WMJf1OVUxB54EPAICkD2ZGYtQzRQ4cwHQDeZkSMOVbTS5O/K RzhE4/qBItpqgVx4+cj54ZrYwqTNxBHy5CfvwLdK8ULU8wqZuEx8Wd6YyQJc/YSM6zpG URPAbpNrqqla4X9+jL9B9Pmj3cGAAY8wGncos5SB54+bHuMa07hA95/Q12sDlCuvObBs 9yZNHuErmg5D1YggeajlOWqcVzCycpVXVIetge5uCXsKEf+PP0TrmtiQhoN5r6A+vw3z OktQ== X-Gm-Message-State: AJIora/6cU4kZvlRiOa0fjqOoxoeAZaXZR55dvyleC9F6N+Cmu0ytMQ7 eQvERLy/+mXytQf3Bwn0IDk= X-Google-Smtp-Source: AGRyM1t1cquMTmXGJCiGKVk2AVCoqIlo3jE/eV8/EBvYZj+4IXVDpTEb2RolTI2cV4t/8c2xxA5X7w== X-Received: by 2002:adf:ffc1:0:b0:21d:66a1:c3ee with SMTP id x1-20020adfffc1000000b0021d66a1c3eemr199763wrs.364.1658437340126; Thu, 21 Jul 2022 14:02:20 -0700 (PDT) Received: from localhost.localdomain (host-95-235-102-55.retail.telecomitalia.it. [95.235.102.55]) by smtp.gmail.com with ESMTPSA id d12-20020adffbcc000000b0021b8c554196sm2884383wrs.29.2022.07.21.14.02.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jul 2022 14:02:18 -0700 (PDT) From: "Fabio M. De Francesco" To: Ira Weiny , Andrew Morton , Catalin Marinas , "Matthew Wilcox (Oracle)" , Will Deacon , Peter Collingbourne , Vlastimil Babka , Sebastian Andrzej Siewior , Jonathan Corbet , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: "Fabio M. De Francesco" , Mike Rapoport , Thomas Gleixner Subject: [PATCH 2/7] highmem: Specify that kmap_local_page() is callable from interrupts Date: Thu, 21 Jul 2022 23:02:01 +0200 Message-Id: <20220721210206.13774-3-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220721210206.13774-1-fmdefrancesco@gmail.com> References: <20220721210206.13774-1-fmdefrancesco@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In a recent thread about converting kmap() to kmap_local_page(), the safety of calling kmap_local_page() was questioned.[1] "any context" should probably be enough detail for users who want to know whether or not kmap_local_page() can be called from interrupts. However, Linux still has kmap_atomic() which might make users think they must use the latter in interrupts. Add "including interrupts" for better clarity. [1] https://lore.kernel.org/lkml/3187836.aeNJFYEL58@opensuse/ Cc: Andrew Morton Cc: Matthew Wilcox (Oracle) Cc: Mike Rapoport Cc: Sebastian Andrzej Siewior Cc: Thomas Gleixner Suggested-by: Ira Weiny Signed-off-by: Fabio M. De Francesco --- include/linux/highmem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/highmem.h b/include/linux/highmem.h index accd286a6af5..0ba031ad29c2 100644 --- a/include/linux/highmem.h +++ b/include/linux/highmem.h @@ -64,7 +64,7 @@ static inline void kmap_flush_unused(void); * * Returns: The virtual address of the mapping * - * Can be invoked from any context. + * Can be invoked from any context, including interrupts. * * Requires careful handling when nesting multiple mappings because the map * management is stack based. The unmap has to be in the reverse order of --=20 2.37.1 From nobody Fri Apr 17 21:03:54 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71377CCA485 for ; Thu, 21 Jul 2022 21:02:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233734AbiGUVCc (ORCPT ); Thu, 21 Jul 2022 17:02:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233684AbiGUVCY (ORCPT ); Thu, 21 Jul 2022 17:02:24 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E105904FB; Thu, 21 Jul 2022 14:02:23 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id m17so3672860wrw.7; Thu, 21 Jul 2022 14:02:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QGH8iGVkQVr4d3CxxIU6taEk8nP/KLAdOHtdDle5izA=; b=Lqi+vYv5emo6R5/SLxe3DMM7ewKKPkhYCzm9oWrm+MdoUNRWLSKmtaFQeBse/n0oAU cZix/lgg6tCQRNaBTutgQQBz6Z++bXLhPYmIDgqkabQxD/bqYPOOXwsncFcRKc0r+tmu 2We0rJz3VRTULAuxZ5f2MywrMjkUP15vJOFsPpKcxynSE34HhWaHpHLqUZzHstda9J9C KA2XdBkL3HM3zITndsmGbuqR4XoxKtrqHC+PPFWyGzvLz2XySZi8VnrKeJ2DA1ZOMn63 G8IfVOV6s3tOTw5zAYZ2h2PQdqWaKwG4WxNl4lCDtn0XD+4O1VKGT/eWJpukCswnACnF SOpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QGH8iGVkQVr4d3CxxIU6taEk8nP/KLAdOHtdDle5izA=; b=bDlDDNobwlI3cgQFe9VLIIhamrSwR3w1Mx/NugXT5coSukbIuuUw7gnm7jEwheeaW4 d28YsK+s9AmwIt8mY9ta0uI7pRU9ioTS6zdR9ocULWYW+Gmd2t++duURJputZKZ3Qd5B lMIkJM+yDuOOBbbM1tdn9XRG5vdbbxn1BbhwNAlg+w6kQiEjPn+UpaGYoFCHoCmlSXgy kEd486JVg9Bx2oN3lN93xl+mBiedZRYIZThUj/acJE8YpuKjwTWHkO3qPQy5vRB2peHR UtvXjdNJTc/TVZloSAk3xygfKoxu/yA0w+1U135krNu3AnUs1PpJyXMbbemZ9DH2f+mj CIAw== X-Gm-Message-State: AJIora8kG6cqLpVysCHaGEhJ04e6gtnFSwwSQanqOzdpnW4cg+qgugAr 0Z6YA0waVYk3T0QSZ2d4ZAs= X-Google-Smtp-Source: AGRyM1uaYG8/IthKEG670yeghS29v1XZ0Cm99Y+vHnPaob7HrGzij/dVBXXy//c6vX6/KwH/ki5uRA== X-Received: by 2002:a5d:5951:0:b0:21e:5abd:8e52 with SMTP id e17-20020a5d5951000000b0021e5abd8e52mr185655wri.528.1658437342770; Thu, 21 Jul 2022 14:02:22 -0700 (PDT) Received: from localhost.localdomain (host-95-235-102-55.retail.telecomitalia.it. [95.235.102.55]) by smtp.gmail.com with ESMTPSA id d12-20020adffbcc000000b0021b8c554196sm2884383wrs.29.2022.07.21.14.02.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jul 2022 14:02:21 -0700 (PDT) From: "Fabio M. De Francesco" To: Ira Weiny , Andrew Morton , Catalin Marinas , "Matthew Wilcox (Oracle)" , Will Deacon , Peter Collingbourne , Vlastimil Babka , Sebastian Andrzej Siewior , Jonathan Corbet , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: "Fabio M. De Francesco" , Mike Rapoport , Thomas Gleixner Subject: [PATCH 3/7] Documentation/mm: Don't kmap*() pages which can't come from HIGHMEM Date: Thu, 21 Jul 2022 23:02:02 +0200 Message-Id: <20220721210206.13774-4-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220721210206.13774-1-fmdefrancesco@gmail.com> References: <20220721210206.13774-1-fmdefrancesco@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" There is no need to kmap*() pages which are guaranteed to come from ZONE_NORMAL (or lower). Linux has currently several call sites of kmap{,_atomic,_local_page}() on pages allocated, for instance, with alloc_page(GFP_NOFS) and other similar allocations. Therefore, add a paragraph to highmem.rst, to explain better that a plain page_address() should be used for getting the address of pages which cannot come from ZONE_HIGHMEM. Cc: Andrew Morton Cc: Matthew Wilcox (Oracle) Cc: Mike Rapoport Cc: Sebastian Andrzej Siewior Cc: Thomas Gleixner Suggested-by: Ira Weiny Signed-off-by: Fabio M. De Francesco --- Documentation/vm/highmem.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/vm/highmem.rst b/Documentation/vm/highmem.rst index c9887f241c6c..f266354c82ab 100644 --- a/Documentation/vm/highmem.rst +++ b/Documentation/vm/highmem.rst @@ -71,6 +71,12 @@ list shows them in order of preference of use. kmap_local_page() always returns a valid virtual address and it is assum= ed that kunmap_local() will never fail. =20 + On CONFIG_HIGHMEM=3Dn kernels and for low memory pages this returns the + virtual address of the direct mapping. Only real highmem pages are + temporarily mapped. Therefore, users should instead call a plain + page_address() for getting the address of memory pages which, depending + on the GFP_* flags, cannot come from ZONE_HIGHMEM. + Nesting kmap_local_page() and kmap_atomic() mappings is allowed to a cer= tain extent (up to KMAP_TYPE_NR) but their invocations have to be strictly or= dered because the map implementation is stack based. See kmap_local_page() kdo= cs --=20 2.37.1 From nobody Fri Apr 17 21:03:54 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3311FCCA485 for ; Thu, 21 Jul 2022 21:02:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233733AbiGUVCk (ORCPT ); Thu, 21 Jul 2022 17:02:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233706AbiGUVC2 (ORCPT ); Thu, 21 Jul 2022 17:02:28 -0400 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 161B4904F2; Thu, 21 Jul 2022 14:02:27 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id n12so3950902wrc.8; Thu, 21 Jul 2022 14:02:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CzOZ/buUjSLGOsPD1/ja3wfCZsVe9ZvJX2WkV0R1uMA=; b=FW/664FOnx9kvxzM6wGlPoF4ICJysh65o5yUWQl+EDU0FhKo/GOGJOYppor7DqIRAC PB7cuZkprILBa7jFTac1CdLpLHXrbl/gb997eSZURLXCMBpRbhTXiQ90LkJ3QAiAzfeD /NPJo2VXESdT/uGAUaY3uVQE1FVkOoo6VMAVZgVmVCxaPDVHPnih315rO2K1Eh8rF4Fv 4SMC/Pye4AQJmrrhFcoW36mI6mUL+z/UbsD8efFBNb6WvWFHdMB0pPPnkBLYEwiWt+0Z u7Xo64/cyIXlQDHKybFJ3SKn98eLMScDHkgTDAPo74OsjLwge9dmBgNndmStzRVhwplo XIcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CzOZ/buUjSLGOsPD1/ja3wfCZsVe9ZvJX2WkV0R1uMA=; b=sNfvyO490vmqD10pKwXGz5KMFFpl4aJW95UFU5smx4CEVYZgsaaT+nlEwmRba2YaJ8 JSCfc0Vp4graOJImp9Rkzxw0fzD8Sj+uk2rvWm06iGSGvYBWEZyhDMpwMWFspgRi20nG g5BO1mp+kgIiJqHa9+cjaeLzaBGyPRYuy199d4S7vBrC8HoScjFAAUU0feGmj+2ZqRfz eOAj021CAvZwPdZ3RGHBNSExwK1cnvYqKkMwKnb56CFP8MwvUU3yw/QgJhJCg/IzOeUS S6bghedqL25dNgdTCyssDn3KoXsT6r/kz24JuXvinMvr2sholsP1MgHvA6kEF2SB7rQ/ 0sug== X-Gm-Message-State: AJIora8ZfGsMj5ynGQTDAPwv+wAk3e4US7NQ6F0ig/x/VY9/oHivVM9x C1dP5/AYuI1JZYr9g1dhCyM= X-Google-Smtp-Source: AGRyM1uXo/iZjsT8WmiiksOoyLvdRoLXooFYZcBcZDEwM9Q2X8P4JSnySPvwmXVpAEOSQObRxIp49Q== X-Received: by 2002:a5d:6252:0:b0:21e:4457:1bca with SMTP id m18-20020a5d6252000000b0021e44571bcamr184739wrv.287.1658437345312; Thu, 21 Jul 2022 14:02:25 -0700 (PDT) Received: from localhost.localdomain (host-95-235-102-55.retail.telecomitalia.it. [95.235.102.55]) by smtp.gmail.com with ESMTPSA id d12-20020adffbcc000000b0021b8c554196sm2884383wrs.29.2022.07.21.14.02.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jul 2022 14:02:24 -0700 (PDT) From: "Fabio M. De Francesco" To: Ira Weiny , Andrew Morton , Catalin Marinas , "Matthew Wilcox (Oracle)" , Will Deacon , Peter Collingbourne , Vlastimil Babka , Sebastian Andrzej Siewior , Jonathan Corbet , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: "Fabio M. De Francesco" , Mike Rapoport , Thomas Gleixner Subject: [PATCH 4/7] Documentation/mm: Avoid invalid use of addresses from kmap_local_page() Date: Thu, 21 Jul 2022 23:02:03 +0200 Message-Id: <20220721210206.13774-5-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220721210206.13774-1-fmdefrancesco@gmail.com> References: <20220721210206.13774-1-fmdefrancesco@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Users of kmap_local_page() must be absolutely sure to not hand kernel virtual address obtained calling kmap_local_page() on highmem pages to other contexts because those pointers are thread local, therefore, they are no longer valid across different contexts. Extend the documentation of kmap_local_page() to warn users about the above-mentioned potential invalid use of pointers returned by kmap_local_page(). Cc: Andrew Morton Cc: Matthew Wilcox (Oracle) Cc: Mike Rapoport Cc: Sebastian Andrzej Siewior Cc: Thomas Gleixner Suggested-by: Ira Weiny Signed-off-by: Fabio M. De Francesco --- Documentation/vm/highmem.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/vm/highmem.rst b/Documentation/vm/highmem.rst index f266354c82ab..50d2b1fac24a 100644 --- a/Documentation/vm/highmem.rst +++ b/Documentation/vm/highmem.rst @@ -77,6 +77,13 @@ list shows them in order of preference of use. page_address() for getting the address of memory pages which, depending on the GFP_* flags, cannot come from ZONE_HIGHMEM. =20 + While it is significantly faster than kmap(), for the higmem case it + comes with restrictions about the pointers validity. Contrary to kmap() + mappings, the local mappings are only valid in the context of the caller + and cannot be handed to other contexts. This implies that users must + be absolutely sure to keep the use of the return address local to the + thread which mapped it. + Nesting kmap_local_page() and kmap_atomic() mappings is allowed to a cer= tain extent (up to KMAP_TYPE_NR) but their invocations have to be strictly or= dered because the map implementation is stack based. See kmap_local_page() kdo= cs --=20 2.37.1 From nobody Fri Apr 17 21:03:54 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0EEAC43334 for ; Thu, 21 Jul 2022 21:02:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233542AbiGUVCp (ORCPT ); Thu, 21 Jul 2022 17:02:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233727AbiGUVCa (ORCPT ); Thu, 21 Jul 2022 17:02:30 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6C5B90D89; Thu, 21 Jul 2022 14:02:28 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id d8so3935556wrp.6; Thu, 21 Jul 2022 14:02:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DaR5sQH4yLBlK+oiJh3kpc8qiO8mkIw02kY3ZSEU9aM=; b=Svx2QVXXAhFOsHMBl04OUx/8AH/SG8+a/6HoVoUzdmGUfegov4t0WWTiRz9A7hp5Xe eJDfdyW6IjWHg5Z9jluI0zkt5sh4YHjFYhGoS4tUCx+0+zG04U407WG8jpt7b6LcD2Es dSNkWkvMYYX6lqnS0xnLKS8kAP9r68vTN+CEs8uJJjDac459A0LS9oZss5eqSsN6wdqJ wM8ox6zdURucIg5uWetpw+MoBZa89Rb5bNK1/a2tzAT2qLu4opiHLBtOxbEooapeR4Pm qB+BSLLfeoofTBvRykK1ySfFEUde0iPS/8bEmGD6Z799U04nH104PXYA/zbtsaU2k65l s8yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DaR5sQH4yLBlK+oiJh3kpc8qiO8mkIw02kY3ZSEU9aM=; b=zE+Nt9x0gTbyy/vwRxAp8dhKYyMRv0CEH+saLLzIIlSEp/84q14IvmeswlyXBjQ8Cp QKjeuvUQZoul2DKZc0BBOkAE7erbP41C3FQbYzBvLXYQHxmiY42T09WynYkmUWfuhs49 /x4m/KMv91EgFLqHjF3jaxxiuS+v4317xIPFmZ7hkvfOZ+ygbW3Fix7URCp4gOZIPozK TMYzkXtAI82KPo+fkxGrQOr8EhUyNNkaIs1d/3qveWhonLua695oscY4Q1ZBC2JZ1wVv FdbSIvYtLUXfDVkUxVxUGbc2TaCqjtfJFE+pjwU4AtmjTp4uLthERVhgQtMxa+LFZYRG 987g== X-Gm-Message-State: AJIora+uvP/DqYSO96R+2WvMFlhxTN2+p4SC6N3jIDMYypXLS4IdlrGp nfb1xBHpSlqYe3j0BqmgsP4= X-Google-Smtp-Source: AGRyM1tzyvjyOaIkGk7ATDdnIRPrKCAwM4oq9G4LVQJ0fzqhAevt+Z0aFxLrHUZ4bk20RnZ5wwQm9A== X-Received: by 2002:a05:6000:178d:b0:21d:a3cc:54c8 with SMTP id e13-20020a056000178d00b0021da3cc54c8mr192475wrg.602.1658437348013; Thu, 21 Jul 2022 14:02:28 -0700 (PDT) Received: from localhost.localdomain (host-95-235-102-55.retail.telecomitalia.it. [95.235.102.55]) by smtp.gmail.com with ESMTPSA id d12-20020adffbcc000000b0021b8c554196sm2884383wrs.29.2022.07.21.14.02.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jul 2022 14:02:26 -0700 (PDT) From: "Fabio M. De Francesco" To: Ira Weiny , Andrew Morton , Catalin Marinas , "Matthew Wilcox (Oracle)" , Will Deacon , Peter Collingbourne , Vlastimil Babka , Sebastian Andrzej Siewior , Jonathan Corbet , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: "Fabio M. De Francesco" , Mike Rapoport , Thomas Gleixner Subject: [PATCH 5/7] Documentation/mm: Prefer kmap_local_page() and avoid kmap() Date: Thu, 21 Jul 2022 23:02:04 +0200 Message-Id: <20220721210206.13774-6-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220721210206.13774-1-fmdefrancesco@gmail.com> References: <20220721210206.13774-1-fmdefrancesco@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The reasoning for converting kmap() to kmap_local_page() was questioned recently.[1] There are two main problems with kmap(): (1) It comes with an overhead as mapping space is restricted and protected by a global lock for synchronization and (2) kmap() also requires global TLB invalidation when its pool wraps and it might block when the mapping space is fully utilized until a slot becomes available. Warn users to avoid the use of kmap() and instead use kmap_local_page(), by designing their code to map pages in the same context the mapping will be used. [1] https://lore.kernel.org/lkml/1891319.taCxCBeP46@opensuse/ Cc: Andrew Morton Cc: Matthew Wilcox (Oracle) Cc: Mike Rapoport Cc: Sebastian Andrzej Siewior Cc: Thomas Gleixner Suggested-by: Ira Weiny Signed-off-by: Fabio M. De Francesco --- Documentation/vm/highmem.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/vm/highmem.rst b/Documentation/vm/highmem.rst index 50d2b1fac24a..564017b447b1 100644 --- a/Documentation/vm/highmem.rst +++ b/Documentation/vm/highmem.rst @@ -84,6 +84,11 @@ list shows them in order of preference of use. be absolutely sure to keep the use of the return address local to the thread which mapped it. =20 + Most code can be designed to use thread local mappings. User should + therefore try to design their code to avoid the use of kmap() by mapping + pages in the same thread the address will be used and prefer + kmap_local_page(). + Nesting kmap_local_page() and kmap_atomic() mappings is allowed to a cer= tain extent (up to KMAP_TYPE_NR) but their invocations have to be strictly or= dered because the map implementation is stack based. See kmap_local_page() kdo= cs --=20 2.37.1 From nobody Fri Apr 17 21:03:54 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3255EC43334 for ; Thu, 21 Jul 2022 21:02:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231670AbiGUVCu (ORCPT ); Thu, 21 Jul 2022 17:02:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233713AbiGUVCi (ORCPT ); Thu, 21 Jul 2022 17:02:38 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F49390D8B; Thu, 21 Jul 2022 14:02:31 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id m17so3673283wrw.7; Thu, 21 Jul 2022 14:02:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u10tCeHxgugC+7t5c4hTzmt45MJlA8VbgBQ6EKUnR90=; b=eQQJOhmUeA3aBjl8m25IUooxJXf223IIbslwbkpaJF6Fa5fhjR4ePkJN6isSvHgtz7 eGYmDa+xIjQ/P44h0vTxk6t/B6xyHI4lfBwIKencgc1g0Z4dLkmNG2fC7j2uYDJiLHBu 3y/G82+Kt67x0FAD2+HFVk9p0yduqZKN3q/m8zNN0F5JhlmChqFD++pInwjXR5+xFupq wUlT1RijfuXHLR/ef8gVXx3UXRtpyNRLhkPUasREwBuksgUO9xWlZ3mbZZWNslT8vCio SaQoZJaai389QOLKJGjZUqeorHw2u/Ds+q5wA5JWPjfgaQqzmEgtlbsm45YkAKQ8bK22 laJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u10tCeHxgugC+7t5c4hTzmt45MJlA8VbgBQ6EKUnR90=; b=bce1OH2wn04teiAHA+ZscJ87Uh/0QmSQmtS3VPS86NukbAClluLofvPJyVl2VT4ZNJ uI3ZmZZA3gdpyTRkvSpmJnbZjpN8Hn9DIikiEhvrAcZ46DywUH97buTG1Cz0TfHrC2DU x4Uh4wjvtpHCfb8550/iWp1+4bjWyJmqaToQchkJd/vW6aOvoFkB5Uvl0HnzVbulD/Iz gCecaw0HKb2JgUzRQ2aMRwgSRBu8ANADJYKrc0UqZvMNlunTEOVMRoQFw10dxvFeuNBz eMo+L1DzaYeyhg5EVR7WUQfxaV0nD8FYvROL3t5HgiatIyJWe1IpFJO/iskmpekVdEPU hLQw== X-Gm-Message-State: AJIora92sXYXz9CjAwyM8Ic/773bd4sTEMM5rcWuFHA+M6Z4UYUEpw3U W8rZNshsN4+cSZWhn1QF4F0= X-Google-Smtp-Source: AGRyM1s1hVyhBwwGLVuNtYrm5Qeoc6vYhpoL6RjksqTuhA5nHSBW4K9cUn6wI9YoCkXl9KLkd7M29g== X-Received: by 2002:adf:9d90:0:b0:21e:4cd3:b966 with SMTP id p16-20020adf9d90000000b0021e4cd3b966mr169351wre.665.1658437350730; Thu, 21 Jul 2022 14:02:30 -0700 (PDT) Received: from localhost.localdomain (host-95-235-102-55.retail.telecomitalia.it. [95.235.102.55]) by smtp.gmail.com with ESMTPSA id d12-20020adffbcc000000b0021b8c554196sm2884383wrs.29.2022.07.21.14.02.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jul 2022 14:02:29 -0700 (PDT) From: "Fabio M. De Francesco" To: Ira Weiny , Andrew Morton , Catalin Marinas , "Matthew Wilcox (Oracle)" , Will Deacon , Peter Collingbourne , Vlastimil Babka , Sebastian Andrzej Siewior , Jonathan Corbet , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: "Fabio M. De Francesco" , Mike Rapoport , Thomas Gleixner Subject: [PATCH 6/7] highmem: Delete a sentence from kmap_local_page() kdocs Date: Thu, 21 Jul 2022 23:02:05 +0200 Message-Id: <20220721210206.13774-7-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220721210206.13774-1-fmdefrancesco@gmail.com> References: <20220721210206.13774-1-fmdefrancesco@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" kmap_local_page() should always be preferred in place of kmap() and kmap_atomic(). "Only use when really necessary." is not consistent with the Documentation/mm/highmem.rst and these kdocs it embeds. Therefore, delete the above-mentioned sentence from kdocs. Cc: Andrew Morton Cc: Matthew Wilcox (Oracle) Cc: Mike Rapoport Cc: Sebastian Andrzej Siewior Cc: Thomas Gleixner Suggested-by: Ira Weiny Reviewed-by: Ira Weiny Signed-off-by: Fabio M. De Francesco --- include/linux/highmem.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/linux/highmem.h b/include/linux/highmem.h index 0ba031ad29c2..63f25dfc6317 100644 --- a/include/linux/highmem.h +++ b/include/linux/highmem.h @@ -86,8 +86,7 @@ static inline void kmap_flush_unused(void); * temporarily mapped. * * While it is significantly faster than kmap() for the higmem case it - * comes with restrictions about the pointer validity. Only use when really - * necessary. + * comes with restrictions about the pointer validity. * * On HIGHMEM enabled systems mapping a highmem page has the side effect of * disabling migration in order to keep the virtual address stable across --=20 2.37.1 From nobody Fri Apr 17 21:03:54 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18DFEC433EF for ; Thu, 21 Jul 2022 21:03:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232683AbiGUVDC (ORCPT ); Thu, 21 Jul 2022 17:03:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233794AbiGUVCk (ORCPT ); Thu, 21 Jul 2022 17:02:40 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 958CA91CC3; Thu, 21 Jul 2022 14:02:35 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id a5so3936859wrx.12; Thu, 21 Jul 2022 14:02:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XSYPcrbVTzgClSZXRMYRyVvkc6OfsxqUTpv5KCNWl3U=; b=p5uPLEeZkNHeCfs0C/ALizG2/6Ja3FGzmfJSLjC5OvjBkH1b8Vgh2AFSvqsmzRNLuL 7jg9QFe09SsA5V4BH8n7jK/mxpbMggRUAJ+tGCfMm5Wyi23XbmTk09PvizfK1rOUoEdT zSB6p+IdrV9M5zpB4zgjhcKx7X2A2tek7GgX3kNPsNprN7JVXJCU09vW3XfFSWqdGZff jc+GtN3Cx7xpyrXDtN6EQYevs4zn+lDtYqEZ7/YZNtFypf/TpsmIdgJjfnOj2iolRBYt etiLygZfp5CelF7+5of+tBHfW0xLMfubKv1EwTaUqH/g65uSfoGBgwSuSLUgbcmkY4dR 2USA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XSYPcrbVTzgClSZXRMYRyVvkc6OfsxqUTpv5KCNWl3U=; b=IdTi5E1ickO6z4/HL24Fzij9AUMmdnF7v/1A61tAsYas8aBW/ctuEX8ggz15ot3k9F NaldXCAS9Reki4WLvouEd5wLvE7+i2wRXkGpet8jv53R3pnpJhOmqsM5RyAB0Wq57zW2 gk+jiwjy/9bvu9gfBzUsMhTQXrgDMX6zp7eARL5xWr6r7kwtTSCW64vZW1hgDZ3sh8Sm pXPvZzGZG7Bl0S6ytpHSbn9lqlEeHq1hXQ4WV8sUv1r69X/053xY0df4mgKXoJLL34yY Yf//CISWFkpa51KtaBTlT2uwZQzPA9Y6Ets/Ym+HYSXUqw2mX9WfKBKvhMEg3JyunRRx o4zQ== X-Gm-Message-State: AJIora/3y2Q6EgECYb2oavsNwpU9C3vPFiul290I66Who9vRAMpGwXEc GpZmzpg887l0K67WeIjCASo= X-Google-Smtp-Source: AGRyM1s/7UEwOZfzWdNMMaLR/ZiIdGlNAPfmvyAVgWnQNsHUG6r20o491RZHqNrFSTFFX70ogSY/3w== X-Received: by 2002:adf:f245:0:b0:21d:a39a:bed5 with SMTP id b5-20020adff245000000b0021da39abed5mr190359wrp.508.1658437353314; Thu, 21 Jul 2022 14:02:33 -0700 (PDT) Received: from localhost.localdomain (host-95-235-102-55.retail.telecomitalia.it. [95.235.102.55]) by smtp.gmail.com with ESMTPSA id d12-20020adffbcc000000b0021b8c554196sm2884383wrs.29.2022.07.21.14.02.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jul 2022 14:02:32 -0700 (PDT) From: "Fabio M. De Francesco" To: Ira Weiny , Andrew Morton , Catalin Marinas , "Matthew Wilcox (Oracle)" , Will Deacon , Peter Collingbourne , Vlastimil Babka , Sebastian Andrzej Siewior , Jonathan Corbet , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: "Fabio M. De Francesco" , Mike Rapoport , Thomas Gleixner Subject: [PATCH 7/7] Documentation/mm: Add details about kmap_local_page() and preemption Date: Thu, 21 Jul 2022 23:02:06 +0200 Message-Id: <20220721210206.13774-8-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220721210206.13774-1-fmdefrancesco@gmail.com> References: <20220721210206.13774-1-fmdefrancesco@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" What happens if a thread is preempted after mapping pages with kmap_local_page() was questioned recently.[1] Commit f3ba3c710ac5 ("mm/highmem: Provide kmap_local*") from Thomas Gleixner explains clearly that on context switch, the maps of an outgoing task are removed and the map of the incoming task are restored and that kmap_local_page() can be invoked from both preemptible and atomic contexts.[2] Therefore, for the purpose to make it clearer that users can call kmap_local_page() from contexts that allow preemption, rework a couple of sentences and add further information in highmem.rst. [1] https://lore.kernel.org/lkml/5303077.Sb9uPGUboI@opensuse/ [2] https://lore.kernel.org/all/20201118204007.468533059@linutronix.de/ Cc: Andrew Morton Cc: Matthew Wilcox (Oracle) Cc: Mike Rapoport Cc: Sebastian Andrzej Siewior Cc: Thomas Gleixner Suggested-by: Ira Weiny Signed-off-by: Fabio M. De Francesco --- Documentation/vm/highmem.rst | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Documentation/vm/highmem.rst b/Documentation/vm/highmem.rst index 564017b447b1..8ce43965ddef 100644 --- a/Documentation/vm/highmem.rst +++ b/Documentation/vm/highmem.rst @@ -60,14 +60,19 @@ list shows them in order of preference of use. This function should be preferred, where feasible, over all the others. =20 These mappings are thread-local and CPU-local, meaning that the mapping - can only be accessed from within this thread and the thread is bound the - CPU while the mapping is active. Even if the thread is preempted (since - preemption is never disabled by the function) the CPU can not be - unplugged from the system via CPU-hotplug until the mapping is disposed. + can only be accessed from within this thread and the thread is bound to = the + CPU while the mapping is active. Although preemption is never disabled by + this function, the CPU can not be unplugged from the system via + CPU-hotplug until the mapping is disposed. =20 It's valid to take pagefaults in a local kmap region, unless the context in which the local mapping is acquired does not allow it for other reaso= ns. =20 + As said, pagefaults and preemption are never disabled. There is no need = to + disable preemption because, when context switches to a different task, t= he + maps of the outgoing task are saved and those of the incoming one are + restored. + kmap_local_page() always returns a valid virtual address and it is assum= ed that kunmap_local() will never fail. =20 --=20 2.37.1