From mboxrd@z Thu Jan 1 00:00:00 1970 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5858C352A1 for ; Tue, 6 Dec 2022 19:15:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4695B8E0003; Tue, 6 Dec 2022 14:15:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 418B58E0001; Tue, 6 Dec 2022 14:15:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2B9AA8E0003; Tue, 6 Dec 2022 14:15:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 19D2A8E0001 for ; Tue, 6 Dec 2022 14:15:11 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D0429A061D for ; Tue, 6 Dec 2022 19:15:10 +0000 (UTC) X-FDA: 80212834380.16.53006AA Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by imf23.hostedemail.com (Postfix) with ESMTP id 59EDA140007 for ; Tue, 6 Dec 2022 19:15:09 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=FbR73fIs; spf=pass (imf23.hostedemail.com: domain of fmdefrancesco@gmail.com designates 209.85.167.53 as permitted sender) smtp.mailfrom=fmdefrancesco@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670354110; a=rsa-sha256; cv=none; b=Z6NKrEoPNWC7HjwJ5xz2iGpvS315D5RITIBLmr9XPOTHwxjTt+08Hv+Bq5jdsiNin35k0z TGqdfnP12Y4EF0L7+bXBPFqXfjB9GY3ncFHgcKg2vvK3i1+EzJhfVtmtfdgCTs/Fz2UPQJ QanTboj1th34Ij7X+m89VzboktD9TVA= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=FbR73fIs; spf=pass (imf23.hostedemail.com: domain of fmdefrancesco@gmail.com designates 209.85.167.53 as permitted sender) smtp.mailfrom=fmdefrancesco@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670354110; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=IfFKOBr66s1CwYSG2TTOFX37oTDo5VCSWbNTI8/Kwv4=; b=BNCc55XW9TLHnr3AN2I7mWR/kFeNbs8Bu+/WTbcvMvfGlV7wy52IvwDqgEAIQWKQp7g2xB QfIzBJDkf6EREhGRlHA4pn3HLDt0ed5OYC/vRTJ/3ad1hy9+ECHJX8BPxtmLVdyKCq3YIY bUNicJuDq7BA2jWAKuyzZjfCbVkt6TY= Received: by mail-lf1-f53.google.com with SMTP id bp15so25167043lfb.13 for ; Tue, 06 Dec 2022 11:15:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=IfFKOBr66s1CwYSG2TTOFX37oTDo5VCSWbNTI8/Kwv4=; b=FbR73fIsdMR2GPrgHhHD+UTq9hQpNRGnvsBYxAjUFp6pfvgZr0f3krQfwdG05HyEy1 GrqzuNBjEozr5uCrq355J5hfAROhjBeuriFoK7Wx/8Y+5uepSm64UppuyPyZyBXJu7sb t6hTT7Q7l6Yc3Vsc/E0zrw8cEhE1vTktFBImAKIE213k6f94zcrTVKWhHa3F6N2u+JYs YXCI/iRDp+4YGirsctZXJg5BTeMwuqg8KGgarVtxG2GiWC/WVUXJvhMIOaR5YNxPHSiS U1SMKtmtkVQdQSiGjdGkp6vMI05YWsRoFBqIh9b+qKNbsMfSXUli4dHVKTvkNWaIWHYj PQoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IfFKOBr66s1CwYSG2TTOFX37oTDo5VCSWbNTI8/Kwv4=; b=SBQ0nMc+zInm5VawM9ir0c9THPsYp+aXcHziJy/Jx3ExmZBZQNQ6w08SizwJbiOMgS NCAmKI89cSKt47J0iBxa0YqOlHy5H5wb9mSJntXnDVSdUe8yg82VEZdfnXZGaiG+jfvG PycbDJTWgQeaEjuXV9Mqms5gcDC1CI71OFtv68U/4KWlrHlPFtQB3UIidVYXHeHFRihC B2ly/yabIIU5tqN2rQLrlnejYQKjk5TaiqnrVVJcgXWqOpJv281JPjPMW05Rn0h16ZMV nR2+fsNsq2czkyza+y9i9W0hBqhj7JSRgWweZwJfG79SCu0ivPN0MmwHPxs553TPRVvJ 91GA== X-Gm-Message-State: ANoB5pliARp3xSs5YR1dPVsKyUwcLnUII6wQLEh0mWnXtHMdjjX2/Enb L+KZNdHLeYhXkmUq7GupMN0Dq7BoeThEv038tak= X-Google-Smtp-Source: AA0mqf6ETBMrhmv2FnJL6/8iC29PFIRvFowg7iEsc9rHdp3yWtBwlqKEvdeK6CW7hUEfF3YvW0no1zsbDZQmKY5m740= X-Received: by 2002:a19:760b:0:b0:4b5:67d8:e3c2 with SMTP id c11-20020a19760b000000b004b567d8e3c2mr4872095lff.166.1670354108416; Tue, 06 Dec 2022 11:15:08 -0800 (PST) MIME-Version: 1.0 References: <20221206070029.7342-1-fmdefrancesco@gmail.com> In-Reply-To: From: "Fabio M. De Francesco" Date: Tue, 6 Dec 2022 20:14:52 +0100 Message-ID: Subject: Re: [PATCH] mm/highmem: Add notes about conversions from kmap{,_atomic}() To: Sebastian Andrzej Siewior Cc: Jonathan Corbet , Andrew Morton , Ira Weiny , Mike Rapoport , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Mike Rapoport , Peter Zijlstra , Thomas Gleixner Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [4.10 / 9.00]; SORBS_IRL_BL(3.00)[209.85.167.53:from]; SUBJECT_HAS_UNDERSCORES(1.00)[]; BAD_REP_POLICIES(0.10)[]; MIME_GOOD(-0.10)[text/plain]; RCVD_NO_TLS_LAST(0.10)[]; BAYES_HAM(-0.00)[34.54%]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; DMARC_POLICY_ALLOW(0.00)[gmail.com,none]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_SEVEN(0.00)[11]; DKIM_TRACE(0.00)[gmail.com:+]; TO_MATCH_ENVRCPT_SOME(0.00)[]; ARC_SIGNED(0.00)[hostedemail.com:s=arc-20220608:i=1]; FROM_HAS_DN(0.00)[]; R_DKIM_ALLOW(0.00)[gmail.com:s=20210112]; MID_RHS_MATCH_FROMTLD(0.00)[]; TO_DN_SOME(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[linux-mm@kvack.org]; R_SPF_ALLOW(0.00)[+ip4:209.85.128.0/17:c]; ARC_NA(0.00)[] X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 59EDA140007 X-Stat-Signature: hibagaod5muo4pc56ccc4njw7bxfkt4j X-HE-Tag: 1670354109-824407 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On marted=C3=AC 6 dicembre 2022 09:00:10 CET Sebastian Andrzej Siewior wrot= e: > On 2022-12-06 08:00:29 [+0100], Fabio M. De Francesco wrote: > > diff --git a/Documentation/mm/highmem.rst b/Documentation/mm/highmem.rs= t > > index 0f731d9196b0..9523e92299f6 100644 > > --- a/Documentation/mm/highmem.rst > > +++ b/Documentation/mm/highmem.rst > > @@ -100,10 +101,21 @@ list shows them in order of preference of use. > > > > (included in the "Functions" section) for details on how to manage nested > > mappings. > > > > -* kmap_atomic(). This permits a very short duration mapping of a sing= le > > - page. Since the mapping is restricted to the CPU that issued it, it > > - performs well, but the issuing task is therefore required to stay on that > > - CPU until it has finished, lest some other task displace its mapping= s. > > +* kmap_atomic(). This function has been deprecated; use kmap_local_page(). > > + > > + NOTE: Conversions to kmap_local_page() must take care to follow the > > mapping + restrictions imposed on kmap_local_page(). Furthermore, code > > between the + map/unmap operations may implicitly depended on the side > > effects of + kmap_atomic(), such as disabling pagefaults, migration, > > and/or preemption. + Such conversions should be changed to make explic= it > > calls for those + requirements. Sebastian, thanks for taking a look at my patch and replying. > Furthermore, code between the kmap_atomic() and kunmap_atomic() > functions may implicitly depended I suppose it should be "depend"? Shouldn't it? > on the side effects of kmap_atomic() > namely disabling pagefaults or preemption or both. I agree with you for rephrasing, mainly because it is written in poor English. However, I still have doubts about why you deleted "migration". AFAIK, __kmap_local_pfn_prot() always takes care of disabling migration for HIGHMEM enabled kernels. How about !HIGHMEM, where kmap_local_page() is an indirect call to page_address()? Did you mean that, if the code between kmap_atomic() and kunmap_atomic() depended on migrate_disable() (in PREEMPT_RT) we should alw= ays just stay safe and call preempt_disable() together with conversion to kmap_local_page()? If so, I understand and I again agree with you. If not, I'm missing somethi= ng; so please let me understand properly. Aside from the above, I'm not sure whether you deleted the last phrase befo= re your suggestion. What about making it to become "For the above-mentioned cases, conversions should also explicitly disable page-faults and/or preemption"? Thanks again for noticing my mistakes. Fabio > > > + [Legacy documentation] > > + > > + This permits a very short duration mapping of a single page. Since = the > > + mapping is restricted to the CPU that issued it, it performs well, b= ut > > + the issuing task is therefore required to stay on that CPU until it = has > > + finished, lest some other task displace its mappings. > > > > kmap_atomic() may also be used by interrupt contexts, since it does = not > > sleep and the callers too may not sleep until after kunmap_atomic() = is > > Sebastian