Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp786353ybh; Wed, 11 Mar 2020 10:46:35 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvfuYqk2Dgby5aDnUwTyTR66gjeh4Hl/6p7J1cZOCVeGDxhC7FnTgogAErR6Fk+fdW6ICl3 X-Received: by 2002:a9d:7c9a:: with SMTP id q26mr3394351otn.206.1583948795070; Wed, 11 Mar 2020 10:46:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583948795; cv=none; d=google.com; s=arc-20160816; b=gCoalX71+A/3Pqp/SSi32NxkgPisVqC/ZZSEiLr7Vbs8om/xwUn2NNxxbeV8Wg9MpH tfTlU3eOq9h56m6ta+ypckLdoK1N/NQj0Rd5jGvASe9YMGg3qaYfpJvpu50n02F/kXks 9nDZ/okMjlOmUJIsfW5tt7OgIRqvc1L85svm3h/gmRI7wBsldoPAe1xlfCse0/UQyRJz AUPFbaXcFyqxBfn0ylu2Ku0FHxMq+1ncWeuMZJL//1i8L6UrWJ0RZdc5/4v+xjz1pkKV B4itedbG/HEXs+ojpwtU+BK0RyvimieV6qW441WdeO6SBUdKK0JzS3TCYlFTM42krtNJ wJjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=g0bFqwsXkUukHh8ZfDKot08BOWer+gFninhmoUg4N4E=; b=pCYpUdnEvhyhDcWtbpEUmFuG29yDNeRFHuGYTxnQYW4/OjkGtzXIHQkekyg8ubffO9 6ZaN6LTGbch71SMtMlYu9BXm34y7q6N9v0LIDVKlDAGXIS1/kZH1PBi9jFnRqQ929z/D /lpdgF++keyY9wdKucgcuudcRtERVmCnz3pXSBZKyULVeYQ8oEapJWn8FaYFI9Oze0Wp JiacZo9A5qP0K1XuIKrNFqjXSDB2yFIgSNMi7fYanw4SGjo7Oquv3iSxhGL9biqk34Jt q9EJUPhU9M5u8SrCVAJkbW5q8BgDQu+g6yuy7se8OOr6CpZ+Yg7sX1rzF6q01o8k76GX 6HTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=hP0KGGjq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a3si1425976oie.164.2020.03.11.10.46.23; Wed, 11 Mar 2020 10:46:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=hP0KGGjq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730690AbgCKRpT (ORCPT + 99 others); Wed, 11 Mar 2020 13:45:19 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:41213 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730624AbgCKRpR (ORCPT ); Wed, 11 Mar 2020 13:45:17 -0400 Received: by mail-ed1-f67.google.com with SMTP id m25so3900154edq.8 for ; Wed, 11 Mar 2020 10:45:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=g0bFqwsXkUukHh8ZfDKot08BOWer+gFninhmoUg4N4E=; b=hP0KGGjqaMgRA4J7UQgYmOlx7VkzP0/sjYdfJ/2GmHapvrqjnyoyHI8+DQQfzi6xf/ nNCLkXm17Dfa5oVtbfCkrKT0PvAFyNKjn7Rf9P9jyrorKlGVigawlGZ93mmvCLR1tGpk DwwNenl0Av3HBTOa4oVJsOk9fVK1C6sFYAgA5XZR80mOTseCDx47FLomQnGOecrSvwXW 0tSbUvndpYS30PHYZe4LenZnmzs7CYwSn1Rvw1EmgMdLWkZALLdlD3pVTOV58AEbz9K7 15L1g4d4KWQUnINWXZ5jmf/zb0MquJw7Ab+Qn0Orfx0JZaJJsp4zOjlNngJFaLSCv+h+ AJ5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=g0bFqwsXkUukHh8ZfDKot08BOWer+gFninhmoUg4N4E=; b=FMQNYGs5Dg58i4ggC4OzRD1SDrNXTOjtIwBhao/4frWIMgpfsXf0+T/wf6nPoZe3vl QhgPWaWr3WGVPUGiaaXnX5UbpSa11qiG4HzSBXiySphMQwAzSy+cw948tHK6cnKcPLBp nR+cWqwlRZgwT1RLMW2WaniP00l5Aa8YMN3ITRiZh+VL7+3JZ2dlxe35nw+9V3pUPSlr yDzLNEjnuecBYY1AZtU3ljlf1MIK8CypiabZ22M1tQ9M7HB6e+mZOroMAH4cxI/vXUDa dEZ9B5sNDRzOMDA6l3ICol+5d15vlvNIwCxRqF4KhfGqHJ5P8pYbTWQgkgaz3u3vyj04 nZOQ== X-Gm-Message-State: ANhLgQ3CrTW9dcXv/xdsXZNshvnnyg9PK1d+BJ45MTDxdT03Wu/M5zKV ZzLR4MO1MU6pNf7r23F5sv4dhgkRXufgXdKcU1cI9A== X-Received: by 2002:a05:6402:343:: with SMTP id r3mr2781292edw.85.1583948715601; Wed, 11 Mar 2020 10:45:15 -0700 (PDT) MIME-Version: 1.0 References: <20200311123848.118638-1-shile.zhang@linux.alibaba.com> In-Reply-To: <20200311123848.118638-1-shile.zhang@linux.alibaba.com> From: Pavel Tatashin Date: Wed, 11 Mar 2020 13:45:04 -0400 Message-ID: Subject: Re: [PATCH v3] mm: fix tick timer stall during deferred page init To: Shile Zhang Cc: Andrew Morton , Kirill Tkhai , linux-mm , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 11, 2020 at 8:39 AM Shile Zhang wrote: > > When 'CONFIG_DEFERRED_STRUCT_PAGE_INIT' is set, 'pgdatinit' kthread will > initialise the deferred pages with local interrupts disabled. It is > introduced by commit 3a2d7fa8a3d5 ("mm: disable interrupts while > initializing deferred pages"). > > On machine with NCPUS <= 2, the 'pgdatinit' kthread could be bound to > the boot CPU, which could caused the tick timer long time stall, system > jiffies not be updated in time. > > The dmesg shown that: > > [ 0.197975] node 0 initialised, 32170688 pages in 1ms > > Obviously, 1ms is unreasonable. > > Now, fix it by restore in the pending interrupts for every 32*1204 pages > (128MB) initialized, give the chance to update the systemd jiffies. > The reasonable demsg shown likes: > > [ 1.069306] node 0 initialised, 32203456 pages in 894ms Sorry for joining late to this thread. I wonder if we could use sched_clock() to print this statistics. Or not to print statistics at all? ============== diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 3c4eb750a199..5958f599aced 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1770,7 +1770,7 @@ static int __init deferred_init_memmap(void *data) const struct cpumask *cpumask = cpumask_of_node(pgdat->node_id); unsigned long spfn = 0, epfn = 0, nr_pages = 0; unsigned long first_init_pfn, flags; - unsigned long start = jiffies; + unsigned long start = sched_clock(); struct zone *zone; int zid; u64 i; @@ -1817,8 +1817,8 @@ static int __init deferred_init_memmap(void *data) /* Sanity check that the next zone really is unpopulated */ WARN_ON(++zid < MAX_NR_ZONES && populated_zone(++zone)); - pr_info("node %d initialised, %lu pages in %ums\n", - pgdat->node_id, nr_pages, jiffies_to_msecs(jiffies - start)); + pr_info("node %d initialised, %lu pages in %lldns\n", + pgdat->node_id, nr_pages, sched_clock() - start); pgdat_init_report_one_done(); return 0; ============== [ 1.245331] node 0 initialised, 10256176 pages in 373565742ns Pasha > Fixes: 3a2d7fa8a3d5 ("mm: disable interrupts while initializing deferred pages"). > > Co-developed-by: Kirill Tkhai > Signed-off-by: Kirill Tkhai > Signed-off-by: Shile Zhang > --- > mm/page_alloc.c | 25 ++++++++++++++++++++++--- > 1 file changed, 22 insertions(+), 3 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 3c4eb750a199..a3a47845e150 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -1763,12 +1763,17 @@ deferred_init_maxorder(u64 *i, struct zone *zone, unsigned long *start_pfn, > return nr_pages; > } > > +/* > + * Release the pending interrupts for every TICK_PAGE_COUNT pages. > + */ > +#define TICK_PAGE_COUNT (32 * 1024) > + > /* Initialise remaining memory on a node */ > static int __init deferred_init_memmap(void *data) > { > pg_data_t *pgdat = data; > const struct cpumask *cpumask = cpumask_of_node(pgdat->node_id); > - unsigned long spfn = 0, epfn = 0, nr_pages = 0; > + unsigned long spfn = 0, epfn = 0, nr_pages = 0, prev_nr_pages = 0; > unsigned long first_init_pfn, flags; > unsigned long start = jiffies; > struct zone *zone; > @@ -1779,6 +1784,7 @@ static int __init deferred_init_memmap(void *data) > if (!cpumask_empty(cpumask)) > set_cpus_allowed_ptr(current, cpumask); > > +again: > pgdat_resize_lock(pgdat, &flags); > first_init_pfn = pgdat->first_deferred_pfn; > if (first_init_pfn == ULONG_MAX) { > @@ -1790,7 +1796,6 @@ static int __init deferred_init_memmap(void *data) > /* Sanity check boundaries */ > BUG_ON(pgdat->first_deferred_pfn < pgdat->node_start_pfn); > BUG_ON(pgdat->first_deferred_pfn > pgdat_end_pfn(pgdat)); > - pgdat->first_deferred_pfn = ULONG_MAX; > > /* Only the highest zone is deferred so find it */ > for (zid = 0; zid < MAX_NR_ZONES; zid++) { > @@ -1809,9 +1814,23 @@ static int __init deferred_init_memmap(void *data) > * that we can avoid introducing any issues with the buddy > * allocator. > */ > - while (spfn < epfn) > + while (spfn < epfn) { > nr_pages += deferred_init_maxorder(&i, zone, &spfn, &epfn); > + /* > + * Release the interrupts for every TICK_PAGE_COUNT pages > + * (128MB) to give tick timer the chance to update the > + * system jiffies. > + */ > + if ((nr_pages - prev_nr_pages) > TICK_PAGE_COUNT) { > + prev_nr_pages = nr_pages; > + pgdat->first_deferred_pfn = spfn; > + pgdat_resize_unlock(pgdat, &flags); > + goto again; > + } > + } > + > zone_empty: > + pgdat->first_deferred_pfn = ULONG_MAX; > pgdat_resize_unlock(pgdat, &flags); > > /* Sanity check that the next zone really is unpopulated */ > -- > 2.24.0.rc2 >