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=-9.9 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1,USER_IN_DEF_DKIM_WL autolearn=no 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 5D5FFCA9EB9 for ; Wed, 23 Oct 2019 01:31:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 22AB72086D for ; Wed, 23 Oct 2019 01:31:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="icuzZkfs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 22AB72086D Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B8F2D6B0003; Tue, 22 Oct 2019 21:31:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B3F186B0006; Tue, 22 Oct 2019 21:31:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A2E0C6B0007; Tue, 22 Oct 2019 21:31:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0107.hostedemail.com [216.40.44.107]) by kanga.kvack.org (Postfix) with ESMTP id 7C00C6B0003 for ; Tue, 22 Oct 2019 21:31:50 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 0A24D5833 for ; Wed, 23 Oct 2019 01:31:50 +0000 (UTC) X-FDA: 76073322780.02.day63_2d07f6f13c140 X-HE-Tag: day63_2d07f6f13c140 X-Filterd-Recvd-Size: 5909 Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Wed, 23 Oct 2019 01:31:49 +0000 (UTC) Received: by mail-pl1-f193.google.com with SMTP id c16so5502744plz.9 for ; Tue, 22 Oct 2019 18:31:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=U+vdvB09PkcmP9LOSiC0ehQS4Gt1iKc8AAE0Dv+6kRA=; b=icuzZkfsf6ZSelPljNgPbP4csFqQFl2Ak5zwtLrdaLzvtkDGqlGgHiI5ub/qNRiYTQ apk71bTqumsbDb7iSBkXZkY6/OKbTlASf7av5e31sVfx88j1rni0PhG7iMpdyhYmM3Bq S7+HsNCX6tXaG571Wv7zg2f2pLhe1sYoMKHukdQ1zSiRKeja3NPf/JrKf9efFnsBVaNy +//ppc/74V7hoIpZ+5Bxp9cC0faI8PSbJjxKwB0dJhx/FQZBK9acMIuBtw/qXSaOEn9B VFFmbeX102i95ofIX9FtrFPXLWGBY6UqP3xft51SwN7QCAlzxjlHvKZQObOL1Shk63c8 E7/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=U+vdvB09PkcmP9LOSiC0ehQS4Gt1iKc8AAE0Dv+6kRA=; b=jC2a1agv8WtvCCiaWwY0wWHedLsDKcXTPNRIS3k+4RElwD5VDTxYzRkTLMmD7M5w6k 02ancNMu/x+70qFMgSw4sFqQSQRkKyzMmMFlxCAuXCXp4hVK41j2ADaPQrLlIq04jnT4 eTfShI2OGC//9XhoQlznFlMPf5CCyGAkLQ1e5YsWFX9XLgVJOqIa3znFIwdfyk2LgjVu XR+u93aMNSC92jOiNfcxNJkH73ZOLMDmZqQ9p/qV92H9n1pjVSIOMNDaRTDIVwinoLtS 3EVIUWX1khIgV/jD542g8lXq9W+4dFPoqdNi7G07zlP2OvaVyIPWtfGbpjPxX+fAmTpI JuqA== X-Gm-Message-State: APjAAAW7KPaWgyfgUn8tll4GSkWyx5oAFkLC44TPi4PPYQnbCVrNY6mY yb6zik3bl8lDXF4OuJHB0eKDunGqmVc= X-Google-Smtp-Source: APXvYqxE8RiHT/nJrFWc4+VZpi4jlH8YH8RQGdcO2b3ip3wceSVMGwRPpH13x8KxC3Mfvmi0sr0OYQ== X-Received: by 2002:a17:902:bc81:: with SMTP id bb1mr6876407plb.244.1571794307043; Tue, 22 Oct 2019 18:31:47 -0700 (PDT) Received: from [100.112.92.218] ([104.133.9.106]) by smtp.gmail.com with ESMTPSA id g20sm20806561pfo.73.2019.10.22.18.31.45 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Oct 2019 18:31:46 -0700 (PDT) Date: Tue, 22 Oct 2019 18:31:27 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Yang Shi cc: Hugh Dickins , aarcange@redhat.com, kirill.shutemov@linux.intel.com, gavin.dg@linux.alibaba.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: thp: handle page cache THP correctly in PageTransCompoundMap In-Reply-To: <4ea5d015-19cb-d5d9-42f7-d1319d8de7c4@linux.alibaba.com> Message-ID: References: <1571769577-89735-1-git-send-email-yang.shi@linux.alibaba.com> <4ea5d015-19cb-d5d9-42f7-d1319d8de7c4@linux.alibaba.com> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 Tue, 22 Oct 2019, Yang Shi wrote: > On 10/22/19 3:27 PM, Hugh Dickins wrote: > > > > I completely agree that the current PageTransCompoundMap() is wrong. > > > > A fix for that is one of many patches I've not yet got to upstreaming. > > Comparing yours and mine, I'm worried by your use of PageDoubleMap(), > > because really that's a flag for anon THP, and not properly supported > > on shmem (or now I suppose file) THP - I forget the details, is it > > that it sometimes gets set, but never cleared? Generally, we just > > don't refer to PageDoubleMap() on shmem THPs (but there may be > > exceptions: sorting out the THP mapcount maze, and eliminating > > PageDoubleMap(), is one of my long-held ambitions, not yet reached). > > > > Here's the patch I've been carrying, but it's from earlier, so I > > should warn that I've done no more than build-testing it on 5.4, > > and I'm too far away from these issues at the moment to be able to > > make a good judgement or argue for it - I hope you and others can > > decide which patch is the better. I should also add that we're > > barely using PageTransCompoundMap() at all: at best it can only > > give a heuristic guess as to whether the page is pmd-mapped in > > any particular case, and we preferred to take forward the KVM > > patches we posted back in April 2016, plumbing hva down to where > > it's needed - though of course those are somewhat different now. > > Thanks for catching this. I was definitely thinking about using > compount_mapcount instead of DoubleMap flag when I was working the patch. I > just simply thought it would change less file by using DoubleMap flag but I > didn't notice it was kind of unbalanced for file THP. > > With the unbalanced DoubleMap flag, it sounds better to use > compound_mapcount. Yes: no doubt PageDoubleMap could be fixed on shmem+file, but I have no interest in doing that, because it's just unnecessary overhead for them. (They have their own overhead, of subpage mapcounting for pmd: which is something to eliminate and unify with anon when I get around to it.) > > Thanks for sharing your patch, I'm going to rework v2 by using > compound_mapcount. Do you mind I might steal your patch? Please do! One less for me to worry about, thanks. > > I'm supposed we'd better fix this bug regardless of whether you would like to > move forward your KVM patches. Absolutely. There remain a few other uses of PageTransCompoundMap anyway, and I really wanted this outright mm fix to go in before re-submitting AndresLC's KVM patch (I'll ask a KVM-savvy colleague to take that over, Cc'ing you, once the mm end is correct). Hugh