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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8F98C433EF for ; Tue, 7 Jun 2022 14:12:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245211AbiFGOL6 (ORCPT ); Tue, 7 Jun 2022 10:11:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245218AbiFGOLs (ORCPT ); Tue, 7 Jun 2022 10:11:48 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02159AE241; Tue, 7 Jun 2022 07:11:48 -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=4nUpYTI4YzQUWe3MX/DeuqIdjPgTHj7mksBWnabO8pk=; b=IoritkaL90aqbR+RUHZKoSo8fb np1ux4ttns5tYj2sJk/FAj12Ak/CQ/wW4eIuwXN5ulK6rhUSeL7wfME8a6K9gYUgIYgqg08BNe9+I tus3kQ04SmPJZl9V4GH+E2xTibe280AETqIE3sbtSug/TUXDR0128c42jRa/+qeI8q7uri0dQOk1f wWHM11+pgzBreVL8bkL3da/JDGIf99g2HUm8tnTrzT4cPM9I17c3dxlon1CkQMKJOgWEf9FbWmKJ9 h7TOtnv+jsL8ABFyKBR86bb03b2ZVDj0NIek4XcowncLGE0YjVino+xsZhqucJvOU+7lO9abDpL7s BM8iPWpg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nyZvo-00BhC6-Sq; Tue, 07 Jun 2022 14:11:40 +0000 Date: Tue, 7 Jun 2022 15:11:40 +0100 From: Matthew Wilcox To: Brian Foster Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-aio@kvack.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-xfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-ntfs-dev@lists.sourceforge.net, ocfs2-devel@oss.oracle.com, linux-mtd@lists.infradead.org, virtualization@lists.linux-foundation.org Subject: Re: [PATCH 05/20] mm/migrate: Convert expected_page_refs() to folio_expected_refs() Message-ID: References: <20220606204050.2625949-1-willy@infradead.org> <20220606204050.2625949-6-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org On Tue, Jun 07, 2022 at 09:41:57AM -0400, Brian Foster wrote: > On Mon, Jun 06, 2022 at 09:40:35PM +0100, Matthew Wilcox (Oracle) wrote: > > -static int expected_page_refs(struct address_space *mapping, struct page *page) > > +static int folio_expected_refs(struct address_space *mapping, > > + struct folio *folio) > > { > > - int expected_count = 1; > > + int refs = 1; > > + if (!mapping) > > + return refs; > > > > - if (mapping) > > - expected_count += compound_nr(page) + page_has_private(page); > > - return expected_count; > > + refs += folio_nr_pages(folio); > > + if (folio_get_private(folio)) > > + refs++; > > Why not folio_has_private() (as seems to be used for later > page_has_private() conversions) here? We have a horrid confusion that I'm trying to clean up stealthily without anyone noticing. I would have gotten away with it too if it weren't for you pesky kids. #define PAGE_FLAGS_PRIVATE \ (1UL << PG_private | 1UL << PG_private_2) static inline int page_has_private(struct page *page) { return !!(page->flags & PAGE_FLAGS_PRIVATE); } So what this function is saying is that there is one extra refcount expected on the struct page if PG_private _or_ PG_private_2 is set. How are filesystems expected to manage their page's refcount with this rule? Increment the refcount when setting PG_private unless PG_private_2 is already set? Decrement the refcount when clearing PG_private_2 unless PG_private is set? This is garbage. IMO, PG_private_2 should have no bearing on the page's refcount. Only btrfs and the netfs's use private_2 and neither of them do anything to the refcount when setting/clearing it. So that's what I'm implementing here. > > + > > + return refs;; > > Nit: extra ; Oh, that's where it went ;-) I had a compile error due to a missing semicolon at some point, and thought it was just a typo ... 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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 99A06C433EF for ; Tue, 7 Jun 2022 14:12:05 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.94.2) (envelope-from ) id 1nyZwD-0004rt-1L; Tue, 07 Jun 2022 14:12:03 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nyZwB-0004rb-Gb; Tue, 07 Jun 2022 14:12:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; 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:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=4nUpYTI4YzQUWe3MX/DeuqIdjPgTHj7mksBWnabO8pk=; b=J5Otw9dDfq9FxnBKeTM+ISyV9x mQ5Vv+jQ4j2LbkoPrF2ftfXDtRX8f2I4u9QPBptb95v0XMIv8w2mUPz/WwJFMRAlqJGQYY0u9Itte SpTJ2WG+PqF9X8FXPv/wHeQcUAsG4IcwzLXc+QE1utU41Jk24UOAhcWUCYpCATA/9JLg=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; 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:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=4nUpYTI4YzQUWe3MX/DeuqIdjPgTHj7mksBWnabO8pk=; b=JzakT+xOiMdL/kbtBMgWRy45fj zOY/e6G8/1f7qxOIlytmLbPQcWP2fssfbYVUEf9Z5LlVPV68Ebj9cKaQFJTMfPlMV9qLo2tKXPAhH YHl5RrWFZWMlsDS4QnKmjV+Fj30IFoksK88jJ0mUCWe57GcQYSHeY9Qs8JCGK63RM4qE=; Received: from casper.infradead.org ([90.155.50.34]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.94.2) id 1nyZw5-0000Ow-0d; Tue, 07 Jun 2022 14:12:02 +0000 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=4nUpYTI4YzQUWe3MX/DeuqIdjPgTHj7mksBWnabO8pk=; b=IoritkaL90aqbR+RUHZKoSo8fb np1ux4ttns5tYj2sJk/FAj12Ak/CQ/wW4eIuwXN5ulK6rhUSeL7wfME8a6K9gYUgIYgqg08BNe9+I tus3kQ04SmPJZl9V4GH+E2xTibe280AETqIE3sbtSug/TUXDR0128c42jRa/+qeI8q7uri0dQOk1f wWHM11+pgzBreVL8bkL3da/JDGIf99g2HUm8tnTrzT4cPM9I17c3dxlon1CkQMKJOgWEf9FbWmKJ9 h7TOtnv+jsL8ABFyKBR86bb03b2ZVDj0NIek4XcowncLGE0YjVino+xsZhqucJvOU+7lO9abDpL7s BM8iPWpg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nyZvo-00BhC6-Sq; Tue, 07 Jun 2022 14:11:40 +0000 Date: Tue, 7 Jun 2022 15:11:40 +0100 From: Matthew Wilcox To: Brian Foster Message-ID: References: <20220606204050.2625949-1-willy@infradead.org> <20220606204050.2625949-6-willy@infradead.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Headers-End: 1nyZw5-0000Ow-0d Subject: Re: [f2fs-dev] [PATCH 05/20] mm/migrate: Convert expected_page_refs() to folio_expected_refs() X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aio@kvack.org, linux-nfs@vger.kernel.org, cluster-devel@redhat.com, linux-ntfs-dev@lists.sourceforge.net, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-mtd@lists.infradead.org, ocfs2-devel@oss.oracle.com, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-xfs@vger.kernel.org, linux-btrfs@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On Tue, Jun 07, 2022 at 09:41:57AM -0400, Brian Foster wrote: > On Mon, Jun 06, 2022 at 09:40:35PM +0100, Matthew Wilcox (Oracle) wrote: > > -static int expected_page_refs(struct address_space *mapping, struct page *page) > > +static int folio_expected_refs(struct address_space *mapping, > > + struct folio *folio) > > { > > - int expected_count = 1; > > + int refs = 1; > > + if (!mapping) > > + return refs; > > > > - if (mapping) > > - expected_count += compound_nr(page) + page_has_private(page); > > - return expected_count; > > + refs += folio_nr_pages(folio); > > + if (folio_get_private(folio)) > > + refs++; > > Why not folio_has_private() (as seems to be used for later > page_has_private() conversions) here? We have a horrid confusion that I'm trying to clean up stealthily without anyone noticing. I would have gotten away with it too if it weren't for you pesky kids. #define PAGE_FLAGS_PRIVATE \ (1UL << PG_private | 1UL << PG_private_2) static inline int page_has_private(struct page *page) { return !!(page->flags & PAGE_FLAGS_PRIVATE); } So what this function is saying is that there is one extra refcount expected on the struct page if PG_private _or_ PG_private_2 is set. How are filesystems expected to manage their page's refcount with this rule? Increment the refcount when setting PG_private unless PG_private_2 is already set? Decrement the refcount when clearing PG_private_2 unless PG_private is set? This is garbage. IMO, PG_private_2 should have no bearing on the page's refcount. Only btrfs and the netfs's use private_2 and neither of them do anything to the refcount when setting/clearing it. So that's what I'm implementing here. > > + > > + return refs;; > > Nit: extra ; Oh, that's where it went ;-) I had a compile error due to a missing semicolon at some point, and thought it was just a typo ... _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B1B2CC43334 for ; Tue, 7 Jun 2022 14:12:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YSU4FGN9vQ7Cp1PTlJtN4J4rGCgb6e81shk1DSWCDQ0=; b=k0TEo+2fpUAeke 2So4lomb9pwwqL2xzSvrCoe3JV346TMZDU1rU3T2fRF0c1IRy5ihfPLIm+RcXZ0GvkJnwot0xXWR/ JF1oDI9tLw2OCcWBFDdfMIx7TQeqgmadeaW+imiMXzn3PmHTexx/XXbi1ih077n2qhwuBLb3m0TGn 3HNJeC40z+Z3oNc5aQL0OyCk6TwKIZQeKYHa9NSjrYYzDJ/NSZ8+k9EeOUXxQauWMY2s3lvm5WIHg 2LFjAGof83KL9QJk1EArnuQolLFb7Rkd2jdv7A+AY+CYlx6RbPBNWQfcg9TDhPgORT9Rkey6xTWu7 bXd4vU9qD8WzepODETuw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nyZwH-007yA7-IM; Tue, 07 Jun 2022 14:12:09 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nyZvu-007xxK-Cs for linux-mtd@bombadil.infradead.org; Tue, 07 Jun 2022 14:11:46 +0000 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=4nUpYTI4YzQUWe3MX/DeuqIdjPgTHj7mksBWnabO8pk=; b=IoritkaL90aqbR+RUHZKoSo8fb np1ux4ttns5tYj2sJk/FAj12Ak/CQ/wW4eIuwXN5ulK6rhUSeL7wfME8a6K9gYUgIYgqg08BNe9+I tus3kQ04SmPJZl9V4GH+E2xTibe280AETqIE3sbtSug/TUXDR0128c42jRa/+qeI8q7uri0dQOk1f wWHM11+pgzBreVL8bkL3da/JDGIf99g2HUm8tnTrzT4cPM9I17c3dxlon1CkQMKJOgWEf9FbWmKJ9 h7TOtnv+jsL8ABFyKBR86bb03b2ZVDj0NIek4XcowncLGE0YjVino+xsZhqucJvOU+7lO9abDpL7s BM8iPWpg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nyZvo-00BhC6-Sq; Tue, 07 Jun 2022 14:11:40 +0000 Date: Tue, 7 Jun 2022 15:11:40 +0100 From: Matthew Wilcox To: Brian Foster Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-aio@kvack.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, linux-xfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-ntfs-dev@lists.sourceforge.net, ocfs2-devel@oss.oracle.com, linux-mtd@lists.infradead.org, virtualization@lists.linux-foundation.org Subject: Re: [PATCH 05/20] mm/migrate: Convert expected_page_refs() to folio_expected_refs() Message-ID: References: <20220606204050.2625949-1-willy@infradead.org> <20220606204050.2625949-6-willy@infradead.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-mtd" Errors-To: linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org On Tue, Jun 07, 2022 at 09:41:57AM -0400, Brian Foster wrote: > On Mon, Jun 06, 2022 at 09:40:35PM +0100, Matthew Wilcox (Oracle) wrote: > > -static int expected_page_refs(struct address_space *mapping, struct page *page) > > +static int folio_expected_refs(struct address_space *mapping, > > + struct folio *folio) > > { > > - int expected_count = 1; > > + int refs = 1; > > + if (!mapping) > > + return refs; > > > > - if (mapping) > > - expected_count += compound_nr(page) + page_has_private(page); > > - return expected_count; > > + refs += folio_nr_pages(folio); > > + if (folio_get_private(folio)) > > + refs++; > > Why not folio_has_private() (as seems to be used for later > page_has_private() conversions) here? We have a horrid confusion that I'm trying to clean up stealthily without anyone noticing. I would have gotten away with it too if it weren't for you pesky kids. #define PAGE_FLAGS_PRIVATE \ (1UL << PG_private | 1UL << PG_private_2) static inline int page_has_private(struct page *page) { return !!(page->flags & PAGE_FLAGS_PRIVATE); } So what this function is saying is that there is one extra refcount expected on the struct page if PG_private _or_ PG_private_2 is set. How are filesystems expected to manage their page's refcount with this rule? Increment the refcount when setting PG_private unless PG_private_2 is already set? Decrement the refcount when clearing PG_private_2 unless PG_private is set? This is garbage. IMO, PG_private_2 should have no bearing on the page's refcount. Only btrfs and the netfs's use private_2 and neither of them do anything to the refcount when setting/clearing it. So that's what I'm implementing here. > > + > > + return refs;; > > Nit: extra ; Oh, that's where it went ;-) I had a compile error due to a missing semicolon at some point, and thought it was just a typo ... ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ 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 smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9B63FC433EF for ; Tue, 7 Jun 2022 14:12:13 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 546F26100D; Tue, 7 Jun 2022 14:12:13 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sYSM24eHETZd; Tue, 7 Jun 2022 14:12:11 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id 03C7260D6E; Tue, 7 Jun 2022 14:12:11 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id CA998C0032; Tue, 7 Jun 2022 14:12:10 +0000 (UTC) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 57A09C002D for ; Tue, 7 Jun 2022 14:12:08 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 3FBF960D6E for ; Tue, 7 Jun 2022 14:12:08 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GcgenUKhMc_3 for ; Tue, 7 Jun 2022 14:12:04 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by smtp3.osuosl.org (Postfix) with ESMTPS id 227B760D61 for ; Tue, 7 Jun 2022 14:12:04 +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=4nUpYTI4YzQUWe3MX/DeuqIdjPgTHj7mksBWnabO8pk=; b=IoritkaL90aqbR+RUHZKoSo8fb np1ux4ttns5tYj2sJk/FAj12Ak/CQ/wW4eIuwXN5ulK6rhUSeL7wfME8a6K9gYUgIYgqg08BNe9+I tus3kQ04SmPJZl9V4GH+E2xTibe280AETqIE3sbtSug/TUXDR0128c42jRa/+qeI8q7uri0dQOk1f wWHM11+pgzBreVL8bkL3da/JDGIf99g2HUm8tnTrzT4cPM9I17c3dxlon1CkQMKJOgWEf9FbWmKJ9 h7TOtnv+jsL8ABFyKBR86bb03b2ZVDj0NIek4XcowncLGE0YjVino+xsZhqucJvOU+7lO9abDpL7s BM8iPWpg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nyZvo-00BhC6-Sq; Tue, 07 Jun 2022 14:11:40 +0000 Date: Tue, 7 Jun 2022 15:11:40 +0100 From: Matthew Wilcox To: Brian Foster Subject: Re: [PATCH 05/20] mm/migrate: Convert expected_page_refs() to folio_expected_refs() Message-ID: References: <20220606204050.2625949-1-willy@infradead.org> <20220606204050.2625949-6-willy@infradead.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Cc: linux-aio@kvack.org, linux-nfs@vger.kernel.org, cluster-devel@redhat.com, linux-ntfs-dev@lists.sourceforge.net, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-mtd@lists.infradead.org, ocfs2-devel@oss.oracle.com, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-xfs@vger.kernel.org, linux-btrfs@vger.kernel.org X-BeenThere: virtualization@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux virtualization List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: virtualization-bounces@lists.linux-foundation.org Sender: "Virtualization" On Tue, Jun 07, 2022 at 09:41:57AM -0400, Brian Foster wrote: > On Mon, Jun 06, 2022 at 09:40:35PM +0100, Matthew Wilcox (Oracle) wrote: > > -static int expected_page_refs(struct address_space *mapping, struct page *page) > > +static int folio_expected_refs(struct address_space *mapping, > > + struct folio *folio) > > { > > - int expected_count = 1; > > + int refs = 1; > > + if (!mapping) > > + return refs; > > > > - if (mapping) > > - expected_count += compound_nr(page) + page_has_private(page); > > - return expected_count; > > + refs += folio_nr_pages(folio); > > + if (folio_get_private(folio)) > > + refs++; > > Why not folio_has_private() (as seems to be used for later > page_has_private() conversions) here? We have a horrid confusion that I'm trying to clean up stealthily without anyone noticing. I would have gotten away with it too if it weren't for you pesky kids. #define PAGE_FLAGS_PRIVATE \ (1UL << PG_private | 1UL << PG_private_2) static inline int page_has_private(struct page *page) { return !!(page->flags & PAGE_FLAGS_PRIVATE); } So what this function is saying is that there is one extra refcount expected on the struct page if PG_private _or_ PG_private_2 is set. How are filesystems expected to manage their page's refcount with this rule? Increment the refcount when setting PG_private unless PG_private_2 is already set? Decrement the refcount when clearing PG_private_2 unless PG_private is set? This is garbage. IMO, PG_private_2 should have no bearing on the page's refcount. Only btrfs and the netfs's use private_2 and neither of them do anything to the refcount when setting/clearing it. So that's what I'm implementing here. > > + > > + return refs;; > > Nit: extra ; Oh, that's where it went ;-) I had a compile error due to a missing semicolon at some point, and thought it was just a typo ... _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization 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 aib29ajc255.phx1.oracleemaildelivery.com (aib29ajc255.phx1.oracleemaildelivery.com [192.29.103.255]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 272EEC43334 for ; Tue, 7 Jun 2022 14:19:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=wuDj1JIXQvMWZMvMjae4L4kIXNSmJoF1dP9BKj1/nYQ=; b=HFWDLIm/KWYZLXMsoJircMumzAldt+iwYJhp9Je/WB6vgsBvLYUZ76uE4laboNlPFKUCsk/d+INk 9UkmKGkcrz2KzePjDK05pkAIUaDyHRW4S0UQI1M4RyKrL10HNE+5QzTSYpMCfvr2CDPg37sRi3PQ kBYjwdpT8dgZU81a3BS4d8xfzA/89KihBkVEL22S4g9+BWbSYX5puvB6ZY4yBB9qpYoNXGNkFqlq C1E/lLhQ+iYoPsa75NiDXa97lwCBp2UVfeqmfu28Lz0b5UqZIDfTeZbusVwyRPftDdR1dkFNrKT5 dCJbg1/dvCXmtIyevnWJnZR+PHiI0tAnGhpeHw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=wuDj1JIXQvMWZMvMjae4L4kIXNSmJoF1dP9BKj1/nYQ=; b=n7dETjq4Mmk7aVoV6tAlTiZ6o+bM9k2cMF+AouBUOQzG79iSaPtFecgeoM6Ep7BdKy37qMwmswBU qk2k0LE50KECnD5sc1liSNisHIV6Ukq81H5moDqoXxLtZ+GRustmVHprMuc2nz5JlW81ZfarP1zd N0TbTdvbs3GemmXfrsnXXBVV0gWPTikP+MZzDoFEVYSiJKdri5hEDlWINLrgNNHBD4syKqgfCtKf fVKEJj6mcgh7tGfCQU9mrbesEvfTYFg3BFOB3OPGKMJUCqsMfw0VaLGlyx2kIgDV64Ma7Ir3ET+a 8HkLBR4aXtk+U9N7q32R6kEnWJHeulUr75+pfA== Received: by omta-ad3-fd3-302-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220517 64bit (built May 17 2022)) with ESMTPS id <0RD4000WZ2H3WS70@omta-ad3-fd3-302-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Tue, 07 Jun 2022 14:19:51 +0000 (GMT) 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=4nUpYTI4YzQUWe3MX/DeuqIdjPgTHj7mksBWnabO8pk=; b=IoritkaL90aqbR+RUHZKoSo8fb np1ux4ttns5tYj2sJk/FAj12Ak/CQ/wW4eIuwXN5ulK6rhUSeL7wfME8a6K9gYUgIYgqg08BNe9+I tus3kQ04SmPJZl9V4GH+E2xTibe280AETqIE3sbtSug/TUXDR0128c42jRa/+qeI8q7uri0dQOk1f wWHM11+pgzBreVL8bkL3da/JDGIf99g2HUm8tnTrzT4cPM9I17c3dxlon1CkQMKJOgWEf9FbWmKJ9 h7TOtnv+jsL8ABFyKBR86bb03b2ZVDj0NIek4XcowncLGE0YjVino+xsZhqucJvOU+7lO9abDpL7s BM8iPWpg==; Date: Tue, 7 Jun 2022 15:11:40 +0100 To: Brian Foster Message-id: References: <20220606204050.2625949-1-willy@infradead.org> <20220606204050.2625949-6-willy@infradead.org> MIME-version: 1.0 Content-disposition: inline In-reply-to: X-Source-IP: 90.155.50.34 X-Proofpoint-Virus-Version: vendor=nai engine=6400 definitions=10371 signatures=594849 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 spamscore=0 malwarescore=0 bulkscore=0 adultscore=0 mlxscore=0 clxscore=148 lowpriorityscore=0 phishscore=0 impostorscore=0 mlxlogscore=828 suspectscore=0 priorityscore=176 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206070058 domainage_hfrom=8379 Cc: linux-aio@kvack.org, linux-nfs@vger.kernel.org, cluster-devel@redhat.com, linux-ntfs-dev@lists.sourceforge.net, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-mtd@lists.infradead.org, ocfs2-devel@oss.oracle.com, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-xfs@vger.kernel.org, linux-btrfs@vger.kernel.org Subject: Re: [Ocfs2-devel] [PATCH 05/20] mm/migrate: Convert expected_page_refs() to folio_expected_refs() X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Matthew Wilcox via Ocfs2-devel Reply-to: Matthew Wilcox Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com X-ServerName: casper.infradead.org X-Proofpoint-SPF-Result: None X-Spam: Clean X-Proofpoint-ORIG-GUID: oE8jFuOoaFidihpfkY2es2TouFLZcdJ3 X-Proofpoint-GUID: oE8jFuOoaFidihpfkY2es2TouFLZcdJ3 Reporting-Meta: AAEMoQroQueGomhiQHHGZ6KhIa6pGbK3ERdS85VG05rpAaz+Psp18+t+r04XY4QL BpoK9SUQaMM/tuUaFFr4EriSAZtfBPjyopRWqLx98p8tukOAdxE73Iv9/oW/t4mn DimbNERLXuyA/P7Or00WS2MWLB6WLfU3SPlObE4/8ajfW1kFpXt4VbYx4BOYyxHE FpVKf3CylZd0wrRlC8oaApisuTE6cH0ZlSkSOHsJJs8T19DLzQga8TWtw1lvyrsC fJOmwqLNTI4Q4KiWI/Rtc9ztfZiySzoda6NFW5aBLDziZQBgd3GPAVlTXR8VC5fv z8n2GPYgFLPEyec1YJiR2pOwmmT7P4loiuDz7i68lvhZGFPPRMeaGZ3X5JWI6xvW X2vnehIRG3a/WZ8nvLAp15/1Hc+n6+3ghCOKO/CWPpK9SDCRft2ic9W/c+w7KgLL iuet64r0yhTrRSqThVCSNPsBD+RecpAL5t5ViK5I5cEyW8Qu1Ito9a9tVHlhUK1Q WwSpn2eHSuNx3zZpCxJN2VuZ4afH9f30fTHJKRw3o/G2 On Tue, Jun 07, 2022 at 09:41:57AM -0400, Brian Foster wrote: > On Mon, Jun 06, 2022 at 09:40:35PM +0100, Matthew Wilcox (Oracle) wrote: > > -static int expected_page_refs(struct address_space *mapping, struct page *page) > > +static int folio_expected_refs(struct address_space *mapping, > > + struct folio *folio) > > { > > - int expected_count = 1; > > + int refs = 1; > > + if (!mapping) > > + return refs; > > > > - if (mapping) > > - expected_count += compound_nr(page) + page_has_private(page); > > - return expected_count; > > + refs += folio_nr_pages(folio); > > + if (folio_get_private(folio)) > > + refs++; > > Why not folio_has_private() (as seems to be used for later > page_has_private() conversions) here? We have a horrid confusion that I'm trying to clean up stealthily without anyone noticing. I would have gotten away with it too if it weren't for you pesky kids. #define PAGE_FLAGS_PRIVATE \ (1UL << PG_private | 1UL << PG_private_2) static inline int page_has_private(struct page *page) { return !!(page->flags & PAGE_FLAGS_PRIVATE); } So what this function is saying is that there is one extra refcount expected on the struct page if PG_private _or_ PG_private_2 is set. How are filesystems expected to manage their page's refcount with this rule? Increment the refcount when setting PG_private unless PG_private_2 is already set? Decrement the refcount when clearing PG_private_2 unless PG_private is set? This is garbage. IMO, PG_private_2 should have no bearing on the page's refcount. Only btrfs and the netfs's use private_2 and neither of them do anything to the refcount when setting/clearing it. So that's what I'm implementing here. > > + > > + return refs;; > > Nit: extra ; Oh, that's where it went ;-) I had a compile error due to a missing semicolon at some point, and thought it was just a typo ... _______________________________________________ Ocfs2-devel mailing list Ocfs2-devel@oss.oracle.com https://oss.oracle.com/mailman/listinfo/ocfs2-devel From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthew Wilcox Date: Tue, 7 Jun 2022 15:11:40 +0100 Subject: [Cluster-devel] [PATCH 05/20] mm/migrate: Convert expected_page_refs() to folio_expected_refs() In-Reply-To: References: <20220606204050.2625949-1-willy@infradead.org> <20220606204050.2625949-6-willy@infradead.org> Message-ID: List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Tue, Jun 07, 2022 at 09:41:57AM -0400, Brian Foster wrote: > On Mon, Jun 06, 2022 at 09:40:35PM +0100, Matthew Wilcox (Oracle) wrote: > > -static int expected_page_refs(struct address_space *mapping, struct page *page) > > +static int folio_expected_refs(struct address_space *mapping, > > + struct folio *folio) > > { > > - int expected_count = 1; > > + int refs = 1; > > + if (!mapping) > > + return refs; > > > > - if (mapping) > > - expected_count += compound_nr(page) + page_has_private(page); > > - return expected_count; > > + refs += folio_nr_pages(folio); > > + if (folio_get_private(folio)) > > + refs++; > > Why not folio_has_private() (as seems to be used for later > page_has_private() conversions) here? We have a horrid confusion that I'm trying to clean up stealthily without anyone noticing. I would have gotten away with it too if it weren't for you pesky kids. #define PAGE_FLAGS_PRIVATE \ (1UL << PG_private | 1UL << PG_private_2) static inline int page_has_private(struct page *page) { return !!(page->flags & PAGE_FLAGS_PRIVATE); } So what this function is saying is that there is one extra refcount expected on the struct page if PG_private _or_ PG_private_2 is set. How are filesystems expected to manage their page's refcount with this rule? Increment the refcount when setting PG_private unless PG_private_2 is already set? Decrement the refcount when clearing PG_private_2 unless PG_private is set? This is garbage. IMO, PG_private_2 should have no bearing on the page's refcount. Only btrfs and the netfs's use private_2 and neither of them do anything to the refcount when setting/clearing it. So that's what I'm implementing here. > > + > > + return refs;; > > Nit: extra ; Oh, that's where it went ;-) I had a compile error due to a missing semicolon at some point, and thought it was just a typo ...