Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1438231 > unrolled thread
| Started by | "Jan Beulich" <JBeulich@suse.com> |
|---|---|
| First post | 2016-07-07 09:40 +0200 |
| Last post | 2016-07-07 11:40 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[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
| From | "Jan Beulich" <JBeulich@suse.com> |
|---|---|
| Date | 2016-07-07 09:40 +0200 |
| Subject | [PATCH] xen/privcmd: sprinkle around cond_resched() calls in mmap ioctl handling |
| Message-ID | <rSc4F-3S8-9@gated-at.bofh.it> |
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;
[toc] | [next] | [standalone]
| From | David Vrabel <david.vrabel@citrix.com> |
|---|---|
| Date | 2016-07-07 11:40 +0200 |
| Subject | Re: [Xen-devel] [PATCH] xen/privcmd: sprinkle around cond_resched() calls in mmap ioctl handling |
| Message-ID | <rSdWO-55O-49@gated-at.bofh.it> |
| In reply to | #1438231 |
On 07/07/16 08:35, Jan Beulich wrote: > Many of these operations can take arbitrarily long, which can become a > problem irrespective of them being exposed to privileged users only. If this is a concern I would rather see large numbers of mapping requests processed in smaller batches. This would also limit the amount of memory needed. Note also that xen_remap_domain_gfn() array already has a cond_resched() after every batch of 16 GFNs. David
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web