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 6D2E8C43334 for ; Thu, 9 Jun 2022 12:51:02 +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:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=X3FGtcpjknpSApUEkwWyaVcgTh0vtsm5wbVRknqEK/4=; b=Ec5J053Yy7uEhm ET4lXYxJ6uMWN+Vh3P4AUGjeRBG2bB0PUoMhTkqhSnQY4pyS2g/yCCFeCCNnUzSwVPIpK3lOY0ubL rUQsGAeRb3i3ECBYb1UUnWBwIHuwzshPAqWpxFgHXbehqZ+dE1iAeHgouOLMdMevq+5WoB4355Xtn LSXuP/ErNonq6fmjcvXKFQKQWMYrVKScKtZa1lJhn/T/ETK6z0XOrsndPIhwcsrWLpuUIpIs+Dj1A swp9wDFW7cSHxviFgzFnenx0xn8UvxTAVIoh7CmIlg5MCixhhvuc8nrrvarUBzW3zo8Azc4zhaSdf O18PiJLG8aSLsXa/3HZQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzHcQ-001trQ-AH; Thu, 09 Jun 2022 12:50:34 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzHcJ-001tmj-3q for linux-mtd@lists.infradead.org; Thu, 09 Jun 2022 12:50:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654779026; h=from:from: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; bh=jSyVt04wqMoyKuQwGc4zbS9w9C6qNO7mTJG8w/5DiLs=; b=QG9LNwlLX2+zP2FFRisOkQ8oURnxcBY1TVruweSW1Dq+W8cWpiE0sZkktGYQIBMpuTLsTJ 0M4JZKqwXhsn6G+s9W2m3H5/DIAFpBzDzKIy6i9LNm/Nzc1UsF2YlPG6hLiDnol8j/M/qh RvmiyYfBinu7g+c2Hrb2ejzE9aqHdTM= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-526-eAE20LUeMjSqdyRE0G9eRA-1; Thu, 09 Jun 2022 08:50:23 -0400 X-MC-Unique: eAE20LUeMjSqdyRE0G9eRA-1 Received: by mail-wm1-f71.google.com with SMTP id bi22-20020a05600c3d9600b0039c4144992cso7469324wmb.5 for ; Thu, 09 Jun 2022 05:50:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=jSyVt04wqMoyKuQwGc4zbS9w9C6qNO7mTJG8w/5DiLs=; b=L2cOV9+vA00GSTw85CkOd29qdwmG7bbnpGdAYwwZARWurcatDbwir2VGs0FOdDooXK Nu3a6sJYXi4ulacR1JlJTE1tenAK9TneIaPtdG0mdq+9sLBdUrbTsJZSGfmBGozwsle+ Df7v2JL88ggkV4TgFEKdgJqRIakhzUBrAHprvzGIKL5H4pAe4PcjCBO1WKgs606YJCj+ tqFD73y7Lyp1JDql9cBmIjp1M0uwE+iEdKfMv8vJ5ymHVS1XLkLR7TQEOWWpK64ivj5G 2iZawdXijEm7ou1z98gjK+gkQ+iWp1R6X3C+0I2ptNAkhBbXoa7rNL7fhQCxr+rvLdTY gvFA== X-Gm-Message-State: AOAM532TG8JVxeMp/ItZZ8OL85eee7S9BFmUPj/cQFTBxya+IrM+W0Mn GuiEGNXaIL6aL3H4F14a430m495k0knaiaS/eRGHeEcBt6ZDPMD3E4fjeCdvGxSM37Bphv9DNZV cLzHjcTWA0M8H9yUdo5WM4B3YHg== X-Received: by 2002:a1c:4c0d:0:b0:39c:5233:1873 with SMTP id z13-20020a1c4c0d000000b0039c52331873mr3299346wmf.28.1654779022064; Thu, 09 Jun 2022 05:50:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJlGErsfVOd4GnScqiilTH958FLxgjsObuI+18makmIYSKefVpu0HdsVXKQhmSAU7kjNobOQ== X-Received: by 2002:a1c:4c0d:0:b0:39c:5233:1873 with SMTP id z13-20020a1c4c0d000000b0039c52331873mr3299322wmf.28.1654779021707; Thu, 09 Jun 2022 05:50:21 -0700 (PDT) Received: from ?IPV6:2a09:80c0:192:0:20af:34be:985b:b6c8? ([2a09:80c0:192:0:20af:34be:985b:b6c8]) by smtp.gmail.com with ESMTPSA id j8-20020a056000124800b002185d79dc7fsm5672822wrx.75.2022.06.09.05.50.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Jun 2022 05:50:21 -0700 (PDT) Message-ID: Date: Thu, 9 Jun 2022 14:50:20 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v2 03/19] fs: Add aops->migrate_folio To: "Matthew Wilcox (Oracle)" , linux-fsdevel@vger.kernel.org Cc: 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, Christoph Hellwig References: <20220608150249.3033815-1-willy@infradead.org> <20220608150249.3033815-4-willy@infradead.org> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20220608150249.3033815-4-willy@infradead.org> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220609_055027_296074_ECF29BAE X-CRM114-Status: GOOD ( 31.67 ) 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 08.06.22 17:02, Matthew Wilcox (Oracle) wrote: > Provide a folio-based replacement for aops->migratepage. Update the > documentation to document migrate_folio instead of migratepage. > > Signed-off-by: Matthew Wilcox (Oracle) > Reviewed-by: Christoph Hellwig > --- > Documentation/filesystems/locking.rst | 5 ++-- > Documentation/filesystems/vfs.rst | 13 ++++++----- > Documentation/vm/page_migration.rst | 33 ++++++++++++++------------- > include/linux/fs.h | 4 +++- > mm/compaction.c | 4 +++- > mm/migrate.c | 11 +++++---- > 6 files changed, 40 insertions(+), 30 deletions(-) > > diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst > index c0fe711f14d3..3d28b23676bd 100644 > --- a/Documentation/filesystems/locking.rst > +++ b/Documentation/filesystems/locking.rst > @@ -253,7 +253,8 @@ prototypes:: > void (*free_folio)(struct folio *); > int (*direct_IO)(struct kiocb *, struct iov_iter *iter); > bool (*isolate_page) (struct page *, isolate_mode_t); > - int (*migratepage)(struct address_space *, struct page *, struct page *); > + int (*migrate_folio)(struct address_space *, struct folio *dst, > + struct folio *src, enum migrate_mode); > void (*putback_page) (struct page *); isolate_page/putback_page are leftovers from the previous patch, no? > int (*launder_folio)(struct folio *); > bool (*is_partially_uptodate)(struct folio *, size_t from, size_t count); > @@ -281,7 +282,7 @@ release_folio: yes > free_folio: yes > direct_IO: > isolate_page: yes > -migratepage: yes (both) > +migrate_folio: yes (both) > putback_page: yes Dito. > launder_folio: yes > is_partially_uptodate: yes > diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst > index a08c652467d7..3ae1b039b03f 100644 > --- a/Documentation/filesystems/vfs.rst > +++ b/Documentation/filesystems/vfs.rst > @@ -740,7 +740,8 @@ cache in your filesystem. The following members are defined: > /* isolate a page for migration */ > bool (*isolate_page) (struct page *, isolate_mode_t); > /* migrate the contents of a page to the specified target */ > - int (*migratepage) (struct page *, struct page *); > + int (*migrate_folio)(struct mapping *, struct folio *dst, > + struct folio *src, enum migrate_mode); > /* put migration-failed page back to right list */ > void (*putback_page) (struct page *); Dito. > int (*launder_folio) (struct folio *); > @@ -935,12 +936,12 @@ cache in your filesystem. The following members are defined: > is successfully isolated, VM marks the page as PG_isolated via > __SetPageIsolated. > > -``migrate_page`` > +``migrate_folio`` > This is used to compact the physical memory usage. If the VM > - wants to relocate a page (maybe off a memory card that is > - signalling imminent failure) it will pass a new page and an old > - page to this function. migrate_page should transfer any private > - data across and update any references that it has to the page. > + wants to relocate a folio (maybe from a memory device that is > + signalling imminent failure) it will pass a new folio and an old > + folio to this function. migrate_folio should transfer any private > + data across and update any references that it has to the folio. > > ``putback_page`` > Called by the VM when isolated page's migration fails. Dito. > diff --git a/Documentation/vm/page_migration.rst b/Documentation/vm/page_migration.rst > index 8c5cb8147e55..e0f73ddfabb1 100644 > --- a/Documentation/vm/page_migration.rst > +++ b/Documentation/vm/page_migration.rst > @@ -181,22 +181,23 @@ which are function pointers of struct address_space_operations. > Once page is successfully isolated, VM uses page.lru fields so driver > shouldn't expect to preserve values in those fields. > > -2. ``int (*migratepage) (struct address_space *mapping,`` > -| ``struct page *newpage, struct page *oldpage, enum migrate_mode);`` > - > - After isolation, VM calls migratepage() of driver with the isolated page. > - The function of migratepage() is to move the contents of the old page to the > - new page > - and set up fields of struct page newpage. Keep in mind that you should > - indicate to the VM the oldpage is no longer movable via __ClearPageMovable() > - under page_lock if you migrated the oldpage successfully and returned > - MIGRATEPAGE_SUCCESS. If driver cannot migrate the page at the moment, driver > - can return -EAGAIN. On -EAGAIN, VM will retry page migration in a short time > - because VM interprets -EAGAIN as "temporary migration failure". On returning > - any error except -EAGAIN, VM will give up the page migration without > - retrying. > - > - Driver shouldn't touch the page.lru field while in the migratepage() function. > +2. ``int (*migrate_folio) (struct address_space *mapping,`` > +| ``struct folio *dst, struct folio *src, enum migrate_mode);`` > + > + After isolation, VM calls the driver's migrate_folio() with the > + isolated folio. The purpose of migrate_folio() is to move the contents > + of the source folio to the destination folio and set up the fields > + of destination folio. Keep in mind that you should indicate to the > + VM the source folio is no longer movable via __ClearPageMovable() > + under folio if you migrated the source successfully and returned > + MIGRATEPAGE_SUCCESS. If driver cannot migrate the folio at the > + moment, driver can return -EAGAIN. On -EAGAIN, VM will retry folio > + migration in a short time because VM interprets -EAGAIN as "temporary > + migration failure". On returning any error except -EAGAIN, VM will > + give up the folio migration without retrying. > + > + Driver shouldn't touch the folio.lru field while in the migrate_folio() > + function. > > 3. ``void (*putback_page)(struct page *);`` Hmm, here it's a bit more complicated now, because we essentially have two paths: LRU+migrate_folio or !LRU+movable_ops (isolate/migrate/putback page) -- Thanks, David / dhildenb ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/