From patchwork Fri Dec 23 00:38:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zach O'Keefe X-Patchwork-Id: 13080469 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 54C04C4332F for ; Fri, 23 Dec 2022 00:38:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4C610900003; Thu, 22 Dec 2022 19:38:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 47607900002; Thu, 22 Dec 2022 19:38:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 33EE4900003; Thu, 22 Dec 2022 19:38:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 25FED900002 for ; Thu, 22 Dec 2022 19:38:49 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id EDAA2120124 for ; Fri, 23 Dec 2022 00:38:48 +0000 (UTC) X-FDA: 80271710736.28.27622E9 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) by imf09.hostedemail.com (Postfix) with ESMTP id 7726514000A for ; Fri, 23 Dec 2022 00:38:46 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=FLsbQzGU; spf=pass (imf09.hostedemail.com: domain of 3lfikYwcKCD44tpjjkjlttlqj.htrqnsz2-rrp0fhp.twl@flex--zokeefe.bounces.google.com designates 209.85.214.202 as permitted sender) smtp.mailfrom=3lfikYwcKCD44tpjjkjlttlqj.htrqnsz2-rrp0fhp.twl@flex--zokeefe.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=1671755926; 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=pj0EgZKbDjiuk7KGxj5RPUOD4ch/E6XYT7fWV0ZO0z0=; b=X2G7lISjSkStJ3P+7X/hMkwB/eCD5+TFUo7gVt4OzYE7dxHNGWQvf8FFEpJ/OkLUeCpCki cfzWBPIDrOxg5jB6EaTqxs9XRPtYjbM5wGpMDz6DFaS7rDqIx9t8LrhBDejRVSZ2mNeqCY PCp07iyqq7PbpZ3a2bKo6D7l16v0qaw= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=FLsbQzGU; spf=pass (imf09.hostedemail.com: domain of 3lfikYwcKCD44tpjjkjlttlqj.htrqnsz2-rrp0fhp.twl@flex--zokeefe.bounces.google.com designates 209.85.214.202 as permitted sender) smtp.mailfrom=3lfikYwcKCD44tpjjkjlttlqj.htrqnsz2-rrp0fhp.twl@flex--zokeefe.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1671755926; a=rsa-sha256; cv=none; b=08SEgA3WrCRXI5kNagTvP2JIoWj+bxzKwkpMtfybmYXV95nViNFczTR3yRTvtSXDMIlLQM lIUf64hfApn8Yoqa52xqEzG9RLezn4ZFuG5Iy/wEnlqda67MI56/rULXZsqDwHr8Vt7cOx NCS0VyhHNIsdBp0ZpAtZFbSseHePcQA= Received: by mail-pl1-f202.google.com with SMTP id d2-20020a170902cec200b001899479b1d8so2367637plg.22 for ; Thu, 22 Dec 2022 16:38:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=pj0EgZKbDjiuk7KGxj5RPUOD4ch/E6XYT7fWV0ZO0z0=; b=FLsbQzGUzi8X6ddbZmbpw/HZBNFeVflu/WFjFtew2Ci8ZTEWv9EtO7iV6FdhiHazze /89VaUJ7Vzp4fyyDogVwJUUJlaiFgTNoT/8gP9Kfm/NqxAUE12GUN6e8h/n1YHgNm1XZ N+ww/ysSMJkG0cIyGnaDym7tALcFAu3Lb1t1ANLpVF3w0Tlh5ixhMggCUuiv4phMAbQf QKZRg9rmLYMYIRLK+LqVijiLmb4r7xUkBYJW5eY5iHljh0YAKSDC+K8oSpNE/DuIHMe2 uV3gbcbTELuBvibIDzppEI0kCgkGOWMReAWPmKOhS/KGmJKRSirGunC2MRFeKVaKZW0B CESw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=pj0EgZKbDjiuk7KGxj5RPUOD4ch/E6XYT7fWV0ZO0z0=; b=UeWLLX/ICGGtzykK7ijhkLettdNnpvv7+8v8Fmd5ykNFh/031LnE9hqFVb8NMeCu8O kcA0hn0TG1eCqIaaqDorYdrJzu1cvSDHbhcNgpzV9yCuMPxE+HtxC+jMNAedyJfYrMwH obIQGHTkLvaGeGZg/iTyz49XfNTj/wP9oW6iTtP4Fhf86galWgMCwduAWdpW9pg3K2Cc sp7qg3PZHPHwB7TfwgX7AtnHn4cMOoPbjvBloCWqphUAzHWjM3EQQuSngKClQ17iSj9e YvvoY0a617HROj4f89IVydF16b+UCOBa+Lw0I9P15f6dht8Fu5UYlbQNlY+Yo78ejPbc GIoQ== X-Gm-Message-State: AFqh2ko6C/3zbmTwblQVMWgmjLMuJesfTbDLcfBUJmqaXUbF3Va77nfr AbYCxCMhMQ7MN2r3h7ntImzoZZ6sCd7iyOwaXtZ0Ho9KncMl6iufoL+flka8MD/1PTPZsh50blb CRw82daKMhHAGC7eraFeaRfOxuGHTrcB46/G7TMu3B0OLrujsQS+kEyreJK8= X-Google-Smtp-Source: AMrXdXs+nNjC4ecTRRHmDG7RPsuUuf800+liBbOpsCvoGs3kNCqT/z1qZUuk1zS2cJm3goh4OyNDknPWwV3I X-Received: from zokeefe3.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1b6]) (user=zokeefe job=sendgmr) by 2002:a05:6a00:278f:b0:577:29c9:a7b with SMTP id bd15-20020a056a00278f00b0057729c90a7bmr493853pfb.61.1671755925016; Thu, 22 Dec 2022 16:38:45 -0800 (PST) Date: Thu, 22 Dec 2022 16:38:33 -0800 Mime-Version: 1.0 X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20221223003833.2793963-1-zokeefe@google.com> Subject: [PATCH] mm/shmem: restore SHMEM_HUGE_DENY precedence over MADV_COLLAPSE From: "Zach O'Keefe" To: linux-mm@kvack.org Cc: Andrew Morton , Hugh Dickins , Yang Shi , "Zach O'Keefe" X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 7726514000A X-Stat-Signature: 1j7brmox1aji9p8giaejbaz8s7x36mgf X-HE-Tag: 1671755926-6689 X-HE-Meta: U2FsdGVkX186ZLriDkqfwZ/UyRTydPDXo35r7K1NzzGLj6mZ33RkvB2XVS4rp+4Kg9rS7JWfe5c120GGqYY8J9Pqg3JMwQZpHfN4knkTlRSBw4R4v8Rbe10tVPuxDiELoYaGUufEEttpx/MrcN5HSYTmyj1JpjdihYGncZqE5BhRzhyzPvi6s8Gh0Z1++2HOztHZOtWy405EWg0cVpd6hJayE9r/0bpkECgStFA6Q47b/k91upd0vJxJ75f32FdbhZo9JalLohwV3x544hBXDcQQToStApVfzV7biswlD4KaNJNwOr75drC6fqPWlbSnSarHKL1QEnxsWyFL0viiYfjt34RrC9vPg0mgmsppig8NI1hs1zh3VVuZFbiWTw/CdzxMikG9A3fcNFLsnkwugx6WmUeY+1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owner-majordomo@kvack.org List-ID: SHMEM_HUGE_DENY is for emergency use by the admin, to disable allocation of shmem huge pages if, for example, a dangerous bug is found in their usage: see "deny" in Documentation/mm/transhuge.rst. An app using madvise(,,MADV_COLLAPSE) should not be allowed to override it: restore its precedence over shmem_huge_force. Fixes: 7c6c6cc4d3a2 ("mm/shmem: add flag to enforce shmem THP in hugepage_vma_check()") Suggested-by: Hugh Dickins Signed-off-by: Zach O'Keefe Cc: Yang Shi Acked-by: David Hildenbrand --- mm/shmem.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index c301487be5fb..0005ab2c29af 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -478,12 +478,10 @@ bool shmem_is_huge(struct vm_area_struct *vma, struct inode *inode, if (vma && ((vma->vm_flags & VM_NOHUGEPAGE) || test_bit(MMF_DISABLE_THP, &vma->vm_mm->flags))) return false; - if (shmem_huge_force) - return true; - if (shmem_huge == SHMEM_HUGE_FORCE) - return true; if (shmem_huge == SHMEM_HUGE_DENY) return false; + if (shmem_huge_force || shmem_huge == SHMEM_HUGE_FORCE) + return true; switch (SHMEM_SB(inode->i_sb)->huge) { case SHMEM_HUGE_ALWAYS: