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=-6.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 6534CCA9EAF for ; Thu, 24 Oct 2019 19:26:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 23A7020663 for ; Thu, 24 Oct 2019 19:26:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HZzlc6ST" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 23A7020663 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C70106B0006; Thu, 24 Oct 2019 15:26:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C46EB6B0007; Thu, 24 Oct 2019 15:26:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B5D096B0008; Thu, 24 Oct 2019 15:26:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0132.hostedemail.com [216.40.44.132]) by kanga.kvack.org (Postfix) with ESMTP id 9424A6B0006 for ; Thu, 24 Oct 2019 15:26:42 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id E34D0181B10F2 for ; Thu, 24 Oct 2019 19:26:41 +0000 (UTC) X-FDA: 76079660202.26.fifth87_1d540b191510c X-HE-Tag: fifth87_1d540b191510c X-Filterd-Recvd-Size: 4578 Received: from mail-qk1-f194.google.com (mail-qk1-f194.google.com [209.85.222.194]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Thu, 24 Oct 2019 19:26:41 +0000 (UTC) Received: by mail-qk1-f194.google.com with SMTP id u22so24484854qkk.11 for ; Thu, 24 Oct 2019 12:26:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=t+CzAtbw8jtnXuNwdGiXIAgWX3ZpOEqfrbMNOOMcZeA=; b=HZzlc6STA7Inz7B4IqH/Phjkj29ALzhIseK/7OdIc5B6QuDilMBW0dzSe8/kf2J9lb 1JoD0GIEvGoICGWTsHH4MH+xsyFb93LsAFmlSqr853s1sEyQKtF1j67jxXzepYlPG3m1 NitbB5EoyOgX+d7d70b6mzaXVeWAH2ir6yVtpqiiREkq/aEgqwbrASSBgp1x7ti/HCAV lHmvLrTVayekjd7PdCkrmUxcPuIvahJDPZwRdF6N8w5mGMtgUNsr9nqtYX+YiQiLjeFa ovJNtdJ1xcIQYMjiB+L+n8HUeTk+2huOOgqBC0sRFpK1KW3uYGK9P0b4iHpH/n8HPRtT 00Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=t+CzAtbw8jtnXuNwdGiXIAgWX3ZpOEqfrbMNOOMcZeA=; b=CoSEba/xKW47Wl1KkhS8Rq5WS4r1VVflNITeW8oBJbWsgMMG4gbUX/9qNQ9LjwI+ET do9fNI+N2p+VSk6BjBcsfwgCJAQzwf+mIzvEOeeQ0O0G6GSxei7fl2bduhUck9qBXMZ+ Jdk7Te1QZTdAatSKi1apXkaaKVV6mglYaz2aGjWZAWPoL1zUkorKal+k2/i/VmtvTxpA qfttMEzaHbJ6356pDQinwjaCYzk5qLJ9kOw9PpUoP7/2rXiYs7jNLe8A1Hd1x1V0xkx5 c/qp2m9A6+ubMVUVcWQL5Z7vEr7btpKCZfOc4wWRn+jKFDr70SuWdKUcIVJDQ94Mvhlj /fWg== X-Gm-Message-State: APjAAAXdOUXIEjV+rKtF8ZBeMNLQOdx45bat638aYP7oh56lXmmqj/wp qlIKmy5F5C2sJihUw39QElyCiWCx78cghASZ7K4= X-Google-Smtp-Source: APXvYqx+0y4wH+73RucQWwC1E1dyvBkv470jOt4TQuya1MH+R3kIBaQ++6ZVNm5n21pRzWUioLgEmx6yPO9r+v+KLrM= X-Received: by 2002:a37:4f88:: with SMTP id d130mr15747600qkb.168.1571945200852; Thu, 24 Oct 2019 12:26:40 -0700 (PDT) MIME-Version: 1.0 References: <1571938066-29031-1-git-send-email-yang.shi@linux.alibaba.com> In-Reply-To: <1571938066-29031-1-git-send-email-yang.shi@linux.alibaba.com> From: Song Liu Date: Thu, 24 Oct 2019 12:26:29 -0700 Message-ID: Subject: Re: [PATCH] mm: thp: clear PageDoubleMap flag when the last PMD map gone To: Yang Shi Cc: Hugh Dickins , kirill.shutemov@linux.intel.com, aarcange@redhat.com, Andrew Morton , Linux-MM , open list Content-Type: text/plain; charset="UTF-8" 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 Thu, Oct 24, 2019 at 10:28 AM Yang Shi wrote: > > File THP sets PageDoubleMap flag when the first it gets PTE mapped, but > the flag is never cleared until the THP is freed. This result in > unbalanced state although it is not a big deal. > > Clear the flag when the last compound_mapcount is gone. It should be > cleared when all the PTE maps are gone (become PMD mapped only) as well, > but this needs check all subpage's _mapcount every time any subpage's > rmap is removed, the overhead may be not worth. The anonymous THP also > just clears PageDoubleMap flag when the last PMD map is gone. > > Cc: Hugh Dickins > Cc: Kirill A. Shutemov > Cc: Andrea Arcangeli > Signed-off-by: Yang Shi Looks good to me. Thanks! Acked-by: Song Liu > --- > Hugh thought it is unnecessary to fix it completely due to the overhead > (https://lkml.org/lkml/2019/10/22/1011), but it sounds simple to achieve > the similar balance as anonymous THP. > > mm/rmap.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/mm/rmap.c b/mm/rmap.c > index 0c7b2a9..d17cbf3 100644 > --- a/mm/rmap.c > +++ b/mm/rmap.c > @@ -1236,6 +1236,9 @@ static void page_remove_file_rmap(struct page *page, bool compound) > __dec_node_page_state(page, NR_SHMEM_PMDMAPPED); > else > __dec_node_page_state(page, NR_FILE_PMDMAPPED); > + > + /* The last PMD map is gone */ > + ClearPageDoubleMap(compound_head(page)); > } else { > if (!atomic_add_negative(-1, &page->_mapcount)) > goto out; > -- > 1.8.3.1 > >