Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8563870imu; Thu, 15 Nov 2018 13:40:05 -0800 (PST) X-Google-Smtp-Source: AJdET5dngZd3ly9zw9XD+Pzn/RjbxRK6dHUTOV6EN4YOuWMI6VNBlAR95UM74UFEkeuUXlh0mIS9 X-Received: by 2002:a63:8c2:: with SMTP id 185mr7564880pgi.26.1542318005445; Thu, 15 Nov 2018 13:40:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542318005; cv=none; d=google.com; s=arc-20160816; b=ZGV1UaIgKn3VJQVdoXf9/YR4/Us4CpL3pYqSllj97/OHSfErr3SOjcMK4H1IuRuiNE 58L/tFGaUaJHEaBKOHUc6fKdTyKVit9PZ2qR43JFfPA1EcW68hSKJgaIZ0c7OdY2yYTb O0a2jt+LdblYq5rsu58gEeb8ipmNFux+xwlG9MLjFLx7MlS4bLu7WgvbWnklJpDw3vTP no+TXhC/3vvHzGdtd2kR+5cy2eybGo+ptjyFEMaTclQv8XXSNR+Ja4zo0qAU98D/Vq1n h/5Rastsk5mK/WmIOnH2H2i0tcwG56mVH648tRiAe/y71AtEw1uWqUDMw5j0nhG/lYB5 9YcQ== 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:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=B9L1Oz234vYFAqPYduJP+p+ptVegzSEv7Dix6LwLxRs=; b=S0ggS5OZw0uaekAa7npT3mJg+caBvWNGEIb8I7+huRRoFoTw9StORFA+B+fwNrgOEu 78hXy9E40ff+GpqYFY1H/7lsqLAevFYe67lyG4LpgWsi+1Q5pmjF3ayDx7XK2aLO5j1t UTngEJ3sL4Skk1CiX2zYt7ZtSCwrJ5LdDvckTIv97dvUhV7CLIJcMlUsgloAEXdgBC6x BO6MKnitjHdaS+oy8Ol7r718mQO5NzN+bVL/m6r1OiWchsz+ailvNUjDvKXhz9oGMtsV yk1qS7Fz+CTGXX+aBtjB38tp4/Y8KrOjDv4fi/pYV4R2aatcpxupSrbTTZlGLQ2+c+4f EamA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v7si2047654plz.250.2018.11.15.13.39.50; Thu, 15 Nov 2018 13:40:05 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726423AbeKPHrJ (ORCPT + 99 others); Fri, 16 Nov 2018 02:47:09 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:38588 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725856AbeKPHrJ (ORCPT ); Fri, 16 Nov 2018 02:47:09 -0500 Received: from akpm3.svl.corp.google.com (unknown [104.133.8.65]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A5E5FC75; Thu, 15 Nov 2018 21:37:36 +0000 (UTC) Date: Thu, 15 Nov 2018 13:37:35 -0800 From: Andrew Morton To: Wei Yang Cc: mhocko@suse.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: use managed_zone() for more exact check in zone iteration Message-Id: <20181115133735.bb0313ec9293c415d08be550@linux-foundation.org> In-Reply-To: <20181114235040.36180-1-richard.weiyang@gmail.com> References: <20181114235040.36180-1-richard.weiyang@gmail.com> X-Mailer: Sylpheed 3.6.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 15 Nov 2018 07:50:40 +0800 Wei Yang wrote: > For one zone, there are three digits to describe its space range: > > spanned_pages > present_pages > managed_pages > > The detailed meaning is written in include/linux/mmzone.h. This patch > concerns about the last two. > > present_pages is physical pages existing within the zone > managed_pages is present pages managed by the buddy system > > >From the definition, managed_pages is a more strict condition than > present_pages. > > There are two functions using zone's present_pages as a boundary: > > populated_zone() > for_each_populated_zone() > > By going through the kernel tree, most of their users are willing to > access pages managed by the buddy system, which means it is more exact > to check zone's managed_pages for a validation. > > This patch replaces those checks on present_pages to managed_pages by: > > * change for_each_populated_zone() to for_each_managed_zone() > * convert for_each_populated_zone() to for_each_zone() and check > populated_zone() where is necessary > * change populated_zone() to managed_zone() at proper places > > Signed-off-by: Wei Yang > > --- > > Michal, after last mail, I did one more thing to replace > populated_zone() with managed_zone() at proper places. > > One thing I am not sure is those places in mm/compaction.c. I have > chaged them. If not, please let me know. > > BTW, I did a boot up test with the patched kernel and looks smooth. Seems sensible, but a bit scary. A basic boot test is unlikely to expose subtle gremlins. Worse, the situations in which managed_zone() != populated_zone() are rare(?), so it will take a long time for problems to be discovered, I expect. I'll toss it in there for now, let's see who breaks :(