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 ACB7CC2BB41 for ; Wed, 17 Aug 2022 19:39:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0EA996B0073; Wed, 17 Aug 2022 15:39:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 099ED8D0002; Wed, 17 Aug 2022 15:39:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA29B8D0001; Wed, 17 Aug 2022 15:39:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D82366B0073 for ; Wed, 17 Aug 2022 15:39:24 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9CEC8120AFD for ; Wed, 17 Aug 2022 19:39:24 +0000 (UTC) X-FDA: 79810098648.29.BFC8F0F Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf25.hostedemail.com (Postfix) with ESMTP id A6F2CA01B8 for ; Wed, 17 Aug 2022 19:39:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=WoWmxJLPPEJlc4MBe2emZrwXtinJcbksNx6kTZ5w/4A=; b=iRPQe+BSxKxiS/k952a8GmKJ3d mMV5tkdL9WTH1tdiBGm3mceFXv6TMrZH5BYCu2aUdp8LJMqbNlzCkVjoOOy12TluIcrKBOiHVs2ap yMBLC1IrclJnfO6zSsdWaRjrEfdIUVdVKrZl550Mxl3L3G3Fvw2gYmM9HgsQiIWWLexjsJrKShwa4 P8IxH9SdmA1EDFO1d8+peik1zN2RnA1JRP3tWjkhigq6nIRVNSAsOIQAI0x4Mi/CFEGbQZ7rVDZ8B /1kZK81K3OXAo8h0YaqZPh1UhhpOLeF2IE7dZaoFFZG0cDSDEZO+EwRt9QR4KJy8hkI1FOV0VYok6 SRwQuqdg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oOOsO-008cve-BL; Wed, 17 Aug 2022 19:38:52 +0000 Date: Wed, 17 Aug 2022 20:38:52 +0100 From: Matthew Wilcox To: "Kirill A. Shutemov" 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: References: <20220817102935.cqcqpmuu3vanfb63@box.shutemov.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220817102935.cqcqpmuu3vanfb63@box.shutemov.name> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660765162; a=rsa-sha256; cv=none; b=BBXMjLVfQ+2iePPZuheGuKteNCaMpNsbybdYuh/yapsbFA+0LlN9EIvo+4jxk3Qb90ImgT 55ypBlwMyo6juY1FMfAs86ipk8A0EgFmejiv18Xi6PccvTgeRjdDX6G7pRBfXF0SNkDrpi P6LivsDf/6vN+2NezK9UIB/gacJi98s= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=iRPQe+BS; dmarc=none; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660765162; 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=WoWmxJLPPEJlc4MBe2emZrwXtinJcbksNx6kTZ5w/4A=; b=UPIsbT1qN7gh/HVEv8e876sRQ4Kj7gYIHtTBzUFoavfRROxJFWr23RAMc2mA0KvTBkM+O/ lRlEzYvlCVtiu8uy2lO9HQuaLnFHEv8jOl5Un+4krNz6w0cVnSmaqX1av53Cbvid2FFdV3 4TxFnH+XUAVafnqK/HG2BHWd3I9UEDQ= X-Stat-Signature: 3desisad1eggbm86xoo9gxiuehxj8ec9 X-Rspamd-Queue-Id: A6F2CA01B8 Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=iRPQe+BS; dmarc=none; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1660765161-602568 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 Wed, Aug 17, 2022 at 01:29:35PM +0300, Kirill A. Shutemov wrote: > 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? I'm not proposing getting rid of kmap_local_folio(). That should still exist and work for users who need to use it in atomic context. Indeed, I'm intending to put a note in the doc for folio_map_local() suggesting that users may prefer to use kmap_local_folio(). Good idea to put a might_sleep() in folio_map_local() though.