From: Hillf Danton <hdanton@sina.com>
To: Mike Christie <mchristi@redhat.com>
Cc: "Kirill A. Shutemov" <kirill@shutemov.name>,
axboe@kernel.dk, James.Bottomley@HansenPartnership.com,
martin.petersen@oracle.com, linux-kernel@vger.kernel.org,
linux-scsi@vger.kernel.org, linux-block@vger.kernel.org,
Linux-MM <linux-mm@kvack.org>
Subject: Re: [RFC PATCH] Add proc interface to set PF_MEMALLOC flags
Date: Wed, 11 Sep 2019 11:13:48 +0800 [thread overview]
Message-ID: <20190911031348.9648-1-hdanton@sina.com> (raw)
In-Reply-To: <20190910100000.mcik63ot6o3dyzjv@box.shutemov.name>
On Tue, 10 Sep 2019 11:06:03 -0500 From: Mike Christie <mchristi@redhat.com>
>
> > Really? Without any privilege check? So any random user can tap into
> > __GFP_NOIO allocations?
>
> That was a mistake on my part. I will add it in.
>
You may alternatively madvise a nutcracker as long as you would have
added a sledgehammer under /proc instead of a gavel.
--- a/include/uapi/asm-generic/mman-common.h
+++ b/include/uapi/asm-generic/mman-common.h
@@ -45,6 +45,7 @@
#define MADV_SEQUENTIAL 2 /* expect sequential page references */
#define MADV_WILLNEED 3 /* will need these pages */
#define MADV_DONTNEED 4 /* don't need these pages */
+#define MADV_NOIO 5 /* set PF_MEMALLOC_NOIO */
/* common parameters: try to keep these consistent across architectures */
#define MADV_FREE 8 /* free pages only if memory pressure */
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -716,6 +716,7 @@ madvise_behavior_valid(int behavior)
case MADV_WILLNEED:
case MADV_DONTNEED:
case MADV_FREE:
+ case MADV_NOIO:
#ifdef CONFIG_KSM
case MADV_MERGEABLE:
case MADV_UNMERGEABLE:
@@ -813,6 +814,11 @@ SYSCALL_DEFINE3(madvise, unsigned long,
if (!madvise_behavior_valid(behavior))
return error;
+ if (behavior == MADV_NOIO) {
+ current->flags |= PF_MEMALLOC_NOIO;
+ return 0;
+ }
+
if (start & ~PAGE_MASK)
return error;
len = (len_in + ~PAGE_MASK) & PAGE_MASK;
next prev parent reply other threads:[~2019-09-11 3:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20190909162804.5694-1-mchristi@redhat.com>
2019-09-09 18:26 ` [RFC PATCH] Add proc interface to set PF_MEMALLOC flags Mike Christie
2019-09-10 8:35 ` Damien Le Moal
2019-09-11 8:40 ` Martin Raiber
2019-09-11 16:56 ` Mike Christie
2019-09-11 19:21 ` Martin Raiber
2019-09-12 16:22 ` Mike Christie
2019-09-12 16:27 ` Mike Christie
2019-09-11 8:43 ` Martin Raiber
[not found] ` <ee39d997-ee07-22c7-3e59-a436cef4d587@I-love.SAKURA.ne.jp>
2019-09-10 23:28 ` Kirill A. Shutemov
2019-09-11 15:23 ` Mike Christie
[not found] ` <20190910100000.mcik63ot6o3dyzjv@box.shutemov.name>
2019-09-10 16:06 ` Mike Christie
2019-09-11 3:13 ` Hillf Danton [this message]
2019-09-11 13:52 ` Hillf Danton
[not found] ` <c48cd3d8-699d-a614-b12d-1ddef71691f3@I-love.SAKURA.ne.jp>
2019-09-11 15:44 ` Mike Christie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190911031348.9648-1-hdanton@sina.com \
--to=hdanton@sina.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=axboe@kernel.dk \
--cc=kirill@shutemov.name \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=mchristi@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).