Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1286228ybg; Wed, 23 Oct 2019 13:18:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhU5Cs7zNuqXBq/6WXF4wy5WJRnos4+7HSJlzTlfz+NTcz0bG7KcDCab0jOu7EFyBMS/XK X-Received: by 2002:a50:91c4:: with SMTP id h4mr27090118eda.36.1571861937543; Wed, 23 Oct 2019 13:18:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571861937; cv=none; d=google.com; s=arc-20160816; b=JaBcZhF36TSAeZPOg4aHHV8Yq/eY4oj9NboQy8iG+VbHiJulucnVEo9fUIJ7ySVF6V TOxjelT64WFZdpmqAl4ss70B99QxfukzE3v0QdEbBjNsdDRVrouT8Tv/eK4aaPGxeCUe JlQRGuuCG+eItMcmtnQ06lDPHebB0BJIXDGRKj2fdWIWrUgusxLpiCaseV5kgLBYIMAy xsCfm39+Vgh6kn6Ed7RUXUCiF0AJpfz8TLPDDUwXxDpSDAGBoSbNJxgSI8vzZclzNyLk ZGSbvJ9J+xFZCAkjHdK5rfG+LnOjN1amlepo2qAUhwSZZmnsLnDkR2YuuBdTs9/aWb5f lQ2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Wu9dmi2V79BT1KK4v8iBj41zv6i9ulaWPNqT67sD2Q0=; b=TVZHXKAKBxyhShopDtZweGlO86OqVAxxKjQri1eB01nijeaQr45fhZjlx9GhdmU7iP rsvR5A14kDIDHI9RLlMlFuXtEGzSsrYg6nKhaSqXSbKh8qudi7sSVdNUghAdwG8Y1eTq 89rZoEv9cD4vL7WhBy2AQQv4QmiOUh426NlqFs9WpU1JHYM4fohdivsAhDGzTxmGxijA m5IMYKjqcH701uFvlbE7jeptWso+EAWEfKwZwZdiz0eC6sg8++BgcFzVfSX6AEITp6De mJPVLEALuuWkRQivc1Vl+FtI1I/UpZh3ZqKyACc42i9aXnCxrGWG589BZ4N9KX4zavL6 GTVw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c30si8299692ede.125.2019.10.23.13.18.32; Wed, 23 Oct 2019 13:18:57 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406122AbfJWNs2 (ORCPT + 99 others); Wed, 23 Oct 2019 09:48:28 -0400 Received: from mx2.suse.de ([195.135.220.15]:57404 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2405869AbfJWNs2 (ORCPT ); Wed, 23 Oct 2019 09:48:28 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 49913B239; Wed, 23 Oct 2019 13:48:26 +0000 (UTC) Date: Wed, 23 Oct 2019 15:48:24 +0200 From: Michal Hocko To: Johannes Weiner Cc: Andrew Morton , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: Re: [PATCH 1/8] mm: vmscan: simplify lruvec_lru_size() Message-ID: <20191023134824.GB17610@dhcp22.suse.cz> References: <20191022144803.302233-1-hannes@cmpxchg.org> <20191022144803.302233-2-hannes@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191022144803.302233-2-hannes@cmpxchg.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 22-10-19 10:47:56, Johannes Weiner wrote: > This function currently takes the node or lruvec size and subtracts > the zones that are excluded by the classzone index of the > allocation. It uses four different types of counters to do this. > > Just add up the eligible zones. The original intention was to optimize this for GFP_KERNEL like allocations by reducing the number of zones to reduce. But considering this is not called from hot paths I do agree that a simpler code is more preferable. > Signed-off-by: Johannes Weiner Acked-by: Michal Hocko > --- > mm/vmscan.c | 21 +++++---------------- > 1 file changed, 5 insertions(+), 16 deletions(-) > > diff --git a/mm/vmscan.c b/mm/vmscan.c > index 1154b3a2b637..57f533b808f2 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -351,32 +351,21 @@ unsigned long zone_reclaimable_pages(struct zone *zone) > */ > unsigned long lruvec_lru_size(struct lruvec *lruvec, enum lru_list lru, int zone_idx) > { > - unsigned long lru_size = 0; > + unsigned long size = 0; > int zid; > > - if (!mem_cgroup_disabled()) { > - for (zid = 0; zid < MAX_NR_ZONES; zid++) > - lru_size += mem_cgroup_get_zone_lru_size(lruvec, lru, zid); > - } else > - lru_size = node_page_state(lruvec_pgdat(lruvec), NR_LRU_BASE + lru); > - > - for (zid = zone_idx + 1; zid < MAX_NR_ZONES; zid++) { > + for (zid = 0; zid <= zone_idx; zid++) { > struct zone *zone = &lruvec_pgdat(lruvec)->node_zones[zid]; > - unsigned long size; > > if (!managed_zone(zone)) > continue; > > if (!mem_cgroup_disabled()) > - size = mem_cgroup_get_zone_lru_size(lruvec, lru, zid); > + size += mem_cgroup_get_zone_lru_size(lruvec, lru, zid); > else > - size = zone_page_state(&lruvec_pgdat(lruvec)->node_zones[zid], > - NR_ZONE_LRU_BASE + lru); > - lru_size -= min(size, lru_size); > + size += zone_page_state(zone, NR_ZONE_LRU_BASE + lru); > } > - > - return lru_size; > - > + return size; > } > > /* > -- > 2.23.0 -- Michal Hocko SUSE Labs