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: 13162510 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FDD0C64EC4 for ; Mon, 6 Mar 2023 23:00:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0F5F96B0083; Mon, 6 Mar 2023 18:00:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 07EFA280001; Mon, 6 Mar 2023 18:00:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E61106B0087; Mon, 6 Mar 2023 18:00:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D08146B0083 for ; Mon, 6 Mar 2023 18:00:13 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9C39E140475 for ; Mon, 6 Mar 2023 23:00:13 +0000 (UTC) X-FDA: 80539993506.17.E9A146E Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf16.hostedemail.com (Postfix) with ESMTP id DF44C18001B for ; Mon, 6 Mar 2023 23:00:11 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=qDKEgow2; spf=pass (imf16.hostedemail.com: domain of 3e3AGZAoKCJwFPDKQCDPKJCKKCHA.8KIHEJQT-IIGR68G.KNC@flex--jthoughton.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3e3AGZAoKCJwFPDKQCDPKJCKKCHA.8KIHEJQT-IIGR68G.KNC@flex--jthoughton.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678143611; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=Eg6WHRqrr+nDg1zkB4Sv+OHD2/2VAlH0scI+mVHlbQk=; b=YQSt9yPrmpa8dW77/bFeiFQc1Z816K0OZ1B+beao4k4oZBjWJstuWcN3z+HGJswGdAtmng JjUL+3eGabChvLGfWPRg8OiLJZLaHu6JzMvHG36Rjio+y3PvNTTERFVhw7ajCtVqinDIId KmdcNZ2eHgBs05734JK42T3KTWjCYSE= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=qDKEgow2; spf=pass (imf16.hostedemail.com: domain of 3e3AGZAoKCJwFPDKQCDPKJCKKCHA.8KIHEJQT-IIGR68G.KNC@flex--jthoughton.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3e3AGZAoKCJwFPDKQCDPKJCKKCHA.8KIHEJQT-IIGR68G.KNC@flex--jthoughton.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678143611; a=rsa-sha256; cv=none; b=iCLlq4eM9AHUwRhSkMPFoS5F8DhzujLXKRo3BghCR1gfzd2QLxFP03lg17ljBqeLFYZ2yV 8pBaOXaGbqSecdMVvpTfuwAkhYX84outgv0MSz2ExcWsTPvcMMQwn786M4VZSf1/PHoWIE ++6h+/dOoASh4O+qlEsvSYfpe7bPYsI= Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-536c6ce8d74so115991917b3.9 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=koBo2IIqnopT3JhYCpoVtAhggkAVAo9HIf9fcZT0YFC4y/K3fyllGCpiSPXgCf/ydy 7Lh3QDYvxDvXrpcv/JKamMfgpLJ1h2xn+ZE8cpg3qHVtDQPmUKsOLEbL/YAW7zqvwVbY pg4vvcabm3+D8N+iagJP2PpJWa3SGwvevWlOBlO7Vrb/lNqbQuJeB6AvNxQOX2e0IIG7 11WJn1oxmuaze5RlhYUfxTNeCf9LsLUQye4P6oFvfwOva44k+E/qC9xe7I95ge5HGr0n qNxm52McttYSeY/g25DUl1D1Cpjg6mE5HZO5CVKUJDyZ12emIJhL3vBe1R+VRYHQszuD uZnA== X-Gm-Message-State: AO0yUKWpmN+41oTW7U/vEaE1Grb9pOVH+cgbi2cX1rKm5UdHR/cjiuIm z0VRPYTiXtoAfSMW0VaULAGCWVQ/v0lq+oAq X-Google-Smtp-Source: AK7set+0qK6jHYvrfOqyOBwwU7OzYF/ek6KS4Yy2ZQeKk4EZKqh86bGpn7pvR5e6UNfXH8U2eZKK8KXde4kDH3qT 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-Rspamd-Queue-Id: DF44C18001B X-Stat-Signature: tgne54cfy8i6p6qyhekzuan9fdqm4dnz X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1678143611-550946 X-HE-Meta: U2FsdGVkX1945nJFj3VJpSNNEeoVqSxYsXODhO35Rht9VVGv90mukmzH9rlpeQ1IFRXz5evNRZC5sZyzulL3Dl+SjpK06J8qIeOkTkjvCSo/tY0aWQ23by1jHB/vzy+zi/fH9D6XNvZNvHYZU8R1T3JzqsiSgZeitnvSxXEmgOIvpFodFgajOo6oI+i0UHcaIfAZLsYUO6bbITUGVRbwQ5x0027+KotR4v9Ik9mpzpd9mzLdgia87pvXtWDxKeznUREMM+2CU4FyFfb/NAYlnhmWy+o4bBujUFga+Tk/JjDKzMV1S/ERsG9yrM7B0BC23rZIWph++4zGLPcHAkRYgad2MTxmdMsMQqaHGjEceuSWV4zswNRk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d5dMInZOEoEvZB3D7ohKf7vzLi9Fn/zdUvTQ0oR9Y/dLvU9ajyTgPwtMyv66qDzX04kVt8z0fb4XxE+KIEZzyeyyHAk70r7+iK+n+0/hCiPIk62LCC2PDOd3bpysTC+lfN77Kq10ikGKrRulrh3QBuXWY0XPxSjH/0ERLq2QA7ChfDLY6JpyAn9SeUcLxiAUODh2kPCASRNzcWS7VOgrxzpBzUK3vF2/VcQDHX9OB4+wmB9/42ioI20ucGNDlhBvlzl7wl+5LgWihxyYd+sKh/5WHyZ2Lek9JArJKrAPQn3cUPWs1EC/Jy77nksgEvV6onPpA7AZpQtpnVvgNmxjT8TcAmkgDk= 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: 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