From patchwork Wed Oct 23 17:34:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 11207291 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1D275112B for ; Wed, 23 Oct 2019 17:35:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DE86921929 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 DE86921929 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) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A74946B0007; Wed, 23 Oct 2019 13:35:29 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org 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-Original-To: linux-mm@kvack.org 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-Spam-Summary: 1,0,0,,d41d8cd98f00b204,longman@redhat.com,:akpm@linux-foundation.org:mhocko@kernel.org:mgorman@suse.de::linux-kernel@vger.kernel.org:linux-api@vger.kernel.org:hannes@cmpxchg.org:guro@fb.com:vbabka@suse.cz:khlebnikov@yandex-team.ru:jannh@google.com:songliubraving@fb.com:gregkh@linuxfoundation.org:aquini@redhat.com:longman@redhat.com,RULES_HIT:4423:30034:30054:30070,0,RBL:205.139.110.61:@redhat.com:.lbl8.mailshell.net-62.18.0.100 66.10.201.10,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none 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 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_file *m, pg_data_t *pgdat, struct zone *zone) { int order, mtype; + unsigned long iteration_count = 0; for (mtype = 0; mtype < MIGRATE_TYPES; mtype++) { seq_printf(m, "Node %4d, zone %8s, type %12s ", @@ -1397,15 +1398,24 @@ static void pagetypeinfo_showfree_print(struct seq_file *m, * of pages in this order should be more than * sufficient */ - if (++freecount >= 100000) { + if (++freecount > 100000) { overflow = true; - spin_unlock_irq(&zone->lock); - cond_resched(); - spin_lock_irq(&zone->lock); + freecount--; break; } } seq_printf(m, "%s%6lu ", overflow ? ">" : "", freecount); + /* + * Take a break and release the zone lock when + * 100000 or more entries have been iterated. + */ + iteration_count += freecount; + if (iteration_count >= 100000) { + iteration_count = 0; + spin_unlock_irq(&zone->lock); + cond_resched(); + spin_lock_irq(&zone->lock); + } } seq_putc(m, '\n'); }