Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1692941 > unrolled thread
| Started by | Vlastimil Babka <vbabka@suse.cz> |
|---|---|
| First post | 2017-07-20 15:50 +0200 |
| Last post | 2017-07-24 15:00 +0200 |
| Articles | 2 — 2 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.
[PATCH 3/4] mm, page_owner: don't grab zone->lock for init_pages_in_zone() Vlastimil Babka <vbabka@suse.cz> - 2017-07-20 15:50 +0200
Re: [PATCH 3/4] mm, page_owner: don't grab zone->lock for init_pages_in_zone() Michal Hocko <mhocko@kernel.org> - 2017-07-24 15:00 +0200
| From | Vlastimil Babka <vbabka@suse.cz> |
|---|---|
| Date | 2017-07-20 15:50 +0200 |
| Subject | [PATCH 3/4] mm, page_owner: don't grab zone->lock for init_pages_in_zone() |
| Message-ID | <u5k01-8cN-1@gated-at.bofh.it> |
init_pages_in_zone() is run under zone->lock, which means a long lock time and
disabled interrupts on large machines. This is currently not an issue since it
runs early in boot, but a later patch will change that.
However, like other pfn scanners, we don't actually need zone->lock even when
other cpus are running. The only potentially dangerous operation here is
reading bogus buddy page owner due to race, and we already know how to handle
that. The worse that can happen is that we skip some early allocated pages,
which should not affect the debugging power of page_owner noticeably.
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
---
mm/page_owner.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/mm/page_owner.c b/mm/page_owner.c
index 5aa21ca237d9..cf6568d1dc14 100644
--- a/mm/page_owner.c
+++ b/mm/page_owner.c
@@ -567,11 +567,17 @@ static void init_pages_in_zone(pg_data_t *pgdat, struct zone *zone)
continue;
/*
- * We are safe to check buddy flag and order, because
- * this is init stage and only single thread runs.
+ * To avoid having to grab zone->lock, be a little
+ * careful when reading buddy page order. The only
+ * danger is that we skip too much and potentially miss
+ * some early allocated pages, which is better than
+ * heavy lock contention.
*/
if (PageBuddy(page)) {
- pfn += (1UL << page_order(page)) - 1;
+ unsigned long order = page_order_unsafe(page);
+
+ if (order > 0 && order < MAX_ORDER)
+ pfn += (1UL << order) - 1;
continue;
}
@@ -590,6 +596,7 @@ static void init_pages_in_zone(pg_data_t *pgdat, struct zone *zone)
__set_page_owner_init(page_ext, init_handle);
count++;
}
+ cond_resched();
}
pr_info("Node %d, zone %8s: page owner found early allocated %lu pages\n",
@@ -600,15 +607,12 @@ static void init_zones_in_node(pg_data_t *pgdat)
{
struct zone *zone;
struct zone *node_zones = pgdat->node_zones;
- unsigned long flags;
for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; ++zone) {
if (!populated_zone(zone))
continue;
- spin_lock_irqsave(&zone->lock, flags);
init_pages_in_zone(pgdat, zone);
- spin_unlock_irqrestore(&zone->lock, flags);
}
}
--
2.13.2
[toc] | [next] | [standalone]
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2017-07-24 15:00 +0200 |
| Subject | Re: [PATCH 3/4] mm, page_owner: don't grab zone->lock for init_pages_in_zone() |
| Message-ID | <u6L7R-4Yh-31@gated-at.bofh.it> |
| In reply to | #1692941 |
On Thu 20-07-17 15:40:28, Vlastimil Babka wrote:
> init_pages_in_zone() is run under zone->lock, which means a long lock time and
> disabled interrupts on large machines. This is currently not an issue since it
> runs early in boot, but a later patch will change that.
> However, like other pfn scanners, we don't actually need zone->lock even when
> other cpus are running. The only potentially dangerous operation here is
> reading bogus buddy page owner due to race, and we already know how to handle
> that. The worse that can happen is that we skip some early allocated pages,
> which should not affect the debugging power of page_owner noticeably.
Makes sense to me
> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: Michal Hocko <mhocko@suse.com>
> ---
> mm/page_owner.c | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/mm/page_owner.c b/mm/page_owner.c
> index 5aa21ca237d9..cf6568d1dc14 100644
> --- a/mm/page_owner.c
> +++ b/mm/page_owner.c
> @@ -567,11 +567,17 @@ static void init_pages_in_zone(pg_data_t *pgdat, struct zone *zone)
> continue;
>
> /*
> - * We are safe to check buddy flag and order, because
> - * this is init stage and only single thread runs.
> + * To avoid having to grab zone->lock, be a little
> + * careful when reading buddy page order. The only
> + * danger is that we skip too much and potentially miss
> + * some early allocated pages, which is better than
> + * heavy lock contention.
> */
> if (PageBuddy(page)) {
> - pfn += (1UL << page_order(page)) - 1;
> + unsigned long order = page_order_unsafe(page);
> +
> + if (order > 0 && order < MAX_ORDER)
> + pfn += (1UL << order) - 1;
> continue;
> }
>
> @@ -590,6 +596,7 @@ static void init_pages_in_zone(pg_data_t *pgdat, struct zone *zone)
> __set_page_owner_init(page_ext, init_handle);
> count++;
> }
> + cond_resched();
> }
>
> pr_info("Node %d, zone %8s: page owner found early allocated %lu pages\n",
> @@ -600,15 +607,12 @@ static void init_zones_in_node(pg_data_t *pgdat)
> {
> struct zone *zone;
> struct zone *node_zones = pgdat->node_zones;
> - unsigned long flags;
>
> for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; ++zone) {
> if (!populated_zone(zone))
> continue;
>
> - spin_lock_irqsave(&zone->lock, flags);
> init_pages_in_zone(pgdat, zone);
> - spin_unlock_irqrestore(&zone->lock, flags);
> }
> }
>
> --
> 2.13.2
--
Michal Hocko
SUSE Labs
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web