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'); } From patchwork Wed Oct 23 17:34:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 11207293 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 5565C112B for ; Wed, 23 Oct 2019 17:35:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 223C021906 for ; Wed, 23 Oct 2019 17:35:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bqHj+xvP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 223C021906 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 A9BF96B0007; Wed, 23 Oct 2019 13:35:31 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A4E066B0008; Wed, 23 Oct 2019 13:35:31 -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 8C6366B000A; Wed, 23 Oct 2019 13:35:31 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0196.hostedemail.com [216.40.44.196]) by kanga.kvack.org (Postfix) with ESMTP id 6F3DB6B0007 for ; Wed, 23 Oct 2019 13:35:31 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 21DC18419 for ; Wed, 23 Oct 2019 17:35:31 +0000 (UTC) X-FDA: 76075751262.24.verse36_1307540a5a508 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:30029:30034:30054:30070:30090,0,RBL:205.139.110.120:@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:24,LUA_SUMMARY:none X-HE-Tag: verse36_1307540a5a508 X-Filterd-Recvd-Size: 4565 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Wed, 23 Oct 2019 17:35:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571852130; 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=pYPluV593635tS2En896gI8nsdrbZHAmMeMjWWNFoNQ=; b=bqHj+xvPlJ3pHHEVJTKupVCycdfvW4gSoedVTdQDpkhgN2vHhQhTEpYNWDgUvfsOp+QWEX +LRE7yuMThSaxmo9c8M1tvS9eW3QKus1z73bxqxUKQd/8lmiy4Iau0v5GSP9RVEI5xCHWA awHGrR2CCqZW1YLN5IjVgtig4BI0HtQ= 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-236-86yMyZUaPui-i3hDilpdVA-1; Wed, 23 Oct 2019 13:35:26 -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 645CA107AD34; Wed, 23 Oct 2019 17:35:24 +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 8CABF5D6D0; Wed, 23 Oct 2019 17:35:22 +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 2/2] mm, vmstat: List total free blocks for each order in /proc/pagetypeinfo Date: Wed, 23 Oct 2019 13:34:23 -0400 Message-Id: <20191023173423.12532-2-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: 86yMyZUaPui-i3hDilpdVA-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: Now that the free block count for each migration types in /proc/pagetypeinfo may not show the exact count if it excceeds 100,000. Users may not know how much more the counts will be. As the free_area structure has already tracked the total free block count in nr_free, we may as well print it out with no additional cost. That will give users a rough idea of where the upper bounds will be. If there is no overflow, the presence of the total counts will also enable us to check if the nr_free counts match the total number of entries in the free lists. Signed-off-by: Waiman Long --- mm/vmstat.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mm/vmstat.c b/mm/vmstat.c index c5b82fdf54af..172946d8f358 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; + struct free_area *area; unsigned long iteration_count = 0; for (mtype = 0; mtype < MIGRATE_TYPES; mtype++) { @@ -1382,7 +1383,6 @@ static void pagetypeinfo_showfree_print(struct seq_file *m, migratetype_names[mtype]); for (order = 0; order < MAX_ORDER; ++order) { unsigned long freecount = 0; - struct free_area *area; struct list_head *curr; bool overflow = false; @@ -1419,6 +1419,17 @@ static void pagetypeinfo_showfree_print(struct seq_file *m, } seq_putc(m, '\n'); } + + /* + * List total free blocks per order + */ + seq_printf(m, "Node %4d, zone %8s, total ", + pgdat->node_id, zone->name); + for (order = 0; order < MAX_ORDER; ++order) { + area = &(zone->free_area[order]); + seq_printf(m, "%6lu ", area->nr_free); + } + seq_putc(m, '\n'); } /* Print out the free pages at each order for each migatetype */