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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA1DCC43334 for ; Wed, 29 Jun 2022 17:26:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 00DBD8E001A; Wed, 29 Jun 2022 13:26:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EFF858E0015; Wed, 29 Jun 2022 13:26:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E15608E001A; Wed, 29 Jun 2022 13:26:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id D316D8E0015 for ; Wed, 29 Jun 2022 13:26:12 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id A2FFF805E1 for ; Wed, 29 Jun 2022 17:26:12 +0000 (UTC) X-FDA: 79631951784.19.35A9467 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by imf26.hostedemail.com (Postfix) with ESMTP id 0CF8F14002B for ; Wed, 29 Jun 2022 17:26:11 +0000 (UTC) Received: by mail-pf1-f178.google.com with SMTP id x4so15764840pfq.2 for ; Wed, 29 Jun 2022 10:26:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2Mb7kYZrsJg8kdYLNViygC6ruN7N2NsRWZHsCHpBKb8=; b=bXgSMJQYQTwcVf4PefxrkP5YvKMGpQUYC2giX4vaQjdpOgNCey1DUfQ0DMKchC47di 7OFUnZ8w+Mc34iO7qIFSk+gzV8tb0SQ56mcTW7ecKouKlch1lFGuX01aPa4DdezsUswi EAGD6CqDBLn2NCCj/io2rQLoqvc05xSWmPQuREbNFrM+kAnpmigIcKpA1vz+mlhuvFh+ fvibPl4yrsOftdzAZhaW4zPkGG0hGjrQwBFGBEN9vPm3xfwrEq86vyKQeUWlVZWL/sg8 mI4zNqv5DZd6+lGjArs8Gk9n6ePFp1M3jg9BzEsXOyiC+yMBl8TR/CLK8jusUK/zTVPa HVsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2Mb7kYZrsJg8kdYLNViygC6ruN7N2NsRWZHsCHpBKb8=; b=nPo7Sf9qXiKw2BlN/LlHPjlD2JU+1DmFkhHMAjHggWKkRXO6oF/NKpy6PQ3wqBa3/Q 3vv5AimiD0OWegxxuUV2vkG4Tp3KgaL2A1v+pEGAk2bckZX7zEXtatvhUQSXcPpJsQYA vK3niCrYqe6dEsf3nunxzzYkzKVc4jaAKHqV6MA3ySG1rcJ9rJWjDhA3sZz74mqOboAC 0COsPuJUOUrhO59DGawGwCs2t+VFm8oy+3TKhl30R3hLhnNH3yfX6UrUeMXuPnKUrrq/ XK7rFSlxLg1tBX3vPJJ60JJNr+ELq1X9KC3s3ZiX2NLXNKule+FMTCSSOydZcujjvrAW 928A== X-Gm-Message-State: AJIora/sWjKLuiZNdd5z6Tfnz/4GS9QgGW6fPiCc+3p6HfMZPibVd7KB rPTiGsSl9re8FFMDHL4I/aenuW63Ig8g9bY6RWc= X-Google-Smtp-Source: AGRyM1san+AOWB0R/N8npW9ZG9vJCOGaQKfvMisOuYdJ/leLCQQUcBN5anlbsaefFkjWPo9rjT+ssaRKzuI89phczzo= X-Received: by 2002:a63:8f56:0:b0:40c:9877:9f51 with SMTP id r22-20020a638f56000000b0040c98779f51mr3789062pgn.206.1656523570988; Wed, 29 Jun 2022 10:26:10 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Yang Shi Date: Wed, 29 Jun 2022 10:25:58 -0700 Message-ID: Subject: Re: thp: enforcing constraints on file thps To: "Zach O'Keefe" Cc: Song Liu , Matthew Wilcox , Miaohe Lin , Linux MM Content-Type: text/plain; charset="UTF-8" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656523572; a=rsa-sha256; cv=none; b=PtUHcq1MrA0trEFHLiWehQR4+C7kJGhin4Vo9M6Oy3I5Wt7p84tW3JcL1ww/gmtdR794Ai uv0ypuPziMOFRP/M7qisipqDdZSXFhA3J3+GHjx3axtdVU81UWy38ZcSheGOhfVQKDK67L cJikDr0cisscmdhiFZgT8Jzo6uHGBuw= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=bXgSMJQY; spf=pass (imf26.hostedemail.com: domain of shy828301@gmail.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=shy828301@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656523572; 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:in-reply-to:references:references:dkim-signature; bh=2Mb7kYZrsJg8kdYLNViygC6ruN7N2NsRWZHsCHpBKb8=; b=O4nh/6GMzSgvC4XGFAfbIfWNW4M8gqRT2YNLK5eAQfWCMsbPZp3dzksAMkOXEbxjDDmDBU ljJAAHbYJJc6Rv8dwlTmgVV/acmoFbYqyca5F542+I2NlQSl4sYjSg0mLvdvnMGZdZRJ+o j4nHEi0LXSyQVWaF8ZPSWWpBe7RHRK8= X-Rspam-User: Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=bXgSMJQY; spf=pass (imf26.hostedemail.com: domain of shy828301@gmail.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=shy828301@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam02 X-Stat-Signature: u3prgnzufzybshp6c1y6yj6o57au846z X-Rspamd-Queue-Id: 0CF8F14002B X-HE-Tag: 1656523571-567160 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 Wed, Jun 29, 2022 at 7:01 AM Zach O'Keefe wrote: > > Hey All, > > There are currently a number of paths where we can collapse file memory into > THPs: > > 1a) khugepaged - target of vma being processed > 1b) khugepaged - other vma found mapping file, able to lock mmap_lock in > retract_page_tables() > 1b) khugepaged - other vma found mapping file, deferred pte-mapped THP collapse, > processed in collapse_pte_mapped_thp() > 2) page fault finds hugepage in page cache + filemap_map_pages() > > In terms of system-enforced THP constraints: > > * vma flags + thps sysfs settings > > Checked in 1a. (1b now at least respects "never" THP mode after Yang Shi's > cleanup series, but still doesn't respect "madvise" THP mode) > > * MMF_DISABLE_THP > > Checked in 1a and 1b > > I'm wondering if we should align these, and if so, in what direction? I would > argue that a process marked MMF_DISABLE_THP, or a vma marked VM_NOHUGEPAGE, > probably shouldn't be mapping at the pmd level, and that the appropriate checks > should be added in those paths. That depends on how we explain the semantics of MMF_DISABLE_THP and VM_NOHUGEPAGE IMHO. They definitely prevent from allocating/collapsing new THPs for that process or vma, but shall they also prevent from mapping existing THPs to PMD? Maybe not. > > Thanks, > Zach