Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1904766ybg; Thu, 24 Oct 2019 01:49:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQQLpXz7Dd+bRyVB12X1+iEysSIaOmwlL/iuIWqDdYXkZVx9xsPOPMm8thE+5hm7/Z/c0r X-Received: by 2002:a05:6402:1614:: with SMTP id f20mr855045edv.202.1571906961491; Thu, 24 Oct 2019 01:49:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571906961; cv=none; d=google.com; s=arc-20160816; b=XaQYIrR41Dru/ceLD1voizEgOxaHYTSjaIizMdJaMco9RSlHA2OMBFX+geK62Y+PgU cN5OQj78jq+8MODxQ8JzPza+qLheYaPEGxLx0aW40Vg21PWup964YD8X8EPMAzeoUjq6 bcz9uieoNxEqbZEWcFxVkN5++xw52t22vxOCHWKSzqrzzLtnn9jpJwLIbXLk+btEgX/6 hom7518Gs2lxxhZ1nBBhxJf+w3gak0kHl9BmQG1U2oN4pEflV9XBJHjmiqOSlUL8vvQv VyqwhTvhI3Xv/G5wqxolbxFdlQ+23c3lfOk7dGOqGQT5TdmU0P0s8OgAks0R6IstDeL2 HLwQ== 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:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=Oah+sFD9h93XFRkeqX7YtNgEo2DG0iEGX0WBNwPsTlM=; b=K2QpUtCsNQrl3RPMPLdodRg8tGbuOCeISEtoK8FkweKp48PPsP65Gu8PlsNuuDlCzX 6LjZ/5yQ1z8s0LGEQYOBmFBHiylCTtwfrP6TIyAFDkc40bYIEejpUFCZusMoFsx9Tabg zKhCXivugpJMEbq2+f4VcEylWSlVzPGSTUffyloXEL2l4iWsqdaW0d/DlerAR4we3ljL zvvZidwGjRK3Q99QqC2A0WMfE9oKplpXNxAeZaNRQa4QpGucbLfauNe9qXNwYygpHTrp vSATXngMCVjQAgkpLFX+is1gNRK84ALTrBCXeIYdhVjbIL02+Mevo4yZtMRcS6hvHIXJ WPjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ArnYOvDQ; 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 j52si8537682eda.438.2019.10.24.01.48.56; Thu, 24 Oct 2019 01:49:21 -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=ArnYOvDQ; 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 S1730621AbfJWRf1 (ORCPT + 99 others); Wed, 23 Oct 2019 13:35:27 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:38001 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730529AbfJWRf1 (ORCPT ); Wed, 23 Oct 2019 13:35:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571852125; 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=ArnYOvDQvzETIP0sfaN7fvsoSeMud42Qno9KIoTvW5YAcm1Vm+Zc8RS+bfTn8rvqPeCDNH p+u7gBDBp4URnYOJf+U8E46kbzk3yPoeh/UmpNvTH/lTuKx2E+4xnhNT1NZ6TtxXlTQXDG fzoOyP0HVp9bo7eVNA0SAD2lvAGMT7E= 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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