Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1438231
| Path | csiph.com!news.mixmin.net!news.unit0.net!news.panservice.it!diesel.cu.mi.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | "Jan Beulich" <JBeulich@suse.com> |
| Newsgroups | linux.kernel |
| Subject | [PATCH] xen/privcmd: sprinkle around cond_resched() calls in mmap ioctl handling |
| Date | Thu, 07 Jul 2016 09:40:01 +0200 |
| Message-ID | <rSc4F-3S8-9@gated-at.bofh.it> (permalink) |
| X-Mailer | Novell GroupWise Internet Agent 14.2.0 |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=US-ASCII |
| Content-Transfer-Encoding | 8BIT |
| Content-Disposition | inline |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 65 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | <xen-devel@lists.xenproject.org>, <linux-kernel@vger.kernel.org> |
| X-Original-Date | Thu, 07 Jul 2016 01:35:02 -0600 |
| X-Original-Message-ID | <577E224602000078000FBDC1@prv-mh.provo.novell.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1438231 |
Show key headers only | View raw
Many of these operations can take arbitrarily long, which can become a
problem irrespective of them being exposed to privileged users only.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
drivers/xen/privcmd.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
--- 4.7-rc6-xen.orig/drivers/xen/privcmd.c
+++ 4.7-rc6-xen/drivers/xen/privcmd.c
@@ -69,9 +69,13 @@ static long privcmd_ioctl_hypercall(void
static void free_page_list(struct list_head *pages)
{
struct page *p, *n;
+ unsigned idx = 0;
- list_for_each_entry_safe(p, n, pages, lru)
+ list_for_each_entry_safe(p, n, pages, lru) {
+ if (!(++idx & 7))
+ cond_resched();
__free_page(p);
+ }
INIT_LIST_HEAD(pages);
}
@@ -103,6 +107,8 @@ static int gather_array(struct list_head
if (page == NULL)
goto fail;
+ if (pagedata)
+ cond_resched();
pagedata = page_address(page);
list_add_tail(&page->lru, pagelist);
@@ -144,6 +150,9 @@ static int traverse_pages(unsigned nelem
while (nelem--) {
if (pageidx > PAGE_SIZE-size) {
struct page *page;
+
+ if (pagedata)
+ cond_resched();
pos = pos->next;
page = list_entry(pos, struct page, lru);
pagedata = page_address(page);
@@ -169,16 +178,17 @@ static int traverse_pages_block(unsigned
void *state)
{
void *pagedata;
- unsigned pageidx;
+ unsigned pageidx = 0;
int ret = 0;
BUG_ON(size > PAGE_SIZE);
- pageidx = PAGE_SIZE;
-
while (nelem) {
int nr = (PAGE_SIZE/size);
struct page *page;
+
+ if (pageidx++)
+ cond_resched();
if (nr > nelem)
nr = nelem;
pos = pos->next;
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH] xen/privcmd: sprinkle around cond_resched() calls in mmap ioctl handling "Jan Beulich" <JBeulich@suse.com> - 2016-07-07 09:40 +0200 Re: [Xen-devel] [PATCH] xen/privcmd: sprinkle around cond_resched() calls in mmap ioctl handling David Vrabel <david.vrabel@citrix.com> - 2016-07-07 11:40 +0200
csiph-web