From nobody Wed Apr 15 01:30:11 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 4373CC04A68 for ; Thu, 28 Jul 2022 15:48:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231649AbiG1Ps4 (ORCPT ); Thu, 28 Jul 2022 11:48:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbiG1Psx (ORCPT ); Thu, 28 Jul 2022 11:48:53 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E84D868DC6; Thu, 28 Jul 2022 08:48:52 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id oy13so3879992ejb.1; Thu, 28 Jul 2022 08:48:52 -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=qm2EcCBR991c2JvJChOIEBo0CCTasClYUTAC7rsN7XM/brmFbkyXwOAp/UZgfFEkb9 kmRFp7OVyj+i3jUgqmczpBDoy9vPFhekvgo5LDnpBWFHevl++AWAobHHoH6aj8K/iVv+ ZIshjVVuZspA7sw8fStOeJCBP3yxVZtotoVbQQEaE78ZG/VfAiE82qwmPRphV3Kn9oO6 5X4ELVI2EZM3LpzY9sxchscM4X+I0AnU3unGsk1B/XXuWl6Z8WrrzMooh1v58g+GByK6 jclZDzsvinObSQjkf9juoUQbxeAPW93crtzenM1PSBbH8Im0fT4CxcNrPb6ktolikz46 u2sA== 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=Gd/0hGVr7uBNHRCstuSMskoJLfxW5kzs/Yk9XE9SE7lkgQtH4XvdcXnVEeyy3ENKbn SMP+tZzGeusHy3Jq9R3P4enR3q/it4Yy0c0TdRdgET31g/agJE0QBnMzIc5E/a3Ic2uA ZdeLvyJ2a4RMoNDTrie9MT4OW7Gb/vYyr6uAwBPeWYILJkyXXgqGc8w2FvdW1Ittrqod hZZSgtYcnK0mUDpSLSrw3a3kHZRZwbFOtRXPpmb3oH+xJZunWKpSHeGyF7Jn5iOwoGSg hj4zKPsHXOoeUSix0Vx0xM5y1cCuuybqwRiOkX3JXZ1D5ZpYKojA18JlUmJnYyOoJybe dVMA== X-Gm-Message-State: AJIora/zkS9XarAOwbEzrrI504MlLopVEqEmlPuRXvs+a52QwfIbMsvu QHriWrSPJg1trLeY2swYpQU= X-Google-Smtp-Source: AGRyM1scjNpjULkYvj++SP7LnLCjwsybIrA/ytTOCPe33lIKTJlhZ0FoG/cXzLKpwDDflEHTKsNAdw== X-Received: by 2002:a17:906:84e8:b0:72e:2f3c:6784 with SMTP id zp8-20020a17090684e800b0072e2f3c6784mr21733685ejb.390.1659023331426; Thu, 28 Jul 2022 08:48:51 -0700 (PDT) Received: from localhost.localdomain (host-79-56-6-250.retail.telecomitalia.it. [79.56.6.250]) by smtp.gmail.com with ESMTPSA id f7-20020a056402068700b0043adc6552d6sm902487edy.20.2022.07.28.08.48.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 08:48:50 -0700 (PDT) From: "Fabio M. De Francesco" To: Mike Rapoport , Thomas Gleixner , 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" Subject: [PATCH v2 1/7] highmem: Remove unneeded spaces in kmap_local_page() kdocs Date: Thu, 28 Jul 2022 17:48:38 +0200 Message-Id: <20220728154844.10874-2-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220728154844.10874-1-fmdefrancesco@gmail.com> References: <20220728154844.10874-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 Wed Apr 15 01:30:11 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 76E2CC04A68 for ; Thu, 28 Jul 2022 15:49:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231970AbiG1PtB (ORCPT ); Thu, 28 Jul 2022 11:49:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231530AbiG1Psz (ORCPT ); Thu, 28 Jul 2022 11:48:55 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91AF26AA34; Thu, 28 Jul 2022 08:48:54 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id mf4so3874994ejc.3; Thu, 28 Jul 2022 08:48:54 -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=Wi2kogBx1v57y4wibVUnI6G/UgvL1LHvS4d/uPEyg9ZX9fKQ1HixwGecaT2wTR3WV4 Dk4KY/WLb461sl13k+D+nVbhKGeAYYvetQYWCrU0jlW5YL4RcYzYP4U1BLZXEifXoOaQ kxRJS5ngbLWb7qh60YcmDyhJpFMTFBH7tlScHZJemIWQyIGLWw9XBFgsg3YPvmAsYHRE FMUPtHKsn01CUhwf0eWZBqe+tLAxyFw7bOBRB4azCgIdOW6//eiMdB6Q/t9gDeCXEFc7 g3JyLg01hSDloqrmG9HkWhTj7IqgFECvFcDBeE3QSv3tFb+FdJL18Ucy+ZB/aTWA6026 SDKQ== 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=LNAogRaPrEJ5K++CgBrO1qzRgBGH3xJ15HRP15OSpexNoMLnfoXLoXZmj1OkUkwrUv tLEl80GMZ7MtvIeRvDGYxC72F27Yvr6UgMPZj70S9Zjk/kMCVO2XNo6jGtfSKRs6TlPy lce9u20JQNoap3Wim18ncHGuDu3jBgD4hKy8YQ+gSqPjZRSZnoB+nXc5IQ8PkKLXQcij WJpcSWi1LEEiAqq9u8lGuXq+h6ePEH1yh5+bEEknGmBuTTALNeLLeWe0tNQmsjQj19mD d8kk7EqzKS5BdN2VCs6+SzgrRrih3OV3JTp1p/4ZJqauJhENrhJNR45WlP7mMguluxMX DTtQ== X-Gm-Message-State: AJIora/7ApYcsSDc9nefM5AibxBXadK5DeTOuCoc0MZHfju5GHnLUjh/ nHpWNH11PrVO7gIOB1lRdNs= X-Google-Smtp-Source: AGRyM1tD875+kA8zgArLguhNqKdpsnvyBlPd2vCrNHJpX9PLxH1r635BTw2y/NVAwK3twnyTbFh+FQ== X-Received: by 2002:a17:907:6e0f:b0:72e:d066:dfe5 with SMTP id sd15-20020a1709076e0f00b0072ed066dfe5mr21796786ejc.558.1659023333982; Thu, 28 Jul 2022 08:48:53 -0700 (PDT) Received: from localhost.localdomain (host-79-56-6-250.retail.telecomitalia.it. [79.56.6.250]) by smtp.gmail.com with ESMTPSA id f7-20020a056402068700b0043adc6552d6sm902487edy.20.2022.07.28.08.48.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 08:48:52 -0700 (PDT) From: "Fabio M. De Francesco" To: Mike Rapoport , Thomas Gleixner , 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" Subject: [PATCH v2 2/7] highmem: Specify that kmap_local_page() is callable from interrupts Date: Thu, 28 Jul 2022 17:48:39 +0200 Message-Id: <20220728154844.10874-3-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220728154844.10874-1-fmdefrancesco@gmail.com> References: <20220728154844.10874-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 Wed Apr 15 01:30:11 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 B5DB7C19F29 for ; Thu, 28 Jul 2022 15:49:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232289AbiG1PtN (ORCPT ); Thu, 28 Jul 2022 11:49:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231607AbiG1PtE (ORCPT ); Thu, 28 Jul 2022 11:49:04 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BD716BC15; Thu, 28 Jul 2022 08:48:58 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id b11so3827895eju.10; Thu, 28 Jul 2022 08:48:58 -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=MMEv2tnkJHQoNeinZVr2aA1AzEdF5MIKyUzDsdgs4R8=; b=WqKewVXGOxgoft0f+QZJEd1nYoSyTawCHG/6Wbt3TY4yByC5y+bgxM2WjaLjow2zl/ RNUA5iLhQkx0xOUGc+QZ+sPE3/zP20Q68LI8llerJgL0rOSL9s/2U+Oj5yVB9PxV1TTK Ao+2rFu1sbI08zlXKsPowSMZ9B25xImb/UeQpNWsYzTtS4rNipMVmYgUwTiS+QiAiF6/ rNOgRmZytKtpoYSUKIsfGvzoCfwrYCGDsJShamktEnF1E8GF4JuW360K55KwfbPl9HBX 4nUZL1wpvEzhawozc6XOJrbFnlJhQdrtGfyyWAglnzWM/WHzqrLIdhTPqb1coJRQ+Jut O3PQ== 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=MMEv2tnkJHQoNeinZVr2aA1AzEdF5MIKyUzDsdgs4R8=; b=lZKCeu/utrFbGZjMuHMrjptuGUd/gHl4Fbg9SKyH6bwqo5fRSBvJ9TPKCB2MlA5j16 Grc7fHzbBLA6YwA8PYoxuRqPMu8fwrb9lP/QzdIIb6nkyYZ4Ohm9rroX5g2y6ujXTCbR b8eQKRAtUb8cbFqcPsKIHsN8eQBBe4EHb/h/ei1zq8M/S/qHQ5DWSJq6R2/pIYr+Wo0g J24q8i1d7Mn+f3v0UGvJGQurVFeQSmt4qbnJg2Uup8Cx/u06r2qr+eNBbk9OMivojeKd htZ+xxb+5o7lnzNGykBIe1xiB+TE9GsVAFi2eXoBhjLHIzWoNEvRd9WxAXKFhCCXZS6u XCpA== X-Gm-Message-State: AJIora9zdpR2tLtdQQkaVfiDT64X7lQtZ8b3ioesWbrQILOnLMoQC6w1 16mxjqp2z1a8pSnJcbx1pxw= X-Google-Smtp-Source: AGRyM1saWlx994orvUgLkY9NXlF2Oi0bNF3EQ0dvBg/rPXPifykSCqYgf3Bwuyx0uaAkpo+W+3SF+Q== X-Received: by 2002:a17:906:9b14:b0:72b:313b:2df4 with SMTP id eo20-20020a1709069b1400b0072b313b2df4mr20887101ejc.99.1659023336626; Thu, 28 Jul 2022 08:48:56 -0700 (PDT) Received: from localhost.localdomain (host-79-56-6-250.retail.telecomitalia.it. [79.56.6.250]) by smtp.gmail.com with ESMTPSA id f7-20020a056402068700b0043adc6552d6sm902487edy.20.2022.07.28.08.48.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 08:48:55 -0700 (PDT) From: "Fabio M. De Francesco" To: Mike Rapoport , Thomas Gleixner , 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" Subject: [PATCH v2 3/7] Documentation/mm: Don't kmap*() pages which can't come from HIGHMEM Date: Thu, 28 Jul 2022 17:48:40 +0200 Message-Id: <20220728154844.10874-4-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220728154844.10874-1-fmdefrancesco@gmail.com> References: <20220728154844.10874-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 which are clearly known which can't come from ZONE_HIGHMEM. Therefore, add a paragraph to highmem.rst, to explain better that a plain page_address() may be used for getting the address of pages which cannot come from ZONE_HIGHMEM, although it is always safe to use kmap_local_page() / kunmap_local() also on those pages. 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..34d7097d3ce8 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 may call a plain page_address() + for pages which are known to not come from ZONE_HIGHMEM. However, it is + always safe to use kmap_local_page() / kunmap_local(). + 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 Wed Apr 15 01:30:11 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 A3A75C19F29 for ; Thu, 28 Jul 2022 15:49:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232634AbiG1PtR (ORCPT ); Thu, 28 Jul 2022 11:49:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231598AbiG1PtI (ORCPT ); Thu, 28 Jul 2022 11:49:08 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A2DF6BD48; Thu, 28 Jul 2022 08:49:00 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id j22so3886772ejs.2; Thu, 28 Jul 2022 08:49:00 -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=lNL0v8M3ogq6CFgHYJ5gw3skUxo1cyHwx09sKFCivm4=; b=NDPcSSW6IS51pmJKZAmPDSDqw//XotceDPFpPrTWnME1v0ubVsH3OjqWS+O6atJfQT Yk+6kcjfART2IwEZU2POnRTLCeGAmJf6gzO4vfA3muIrmWFo9exWusBCcN1BWuWT6cgx zud2dYbh8HOHNPnPZ1mCNubOvWf6WIg/KA1qXahAu1tUoDIUIDq4Dkqv5ur5FIZ4B3a8 FTILN9VHDJ9eP7WfaMoyf3VhOEbkalf2Trwscbhtpw1Wr0lZpEsQ4gJZ3t9jpXTSWJ7M nqPFzm2diXj14vHjJdMI/htVPNZAvIg1RfKhrTsJjSoC1Ev3n7IlTHPy4FeG7efSNSEh oweA== 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=lNL0v8M3ogq6CFgHYJ5gw3skUxo1cyHwx09sKFCivm4=; b=FRoKQY9Ulo7xoNrkiMkN2L0zQMdOQaoAgkmipqd37UQWUVyoXCtxoeZOOOD5DjLtHW ITYoPK6m6u/qtKxJRHqE1pbVcy/ZGcMT4MLRVPvTq2g47vypT4VHJ4YWZ4Wkk1BNVIBw 4rf8w0Q/W4kfAUpOmlwNfiTsEz5LC2UbnBMUVB87LuM/j7WwoDQIHi+IiTxjlbqKNBez hUhmOX5V817Cdp28+Usesd8W/noiBTrvo7wD4jV3f/FUEs2T5F96iloBAPnRWQ+rdO67 AuXBHFR3w8uKanY4AnXxzk4RVBv7/CJbviT0M204ei3B5Dnf+2CZF1NP9T3xe6y07rrw bskw== X-Gm-Message-State: AJIora/YTUQ/VYD+Ss9Jivu4bnVFAsDDfUSJxy76W05Us3x84SnrnwCI MY6/TvbHDcpjEkY6iuNjsss= X-Google-Smtp-Source: AGRyM1s1lHJVGwf/gl1f3XMa52mfrgiOxmy82DQqsN1S916uAzl1V/CXtmqgra/ZOudzPNYSy0S3YA== X-Received: by 2002:a17:906:8a6a:b0:72b:552e:67f0 with SMTP id hy10-20020a1709068a6a00b0072b552e67f0mr21090041ejc.733.1659023339142; Thu, 28 Jul 2022 08:48:59 -0700 (PDT) Received: from localhost.localdomain (host-79-56-6-250.retail.telecomitalia.it. [79.56.6.250]) by smtp.gmail.com with ESMTPSA id f7-20020a056402068700b0043adc6552d6sm902487edy.20.2022.07.28.08.48.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 08:48:57 -0700 (PDT) From: "Fabio M. De Francesco" To: Mike Rapoport , Thomas Gleixner , 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" Subject: [PATCH v2 4/7] Documentation/mm: Avoid invalid use of addresses from kmap_local_page() Date: Thu, 28 Jul 2022 17:48:41 +0200 Message-Id: <20220728154844.10874-5-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220728154844.10874-1-fmdefrancesco@gmail.com> References: <20220728154844.10874-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 34d7097d3ce8..71dc09563ff8 100644 --- a/Documentation/vm/highmem.rst +++ b/Documentation/vm/highmem.rst @@ -77,6 +77,13 @@ list shows them in order of preference of use. for pages which are known to not come from ZONE_HIGHMEM. However, it is always safe to use kmap_local_page() / kunmap_local(). =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 Wed Apr 15 01:30:11 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 95F37C04A68 for ; Thu, 28 Jul 2022 15:49:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231147AbiG1PtW (ORCPT ); Thu, 28 Jul 2022 11:49:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232371AbiG1PtK (ORCPT ); Thu, 28 Jul 2022 11:49:10 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 003026BD75; Thu, 28 Jul 2022 08:49:02 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id v17so2727327edc.1; Thu, 28 Jul 2022 08:49:02 -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=8APnMmesitYfUJOHbYKV3UsYyKDlX27FBCb0ow0nRC4=; b=BKt6O3q2HbkDhrr8HwxREKaSTHKfqeVpD9X1eWdRIPGxTR9YOTZDJ9La8CrKUIVHcU UaC+aK0PPN2aTNyoJ6+HH/16E/igJFEmuLkra8P6NAha1eFq/8oD5IrKEw1WFOnGlhAe 6yLbU9XedsMRIROtlGW4rgB4NrKgF+stWc23t0qRVTaeKvibRjaS8+yzLHO48C0LPlZN EKqOx8OUCXrO/MhSPjwQnzcHggyU9KzPltUTYh8+1mdKqShH1zQZmuko+eobtVn1gjYP /GLXSoTjMzMivBqcY+BxYfeyyGGQxbCYJ36JvwazuE1a7frXROwO4q5N0MP86dUlTuTi 6+PQ== 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=8APnMmesitYfUJOHbYKV3UsYyKDlX27FBCb0ow0nRC4=; b=wZIwoHK0p8B3PotgJHtJqjT7q7Q9+jdRu2NZ/iO0EooFznxKqHDcnAuil3ceIJ6K4d twvVk0zLaoVcFk+oJSGDPet4YvrfIzH3t1iJ3Urxzt/cak1wU+odhxBU0E1nGmQyYb80 b8znUKDmZWJFvzAAWPmXwxXgWnF/LGhx5GjjOb2YHvB5jo6NmZw/4Gr7UJiwZPxYLqU6 F62u+0hQw5X6B1pATPVqlg5S9HKsbodYRpOLPm6Psu+12nusdq+tZdg1CbSjUzipqnj+ 59MgFMHBOK54HdTD9GYJfeCZaaggJLnV7/tbTEjq52KdUvqmhM+f+9QpRS2jcNniN5Y6 qprw== X-Gm-Message-State: AJIora9SZv/rJqWCJB1mM8RseUvTnajRJpIb4oc+PbBKec2LOOSbjhy5 HUxrCnM682IUm4bpkyfZQHE= X-Google-Smtp-Source: AGRyM1t872rB7bx3zD4Ue8eElwqOoi9+d0jeAoDI7eLvHKJm/Ffzc/5rp5Mqz97IjgW/zLeHRUuMQQ== X-Received: by 2002:a05:6402:e0f:b0:43c:f9f9:37c4 with SMTP id h15-20020a0564020e0f00b0043cf9f937c4mr2092484edh.196.1659023341364; Thu, 28 Jul 2022 08:49:01 -0700 (PDT) Received: from localhost.localdomain (host-79-56-6-250.retail.telecomitalia.it. [79.56.6.250]) by smtp.gmail.com with ESMTPSA id f7-20020a056402068700b0043adc6552d6sm902487edy.20.2022.07.28.08.48.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 08:49:00 -0700 (PDT) From: "Fabio M. De Francesco" To: Mike Rapoport , Thomas Gleixner , 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" Subject: [PATCH v2 5/7] Documentation/mm: Prefer kmap_local_page() and avoid kmap() Date: Thu, 28 Jul 2022 17:48:42 +0200 Message-Id: <20220728154844.10874-6-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220728154844.10874-1-fmdefrancesco@gmail.com> References: <20220728154844.10874-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 71dc09563ff8..e045a4b7b3da 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 Wed Apr 15 01:30:11 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 A53C5C04A68 for ; Thu, 28 Jul 2022 15:49:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232702AbiG1PtZ (ORCPT ); Thu, 28 Jul 2022 11:49:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbiG1PtL (ORCPT ); Thu, 28 Jul 2022 11:49:11 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BE756C13F; Thu, 28 Jul 2022 08:49:05 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id ez10so3815900ejc.13; Thu, 28 Jul 2022 08:49:04 -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=KlmTRWeLKmwBcROEHkHZbITGTJuNYP8SrVX0Tn0EsDoDE333WrbzpPWF4Lgl6DQXUO xFQ9n/SzPBNJljSIlhrn4Dm6zHEjB9uqMp9GOrAHYOc8fiHKCKG3CSi/60P9INq59WN9 NV8Pk4H9K4sv/IilYvuPueF/cGVnwwrWbA2ZYFpmv+a5zlnq9/Um2F38ZFNa0L3Tbk2/ yFtsqEEW3KLLZ77jKRf0+D+J+36JH4ZotQMmnOLLhjxb65tpKnOgCubNmZ4RnoZNNP7w V1QPzb3pAHcCTswGtNGq5sT6kDOk7RQUx25/pziHB9dakj9atDC5DPLgRTzP9O/+8p+N c6qQ== 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=7DJSJTvxDesvbXjpZoQt4hphR98mjzzdDPymQKyNwYFTr9vB8g8i1J1/Fy4EBawArx 8d8Ft8Qk2tLbAood4L+7UZ7bK7Ws3dhF9BlHndMZE1rx8kCdL+a7ROU5/erFwQDNf+3u 175/QBIxuWEpCxsqvJUlrAq88BBJ2CFD+LzKNvXgowuMsTxQ0vc4dEWIlqNKm0lT8B77 DakWhWgL5xMknRXw33o81SibExmj++Po8/GiL5SPRAZ6n/m5wh65oIhNgsRjAuZo/pbg O+J+dqzdhneRb+14+oIxtaEf3wvu6u+Nu0DZ44iUgw+Rsy3XEKrIx7t+lRB3t724WuFG 3z1g== X-Gm-Message-State: AJIora/MJZ9mqtmLKpBubTQ0EVS0GZksL+Zodr7Ub6Pt79J6u1l8Ekkg N85j4ahCxI0S97eb1nyoknI= X-Google-Smtp-Source: AGRyM1uTMEeSgDG1fIOeuAPXXAmYDAa7aYZ2/ZW2ZMjpMF8d6d+ZnfyC0wlCzm8mPzPzj0lOPqgvtw== X-Received: by 2002:a17:906:dc8d:b0:72f:2993:ed84 with SMTP id cs13-20020a170906dc8d00b0072f2993ed84mr21031444ejc.251.1659023343545; Thu, 28 Jul 2022 08:49:03 -0700 (PDT) Received: from localhost.localdomain (host-79-56-6-250.retail.telecomitalia.it. [79.56.6.250]) by smtp.gmail.com with ESMTPSA id f7-20020a056402068700b0043adc6552d6sm902487edy.20.2022.07.28.08.49.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 08:49:02 -0700 (PDT) From: "Fabio M. De Francesco" To: Mike Rapoport , Thomas Gleixner , 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" Subject: [PATCH v2 6/7] highmem: Delete a sentence from kmap_local_page() kdocs Date: Thu, 28 Jul 2022 17:48:43 +0200 Message-Id: <20220728154844.10874-7-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220728154844.10874-1-fmdefrancesco@gmail.com> References: <20220728154844.10874-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 Wed Apr 15 01:30:11 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 10060C04A68 for ; Thu, 28 Jul 2022 15:49:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232862AbiG1Pte (ORCPT ); Thu, 28 Jul 2022 11:49:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232503AbiG1PtM (ORCPT ); Thu, 28 Jul 2022 11:49:12 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B0B46D2EF; Thu, 28 Jul 2022 08:49:07 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id os14so3875234ejb.4; Thu, 28 Jul 2022 08:49:07 -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=4EkCm6C5nf+QegmjlHeacbbo0A11Yc7aT2xPtr0I2M0=; b=MTY21uOSVJ606b1H+dzV0+Mbqybso010MmD5/Mqd+4KHa7NFo4zGxveQhikjlPLS7h 2phxbbJDUvchSme1J5Jik2CP0ZBsOsxpvkPe1FHbdyu7VFSd/kv0MvMC25HIzXGTOBp4 /K9AasJlOVTvwE6f1/htME1MI6gL/vxL6z9RxBmO2MlifW66PnCF74F85H3u4kfURf9g BTD6UB40+0jyyFXceP/L7SB272OfCR4ZGC7SPSvbeyKnRt5/2CEWpXaLkBNxTVCN0L7S LSRHmCEA6epfBbpoxRnBnVd6cMsMw8Zba/bVoIaL0EOfXEpDfkXDBDIqsuy5KpzyPG/Z rc8w== 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=4EkCm6C5nf+QegmjlHeacbbo0A11Yc7aT2xPtr0I2M0=; b=CMs7bfqlyfPzboAn8a8420jvmjJqRs/c+TPADjRa5+R/BSAuoiK7bhHTQj/aSpAAde bMF2S4ri15FR1JhbLSZQw9TY6TFek5tkuNqrhxN5mBaR1MQEUiIGK9qAdfZqO+/ITRuZ BRe+2p3/vXCgSLJcQKH20+nkhai2rCfpx5NCBGPI22Tcb86qST+3LKJa8Zny/fuK0nKU tdtgU3cw2n8QuGUnbq0drEaFRVc861EYWlEtRoZA+YJbebxI9+hhLigV9qy4TWJ0Eh56 uCoE6af0umKUxQyMaMTRGOKGeUwHLaVqWhqPqBHSkirWwzRXAgdWBrB9J0ajHMsAgy37 5PKg== X-Gm-Message-State: AJIora8mch5XgU8KwI6aYZ/2ItcP0W9NN8fQl944QuZfC04lWXvWXSSO emua07GKfmXfj8drjpSLyIY= X-Google-Smtp-Source: AGRyM1v8gE4WJQVj8oN3MLDAqwXgZheR9OSc99+pl1Vd0PVtErruRQgyCcsLPy5Km8V3lKWx68ifSQ== X-Received: by 2002:a17:907:720a:b0:72b:549e:305a with SMTP id dr10-20020a170907720a00b0072b549e305amr21291979ejc.691.1659023345797; Thu, 28 Jul 2022 08:49:05 -0700 (PDT) Received: from localhost.localdomain (host-79-56-6-250.retail.telecomitalia.it. [79.56.6.250]) by smtp.gmail.com with ESMTPSA id f7-20020a056402068700b0043adc6552d6sm902487edy.20.2022.07.28.08.49.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 08:49:04 -0700 (PDT) From: "Fabio M. De Francesco" To: Mike Rapoport , Thomas Gleixner , 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" Subject: [PATCH v2 7/7] Documentation/mm: Add details about kmap_local_page() and preemption Date: Thu, 28 Jul 2022 17:48:44 +0200 Message-Id: <20220728154844.10874-8-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220728154844.10874-1-fmdefrancesco@gmail.com> References: <20220728154844.10874-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 e045a4b7b3da..0f731d9196b0 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