From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46A69CA9EB6 for ; Wed, 23 Oct 2019 17:35:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 04DE021BE5 for ; Wed, 23 Oct 2019 17:35:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PtlJoac/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 04DE021BE5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AC5956B0006; Wed, 23 Oct 2019 13:35:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A74946B0007; Wed, 23 Oct 2019 13:35:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 93BB96B0008; Wed, 23 Oct 2019 13:35:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0089.hostedemail.com [216.40.44.89]) by kanga.kvack.org (Postfix) with ESMTP id 75B626B0006 for ; Wed, 23 Oct 2019 13:35:29 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 28BFC180CE6B8 for ; Wed, 23 Oct 2019 17:35:29 +0000 (UTC) X-FDA: 76075751178.09.level98_12be68f191c0c X-HE-Tag: level98_12be68f191c0c X-Filterd-Recvd-Size: 4687 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Wed, 23 Oct 2019 17:35:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571852128; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Oah+sFD9h93XFRkeqX7YtNgEo2DG0iEGX0WBNwPsTlM=; b=PtlJoac/GG4S7ry0dD6nkG5SaAkF0h3FI4un7lYrSpp8/7UsNTL9w2pVagc2nvwclE/Zs+ Agd0dLtNUgHMXuY3IkGOUp2DRC1kOfIaOvGe4TyfAjRKRxIY6/kQDGyu8OxsdG2lUvc2oB YCFGQmx5ZSGYZrVNMHgCRdYt98JVkhs= 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-350-eJR6LbkuMiWkvuEX-NSWCw-1; Wed, 23 Oct 2019 13:35:24 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 669081800E01; Wed, 23 Oct 2019 17:35:22 +0000 (UTC) Received: from llong.com (dhcp-17-59.bos.redhat.com [10.18.17.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A3E45D6D0; Wed, 23 Oct 2019 17:35:13 +0000 (UTC) From: Waiman Long To: Andrew Morton , Michal Hocko , Mel Gorman Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Johannes Weiner , Roman Gushchin , Vlastimil Babka , Konstantin Khlebnikov , Jann Horn , Song Liu , Greg Kroah-Hartman , Rafael Aquini , Waiman Long Subject: [PATCH 1/2] mm, vmstat: Release zone lock more frequently when reading /proc/pagetypeinfo Date: Wed, 23 Oct 2019 13:34:22 -0400 Message-Id: <20191023173423.12532-1-longman@redhat.com> In-Reply-To: <20191023102737.32274-3-mhocko@kernel.org> References: <20191023102737.32274-3-mhocko@kernel.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: eJR6LbkuMiWkvuEX-NSWCw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: With a threshold of 100000, it is still possible that the zone lock will be held for a very long time in the worst case scenario where all the counts are just below the threshold. With up to 6 migration types and 11 orders, it means up to 6.6 millions. Track the total number of list iterations done since the acquisition of the zone lock and release it whenever 100000 iterations or more have been completed. This will cap the lock hold time to no more than 200,000 list iterations. Signed-off-by: Waiman Long --- mm/vmstat.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/mm/vmstat.c b/mm/vmstat.c index 57ba091e5460..c5b82fdf54af 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1373,6 +1373,7 @@ static void pagetypeinfo_showfree_print(struct seq_fi= le *m, =09=09=09=09=09pg_data_t *pgdat, struct zone *zone) { =09int order, mtype; +=09unsigned long iteration_count =3D 0; =20 =09for (mtype =3D 0; mtype < MIGRATE_TYPES; mtype++) { =09=09seq_printf(m, "Node %4d, zone %8s, type %12s ", @@ -1397,15 +1398,24 @@ static void pagetypeinfo_showfree_print(struct seq_= file *m, =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=09if (++freecount > 100000) { =09=09=09=09=09overflow =3D true; -=09=09=09=09=09spin_unlock_irq(&zone->lock); -=09=09=09=09=09cond_resched(); -=09=09=09=09=09spin_lock_irq(&zone->lock); +=09=09=09=09=09freecount--; =09=09=09=09=09break; =09=09=09=09} =09=09=09} =09=09=09seq_printf(m, "%s%6lu ", overflow ? ">" : "", freecount); +=09=09=09/* +=09=09=09 * Take a break and release the zone lock when +=09=09=09 * 100000 or more entries have been iterated. +=09=09=09 */ +=09=09=09iteration_count +=3D freecount; +=09=09=09if (iteration_count >=3D 100000) { +=09=09=09=09iteration_count =3D 0; +=09=09=09=09spin_unlock_irq(&zone->lock); +=09=09=09=09cond_resched(); +=09=09=09=09spin_lock_irq(&zone->lock); +=09=09=09} =09=09} =09=09seq_putc(m, '\n'); =09} --=20 2.18.1