Message ID | 20220502181714.3483177-11-zokeefe@google.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 30EBFC433FE for <linux-mm@archiver.kernel.org>; Mon, 2 May 2022 18:17:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 749D36B0082; Mon, 2 May 2022 14:17:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6829B6B0083; Mon, 2 May 2022 14:17:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4FCAE6B0085; Mon, 2 May 2022 14:17:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 3FDB36B0082 for <linux-mm@kvack.org>; Mon, 2 May 2022 14:17:46 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 1D04D21364 for <linux-mm@kvack.org>; Mon, 2 May 2022 18:17:46 +0000 (UTC) X-FDA: 79421611332.17.6EA4D12 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) by imf14.hostedemail.com (Postfix) with ESMTP id 710A3100077 for <linux-mm@kvack.org>; Mon, 2 May 2022 18:17:44 +0000 (UTC) Received: by mail-pj1-f74.google.com with SMTP id v9-20020a17090a7c0900b001cb45f88cdcso6705217pjf.0 for <linux-mm@kvack.org>; Mon, 02 May 2022 11:17:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=ycD61MQgIhpcrtvxZMyg0KT3Zd0aTw6m/uwS7wZnXys=; b=eWqDRDglpNbXpoZ5+bjwoeBjrPveZD4+JoqNIiDYpzA9C4b0LEoN8sgqMwLUtQqkrV XukLcdKffY7BcCpD6iMZ3u41seHe32vkpqcpWqsPTzSx067X5AK1/paYIaAj2KkkKM3S fEp798yInNTmIP8aM6Dy+FNvLu8QpmzKhx4A4RFUN7zx490/JDp3MM/xAEaBfnaGvnq/ AMmTrtBj9mxq6S/QnP7ynEUJ15KfvZaatyIEdBzJy0pdXee68ack7LwPfn8CzK+al5C7 G/wLvo9VqbphH+dqeM+2A5gGdSKnIulz+utfao15EaWZ+3U1ajFcGvZUzNtJ0wSN/AJt asZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ycD61MQgIhpcrtvxZMyg0KT3Zd0aTw6m/uwS7wZnXys=; b=uXaq1k3uZIwCeDNfXrabJA9pIJDCSnfpR+AdsRM9S0HFm0AeMM6aotFOU2TRIv+o+3 q73vKmNln3xSvCF41AZCxdSXfxzXX2SY8rKu1KfLEHiCguimnBDL3rI7szb1Rh4JNiJ1 mwYM+Wg1aBFqhzBZOs7PzHmD/7HQyWyXwKJfAJHZyRnxvPSBQgz5LNh6EajR1TSNFXyc sp/RZcj1VterjKM3FTRKhE74+3WJRgaNdORsNHtpowS2YiLbiIEQfNyfxsii6ex6EBWu HN1ttdMAA2cZOziWhQ2wuO5YJNhfdJtupg4fsSfm7k6tXklBGpbxxtcnxXAGYurORcsI psow== X-Gm-Message-State: AOAM532SlJ0PnXmcU+yFXhOuNro6VL7ZcKfKYxqu48OldWG/fOYuuxKO YzXCNNtPEOuuRk4fhCR8KA4BifMJx2UJ X-Google-Smtp-Source: ABdhPJwpoVBUZSp2XH8ZwMq6o6jI2r2XQuljgd/A0tdydjRKi4B+ZObSQFMII7bMi7JXYu/uwxGU58AVeJ+g X-Received: from zokeefe3.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1b6]) (user=zokeefe job=sendgmr) by 2002:aa7:9802:0:b0:50d:4f5d:fef6 with SMTP id e2-20020aa79802000000b0050d4f5dfef6mr12340340pfl.9.1651515464641; Mon, 02 May 2022 11:17:44 -0700 (PDT) Date: Mon, 2 May 2022 11:17:11 -0700 In-Reply-To: <20220502181714.3483177-1-zokeefe@google.com> Message-Id: <20220502181714.3483177-11-zokeefe@google.com> Mime-Version: 1.0 References: <20220502181714.3483177-1-zokeefe@google.com> X-Mailer: git-send-email 2.36.0.464.gb9c8b46e94-goog Subject: [PATCH v4 10/13] mm/madvise: add MADV_COLLAPSE to process_madvise() From: "Zach O'Keefe" <zokeefe@google.com> To: Alex Shi <alex.shi@linux.alibaba.com>, David Hildenbrand <david@redhat.com>, David Rientjes <rientjes@google.com>, Matthew Wilcox <willy@infradead.org>, Michal Hocko <mhocko@suse.com>, Pasha Tatashin <pasha.tatashin@soleen.com>, Peter Xu <peterx@redhat.com>, SeongJae Park <sj@kernel.org>, Song Liu <songliubraving@fb.com>, Vlastimil Babka <vbabka@suse.cz>, Yang Shi <shy828301@gmail.com>, Zi Yan <ziy@nvidia.com>, linux-mm@kvack.org Cc: Andrea Arcangeli <aarcange@redhat.com>, Andrew Morton <akpm@linux-foundation.org>, Arnd Bergmann <arnd@arndb.de>, Axel Rasmussen <axelrasmussen@google.com>, Chris Kennelly <ckennelly@google.com>, Chris Zankel <chris@zankel.net>, Helge Deller <deller@gmx.de>, Hugh Dickins <hughd@google.com>, Ivan Kokshaysky <ink@jurassic.park.msu.ru>, "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>, Jens Axboe <axboe@kernel.dk>, "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>, Matt Turner <mattst88@gmail.com>, Max Filippov <jcmvbkbc@gmail.com>, Miaohe Lin <linmiaohe@huawei.com>, Minchan Kim <minchan@kernel.org>, Patrick Xia <patrickx@google.com>, Pavel Begunkov <asml.silence@gmail.com>, Thomas Bogendoerfer <tsbogend@alpha.franken.de>, "Zach O'Keefe" <zokeefe@google.com> Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 710A3100077 Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=eWqDRDgl; spf=pass (imf14.hostedemail.com: domain of 3SCBwYgcKCGMaPLFFGFHPPHMF.DPNMJOVY-NNLWBDL.PSH@flex--zokeefe.bounces.google.com designates 209.85.216.74 as permitted sender) smtp.mailfrom=3SCBwYgcKCGMaPLFFGFHPPHMF.DPNMJOVY-NNLWBDL.PSH@flex--zokeefe.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspam-User: X-Stat-Signature: qk1pu8dynqq8qdda8heyyxzbmukuft9z X-HE-Tag: 1651515464-569400 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: <linux-mm.kvack.org> |
Series |
mm: userspace hugepage collapse
|
expand
|
diff --git a/mm/madvise.c b/mm/madvise.c index 638517952bd2..08c11217025a 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -1168,13 +1168,15 @@ madvise_behavior_valid(int behavior) } static bool -process_madvise_behavior_valid(int behavior) +process_madvise_behavior_valid(int behavior, struct task_struct *task) { switch (behavior) { case MADV_COLD: case MADV_PAGEOUT: case MADV_WILLNEED: return true; + case MADV_COLLAPSE: + return task == current || capable(CAP_SYS_ADMIN); default: return false; } @@ -1452,7 +1454,7 @@ SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec, goto free_iov; } - if (!process_madvise_behavior_valid(behavior)) { + if (!process_madvise_behavior_valid(behavior, task)) { ret = -EINVAL; goto release_task; }
Allow MADV_COLLAPSE behavior for process_madvise(2) if caller has CAP_SYS_ADMIN or is requesting collapse of it's own memory. Signed-off-by: Zach O'Keefe <zokeefe@google.com> --- mm/madvise.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)