Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4094302ybg; Fri, 25 Oct 2019 13:14:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqxCm4VPl10MEzYEqd8Q35j5B7JVqsCA2weOzHyTofmuQia48kCUmWjaI2DiHdfp5D2VR1t5 X-Received: by 2002:aa7:c24c:: with SMTP id y12mr5924608edo.180.1572034455778; Fri, 25 Oct 2019 13:14:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572034455; cv=none; d=google.com; s=arc-20160816; b=kCqTWwUy9j5LvZLCKSMPtBOl5v/r16Bx+7h/4BMAdjwgpPbdTLl+TV2PA39b2peCpo EqvsjrZgHYSUrKexkGxuKkMYWeiOA+layxz4CodArwoB21i8+uOxJ7XUSfeGn6wrlYfI CjUpUDVCHYz3C7Ou4MffrJJx2HYUmlenR5eo4I+Pba5VVKzGfgdwsRatM2fLdXxsTr/I dmRBWgjIk2gaRYzc4cw2DoICE/uwRG4B8ecwc5oDmWNMG27l156hDc+9HFMHo/3Sr2Ka nPhy50Zt3FUDx2KbuxkKls0IaxkvP5DVOVyMDX6Vq0e7bSxecZsAFqSAMkteGCtk1DrY NVAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:user-agent:in-reply-to:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=n8i+TCwhs+dWNyEedELhI+i+2i1MD1dNVmQL25FSLho=; b=SWiXQoXRrQfbWTLDLww0kXKDvuKvj+krkJhp5CXx2m6FM/3yIBYuKImyYMNtc8mG5x 8gtFFoVm1xgt5OWxYgxgqjKMsMrbYl20cj1Cq3hvUE/JlOlJkfMfNPn7zkwVegKe8GES XXNyhDU5nXpfWDYyCemoxt0flOFyu0UNL+MYfyUI5wnR2/WuqDFvZaKHg6q8lRx9PpP7 M11itplabPS5vJpcoiWwDkk3zqKxxHUTp5dnkTwaPW51m4m+sHUrxi8pqDo+HfK74uCG F6LtRTpkjSugeIh62/Dv63cvNFb5yMVL7scbBfHb2TmrtgUkK+c3HlXd6nhXubjXMp5l 02xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jE1NTew1; 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 i32si2020224ede.394.2019.10.25.13.13.52; Fri, 25 Oct 2019 13:14:15 -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=jE1NTew1; 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 S2504628AbfJYMwl (ORCPT + 99 others); Fri, 25 Oct 2019 08:52:41 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:28512 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2501908AbfJYMwk (ORCPT ); Fri, 25 Oct 2019 08:52:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572007959; 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; bh=n8i+TCwhs+dWNyEedELhI+i+2i1MD1dNVmQL25FSLho=; b=jE1NTew1lG5YZVM3W/f3hVHMophYRDCAOl3HYHcmLL6ec3tWvyQhgd4s8QIPkktxAxniQh Fvxo5H0QzxExHWBvDzZHOXUV/msWVmqQeVGx/T72AN+zozJiYa6whu4K/sxIJI8aV+7rfL S8K4aM9Qd7eMhEn5zXByD5mXUj0ULLg= 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-322-T_9r8giqN4iMM0deT0aUtQ-1; Fri, 25 Oct 2019 08:52:35 -0400 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 EF95A800D41; Fri, 25 Oct 2019 12:52:32 +0000 (UTC) Received: from optiplex-lnx (ovpn-112-25.rdu2.redhat.com [10.10.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 74E5E10013A1; Fri, 25 Oct 2019 12:52:25 +0000 (UTC) Date: Fri, 25 Oct 2019 08:52:22 -0400 From: Rafael Aquini To: Michal Hocko Cc: Andrew Morton , Mel Gorman , Waiman Long , Johannes Weiner , Roman Gushchin , Vlastimil Babka , Konstantin Khlebnikov , Jann Horn , Song Liu , Greg Kroah-Hartman , linux-mm@kvack.org, LKML , Michal Hocko Subject: Re: [PATCH 2/2] mm, vmstat: reduce zone->lock holding time by /proc/pagetypeinfo Message-ID: <20191025125222.GC4596@optiplex-lnx> References: <20191025072610.18526-1-mhocko@kernel.org> <20191025072610.18526-3-mhocko@kernel.org> MIME-Version: 1.0 In-Reply-To: <20191025072610.18526-3-mhocko@kernel.org> User-Agent: Mutt/1.12.1 (2019-06-15) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: T_9r8giqN4iMM0deT0aUtQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 25, 2019 at 09:26:10AM +0200, Michal Hocko wrote: > From: Michal Hocko >=20 > pagetypeinfo_showfree_print is called by zone->lock held in irq mode. > This is not really nice because it blocks both any interrupts on that > cpu and the page allocator. On large machines this might even trigger > the hard lockup detector. >=20 > Considering the pagetypeinfo is a debugging tool we do not really need > exact numbers here. The primary reason to look at the outuput is to see > how pageblocks are spread among different migratetypes and low number of > pages is much more interesting therefore putting a bound on the number > of pages on the free_list sounds like a reasonable tradeoff. >=20 > The new output will simply tell > [...] > Node 6, zone Normal, type Movable >100000 >100000 >100000 >1000= 00 41019 31560 23996 10054 3229 983 648 >=20 > instead of > Node 6, zone Normal, type Movable 399568 294127 221558 102119 = 41019 31560 23996 10054 3229 983 648 >=20 > The limit has been chosen arbitrary and it is a subject of a future > change should there be a need for that. >=20 > While we are at it, also drop the zone lock after each free_list > iteration which will help with the IRQ and page allocator responsiveness > even further as the IRQ lock held time is always bound to those 100k > pages. >=20 > Suggested-by: Andrew Morton > Reviewed-by: Waiman Long > Signed-off-by: Michal Hocko > --- > mm/vmstat.c | 23 ++++++++++++++++++++--- > 1 file changed, 20 insertions(+), 3 deletions(-) >=20 > diff --git a/mm/vmstat.c b/mm/vmstat.c > index 4e885ecd44d1..ddb89f4e0486 100644 > --- a/mm/vmstat.c > +++ b/mm/vmstat.c > @@ -1383,12 +1383,29 @@ static void pagetypeinfo_showfree_print(struct se= q_file *m, > =09=09=09unsigned long freecount =3D 0; > =09=09=09struct free_area *area; > =09=09=09struct list_head *curr; > +=09=09=09bool overflow =3D false; > =20 > =09=09=09area =3D &(zone->free_area[order]); > =20 > -=09=09=09list_for_each(curr, &area->free_list[mtype]) > -=09=09=09=09freecount++; > -=09=09=09seq_printf(m, "%6lu ", freecount); > +=09=09=09list_for_each(curr, &area->free_list[mtype]) { > +=09=09=09=09/* > +=09=09=09=09 * Cap the free_list iteration because it might > +=09=09=09=09 * be really large and we are under a spinlock > +=09=09=09=09 * so a long time spent here could trigger a > +=09=09=09=09 * hard lockup detector. Anyway this is a > +=09=09=09=09 * debugging tool so knowing there is a handful > +=09=09=09=09 * of pages in this order should be more than > +=09=09=09=09 * sufficient > +=09=09=09=09 */ > +=09=09=09=09if (++freecount >=3D 100000) { > +=09=09=09=09=09overflow =3D true; > +=09=09=09=09=09break; > +=09=09=09=09} > +=09=09=09} > +=09=09=09seq_printf(m, "%s%6lu ", overflow ? ">" : "", freecount); > +=09=09=09spin_unlock_irq(&zone->lock); > +=09=09=09cond_resched(); > +=09=09=09spin_lock_irq(&zone->lock); > =09=09} > =09=09seq_putc(m, '\n'); > =09} > --=20 > 2.20.1 >=20 Acked-by: Rafael Aquini