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 D3E60C433EF for ; Fri, 10 Jun 2022 10:17:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348122AbiFJKRq (ORCPT ); Fri, 10 Jun 2022 06:17:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344973AbiFJKRp (ORCPT ); Fri, 10 Jun 2022 06:17:45 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E743D11822 for ; Fri, 10 Jun 2022 03:17:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654856257; 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=Ekvjf5YPr7Sjtvmnh5pMqvNXgm63w4q321GSzdMpiws=; b=R422DQNibOldKWlgmARWqJj/jnBflxYGCJ34dPCeAmqGiPs+R8ZIsaALOJs26KSF7i5shV 8c4iGAzs36ZifLrsLUUvTTYBlEKMNjAuWAXnLpu9z/IiIszg0EPqkub8BmaIO/xtiimXrM E/8YUE26JcZOBvyiHFzLj8IJXPCzQcQ= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-278-HJ0RadLfMp6nlLl1eyZ04g-1; Fri, 10 Jun 2022 06:17:36 -0400 X-MC-Unique: HJ0RadLfMp6nlLl1eyZ04g-1 Received: by mail-wr1-f69.google.com with SMTP id e15-20020adfa44f000000b00219ebf65301so124171wra.4 for ; Fri, 10 Jun 2022 03:17:36 -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=Ekvjf5YPr7Sjtvmnh5pMqvNXgm63w4q321GSzdMpiws=; b=VcPbs4C6zW12bzfBL+imCZaGXxCvGaTuiXSRtCfTlWqsLNOs3HzEMf7FbcDOPtqKDw QNOM455shPbyveEgF5DsJXvee9s3XYT/Zlm4Fw95VYzbTKACnSN77/zLL8vPfgARL2Og TGQOckB6UvXhauCGOxT0qCrYXSPNcA0rLB9i30te1yPFTAnWjrcn9gg368kbCgP4g3Bf czcJnplW/2lWjeI8xKjejbgjtMNkLjd20BJhzaMzvkuLKJgKEoMAlqF+rZoOwklp6V1O 35D+R3sUYwaHqaiy/63JrlhLx+sbgo05OBGfs7UVsAAA3OWRodJ2d9oDwD5tqg49bAW7 cOag== X-Gm-Message-State: AOAM532yUEVI+Sv/nuNXGfdGNReaU9fzNgHKbMp8XMpZgckev0FrEMH/ mzit526nApoXyP+EYXW08ccPSK5NjGfCWgY7dhoTF/lgYEzDiAVwn/DrdLbAb4q8JKfxwcxrCXE PN9JDz6lZFDSpWn5cg0xzgw== X-Received: by 2002:a05:6000:91:b0:217:8efc:f572 with SMTP id m17-20020a056000009100b002178efcf572mr29122722wrx.186.1654856255658; Fri, 10 Jun 2022 03:17:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMoCknlizO69Nl0wuEIzBALIZP/2+KDolU3ne+3dmHgzec6LJk/2XhtTIsrJ35XnXVn7hgfw== X-Received: by 2002:a05:6000:91:b0:217:8efc:f572 with SMTP id m17-20020a056000009100b002178efcf572mr29122693wrx.186.1654856255339; Fri, 10 Jun 2022 03:17:35 -0700 (PDT) Received: from ?IPV6:2003:cb:c705:1f00:4727:6420:1d4d:ca23? (p200300cbc7051f00472764201d4dca23.dip0.t-ipconnect.de. [2003:cb:c705:1f00:4727:6420:1d4d:ca23]) by smtp.gmail.com with ESMTPSA id m17-20020a05600c4f5100b0039c4f53c4fdsm3105741wmq.45.2022.06.10.03.17.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 10 Jun 2022 03:17:34 -0700 (PDT) Message-ID: Date: Fri, 10 Jun 2022 12:17:33 +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 Content-Language: en-US To: Matthew Wilcox 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, Christoph Hellwig References: <20220608150249.3033815-1-willy@infradead.org> <20220608150249.3033815-4-willy@infradead.org> From: David Hildenbrand Organization: Red Hat In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On 09.06.22 16:35, Matthew Wilcox wrote: > On Thu, Jun 09, 2022 at 02:50:20PM +0200, David Hildenbrand wrote: >> On 08.06.22 17:02, Matthew Wilcox (Oracle) wrote: >>> 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? > > Argh, right, I completely forgot I needed to update the documentation in > that patch. > >>> +++ 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) > > Oh ... actually, this is just documenting the driver side of things. > I don't really like how it's written. Here, have some rewritten > documentation (which is now part of the previous patch): > LGTM, thanks. -- Thanks, David / dhildenb