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.9 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_PASS 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 17BD5C67839 for ; Fri, 14 Dec 2018 13:35:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ABC5A20643 for ; Fri, 14 Dec 2018 13:35:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729964AbeLNNfn (ORCPT ); Fri, 14 Dec 2018 08:35:43 -0500 Received: from lithops.sigma-star.at ([195.201.40.130]:52702 "EHLO lithops.sigma-star.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726554AbeLNNfn (ORCPT ); Fri, 14 Dec 2018 08:35:43 -0500 Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id 9F60B6083258; Fri, 14 Dec 2018 14:35:40 +0100 (CET) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id cwxB-2hDAHgk; Fri, 14 Dec 2018 14:35:40 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id 381BA6083257; Fri, 14 Dec 2018 14:35:40 +0100 (CET) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id hJmSI9uqdjDk; Fri, 14 Dec 2018 14:35:40 +0100 (CET) Received: from blindfold.localnet (213-47-184-186.cable.dynamic.surfer.at [213.47.184.186]) by lithops.sigma-star.at (Postfix) with ESMTPSA id C7CFB6083243; Fri, 14 Dec 2018 14:35:38 +0100 (CET) From: Richard Weinberger To: Gao Xiang , Artem Bityutskiy Cc: zhangjun , Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, "Darrick J . Wong" , hch@lst.de, bfoster@redhat.com, Dave Chinner , akpm@linux-foundation.org, kirill.shutemov@linux.intel.com, mhocko@suse.com, n-horiguchi@ah.jp.nec.com, mgorman@techsingularity.net, aarcange@redhat.com, willy@infradead.org, linux@dominikbrodowski.net, linux-mm@kvack.org, Gao Xiang Subject: Re: [PATCH] fix page_count in ->iomap_migrate_page() Date: Fri, 14 Dec 2018 14:35:38 +0100 Message-ID: <5520068.cAKZ7BqcUI@blindfold> In-Reply-To: <2b19b3c4-2bc4-15fa-15cc-27a13e5c7af1@aol.com> References: <1544766961-3492-1-git-send-email-openzhangj@gmail.com> <1618433.IpySj692Hd@blindfold> <2b19b3c4-2bc4-15fa-15cc-27a13e5c7af1@aol.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am Freitag, 14. Dezember 2018, 13:26:28 CET schrieb Gao Xiang: > Hi Richard, > > On 2018/12/14 19:25, Richard Weinberger wrote: > > This is the third place which needs this workaround. > > UBIFS, F2FS, and now iomap. > > > > I agree with Dave that nobody can assume that PG_private implies an additional > > page reference. > > But page migration does that. Including parts of the write back code. > > It seems that it's clearly documented in > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/mm.h#n780 > > * A pagecache page contains an opaque `private' member, which belongs to the > * page's address_space. Usually, this is the address of a circular list of > * the page's disk buffers. PG_private must be set to tell the VM to call > * into the filesystem to release these pages. > * > * A page may belong to an inode's memory mapping. In this case, page->mapping > * is the pointer to the inode, and page->index is the file offset of the page, > * in units of PAGE_SIZE. > * > * If pagecache pages are not associated with an inode, they are said to be > * anonymous pages. These may become associated with the swapcache, and in that > * case PG_swapcache is set, and page->private is an offset into the swapcache. > * > * In either case (swapcache or inode backed), the pagecache itself holds one > * reference to the page. Setting PG_private should also increment the > * refcount. The each user mapping also has a reference to the page. > > and when I looked into that, I found > https://lore.kernel.org/lkml/3CB3CA93.D141680B@zip.com.au/ Hmm, in case of UBIFS it seems easy. We can add a get/put_page() around setting/clearing the flag. I did that now and so far none of my tests exploded. Artem, do you remember why UBIFS never raised the page counter when setting PG_private? Thanks, //richard