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 99848C433EF for ; Fri, 10 Jun 2022 10:17:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1ECB58D008C; Fri, 10 Jun 2022 06:17:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 19CBE8D0087; Fri, 10 Jun 2022 06:17:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 03C358D008C; Fri, 10 Jun 2022 06:17:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id EB21F8D0087 for ; Fri, 10 Jun 2022 06:17:40 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id BF7AC61038 for ; Fri, 10 Jun 2022 10:17:40 +0000 (UTC) X-FDA: 79561924680.29.02CCA79 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf24.hostedemail.com (Postfix) with ESMTP id 3B03618006A for ; Fri, 10 Jun 2022 10:17:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654856259; 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=aGxmOt/1L9vbMhO7+V2E3bHkrTuG1+Ol5P1Cfj4iH1O59uAqwGZymMD1R2E4Ktrh4Palpp 1/VDgMCp1MJCRVvaH6DDa7CHfa5tHwLMmJBAMAmugKZehMEleUm4atWO4BpsW3nYFHWDCZ 2HJIiZ02YJ7QNf6rnx3ZQ+CRovul8tw= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-561-OE_fzEEDN36-7rN-nokwhw-1; Fri, 10 Jun 2022 06:17:36 -0400 X-MC-Unique: OE_fzEEDN36-7rN-nokwhw-1 Received: by mail-wr1-f70.google.com with SMTP id y2-20020adff142000000b0021581245fa1so4935490wro.7 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=yottHT56J6vmy0ToyVczLrBRpRnyHfGOlG0pRtK70Hfaz0HGtWzU6y5DrAUu+APLP/ YMf1JXZImWcfWuUIjMZi1A12M5YCxxBCoVOGwIGxhbaXnx0XBFcspJNTg/FGw6ozVPUV Ikf/jYIevkYfnCKHq5ZCwlRw9Bso60ZcQs5SlD6ethAsdKn+c8GC8d98eEDWvcsk/LPT Q/6Y9odvJm49OOwPFqckzcXWCrYlgdtfTXzpfasoL3NiWVga3CSNWAgKeNH11J71VSIb yvcEt7xVxmcdck92rrhdxhfUg2a2ljaKnEX2pusg530thSmXv0J2JqAnNllRJyt6HCBW 0nZg== X-Gm-Message-State: AOAM530ZJi+2jDuu4Sk4owW71x5C0WXbQWxeCO+wvkhpmyxdQP8zgeo7 +EwAX3vnIokP4jTw6QJdHYlaAKmbuRpGviFpZ0bFx+S6PoyFOWgS8BfCRPByNhqTFacC3+YoMel 2gaTZdfV9qts= X-Received: by 2002:a05:6000:91:b0:217:8efc:f572 with SMTP id m17-20020a056000009100b002178efcf572mr29122743wrx.186.1654856255749; 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 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: 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=1654856260; 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=Ekvjf5YPr7Sjtvmnh5pMqvNXgm63w4q321GSzdMpiws=; b=nI2/uZo1uTaFrW92Z3vGVtq2cJX+K82IKxysao9s86otWwdN+24ZGhOL3MWOOl7+m1ln3y uZL+maPhp9e0iZFnm7I/M6BCxBgsaQnzQzEY5tNDeD6+mvCdGmtuTbxKEPraQ2sZbCKaaD nohCK2mUMuiHE+4KbaTQ3hGwJ01eLQc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1654856260; a=rsa-sha256; cv=none; b=EROgcQTMuT+w06MdTwONo1qk8gkMoNQLtU7lR10Hs98eOIPvmMFuig0ifqoU401zxdyxOX zExIxP1aCVP0BkOJOPpjv4i2guSmu9L29sRWEX1tByFdBujDYRCJvviI+6M9z6+Hq2DV1O rZKmVJtHUlENZiWoH4ZWt7Rid5WnIh4= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="aGxmOt/1"; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf24.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com X-Rspam-User: Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="aGxmOt/1"; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf24.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: rspam03 X-Stat-Signature: 6zdtoc7toojug7nhkqb8wytecfiwz1s3 X-Rspamd-Queue-Id: 3B03618006A X-HE-Tag: 1654856260-71196 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 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