Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp527161imn; Thu, 28 Jul 2022 08:00:11 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tvFQJFUfdW1IL0Wj2GbNM8sO5k/p7otSW4jwzRbCPK0EzD6+upVIyDXL6zGnW0W2wG87Ic X-Received: by 2002:aa7:919a:0:b0:52a:eeef:3e65 with SMTP id x26-20020aa7919a000000b0052aeeef3e65mr26851157pfa.15.1659020410766; Thu, 28 Jul 2022 08:00:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659020410; cv=none; d=google.com; s=arc-20160816; b=RYlvZYjyLNN5UCWOQUzF1XixrqL7EnzqUrYYTWoBsM/IdzLc+LZYixQi55bq0m6XJ+ tIM0TFbNfeVBO3H48KSACpq32JpucWyD6AEcHLK7hJsiCOR380k8HWVZ7H4wEEjGdE8K iQoG8wA/Sddxt0244EzaYNGMwggGEHF9HaACb+Qkrj2Mn2qq06Gs+GkP4e/+aqpH3dIF 7m31ABbKRO5LNjFDHTmu3iW7W9kimpeMHW842hyINJmpnu2rNZa5ryjcQIpSrSIXTh4Z 1n3KjNHspRDkMPdMdXe5uDe33Cn+J1XkGca2j1H1rHMcyHFJ2zJS+3kWZK+BrZyy7VwU 73gQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LeWUujqUUuiOXJGzjNUETMmb8nohrj2ZZRb1epQbHFk=; b=v5KigIrV3Qz6tQKRgJU4z2gtLnBWCJVGxTgfUjKMQicvjxm+Lf85D1daO4cFELZ/yT rosf5TMduUYAHMza5n1mnCP8F5v6HyszPolyPnH1KFoWegyWFsZhMOc4uMq75+lH17CI X3Pu+yO+htaqAVnHGkoKK+JOYchADbrF4TWLzv/Z9Z/VwQHBZmUcUB6a3bmR9x1s1sT9 ZWYCUYJLSCyWwCrvKp6h7x6e1Hv0Rnd+jMqnD/7xr3gEJoNYpGhCNxzCR4l17Q5DIZrQ JeA0vbGUzOmAjfh2l6l2Ho6KUsKo/c67MQsQNMvKbjbyWVSp9R4W0VVUERZDpBd6vShq Aqiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=moPHxaWX; 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 m9-20020a170902f64900b0016c29e43c72si1206916plg.140.2022.07.28.07.59.56; Thu, 28 Jul 2022 08:00:10 -0700 (PDT) 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=moPHxaWX; 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 S231588AbiG1Owy (ORCPT + 99 others); Thu, 28 Jul 2022 10:52:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229550AbiG1Oww (ORCPT ); Thu, 28 Jul 2022 10:52:52 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EDCC5E320; Thu, 28 Jul 2022 07:52:51 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id b6so1082689wmq.5; Thu, 28 Jul 2022 07:52:51 -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=LeWUujqUUuiOXJGzjNUETMmb8nohrj2ZZRb1epQbHFk=; b=moPHxaWXP3cr7Si6/x+QRMQbL6jeZTgh0WL8q+R3F86u3P098i6+0rFsoV0tqigSnQ zH/f0FnGyWQQ8div8AovHJ9+SJWIqvzwJuiYugZs53e+H2K4E2QAsRVul7O/IBvE0m8N +Fway6zrPNVG+LHr+fLr+7fujrggd7hLzXI2hSVljE3WeFNfEXTwNabYKIVUGNsQsVw7 w4q7DB4WuBkzXJX1GfLKyZdQjv+SPottmch25I+47q8lIUadGf3PU265/iNLZRam7Uq6 vO9pNjaCQpzfrxKK7UbDV0kBUPVZisvS6i7dPW/hyEep20OPhVE0ROU1jKBMrsRMDevn Gqpg== 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=LeWUujqUUuiOXJGzjNUETMmb8nohrj2ZZRb1epQbHFk=; b=HrHu8uSEna8TeVwS+3VRqWsoicDc1NsjSMTvqiXf7OsSnxLo5YZnme+kCTfSL5y8mE JHwLsNFChA0yTXaDMZn3nIv6soBydkntajReht1XLrDfYL92tD8nxM+llS/sQGO+8D3d Y7siuuW6b6qqWjgZ4Etcw0QNwKKpaymhle3ycP9Ku5PN2WGDpiwhvWc+7VrAQB/WOatg JqocZmCqtVWdaRnw/HzbYM1gjXp1IuUqYy4zOLY4hvYPoQ2xx4Jt7X2krBLOWFYDVRTs vK07tANHSfVoN8a9c2yNuDJ32spu/IU68vJojkmHPptML2agAbh+PsO0waqL3dUJYLvP r6MQ== X-Gm-Message-State: AJIora+pMJ4cqV/iJBqHZBfCn3y2JP/G8H6KJztBqBYztO74qQr1p8Gu oIVd6kISmdepe9YXZQ1ZuQA= X-Received: by 2002:a05:600c:21d7:b0:3a3:2088:bbc6 with SMTP id x23-20020a05600c21d700b003a32088bbc6mr6768686wmj.68.1659019969612; Thu, 28 Jul 2022 07:52:49 -0700 (PDT) Received: from opensuse.localnet (host-79-56-6-250.retail.telecomitalia.it. [79.56.6.250]) by smtp.gmail.com with ESMTPSA id p6-20020a1c5446000000b003a2f96935c0sm6840625wmi.9.2022.07.28.07.52.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 07:52:48 -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 , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Jonathan Corbet Cc: Mike Rapoport , Thomas Gleixner Subject: Re: [PATCH 3/7] Documentation/mm: Don't kmap*() pages which can't come from HIGHMEM Date: Thu, 28 Jul 2022 16:52:45 +0200 Message-ID: <7426546.EvYhyI6sBW@opensuse> In-Reply-To: <87czdykw4j.fsf@meer.lwn.net> References: <20220721210206.13774-1-fmdefrancesco@gmail.com> <20220721210206.13774-4-fmdefrancesco@gmail.com> <87czdykw4j.fsf@meer.lwn.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 On gioved=C3=AC 21 luglio 2022 23:13:00 CEST Jonathan Corbet wrote: > "Fabio M. De Francesco" writes: >=20 > > 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=20 assumed > > that kunmap_local() will never fail. > > =20 > > + On CONFIG_HIGHMEM=3Dn kernels and for low memory pages this returns= =20 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,=20 depending > > + on the GFP_* flags, cannot come from ZONE_HIGHMEM. > > + >=20 > Is this good advice? Well... yes and no :-)=20 However yours is a legit objection.=20 I'm taking most of the suggestion from Ira (from an email in this same=20 thread) and send the v2 of this series. My intention was to avoid things like those I encountered when converting=20 fs/btrfs: page =3D alloc_page(GFP_NOFS); kaddr =3D kmap(page); Why one should kmap*() pages allocated one or two lines above with=20 GFP_NOFS?=20 =46urthermore, since nesting kmap_local_page() / kunmap_local() is last in= =20 first out (LIFO), I had several problems with several un-mappings until=20 David Sterba made me notice that GFP_NOFS is not OR'ed with __GFP_HIGHMEM=20 and suggested to use plain page_address() instead of those unnecessary=20 mappings. However, you are right about the fact that, with most of other allocations,= =20 it is not so clear where and how pages are being allocated. Thanks, =46abio=20 > First, it requires developers to worry about > whether their pages might be in highmem, which is kind of like worrying > about having coins in your pocket in case you need a payphone. But it > would also run afoul of other semantics for kmap*(), such as PKS, should > that ever be merged: >=20 > https://lwn.net/Articles/894531/ > > Thanks, >=20 > jon >=20