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 27848C25B08 for ; Wed, 17 Aug 2022 10:29:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B405D6B0073; Wed, 17 Aug 2022 06:29:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AC9046B0074; Wed, 17 Aug 2022 06:29:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 942A28D0002; Wed, 17 Aug 2022 06:29:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 818A26B0073 for ; Wed, 17 Aug 2022 06:29:41 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 4DA9880849 for ; Wed, 17 Aug 2022 10:29:41 +0000 (UTC) X-FDA: 79808713362.18.F61D1C4 Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by imf23.hostedemail.com (Postfix) with ESMTP id AE9B1140082 for ; Wed, 17 Aug 2022 10:29:40 +0000 (UTC) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id A8A873200A2D; Wed, 17 Aug 2022 06:29:38 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Wed, 17 Aug 2022 06:29:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov.name; h=cc:cc:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1660732178; x=1660818578; bh=nq EWiR7pHJAN6SWkq0ZJTwd01tGFrLCgeNeHZjg9e04=; b=qabXqT3dPxfvNPdaDM 2AC2/ouTn9ntwhiPm0rocA9TAZB5qQuef+NqJQxGmyfS+i5L2W00Q/4dZFOX/8mF vPN2aWRoKw30nGsgi2yotNbzWRNxAiKk1mrlN/RL/SwuUMpDZ+JRY1sZTG0zMbDq fiU0ckSRsGjG7usUG0101csMbx1gmwDQ1hwO/n0S2gNzO/r6NoqbFeGoNHAsji01 cUFW83q/1zj/HJgRPnzAphHWZ7WuZJ6iZIG8HUNphhPeyLEwqosEgN5oyyNAuu8e xXVa0S0o4X82Y1NLB1iWcPJ8FSHJmxRiNmyhc9G1bbjoJv9oj/IVdGJcxhxMWeqr VNfw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1660732178; x=1660818578; bh=nqEWiR7pHJAN6SWkq0ZJTwd01tGF rLCgeNeHZjg9e04=; b=e0uHHh6fLyJ31e4G9LnDAqb4jQDDeb5pQYiZTLOiihc3 X/IWT+GOdBM0KvvLCd4a7a/As6+T06OYiuEJE8qTdqurxsMAFfVhFywYK/G3SstD d6pRsbNxTUHy6xQ+zV00FKqSSJ33AkBkGfRJaHZuuTWgu+yKb2QBZgRQ9LOinL5h yMGzqmNm1+xAAGTMoI01xXbXPFJJTLB6YPVzg8CsQQX/lBgrFZKjgU/CaxSlrIZM +CFIKGi7FojrZeYj2r04twq9+mGR5QWc92VW87/A0WWgWGtsGVfiaN66noIqErLA 1ywhsqV8Uyxj9CjlhO83x84MoVB19KbV4FsS3Tz4QQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdehiedgvdekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdttddttddtvdenucfhrhhomhepfdfmihhr ihhllhcutedrucfuhhhuthgvmhhovhdfuceokhhirhhilhhlsehshhhuthgvmhhovhdrnh grmhgvqeenucggtffrrghtthgvrhhnpefhieeghfdtfeehtdeftdehgfehuddtvdeuheet tddtheejueekjeegueeivdektdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpehkihhrihhllhesshhhuhhtvghmohhvrdhnrghmvg X-ME-Proxy: Feedback-ID: ie3994620:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 17 Aug 2022 06:29:37 -0400 (EDT) Received: by box.shutemov.name (Postfix, from userid 1000) id 7BD29104A77; Wed, 17 Aug 2022 13:29:35 +0300 (+03) Date: Wed, 17 Aug 2022 13:29:35 +0300 From: "Kirill A. Shutemov" To: Matthew Wilcox Cc: Thomas Gleixner , Ira Weiny , "Fabio M. De Francesco" , Luis Chamberlain , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: folio_map Message-ID: <20220817102935.cqcqpmuu3vanfb63@box.shutemov.name> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660732181; a=rsa-sha256; cv=none; b=lvrRSMDLuyzc2z3Hqg0P8xiPJQSDPL9SP2YKB6qR2tutBuDqOW6LwZLr917txIugc0qa/8 1Vw0NdlC/0i2tEo+cwbsx3w1YDbXykIw2X2DzuC4yc9eIXua4YxBSmAI8GCaOZZsv8StMc CnH1uPAbrCln7AJfQ5K5IWxTA2nPSLA= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=shutemov.name header.s=fm2 header.b=qabXqT3d; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=e0uHHh6f; spf=pass (imf23.hostedemail.com: domain of kirill@shutemov.name designates 64.147.123.21 as permitted sender) smtp.mailfrom=kirill@shutemov.name; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660732181; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=nqEWiR7pHJAN6SWkq0ZJTwd01tGFrLCgeNeHZjg9e04=; b=A74RqF7r6dBk+CRWUOMr2b1Yuut6o217JIfvbFd1ik+aucO6MVGN0a8fS1NisiAsahk3UY vgyX/Y+7KWhc3sVQn38FTNAXAJawoVzzeDm54OvBnLw3WaxOrje3Q/pcbwh6FB96JhieDe DT3cwTyT57VGukD+jvSZcwiM6Vv3Q7E= Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=shutemov.name header.s=fm2 header.b=qabXqT3d; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=e0uHHh6f; spf=pass (imf23.hostedemail.com: domain of kirill@shutemov.name designates 64.147.123.21 as permitted sender) smtp.mailfrom=kirill@shutemov.name; dmarc=none X-Rspam-User: X-Stat-Signature: dqbekys5fazc8mrx167h88agsc96nxo8 X-Rspamd-Queue-Id: AE9B1140082 X-Rspamd-Server: rspam06 X-HE-Tag: 1660732180-818421 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 Tue, Aug 16, 2022 at 07:08:22PM +0100, Matthew Wilcox wrote: > Some of you will already know all this, but I'll go into a certain amount > of detail for the peanut gallery. > > One of the problems that people want to solve with multi-page folios > is supporting filesystem block sizes > PAGE_SIZE. Such filesystems > already exist; you can happily create a 64kB block size filesystem on > a PPC/ARM/... today, then fail to mount it on an x86 machine. > > kmap_local_folio() only lets you map a single page from a folio. > This works for the majority of cases (eg ->write_begin() works on a > per-page basis *anyway*, so we can just map a single page from the folio). > But this is somewhat hampering for ext2_get_page(), used for directory > handling. A directory record may cross a page boundary (because it > wasn't a page boundary on the machine which created the filesystem), > and juggling two pages being mapped at once is tricky with the stack > model for kmap_local. > > I don't particularly want to invest heavily in optimising for HIGHMEM. > The number of machines which will use multi-page folios and HIGHMEM is > not going to be large, one hopes, as 64-bit kernels are far more common. > I'm happy for 32-bit to be slow, as long as it works. > > For these reasons, I proposing the logical equivalent to this: > > +void *folio_map_local(struct folio *folio) > +{ > + if (!IS_ENABLED(CONFIG_HIGHMEM)) > + return folio_address(folio); > + if (!folio_test_large(folio)) > + return kmap_local_page(&folio->page); > + return vmap_folio(folio); > +} > + > +void folio_unmap_local(const void *addr) > +{ > + if (!IS_ENABLED(CONFIG_HIGHMEM)) > + return; > + if (is_vmalloc_addr(addr)) > + vunmap(addr); > + else > + kunmap_local(addr); > +} > > (where vmap_folio() is a new function that works a lot like vmap(), > chunks of this get moved out-of-line, etc, etc., but this concept) So it aims at replacing kmap_local_page(), but for folios, right? kmap_local_page() interface can be used from any context, but vmap helpers might_sleep(). How do we rectify this? -- Kiryl Shutsemau / Kirill A. Shutemov