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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0275C28D13 for ; Mon, 22 Aug 2022 21:13:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 508908D0002; Mon, 22 Aug 2022 17:13:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4B7D38D0001; Mon, 22 Aug 2022 17:13:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3804F8D0002; Mon, 22 Aug 2022 17:13:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 26A158D0001 for ; Mon, 22 Aug 2022 17:13:52 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id F1404A08B3 for ; Mon, 22 Aug 2022 21:13:51 +0000 (UTC) X-FDA: 79828480662.03.4E9E8EE Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf14.hostedemail.com (Postfix) with ESMTP id 2B8F810007C for ; Mon, 22 Aug 2022 21:12:11 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8E7C06068B; Mon, 22 Aug 2022 21:12:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E194C433D6; Mon, 22 Aug 2022 21:12:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1661202729; bh=Fob4wOawfexzSqxQdwOiADupO6h8B7U7Zo0u31z1Jh0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=bgPNbyAFhac1cFIK1UmYPJEbzphu7GYXX3XxbTHNHnxsCcXK8tftvjtayw3CwiwzV Od9gAs/jNV9ItutoEOQ7/JtI2gEiUGfew9atrghdaW/Nx9G29fMQHlwTN96mTutPuj nvUZVccKsOtPeaHaVLMKOBJNm4tNbwH4Mrw8S7f8= Date: Mon, 22 Aug 2022 14:12:07 -0700 From: Andrew Morton To: Liu Shixin Cc: Greg Kroah-Hartman , huang ying , Aaron Lu , Dave Hansen , "Michal Hocko" , Jesper Dangaard Brouer , Vlastimil Babka , Kemi Wang , "Kefeng Wang" , , Subject: Re: [PATCH -next v2] mm, proc: collect percpu free pages into the free pages Message-Id: <20220822141207.24ff7252913a62f80ea55e90@linux-foundation.org> In-Reply-To: <20220822033354.952849-1-liushixin2@huawei.com> References: <20220822023311.909316-1-liushixin2@huawei.com> <20220822033354.952849-1-liushixin2@huawei.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661202731; a=rsa-sha256; cv=none; b=pmb7tO7BOi+CYbJPWsrQ3/3tPeV/3uyFbNs2h6qpB383qLL4ufACrs3lTDptGdmolWLcoG 6ijChdiuFbqJ5OZIN5S5lZABnTKWmiYG7AJG8vMvw1XdO8nV3N2ck3eJmZ3FB+rwbq04Lo j2tOAaaU9Y7X/F6QIIhXopBkFhAoKnA= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=bgPNbyAF; spf=pass (imf14.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661202731; h=from:from:sender: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:dkim-signature; bh=fS9ch/iJG2YcXY/wGwYXKusfveAKC1F0eF3/CzcW1zY=; b=D4Zcuz075zJG9a9gbOtLJK4jHHLzZiMX7oL8H7sUC2RNAz8f5FaLF/MTIh/F39mon92wFc UTedLAiDiMm+vC7stYryR+x1PpuWOpvkgW9Ypkc7ZbRKw0PLc0rHRka/nyX6aH9xKZZMHn i6jlBnyXOnu+1kRIjzafzDdq6pLX8uk= X-Rspamd-Queue-Id: 2B8F810007C X-Rspam-User: Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=bgPNbyAF; spf=pass (imf14.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspamd-Server: rspam01 X-Stat-Signature: x95hw1sonhf6y1cjcokwqahofk1u4o64 X-HE-Tag: 1661202731-668644 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: On Mon, 22 Aug 2022 11:33:54 +0800 Liu Shixin wrote: > The page on pcplist could be used, but not counted into memory free or > avaliable, and pcp_free is only showed by show_mem() for now. Since commit > d8a759b57035 ("mm, page_alloc: double zone's batchsize"), there is a > significant decrease in the display of free memory, with a large number > of cpus and zones, the number of pages in the percpu list can be very > large, so it is better to let user to know the pcp count. > > On a machine with 3 zones and 72 CPUs. Before commit d8a759b57035, the > maximum amount of pages in the pcp lists was theoretically 162MB(3*72*768KB). > After the patch, the lists can hold 324MB. It has been observed to be 114MB > in the idle state after system startup in practice(increased 80 MB). > Seems reasonable. > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 033f1e26d15b..f89928d3ad4e 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -5853,6 +5853,26 @@ static unsigned long nr_free_zone_pages(int offset) > return sum; > } > > +static unsigned long nr_free_zone_pcplist_pages(struct zone *zone) > +{ > + unsigned long sum = 0; > + int cpu; > + > + for_each_online_cpu(cpu) > + sum += per_cpu_ptr(zone->per_cpu_pageset, cpu)->count; > + return sum; > +} > + > +static unsigned long nr_free_pcplist_pages(void) > +{ > + unsigned long sum = 0; > + struct zone *zone; > + > + for_each_zone(zone) > + sum += nr_free_zone_pcplist_pages(zone); > + return sum; > +} Prevention of races against zone/node hotplug?