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 X-Spam-Level: X-Spam-Status: No, score=-5.0 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 906C6C47256 for ; Sat, 2 May 2020 08:56:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0AC9B2137B for ; Sat, 2 May 2020 08:56:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=cloud.ionos.com header.i=@cloud.ionos.com header.b="Oi3p35hR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0AC9B2137B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=cloud.ionos.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 662898E0005; Sat, 2 May 2020 04:56:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6124B8E0001; Sat, 2 May 2020 04:56:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4D9028E0005; Sat, 2 May 2020 04:56:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0110.hostedemail.com [216.40.44.110]) by kanga.kvack.org (Postfix) with ESMTP id 32E8C8E0001 for ; Sat, 2 May 2020 04:56:56 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id DC240180AD806 for ; Sat, 2 May 2020 08:56:55 +0000 (UTC) X-FDA: 76771173990.06.meat19_76a5123a7a233 X-HE-Tag: meat19_76a5123a7a233 X-Filterd-Recvd-Size: 7257 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by imf20.hostedemail.com (Postfix) with ESMTP for ; Sat, 2 May 2020 08:56:55 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id l18so3876340wrn.6 for ; Sat, 02 May 2020 01:56:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=cWUrhtBOQPhFHdJtWzGRrwgjHQevNUoIVdoMuVU6lG4=; b=Oi3p35hRAPZ/9x5okgKKF+rzEJ0k4NVnQcL5o8zVWmyvFff1FH0nLxq+PilKhUSVAx TabSMKGYuKHPDwIUIFDQ6mpIXOO33K8MRbuShb1KqPnI/7YGIgfCgYMEbA8Bv6dR+N/C Lz3cTZTnKGuEKc82beI/8hMgAhOquzUTGlekS6a6yf1+rmesrR3Yl2JZYac2/NQwqMcy f63eLL5rFio6Y+OwlbJuJCRzBFTJxEkSlw1cqwWh11nbH6g+E0L7hdcaIDlJ07KWgNkK lHeLeiS0/q5JJ9iE/6W0qdtdZ4FGtYuVbiaY6sbeNxLgwO1YD1LMbu6u8kjlxVzRLStb IoIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=cWUrhtBOQPhFHdJtWzGRrwgjHQevNUoIVdoMuVU6lG4=; b=Cm1+vedCaBmF/cTxgAPsuRQV6cCMoTPGoi/cGgx6RuGu9TEyWQttYvsx3qNxwWXKbO PGmQhqfnmT3cGS841HkvSxUgbBIra6QZJRS9wb5r/2i0KmRMHOyblzRlo+mIVncxKF4m f7VWkTfbWXVQHZcefJOJ0rCGdRg3RZG1LnrDe4Ngn9n2sx24TLVbD8lqWtSEbJ8IVZqK 7V0PXEF7KGPKHFDDGsZ1gxqlhY3Y3PowqGFInY2TRxx03kFvVYUevd59Rvs9W2DTzGMX 1dUlpnbPLRDSIrYm2qpRYoYUnhFXfacekAsUgbU9rufowrMt1LykfWAXdg5Mp/MeTdHE ylmg== X-Gm-Message-State: AGi0PuZaV7RwIn/Ji8db3tOiHMlfOzG2HFmH1aUr/EXV1squaYmuSTc/ 8ySv0EjjtkW0XX/N6BYYBsSpDQ== X-Google-Smtp-Source: APiQypKDMZLDoMmUhch880vqn0lUpntebEsdFyCBeYqF2KDIZoyMBsFUe0BxMB4juMNuVtJhvB8ibA== X-Received: by 2002:a05:6000:14c:: with SMTP id r12mr8082018wrx.62.1588409813753; Sat, 02 May 2020 01:56:53 -0700 (PDT) Received: from ?IPv6:2001:16b8:48f0:a800:e80e:f5df:f780:7d57? ([2001:16b8:48f0:a800:e80e:f5df:f780:7d57]) by smtp.gmail.com with ESMTPSA id 91sm762421wrj.57.2020.05.02.01.56.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 02 May 2020 01:56:52 -0700 (PDT) Subject: Re: [RFC PATCH V2 0/9] Introduce attach/clear_page_private to cleanup code To: Matthew Wilcox Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, hch@infradead.org, david@fromorbit.com, Andrew Morton , linux-mm@kvack.org, cl@linux.com, mike.kravetz@oracle.com References: <20200430214450.10662-1-guoqing.jiang@cloud.ionos.com> <20200501221626.GC29705@bombadil.infradead.org> <889f9f82-64ba-50b3-147b-459303617aeb@cloud.ionos.com> <20200502004158.GD29705@bombadil.infradead.org> From: Guoqing Jiang Message-ID: Date: Sat, 2 May 2020 10:56:51 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200502004158.GD29705@bombadil.infradead.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable 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 5/2/20 2:41 AM, Matthew Wilcox wrote: > On Sat, May 02, 2020 at 12:42:15AM +0200, Guoqing Jiang wrote: >> On 5/2/20 12:16 AM, Matthew Wilcox wrote: >>> On Thu, Apr 30, 2020 at 11:44:41PM +0200, Guoqing Jiang wrote: >>>> include/linux/pagemap.h: introduce attach/clear_page_private >>>> md: remove __clear_page_buffers and use attach/clear_page_privat= e >>>> btrfs: use attach/clear_page_private >>>> fs/buffer.c: use attach/clear_page_private >>>> f2fs: use attach/clear_page_private >>>> iomap: use attach/clear_page_private >>>> ntfs: replace attach_page_buffers with attach_page_private >>>> orangefs: use attach/clear_page_private >>>> buffer_head.h: remove attach_page_buffers >>> I think mm/migrate.c could also use this: >>> >>> ClearPagePrivate(page); >>> set_page_private(newpage, page_private(page)); >>> set_page_private(page, 0); >>> put_page(page); >>> get_page(newpage); >>> >> Thanks for checking!=C2=A0 Assume the below change is appropriate. >> >> diff --git a/mm/migrate.c b/mm/migrate.c >> index 7160c1556f79..f214adfb3fa4 100644 >> --- a/mm/migrate.c >> +++ b/mm/migrate.c >> @@ -797,10 +797,7 @@ static int __buffer_migrate_page(struct address_s= pace >> *mapping, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (rc !=3D MIGRATEPAGE_SU= CCESS) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 goto unlock_buffers; >> >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ClearPagePrivate(page); >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 set_page_private(newpage, page_p= rivate(page)); >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 set_page_private(page, 0); >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 put_page(page); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 set_page_private(newpage, detach= _page_private(page)); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 get_page(newpage); > I think you can do: > > @@ -797,11 +797,7 @@ static int __buffer_migrate_page(struct address_sp= ace *mapping, > if (rc !=3D MIGRATEPAGE_SUCCESS) > goto unlock_buffers; > =20 > - ClearPagePrivate(page); > - set_page_private(newpage, page_private(page)); > - set_page_private(page, 0); > - put_page(page); > - get_page(newpage); > + attach_page_private(newpage, detach_page_private(page)); > =20 > bh =3D head; > do { > @@ -810,8 +806,6 @@ static int __buffer_migrate_page(struct address_spa= ce *mapping, > =20 > } while (bh !=3D head); > =20 > - SetPagePrivate(newpage); > - > if (mode !=3D MIGRATE_SYNC_NO_COPY) > > ... but maybe there's a subtlety to the ordering of the setup of the bh > and setting PagePrivate that means what you have there is a better patc= h. Yes, it is better but not sure if the order can be changed here. And seem= s the original commit is this one. commit e965f9630c651fa4249039fd4b80c9392d07a856 Author: Christoph Lameter Date:=C2=A0=C2=A0 Wed Feb 1 03:05:41 2006 -0800 =C2=A0=C2=A0=C2=A0 [PATCH] Direct Migration V9: Avoid writeback / page_m= igrate() method =C2=A0=C2=A0=C2=A0 Migrate a page with buffers without requiring writeba= ck =C2=A0=C2=A0=C2=A0 This introduces a new address space operation migrate= page() that=20 may be used =C2=A0=C2=A0=C2=A0 by a filesystem to implement its own version of page = migration. =C2=A0=C2=A0=C2=A0 A version is provided that migrates buffers attached = to pages. Some =C2=A0=C2=A0=C2=A0 filesystems (ext2, ext3, xfs) are modified to utilize= this feature. =C2=A0=C2=A0=C2=A0 The swapper address space operation are modified so t= hat a regular =C2=A0=C2=A0=C2=A0 migrate_page() will occur for anonymous pages without= writeback=20 (migrate_pages =C2=A0=C2=A0=C2=A0 forces every anonymous page to have a swap entry). Hope mm experts could take a look, so CC more people and mm list. And the question is that if we can setting PagePrivate before setup bh in the __buffer_migrate_page, thanks for your any further input. Thanks, Guoqing