linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Peter Collingbourne <pcc@google.com>,
	John Hubbard <jhubbard@nvidia.com>,
	Matthew Wilcox <willy@infradead.org>,
	"Kirill A . Shutemov" <kirill@shutemov.name>,
	Andrew Morton <akpm@linux-foundation.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Evgenii Stepanov <eugenis@google.com>
Cc: Jann Horn <jannh@google.com>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	linux-mm@kvack.org, kernel test robot <lkp@intel.com>,
	Linux API <linux-api@vger.kernel.org>,
	linux-doc@vger.kernel.org
Subject: Re: [PATCH v4] mm: introduce reference pages
Date: Mon, 19 Jul 2021 22:47:45 +0200	[thread overview]
Message-ID: <3268d400-7435-f038-a1a1-f476adb03845@redhat.com> (raw)
In-Reply-To: <20210619092002.1791322-1-pcc@google.com>


> +SYSCALL_DEFINE2(refpage_create, const void *__user, content, unsigned long,
> +		flags)
> +{
> +	unsigned long content_addr = (unsigned long)content;
> +	struct page *userpage;
> +	struct refpage_private_data *private_data;
> +	int fd;
> +
> +	if (flags != 0)
> +		return -EINVAL;
> +
> +	if ((content_addr & (PAGE_SIZE - 1)) != 0 ||
> +	    get_user_pages(content_addr, 1, 0, &userpage, 0) != 1)
> +		return -EFAULT;
> +
> +	private_data = kzalloc(sizeof(struct refpage_private_data), GFP_KERNEL);
> +	if (!private_data) {
> +		put_page(userpage);
> +		return -ENOMEM;
> +	}
> +
> +	private_data->refpage = alloc_page(GFP_KERNEL);
> +	if (!private_data->refpage) {
> +		kfree(private_data);
> +		put_page(userpage);
> +		return -ENOMEM;
> +	}
> +
> +	copy_highpage(private_data->refpage, userpage);
> +	arch_prep_refpage_private_data(private_data);
> +	put_page(userpage);
> +
> +	fd = anon_inode_getfd("[refpage]", &refpage_file_operations,
> +			      private_data, O_RDONLY | O_CLOEXEC);
> +	if (fd < 0)
> +		put_refpage_private_data(private_data);
> +
> +	return fd;
> +}
> 

Hi,

some questions:

1. is there any upper limit or can a simple process effectively flood 
the system with alloc_page(GFP_KERNEL)? (does ulimit -n apply or is it 
/proc/sys/fs/file-max)

2. Shouldn't there be a GFP_ACCOUNT or am I missing something important?

3. How does this interact with MADV_DONTNEED? I assume we'll be able to 
zap the mapped refpage and on refault, we'll map in the refpage again, 
correct?

-- 
Thanks,

David / dhildenb



  parent reply	other threads:[~2021-07-19 20:49 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-19  9:20 [PATCH v4] mm: introduce reference pages Peter Collingbourne
2021-06-28 12:24 ` Kirill A. Shutemov
2021-07-17  2:58   ` Peter Collingbourne
2021-06-28 13:10 ` Matthew Wilcox
2021-07-17  2:58   ` Peter Collingbourne
2021-06-28 19:33 ` Matthew Wilcox
2021-06-28 19:44   ` John Hubbard
2021-06-28 19:56     ` Matthew Wilcox
2021-07-17  2:58       ` Peter Collingbourne
2021-06-29  7:19 ` John Hubbard
2021-06-29 11:58   ` Matthew Wilcox
2021-06-29 17:48     ` John Hubbard
2021-06-29 18:21       ` Matthew Wilcox
2021-06-29 18:28         ` John Hubbard
2021-07-17  2:59   ` Peter Collingbourne
2021-07-19 20:47 ` David Hildenbrand [this message]
2021-07-19 20:50 ` David Hildenbrand
2021-07-19 22:26   ` Peter Collingbourne
2021-07-19 22:30     ` John Hubbard
2021-07-20  7:28     ` David Hildenbrand

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=3268d400-7435-f038-a1a1-f476adb03845@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=catalin.marinas@arm.com \
    --cc=eugenis@google.com \
    --cc=jannh@google.com \
    --cc=jhubbard@nvidia.com \
    --cc=kirill@shutemov.name \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lkp@intel.com \
    --cc=pcc@google.com \
    --cc=willy@infradead.org \
    /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).