From patchwork Mon Mar 6 23:00:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Houghton X-Patchwork-Id: 6203 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2133183wrd; Mon, 6 Mar 2023 15:33:59 -0800 (PST) X-Google-Smtp-Source: AK7set8nrL/l1cgSCV+iJ4nzbeZc56w9G5vfksOS3fTklUYMklkkE7E4phIYTVjYG3T14+MOzOtV X-Received: by 2002:a05:6a20:258c:b0:cc:ec48:1138 with SMTP id k12-20020a056a20258c00b000ccec481138mr13393354pzd.21.1678145639006; Mon, 06 Mar 2023 15:33:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678145638; cv=none; d=google.com; s=arc-20160816; b=mh+5rzkyt75enWjGFgcBw257xfoTt/O99kaJt51YX0tScXbsffYU3YYng2m3Pc2YEg tCeCgyccsVZq7/FHWcjur4hIToBR6ChRgIgwhYcRkk1fEFeI1giKLPHhYasZZuE021jR nMCYvJGyOnL+aJOcTjo0vyiQoqu4XeB5VToZUyPyPbX25y6KQXbPfXaVkd/kQwnpOELN 2902nTfnVuXmV+KcLcVUFTBG56mM/ZSRSLCjWAtlfBD4vx3ue3dQJRY9Wa3M1VnMVKRt takOwwJUgaNaddX/FmQF/Co97tqwyd31q/MhkuuJRbogvyaIBhPoK9HVn9F9lQZ9bZvq BqMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=Eg6WHRqrr+nDg1zkB4Sv+OHD2/2VAlH0scI+mVHlbQk=; b=0vLOdMtta1Tv5i8SsU8sAt4Ai3nyCZJ5oIgbLBhWtEHWSPdQayurIi4jUvN6lpYvD5 JINgSLRtxhDmaq13tXT5YMIm9C0HQ7LN8dXeQ3I7zW8SPp3gNRWpdTNPLPSH+aB2JzCn 5DHF3Z68YKlLgp27ovxHZlwLlcaxa36l6Un1BVk4GIfvzdvXV9JpujDmt57x/MBGIBuk M4mz2ORC1B02zsuqT607CRaxS1fPyHVfTYOQyKncWUI+vtubd8DU1xoSo/4APos86Bz/ rbJEDQcFGMaxMD1NAxU8yN4WEqQYB915KXRmlJMILy+jx/kwQeWDr24obcB3J0pP0Rka YzSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=qDKEgow2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x131-20020a633189000000b00502d74a68bdsi10682394pgx.701.2023.03.06.15.33.45; Mon, 06 Mar 2023 15:33:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=qDKEgow2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229958AbjCFXAV (ORCPT + 99 others); Mon, 6 Mar 2023 18:00:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229966AbjCFXAS (ORCPT ); Mon, 6 Mar 2023 18:00:18 -0500 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3E6251F9C for ; Mon, 6 Mar 2023 15:00:11 -0800 (PST) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-536cb268ab8so117854717b3.17 for ; Mon, 06 Mar 2023 15:00:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1678143611; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=Eg6WHRqrr+nDg1zkB4Sv+OHD2/2VAlH0scI+mVHlbQk=; b=qDKEgow2LiRqBuoiJsPnDGC7d/4OEen4xB133Txa71+jK0A1BUaXRMNz3BMnfWJoC7 lY88/3+TKc+8bvgw0IDzEEyutgPSxKBxgt5LS3+wfIt91YWXnBIEU3G2sfJnA5gXSEAh 20+xTuhnHDMOVcplgvLifuRmNEQzsrPTdTzXtyIi9XrhpnGMuoy6Ke8cIXBCPuupdCvf ZtT5e7LGoXJQ0DrGdu0IOrKhzoibJ/C4w1hlJjxChq/faRLkVdzOTPb9aYm7B1rW61cs 6/h7JnENcrotwAh90gB9tKFvZgpZWxmIi+JDAFrLNWREQkdMei++CA8pg5ANE1gROqhA V3PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678143611; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Eg6WHRqrr+nDg1zkB4Sv+OHD2/2VAlH0scI+mVHlbQk=; b=08+qnOIfyvkTbSAnRSJ/3i8wLdVkPNsAnRii7kJZJUC7TSMWMOQcwOAbKd19/AI9IR kCjkhTP8k9FPGUE+AdY22qHZFnp3liN4EAV4YkWnUvm40KrdObQ7niKrTFwU6RZ0xJON c+xSwsauo1ZExint6XFoTLhzRmhVqgiMTa0qCXYtQwoUTUoY2u52VqynPMeAOMcwG1fU gP5wGVCby3uAWsosTHpeIMcPm8WJ/fuWI8BG9Q7fJWhyoarY01W7b+R4r0b0gX1NWpLW oEexH6TgK7U6foAKUBV2yq9DwTFmIPaB56IxZ05yxlDUFtByloKCl+31d6CQe2bW3gpQ qvlg== X-Gm-Message-State: AO0yUKVO8USQls40JQ8TcqqSfGR6Q1IhOhNd+RhVoe8fTP/H91IuEkGU E4Kr40d2joLZ5lskh1xK4n4OIKLTp3a7WJSs X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a05:6902:10e:b0:98e:6280:74ca with SMTP id o14-20020a056902010e00b0098e628074camr5337509ybh.1.1678143611042; Mon, 06 Mar 2023 15:00:11 -0800 (PST) Date: Mon, 6 Mar 2023 23:00:02 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.40.0.rc0.216.gc4246ad0f0-goog Message-ID: <20230306230004.1387007-1-jthoughton@google.com> Subject: [PATCH 0/2] mm: rmap: merge HugeTLB mapcount logic with THPs From: James Houghton To: Mike Kravetz , Hugh Dickins , Muchun Song , Peter Xu , "Matthew Wilcox (Oracle)" , Andrew Morton Cc: "Kirill A . Shutemov" , David Hildenbrand , David Rientjes , Axel Rasmussen , Jiaqi Yan , linux-mm@kvack.org, linux-kernel@vger.kernel.org, James Houghton X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759663241766452599?= X-GMAIL-MSGID: =?utf-8?q?1759663241766452599?= HugeTLB pages may soon support being mapped with PTEs. To allow for this case, merge HugeTLB's mapcount scheme with THP's. The first patch of this series comes from the HugeTLB high-granularity mapping series[1], though with some updates, as the original version was buggy[2] and incomplete. I am sending this change as part of this smaller series in hopes that it can be more thoroughly scrutinized. I haven't run any THP performance tests with this series applied. HugeTLB pages don't currently support being mapped with `compound=false`, but this mapcount scheme will make collapsing compound=false mappings in HugeTLB pages quite slow. This can be optimized with future patches (likely by taking advantage of HugeTLB's alignment guarantees). Matthew Wilcox is working on a mapcounting scheme[3] that will avoid the use of each subpage's mapcount. If this series is applied, Matthew's new scheme will automatically apply to HugeTLB pages. [1]: https://lore.kernel.org/linux-mm/20230218002819.1486479-6-jthoughton@google.com/ [2]: https://lore.kernel.org/linux-mm/CACw3F538H+bYcvSY-qG4-gmrgGPRBgTScDzrX9suLyp_q+v_bQ@mail.gmail.com/ [3]: https://lore.kernel.org/linux-mm/Y9Afwds%2FJl39UjEp@casper.infradead.org/ James Houghton (2): mm: rmap: make hugetlb pages participate in _nr_pages_mapped mm: rmap: increase COMPOUND_MAPPED to support 512G HugeTLB pages include/linux/mm.h | 7 +------ mm/hugetlb.c | 4 ++-- mm/internal.h | 9 ++++----- mm/migrate.c | 2 +- mm/rmap.c | 35 ++++++++++++++++++++--------------- 5 files changed, 28 insertions(+), 29 deletions(-) base-commit: 9caa15b8a49949342bdf495bd47660267a3bd371