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 4963CC43334 for ; Thu, 9 Jun 2022 12:50:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B58668D0014; Thu, 9 Jun 2022 08:50:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B02F28D0015; Thu, 9 Jun 2022 08:50:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 92E748D0014; Thu, 9 Jun 2022 08:50:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 83BE48D0006 for ; Thu, 9 Jun 2022 08:50:25 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 65FC761178 for ; Thu, 9 Jun 2022 12:50:25 +0000 (UTC) X-FDA: 79558680810.26.BE8296A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf25.hostedemail.com (Postfix) with ESMTP id C5D7AA0080 for ; Thu, 9 Jun 2022 12:50:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654779024; 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=Rl3YETfEkiQD6P2TsO5Q+i5VUelvKEU17hm+QH6XVlbmrAJ7L3t+EKioFBQ5V87wSzaX2K P9vJkXK6o5F0e3B84HtDADUGHQ9+35O3pCsp1XpTsGXgoMQ02jOISrg18N3vhiAfq/tIlh UX1g0Zx+CYCEYOq3jeqHpE2JcOdz03I= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-675-d9QygLBQO_COvZHSllvPng-1; Thu, 09 Jun 2022 08:50:23 -0400 X-MC-Unique: d9QygLBQO_COvZHSllvPng-1 Received: by mail-wm1-f70.google.com with SMTP id m23-20020a05600c3b1700b0039c6e3c169aso647777wms.2 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=pjQGKCnRlDtzl4nPgpSxtbG1R15tpqlft4svFeUkSVyiSC1FBk/KpVM18ra4Q6zhBn 5I54trQtPqjtbV3FHIHgwGNgxfiZ3vIwObVafkYgKxMu6fdV/FkmTQv7Lv1BKSN7Cfjv imV64seEeMjs39GLjcyg8xxd+q+lIiPnawz0Oz4LYPgosLs2VDwUbA6LECOare093AGZ PgbmXnVyTYi6JbBMdA+dFw8JCYgxrFyZ+8gyXYCVIIZ2SVvLEZcwowkA7emjPI/jhnAQ H0YNOtbZ+sGCfZ6KbDSl0isgqImjwrmhEZzFfwC1q7ju+AW1jwg5ZhCgbUVtPUKHSOvZ YhnQ== X-Gm-Message-State: AOAM530MirPxtH6Odxw9xTiAcl3PmJbtS5JmkAib259kx2Q4Lvnyar4C 6WgAL/cQa2tx1LAVj1/fZbrCWmnaWLF5jgOPhQWRKmF2X2RYYxhnAsabkMBH9bBGTvAibJEZCHE UeOJCjVYXvCU= X-Received: by 2002:a1c:4c0d:0:b0:39c:5233:1873 with SMTP id z13-20020a1c4c0d000000b0039c52331873mr3299363wmf.28.1654779022169; 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> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1654779025; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=jSyVt04wqMoyKuQwGc4zbS9w9C6qNO7mTJG8w/5DiLs=; b=M97mv074aqJATbUZz7uDpT6FVt7sc46ORDC01I0QbwWkyYvcLq/bZssKheMjumkRtpg5eH vxg9fQicPpjgwMFNi8jR1IRPuvXqcZETvyIJf4MCeIx79sCV0wNrTp2rWeZT6BKc2aeeDu pLQ2u9PrY41uAWJnZzLJE0B/2TqPnds= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1654779025; a=rsa-sha256; cv=none; b=N0KNU8dAL+KuWcR0swlw5AXk7Qw77DjSalB+nXYnNXSv/XcWkps66KLsGGntJmLOJ0rQJF r53E+pZhqM8CstDz//QTsoPWSmE9P84dErFSO/Uhyiv7iJoEA3n+WiOlRYW8nWWgEyi6pk BIE3jgmsffNwDgxtikhhqMbFa7vhK0I= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Rl3YETfE; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf25.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com X-Rspamd-Server: rspam11 X-Rspam-User: Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Rl3YETfE; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf25.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com X-Stat-Signature: okug1bsee5ghxsm4wa31gz7dw7tazhhk X-Rspamd-Queue-Id: C5D7AA0080 X-HE-Tag: 1654779024-968155 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 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