Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp439146rdb; Mon, 18 Sep 2023 22:58:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGBn3/E+OPBsc5BpIr3sRtsAA8zH1sMr/Sqqv9fUccsAoS9sn6PmLZpr27ysN1Kir8oTow9 X-Received: by 2002:a05:6358:99a5:b0:13c:eea2:d021 with SMTP id j37-20020a05635899a500b0013ceea2d021mr10855759rwb.9.1695103118789; Mon, 18 Sep 2023 22:58:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695103118; cv=none; d=google.com; s=arc-20160816; b=nzhiHTsZDdolMkvdRll8QT6c0v8E5XPXlqH1r9wbxQkbtunGV51nzLWpp2bs47psLm muqIUdcbV0pNCcQxrwxez8mL48gntfDLPl4Xphje2r1Mlkwc2B7XptBY3j8Y3WmaOpw8 i7YfwCQ8nRXQ2rtscoP7O67ElpaSahpqVqSt6711j8mN4bOjl4MUjtVqT25GPkOktBaN 1l5h8Fb/zrHqmC3Ulf4QB/QdNkjc/0nQek5Q3x1m0yJv41FBK8Gjffn9cHPptrp5R+2w FDYh8MVDt/bO3mcMUsaD8tYU4y2O1tIbQDof8QiM203nOE366p8QP1+6XsVI8FRuQ4tc 84UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=TC8wfBk+ib87P7TgIQGCMrwtRUP58vsgw9dhZZ19d68=; fh=8NqkYSX98HmfLGEx2ifR9Xu6tgXKoR+e165PMZLD5N4=; b=AeltL5uOJff7kCPXbn7CmCK3n8pn+Pha+FhYBbdBe9f5Ksiu7wKeqkh8H+NDjEX+kr jg74IDJE0jCFWG5XxFjqcdfBHowKZcTpSK2zZI7GeB1i4iCvXgPi0Ko4lGIArWJpkUw/ Obk5bL4XcETR55GENjErx6z6b9z17GmcaQRaFjYeR/ry3UQrsANZBcBzcA0mnK+DSx09 NAqhVGmlUGF5c8tJ9Eyhg51snZYn5dt/I3LuLgXhgK6uckAnp9JWl/as1as3nyqro6IK ANADfjV/EK+hI9/BSwYwYbnUbXJkt/J9nYEtNuKrzg9ZnVNuLuktcyommfHiGp2B9HY0 qd1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=hC17YkoD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id t22-20020a63eb16000000b005660335e26fsi8845511pgh.485.2023.09.18.22.58.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 22:58:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=hC17YkoD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id D2DB48036EAF; Mon, 18 Sep 2023 11:25:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229686AbjIRSZL (ORCPT + 99 others); Mon, 18 Sep 2023 14:25:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229668AbjIRSZK (ORCPT ); Mon, 18 Sep 2023 14:25:10 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D2E4112; Mon, 18 Sep 2023 11:25:03 -0700 (PDT) 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=TC8wfBk+ib87P7TgIQGCMrwtRUP58vsgw9dhZZ19d68=; b=hC17YkoDr54/vXu9pLxNScC1tR 58CYaFjKwojnqasqeKRlYiiyhGN4QyLMZXo7pvNF53AngJGnujARir/IibZbgbOBHea1gQYCq/Adb bY5llp7euvOgmQscF8JZZw9iTzNILN3n52VgSdhzDId6M8HxQP0WtxdNDKMDmvtwQXhWX0X9/EnRZ 9Z6DFZm9ZT5/K0IK4Ws+5L/W2vrIs5ZY9T68/cVRDQHoxPATR3IoWSXl/ui2SpfPnqwTCmj9haQmR RirTOGJJ0Z7SauWIWNgcAPcK3Hu/mpvfOupj/ssb6jbVGh4m3ZRjt0hZ4omWsTPNe4GOm9Y3x16Ps SNP1t+ig==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qiIvX-00CXHT-W9; Mon, 18 Sep 2023 18:24:56 +0000 Date: Mon, 18 Sep 2023 19:24:55 +0100 From: Matthew Wilcox To: Luis Chamberlain Cc: Daniel Gomez , "minchan@kernel.org" , "senozhatsky@chromium.org" , "axboe@kernel.dk" , "djwong@kernel.org" , "hughd@google.com" , "akpm@linux-foundation.org" , "linux-kernel@vger.kernel.org" , "linux-block@vger.kernel.org" , "linux-xfs@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" , "gost.dev@samsung.com" , Pankaj Raghav Subject: Re: [PATCH 1/6] filemap: make the folio order calculation shareable Message-ID: References: <20230915095042.1320180-1-da.gomez@samsung.com> <20230915095042.1320180-2-da.gomez@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 18 Sep 2023 11:25:14 -0700 (PDT) On Mon, Sep 18, 2023 at 11:09:00AM -0700, Luis Chamberlain wrote: > On Fri, Sep 15, 2023 at 02:40:07PM +0100, Matthew Wilcox wrote: > > On Fri, Sep 15, 2023 at 09:51:23AM +0000, Daniel Gomez wrote: > > > To make the code that clamps the folio order in the __filemap_get_folio > > > routine reusable to others, move and merge it to the fgf_set_order > > > new subroutine (mapping_size_order), so when mapping the size at a > > > given index, the order calculated is already valid and ready to be > > > used when order is retrieved from fgp_flags with FGF_GET_ORDER. > > > > > > Signed-off-by: Daniel Gomez > > > --- > > > fs/iomap/buffered-io.c | 6 ++++-- > > > include/linux/pagemap.h | 42 ++++++++++++++++++++++++++++++++++++----- > > > mm/filemap.c | 8 -------- > > > 3 files changed, 41 insertions(+), 15 deletions(-) > > > > That seems like a lot of extra code to add in order to avoid copying > > six lines of code and one comment into the shmem code. > > > > It's not wrong, but it seems like a bad tradeoff to me. > > The suggestion to merge came from me, mostly based on later observations > that in the future we may want to extend this with a min order to ensure > the index is aligned the the order. This check would only be useful for > buffred IO for iomap, readahead. It has me wondering if buffer-heads > support for large order folios come around would we a similar check > there? > > So Willy, you would know better if and when a shared piece of code would > be best with all these things in mind. In my mind, this is fundamentally code which belongs in the page cache rather than in individual filesystems. The fly in the ointment is that shmem has forked the page cache in order to do its own slightly specialised thing. I don't see the buffer_head connection; shmem is an extremely special case, and we shouldn't mess around with other filesystems to avoid changing shmem. Ideally, we'd reunify (parts of) shmem and the regular page cache, but that's a lot of work, probably involving the swap layer changing.