Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4002701ybg; Fri, 25 Oct 2019 11:57:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqzih98uysk4ljfTkjtDukN9jLbWlTTy9/0mOgtkyjYYGlAxcz/llPjJCL1ucCkMLduv9rEX X-Received: by 2002:aa7:ca0b:: with SMTP id y11mr5621769eds.51.1572029846001; Fri, 25 Oct 2019 11:57:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572029845; cv=none; d=google.com; s=arc-20160816; b=EoOVOS9mtOx04llDEos268zJc4VI1uoPMBTatz9K1CTDiQZMasCMFKNKhxTVFofg8I fpE8UMAAVQauKYNPOZbRiKgFWi3VzVkgDangUyKE+GbLLurUgMC58007U8AyY9pRRwLX wE5T9iCOqebsZeB8lHXnzLADjPQ6WjlsG/DMwxQPJ1TbxNKgu6a31ExDbu7F5XpStyRP jE64WYKI2+5769ts7Vy57ULiBR9e/l3u8dhNVb0GCN4B1c9i03OtFnB24rRWZwjpTgpP p6OpnBEy5V4T30PsRtzHKBm1YFgC0uQPx4zsoS+V96UnyYCtkqfB7q4fCuO2hSXph/vY UWhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=t+CzAtbw8jtnXuNwdGiXIAgWX3ZpOEqfrbMNOOMcZeA=; b=a504WXc2C7XaBcnTs08faE5VUQ6oYhGxsdMeEuNxkKi9/+xSenRQ4vEqW0AAV5JOXG LyKdcqy+cAyt0hzoHXxC4edfhdfWe8DKXUvSlKcuEpqv3EitcecalS0IcyfHTF2/Ghn0 3HDQlEvJ+UyvCCYTU8X0FYF8CMMz5PqXylU/VEaaJQcKO+jmV2gdnwzkHj0qHn0fld9J UsZY1P3bHM+1u4+2nd4dGBDeaX6I9EdanvAl30haGyS3Zth9yDsbuC9XAvsG7isOuOta CizLoS+1ddDl9cS5cuKUuEV5VcSslmdps3wraZai24f17hZilV4FFDS1qT9lV89Wa3qe xnhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HZzlc6ST; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q20si1729815ejt.249.2019.10.25.11.57.02; Fri, 25 Oct 2019 11:57:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HZzlc6ST; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731758AbfJXT0m (ORCPT + 99 others); Thu, 24 Oct 2019 15:26:42 -0400 Received: from mail-qk1-f194.google.com ([209.85.222.194]:42468 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725963AbfJXT0l (ORCPT ); Thu, 24 Oct 2019 15:26:41 -0400 Received: by mail-qk1-f194.google.com with SMTP id m4so7583900qke.9 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=l8921puY9lJzZSHm1vD/W5E/AZlP31U7UsSu2rXgRqTz8qH7bRYcZfzt1waDW4KUJ5 /WSx/xvujHDFTtHO/6o9++LEfwZZ9Tx3PuHc3X6CDPrIFV1gTMFkRJjUQBloIm5hdjWl o3M50oqV+DYReAbw53dX/FI0grFr+WGV+c+ku77DK10/U5aEGCf647O3BWqwQ3Wh79qE u3KxBQCgYtKVFR3V4+GiQM6KT6wgkmZtUouEJtZPTkHYtoCUJCwszscBu2gXh0ZD5xwI sV04W0pVH95xDKAQpGEOLjJyItEEHyoDGF+i/nWZu8nD399ibKFnVxpBL0b8gCiO1ZEg Ltxg== X-Gm-Message-State: APjAAAUgYegbrWV42OBqciLl1yNDkPMHX4NxNaGBjXMRRARIfhvuDVxC P7uZh2HF9a7yaNV7zEP9UpPi2jRZKYeyv811vSM= 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" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > >