Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp661038ybb; Wed, 1 Apr 2020 07:28:20 -0700 (PDT) X-Google-Smtp-Source: APiQypLDL5NgGjZ5PWVraepWwih8vq9jHMIEXomHPtRqEAT7Bz3igY14N+zDZFAq6l98jukSE4qs X-Received: by 2002:aca:4046:: with SMTP id n67mr3078266oia.156.1585751299992; Wed, 01 Apr 2020 07:28:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585751299; cv=none; d=google.com; s=arc-20160816; b=No0r7JbUYW55+zS2GVZLVM4uJHUkGfyn8czvrhysKcZ7uz4ki26YhQdkRKQao1RU5s dhi3cCt15k+Sei4it0YV8heCPeU5OLdLllte+YaAjC22Ut4XHJCHJYV9cwGFFMQolDPt 1a3BGz2DG1xeGc+UMCMP9PAmyzY6a4dh5Cf2SOBkwOEf1mxEwhGdnYV/gFXuMv2xLjqq 1Sgvr3C0kIqEgO5ayh1xLqLcJ+kOgTgsVzHb5uw8tPqAXAcUl+eoxydyib0lKtMCvg0i JuSyBx645Br/vQ3dx/O1PburDHhAt63i/TnlG7H3MSrdnXfRZMEuNz0fIWx4QpBviK1Q +n+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:autocrypt:from:references:cc:to:subject :dkim-signature; bh=8tB83+dbj/600s4YRU2mDkikcjzMDvEbsmaON6HB5KA=; b=gi3P0UpXqoGppO4+wDU/7pz84BH5/z2S0Tab9BPR6Vo3VIYLjGOLLBXQGgYDa22pCk Jf0UAOtc4jIiaxwzHIYTWe0EgevJMf2RYH61UlrxCgIXJCwak1WZpLsPhmHtkKCgzw4r /2LUMS/Eqbomv11ERDAitPyJxWQl/GELRg51prIhLovsUgEu+/eB/fWxbwvcTN8Dsdw6 09fwytku0leFHqyJa7fgEFL0PJigxMu+AKTAYEP1SIuYHSXdM23AZI9oqz3nvsEY3XNt M3/41GWmCHuzHi6Tz448ddMPjurur7oRwbGqgga0Pv35zWHpJ8YdI1UMj0m7kIiudRgH z59g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bAFfLXaW; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t6si975977oib.255.2020.04.01.07.28.05; Wed, 01 Apr 2020 07:28:19 -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=@redhat.com header.s=mimecast20190719 header.b=bAFfLXaW; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726640AbgDAO0N (ORCPT + 99 others); Wed, 1 Apr 2020 10:26:13 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:24802 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732749AbgDAO0N (ORCPT ); Wed, 1 Apr 2020 10:26:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585751172; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=8tB83+dbj/600s4YRU2mDkikcjzMDvEbsmaON6HB5KA=; b=bAFfLXaWXaeM2mGfBdr8IkWAeipznvWwB/McBCJWmYSBDNSOllkP7Wh8EkA52Ror1zu+im qA8rib2IRZWArudCzdOG2fYyK+8XqtZAKYFt++7+Qv93vNNWb6nwQp56LbOfRiqr/7xxzH lqKgdddrY9mUazWKuYOGF1VwGHytd/0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-181-sfGd8DJKOUGMlyAd9TRAOg-1; Wed, 01 Apr 2020 10:26:10 -0400 X-MC-Unique: sfGd8DJKOUGMlyAd9TRAOg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 66A8918AB2E4; Wed, 1 Apr 2020 14:26:08 +0000 (UTC) Received: from [10.36.114.59] (ovpn-114-59.ams2.redhat.com [10.36.114.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id E859410016EB; Wed, 1 Apr 2020 14:26:06 +0000 (UTC) Subject: Re: [PATCH v3] mm: fix tick timer stall during deferred page init To: Shile Zhang , Andrew Morton , Kirill Tkhai , Pavel Tatashin Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20200311123848.118638-1-shile.zhang@linux.alibaba.com> From: David Hildenbrand Autocrypt: addr=david@redhat.com; prefer-encrypt=mutual; keydata= mQINBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8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zFVU//qVs6uzhsNk0RYMyS0B6oloW3FpyQ+zOVylFWQCzoyyf227y GW8HnXunJSC+4PtlL2AY4yZjAVAPLK2l6mhgClVXTQ/S7cBoTQKP+jvVJOoYkpnFxWE9pn4t H5QIFk7Ip8TKr5k3fXVWk4lnUi9MTF/5L/mWqdyIO1s7cjharQCstfWCzWrVeVctpVoDfJWp 4LwTuQ5yEM2KcPeElLg5fR7WB2zH97oI6/Ko2DlovmfQqXh9xWozQt0iGy5tWzh6I0JrlcxJ ileZWLccC4XKD1037Hy2FLAjzfoWgwBLA6ULu0exOOdIa58H4PsXtkFPrUF980EEibUp0zFz GotRVekFAceUaRvAj7dh76cToeZkfsjAvBVb4COXuhgX6N4pofgNkW2AtgYu1nUsPAo+NftU CxrhjHtLn4QEBpkbErnXQyMjHpIatlYGutVMS91XTQXYydCh5crMPs7hYVsvnmGHIaB9ZMfB njnuI31KBiLUks+paRkHQlFcgS2N3gkRBzH7xSZ+t7Re3jvXdXEzKBbQ+dC3lpJB0wPnyMcX FOTT3aZT7IgePkt5iC/BKBk3hqKteTnJFeVIT7EC+a6YUFg= Organization: Red Hat GmbH Message-ID: <1ca342ec-23e7-7884-5758-2b14675266e4@redhat.com> Date: Wed, 1 Apr 2020 16:26:06 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200311123848.118638-1-shile.zhang@linux.alibaba.com> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11.03.20 13:38, Shile Zhang wrote: > When 'CONFIG_DEFERRED_STRUCT_PAGE_INIT' is set, 'pgdatinit' kthread wil= l > initialise the deferred pages with local interrupts disabled. It is > introduced by commit 3a2d7fa8a3d5 ("mm: disable interrupts while > initializing deferred pages"). >=20 > On machine with NCPUS <=3D 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. >=20 > The dmesg shown that: >=20 > [ 0.197975] node 0 initialised, 32170688 pages in 1ms >=20 > Obviously, 1ms is unreasonable. >=20 > Now, fix it by restore in the pending interrupts for every 32*1204 page= s > (128MB) initialized, give the chance to update the systemd jiffies. > The reasonable demsg shown likes: >=20 > [ 1.069306] node 0 initialised, 32203456 pages in 894ms >=20 > Fixes: 3a2d7fa8a3d5 ("mm: disable interrupts while initializing deferre= d pages"). >=20 > 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(-) >=20 > 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 *zon= e, unsigned long *start_pfn, > return nr_pages; > } > =20 > +/* > + * 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 =3D data; > const struct cpumask *cpumask =3D cpumask_of_node(pgdat->node_id); > - unsigned long spfn =3D 0, epfn =3D 0, nr_pages =3D 0; > + unsigned long spfn =3D 0, epfn =3D 0, nr_pages =3D 0, prev_nr_pages =3D= 0; > unsigned long first_init_pfn, flags; > unsigned long start =3D 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); > =20 > +again: > pgdat_resize_lock(pgdat, &flags); > first_init_pfn =3D pgdat->first_deferred_pfn; > if (first_init_pfn =3D=3D 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 =3D ULONG_MAX; > =20 > /* Only the highest zone is deferred so find it */ > for (zid =3D 0; zid < MAX_NR_ZONES; zid++) { > @@ -1809,9 +1814,23 @@ static int __init deferred_init_memmap(void *dat= a) > * that we can avoid introducing any issues with the buddy > * allocator. > */ > - while (spfn < epfn) > + while (spfn < epfn) { > nr_pages +=3D 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 Nit: 128MB is only true for 4k pages. > + * system jiffies. > + */ > + if ((nr_pages - prev_nr_pages) > TICK_PAGE_COUNT) { > + prev_nr_pages =3D nr_pages; > + pgdat->first_deferred_pfn =3D spfn; > + pgdat_resize_unlock(pgdat, &flags); > + goto again; > + } > + } > + I find that deferred page init code horribly complicated to understand, but that's a different story. Your change looks sane to me and survives my basic testing. Thanks! Acked-by: David Hildenbrand --=20 Thanks, David / dhildenb