Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1276569 > unrolled thread
| Started by | Vlastimil Babka <vbabka@suse.cz> |
|---|---|
| First post | 2015-11-24 16:30 +0100 |
| Last post | 2015-11-25 11:50 +0100 |
| Articles | 4 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH 3/3] mm/cma: always check which page cause allocation failure Vlastimil Babka <vbabka@suse.cz> - 2015-11-24 16:30 +0100
Re: [PATCH 3/3] mm/cma: always check which page cause allocation failure Joonsoo Kim <iamjoonsoo.kim@lge.com> - 2015-11-25 03:40 +0100
[PATCH v2] mm/cma: always check which page cause allocation failure Joonsoo Kim <js1304@gmail.com> - 2015-11-25 06:40 +0100
Re: [PATCH v2] mm/cma: always check which page cause allocation failure Vlastimil Babka <vbabka@suse.cz> - 2015-11-25 11:50 +0100
| From | Vlastimil Babka <vbabka@suse.cz> |
|---|---|
| Date | 2015-11-24 16:30 +0100 |
| Subject | Re: [PATCH 3/3] mm/cma: always check which page cause allocation failure |
| Message-ID | <qynHB-1tb-37@gated-at.bofh.it> |
On 11/13/2015 03:23 AM, Joonsoo Kim wrote:
> Now, we have tracepoint in test_pages_isolated() to notify
> pfn which cannot be isolated. But, in alloc_contig_range(),
> some error path doesn't call test_pages_isolated() so it's still
> hard to know exact pfn that causes allocation failure.
>
> This patch change this situation by calling test_pages_isolated()
> in almost error path. In allocation failure case, some overhead
> is added by this change, but, allocation failure is really rare
> event so it would not matter.
>
> In fatal signal pending case, we don't call test_pages_isolated()
> because this failure is intentional one.
>
> Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> ---
> mm/page_alloc.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index d89960d..e78d78f 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -6756,8 +6756,12 @@ int alloc_contig_range(unsigned long start, unsigned long end,
> if (ret)
> return ret;
>
> + /*
> + * In case of -EBUSY, we'd like to know which page causes problem.
> + * So, just fall through. We will check it in test_pages_isolated().
> + */
> ret = __alloc_contig_migrate_range(&cc, start, end);
> - if (ret)
> + if (ret && ret != -EBUSY)
> goto done;
>
> /*
> @@ -6784,8 +6788,8 @@ int alloc_contig_range(unsigned long start, unsigned long end,
> outer_start = start;
> while (!PageBuddy(pfn_to_page(outer_start))) {
> if (++order >= MAX_ORDER) {
> - ret = -EBUSY;
> - goto done;
> + outer_start = start;
> + break;
> }
> outer_start &= ~0UL << order;
> }
Ugh isn't this crazy loop broken? Shouldn't it test that the buddy it
finds has order high enough? e.g.:
buddy = pfn_to_page(outer_start)
outer_start + (1UL << page_order(buddy)) > start
Otherwise you might end up with something like:
- at "start" there's a page that CMA failed to freed
- at "start-1" there's another non-buddy page
- at "start-3" there's an order-1 buddy, so you set outer_start to start-3
- test_pages_isolated() will complain (via the new tracepoint) about pfn
of start-1, but actually you would like it to complain about pfn of "start"?
So the loop has been broken before your patch, but it didn't matter,
just potentially wasted some time by picking bogus outer_start. But now
your tracepoint will give you weird results.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Joonsoo Kim <iamjoonsoo.kim@lge.com> |
|---|---|
| Date | 2015-11-25 03:40 +0100 |
| Message-ID | <qyy9X-8h3-1@gated-at.bofh.it> |
| In reply to | #1276569 |
On Tue, Nov 24, 2015 at 04:27:56PM +0100, Vlastimil Babka wrote:
> On 11/13/2015 03:23 AM, Joonsoo Kim wrote:
> >Now, we have tracepoint in test_pages_isolated() to notify
> >pfn which cannot be isolated. But, in alloc_contig_range(),
> >some error path doesn't call test_pages_isolated() so it's still
> >hard to know exact pfn that causes allocation failure.
> >
> >This patch change this situation by calling test_pages_isolated()
> >in almost error path. In allocation failure case, some overhead
> >is added by this change, but, allocation failure is really rare
> >event so it would not matter.
> >
> >In fatal signal pending case, we don't call test_pages_isolated()
> >because this failure is intentional one.
> >
> >Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> >---
> > mm/page_alloc.c | 10 +++++++---
> > 1 file changed, 7 insertions(+), 3 deletions(-)
> >
> >diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> >index d89960d..e78d78f 100644
> >--- a/mm/page_alloc.c
> >+++ b/mm/page_alloc.c
> >@@ -6756,8 +6756,12 @@ int alloc_contig_range(unsigned long start, unsigned long end,
> > if (ret)
> > return ret;
> >
> >+ /*
> >+ * In case of -EBUSY, we'd like to know which page causes problem.
> >+ * So, just fall through. We will check it in test_pages_isolated().
> >+ */
> > ret = __alloc_contig_migrate_range(&cc, start, end);
> >- if (ret)
> >+ if (ret && ret != -EBUSY)
> > goto done;
> >
> > /*
> >@@ -6784,8 +6788,8 @@ int alloc_contig_range(unsigned long start, unsigned long end,
> > outer_start = start;
> > while (!PageBuddy(pfn_to_page(outer_start))) {
> > if (++order >= MAX_ORDER) {
> >- ret = -EBUSY;
> >- goto done;
> >+ outer_start = start;
> >+ break;
> > }
> > outer_start &= ~0UL << order;
> > }
>
> Ugh isn't this crazy loop broken? Shouldn't it test that the buddy
> it finds has order high enough? e.g.:
> buddy = pfn_to_page(outer_start)
> outer_start + (1UL << page_order(buddy)) > start
>
> Otherwise you might end up with something like:
> - at "start" there's a page that CMA failed to freed
> - at "start-1" there's another non-buddy page
> - at "start-3" there's an order-1 buddy, so you set outer_start to start-3
> - test_pages_isolated() will complain (via the new tracepoint) about
> pfn of start-1, but actually you would like it to complain about pfn
> of "start"?
>
> So the loop has been broken before your patch, but it didn't matter,
> just potentially wasted some time by picking bogus outer_start. But
> now your tracepoint will give you weird results.
Good catch. I will fix it.
Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Joonsoo Kim <js1304@gmail.com> |
|---|---|
| Date | 2015-11-25 06:40 +0100 |
| Subject | [PATCH v2] mm/cma: always check which page cause allocation failure |
| Message-ID | <qyAY9-1PN-7@gated-at.bofh.it> |
| In reply to | #1276976 |
Now, we have tracepoint in test_pages_isolated() to notify
pfn which cannot be isolated. But, in alloc_contig_range(),
some error path doesn't call test_pages_isolated() so it's still
hard to know exact pfn that causes allocation failure.
This patch change this situation by calling test_pages_isolated()
in almost error path. In allocation failure case, some overhead
is added by this change, but, allocation failure is really rare
event so it would not matter.
In fatal signal pending case, we don't call test_pages_isolated()
because this failure is intentional one.
There was a bogus outer_start problem due to unchecked buddy order
and this patch also fix it. Before this patch, it didn't matter,
because end result is same thing. But, after this patch,
tracepoint will report failed pfn so it should be accurate.
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
---
mm/page_alloc.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index d0499ff..21e9172 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -6748,8 +6748,12 @@ int alloc_contig_range(unsigned long start, unsigned long end,
if (ret)
return ret;
+ /*
+ * In case of -EBUSY, we'd like to know which page causes problem.
+ * So, just fall through. We will check it in test_pages_isolated().
+ */
ret = __alloc_contig_migrate_range(&cc, start, end);
- if (ret)
+ if (ret && ret != -EBUSY)
goto done;
/*
@@ -6776,12 +6780,25 @@ int alloc_contig_range(unsigned long start, unsigned long end,
outer_start = start;
while (!PageBuddy(pfn_to_page(outer_start))) {
if (++order >= MAX_ORDER) {
- ret = -EBUSY;
- goto done;
+ outer_start = start;
+ break;
}
outer_start &= ~0UL << order;
}
+ if (outer_start != start) {
+ order = page_order(pfn_to_page(outer_start));
+
+ /*
+ * outer_start page could be small order buddy page and
+ * it doesn't include start page. Adjust outer_start
+ * in this case to report failed page properly
+ * on tracepoint in test_pages_isolated()
+ */
+ if (outer_start + (1UL << order) <= start)
+ outer_start = start;
+ }
+
/* Make sure the range is really isolated. */
if (test_pages_isolated(outer_start, end, false)) {
pr_info("%s: [%lx, %lx) PFNs busy\n",
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Vlastimil Babka <vbabka@suse.cz> |
|---|---|
| Date | 2015-11-25 11:50 +0100 |
| Subject | Re: [PATCH v2] mm/cma: always check which page cause allocation failure |
| Message-ID | <qyFOa-56R-25@gated-at.bofh.it> |
| In reply to | #1277026 |
On 11/25/2015 06:32 AM, Joonsoo Kim wrote: > Now, we have tracepoint in test_pages_isolated() to notify > pfn which cannot be isolated. But, in alloc_contig_range(), > some error path doesn't call test_pages_isolated() so it's still > hard to know exact pfn that causes allocation failure. > > This patch change this situation by calling test_pages_isolated() > in almost error path. In allocation failure case, some overhead > is added by this change, but, allocation failure is really rare > event so it would not matter. > > In fatal signal pending case, we don't call test_pages_isolated() > because this failure is intentional one. > > There was a bogus outer_start problem due to unchecked buddy order > and this patch also fix it. Before this patch, it didn't matter, > because end result is same thing. But, after this patch, > tracepoint will report failed pfn so it should be accurate. > > Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web