Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp8466842ybn; Tue, 1 Oct 2019 08:30:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqyYkyckaK2EJsI+Mfjag4KAs2Lw95rD03id19R7AFguhLlpKXS9Q/SJMu9pMj9gxq/si/C4 X-Received: by 2002:a17:906:d185:: with SMTP id c5mr24776815ejz.139.1569943819830; Tue, 01 Oct 2019 08:30:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569943819; cv=none; d=google.com; s=arc-20160816; b=XBgjU5q5w2aqnsqWnB9PGjBp/wOsi2JX8FNSTL4ZZm9x0r1OysuDUfbIo5qEpRhGdJ 5vKvXir8tuBOreglNiZ5mPPcED94TFAk8mJft5kVmrG/sDvCX0imnt7tth1q1AyV/C7z 0X/YEfGiPjF2OOYPZoBwLKR4BNF6F60RrHhKoHzvTzUcgpBJx4UHGXGC/RwxlSrPvpdA ljQlIBWlm9+wgatoyGYmquqqKVScYFBdcNnAt9zX3WffIeLF6NtVmaKaaYfgT1kGFBsX OnfFriEm4VDYSCwtyPTtjIkqRX8oBMA7cEkEU2UIfdkeVv5QMwlVGvLuX/C1B+oAS6Zi xmZQ== 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 :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature; bh=0K2FpVpCh6PKnNggfKA86tN6UUW5hrFsV1d9U5M4+WY=; b=drGVq4TTr3BOsymReAcv+l9gEhLboWxbgtXB43tcImTa5oF2sP6SkO1BXF9AJ+KFSd 4e4KAdhhKHUr7AT8zri+9/nxpctcy4qxSo2xfYBHQB3pNv0P87YmAeuB/uWaAddI6QRV 4od30+cKoll8CSEYjXccIzYS82Td+Epl7xcLJGlranqYctNe4EulY0s6Bx3ieEypBUYo 1PLIew3Yetpm7HwISL6Z954zZ51qkN/VJ+LJPD+u82/42hCz8HSwmMzuXP3k2l62du0N w8zmunfn0HZHrFK31BlyQ5Bbn1aDs7Al7VpCk0r9eSMLdxnQj7ZiuraXqrfsvcG0nISw q0rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=I96R73TB; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j3si10769937edj.448.2019.10.01.08.29.54; Tue, 01 Oct 2019 08:30:19 -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=@gmail.com header.s=20161025 header.b=I96R73TB; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389620AbfJAP3c (ORCPT + 99 others); Tue, 1 Oct 2019 11:29:32 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:35377 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389599AbfJAP3c (ORCPT ); Tue, 1 Oct 2019 11:29:32 -0400 Received: by mail-pg1-f196.google.com with SMTP id a24so9916947pgj.2; Tue, 01 Oct 2019 08:29:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=0K2FpVpCh6PKnNggfKA86tN6UUW5hrFsV1d9U5M4+WY=; b=I96R73TBFPYE44iKujpqzQWQK3J8yF4xWvXJLUZpYgjqZvdTkYZpFe7vlHJ4Fb7KI6 UuJK9c5wNUsBgx0I7WAQ3rgO0/SYkDjNjGftUOgU+zaW2J5MoetrZBgK+PWZTIBEt+wb XiaLuvVJSuHzlQFiqch4KFwvyEqunOOx0DgZ0tnzXtVjP7PS4bJBeISmaP3ilz4tSOgy iheasFrAUAnNQYx8TwPfST2krQ2e9g2C6u9oTdKptAPFJzkhs57QsKKQ7Dt1TlrAR3fb NDWVMDZG0hbf1+68yU177bjcto+r0FdQOXZLMzTGoineWqxyuCwuLFL7+kmHkR1Am6pn QpAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=0K2FpVpCh6PKnNggfKA86tN6UUW5hrFsV1d9U5M4+WY=; b=mlC0NM0buQhWI6WWE9XtmuLmY0RJJ/WXpqyqZ84MR1AAy64WszqUjixCx+xZ/vKrRg DLII1VhrEvakeCOUQwmLx+wy2XXoAN/cPz/tDyvzMFECrqQb1CyY0Xyb7spkla0VLJ5e 7156ct5A53ximv/wNdAM7gcj3pWBgcGBpYKcIRgmJfFYMwOOAzdGVfkgA8xh2p0xiicW LPVGA0iC2419WelarZYHG95Ic9G/K6p6KmJyzednzIXCfd8gbZRwkrIhk5AIaUy8mfks fVyrwmji7tLP3mOSkskXgT0nx0CkeJvJqAvfraJBLpVwFWPQLx7pL2l933OU+8V68WjO nIhQ== X-Gm-Message-State: APjAAAUwblJl+tA3vugaKC3mXK2pPqp7InQMo5u5FwhRKWOFVYMu7ZSY 2hE+7A57p5oZMSMu1ZRm8M4= X-Received: by 2002:a62:4e09:: with SMTP id c9mr29034017pfb.152.1569943769921; Tue, 01 Oct 2019 08:29:29 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id z25sm15220217pfn.7.2019.10.01.08.29.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Oct 2019 08:29:29 -0700 (PDT) Subject: [PATCH v11 2/6] mm: Use zone and order instead of free area in free_list manipulators From: Alexander Duyck To: virtio-dev@lists.oasis-open.org, kvm@vger.kernel.org, mst@redhat.com, david@redhat.com, dave.hansen@intel.com, linux-kernel@vger.kernel.org, willy@infradead.org, mhocko@kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, mgorman@techsingularity.net, vbabka@suse.cz, osalvador@suse.de Cc: yang.zhang.wz@gmail.com, pagupta@redhat.com, konrad.wilk@oracle.com, nitesh@redhat.com, riel@surriel.com, lcapitulino@redhat.com, wei.w.wang@intel.com, aarcange@redhat.com, pbonzini@redhat.com, dan.j.williams@intel.com, alexander.h.duyck@linux.intel.com Date: Tue, 01 Oct 2019 08:29:28 -0700 Message-ID: <20191001152928.27008.8178.stgit@localhost.localdomain> In-Reply-To: <20191001152441.27008.99285.stgit@localhost.localdomain> References: <20191001152441.27008.99285.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Duyck In order to enable the use of the zone from the list manipulator functions I will need access to the zone pointer. As it turns out most of the accessors were always just being directly passed &zone->free_area[order] anyway so it would make sense to just fold that into the function itself and pass the zone and order as arguments instead of the free area. In order to be able to reference the zone we need to move the declaration of the functions down so that we have the zone defined before we define the list manipulation functions. Since the functions are only used in the file mm/page_alloc.c we can just move them there to reduce noise in the header. Reviewed-by: Dan Williams Reviewed-by: David Hildenbrand Reviewed-by: Pankaj Gupta Signed-off-by: Alexander Duyck --- include/linux/mmzone.h | 32 ----------------------- mm/page_alloc.c | 68 +++++++++++++++++++++++++++++++++++------------- 2 files changed, 49 insertions(+), 51 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 125f300981c6..270a7b493174 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -100,29 +100,6 @@ struct free_area { unsigned long nr_free; }; -/* Used for pages not on another list */ -static inline void add_to_free_area(struct page *page, struct free_area *area, - int migratetype) -{ - list_add(&page->lru, &area->free_list[migratetype]); - area->nr_free++; -} - -/* Used for pages not on another list */ -static inline void add_to_free_area_tail(struct page *page, struct free_area *area, - int migratetype) -{ - list_add_tail(&page->lru, &area->free_list[migratetype]); - area->nr_free++; -} - -/* Used for pages which are on another list */ -static inline void move_to_free_area(struct page *page, struct free_area *area, - int migratetype) -{ - list_move(&page->lru, &area->free_list[migratetype]); -} - static inline struct page *get_page_from_free_area(struct free_area *area, int migratetype) { @@ -130,15 +107,6 @@ static inline struct page *get_page_from_free_area(struct free_area *area, struct page, lru); } -static inline void del_page_from_free_area(struct page *page, - struct free_area *area) -{ - list_del(&page->lru); - __ClearPageBuddy(page); - set_page_private(page, 0); - area->nr_free--; -} - static inline bool free_area_empty(struct free_area *area, int migratetype) { return list_empty(&area->free_list[migratetype]); diff --git a/mm/page_alloc.c b/mm/page_alloc.c index bc8de8d9416d..5e142047f730 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -877,6 +877,44 @@ static inline struct capture_control *task_capc(struct zone *zone) } #endif /* CONFIG_COMPACTION */ +/* Used for pages not on another list */ +static inline void add_to_free_list(struct page *page, struct zone *zone, + unsigned int order, int migratetype) +{ + struct free_area *area = &zone->free_area[order]; + + list_add(&page->lru, &area->free_list[migratetype]); + area->nr_free++; +} + +/* Used for pages not on another list */ +static inline void add_to_free_list_tail(struct page *page, struct zone *zone, + unsigned int order, int migratetype) +{ + struct free_area *area = &zone->free_area[order]; + + list_add_tail(&page->lru, &area->free_list[migratetype]); + area->nr_free++; +} + +/* Used for pages which are on another list */ +static inline void move_to_free_list(struct page *page, struct zone *zone, + unsigned int order, int migratetype) +{ + struct free_area *area = &zone->free_area[order]; + + list_move(&page->lru, &area->free_list[migratetype]); +} + +static inline void del_page_from_free_list(struct page *page, struct zone *zone, + unsigned int order) +{ + list_del(&page->lru); + __ClearPageBuddy(page); + set_page_private(page, 0); + zone->free_area[order].nr_free--; +} + /* * If this is not the largest possible page, check if the buddy * of the next-highest order is free. If it is, it's possible @@ -939,7 +977,6 @@ static inline void __free_one_page(struct page *page, struct capture_control *capc = task_capc(zone); unsigned long uninitialized_var(buddy_pfn); unsigned long combined_pfn; - struct free_area *area; unsigned int max_order; struct page *buddy; bool to_tail; @@ -977,7 +1014,7 @@ static inline void __free_one_page(struct page *page, if (page_is_guard(buddy)) clear_page_guard(zone, buddy, order, migratetype); else - del_page_from_free_area(buddy, &zone->free_area[order]); + del_page_from_free_list(buddy, zone, order); combined_pfn = buddy_pfn & pfn; page = page + (combined_pfn - pfn); pfn = combined_pfn; @@ -1011,16 +1048,15 @@ static inline void __free_one_page(struct page *page, done_merging: set_page_order(page, order); - area = &zone->free_area[order]; if (is_shuffle_order(order)) to_tail = shuffle_pick_tail(); else to_tail = buddy_merge_likely(pfn, buddy_pfn, page, order); if (to_tail) - add_to_free_area_tail(page, area, migratetype); + add_to_free_list_tail(page, zone, order, migratetype); else - add_to_free_area(page, area, migratetype); + add_to_free_list(page, zone, order, migratetype); } /* @@ -2024,13 +2060,11 @@ void __init init_cma_reserved_pageblock(struct page *page) * -- nyc */ static inline void expand(struct zone *zone, struct page *page, - int low, int high, struct free_area *area, - int migratetype) + int low, int high, int migratetype) { unsigned long size = 1 << high; while (high > low) { - area--; high--; size >>= 1; VM_BUG_ON_PAGE(bad_range(zone, &page[size]), &page[size]); @@ -2044,7 +2078,7 @@ static inline void expand(struct zone *zone, struct page *page, if (set_page_guard(zone, &page[size], high, migratetype)) continue; - add_to_free_area(&page[size], area, migratetype); + add_to_free_list(&page[size], zone, high, migratetype); set_page_order(&page[size], high); } } @@ -2202,8 +2236,8 @@ struct page *__rmqueue_smallest(struct zone *zone, unsigned int order, page = get_page_from_free_area(area, migratetype); if (!page) continue; - del_page_from_free_area(page, area); - expand(zone, page, order, current_order, area, migratetype); + del_page_from_free_list(page, zone, current_order); + expand(zone, page, order, current_order, migratetype); set_pcppage_migratetype(page, migratetype); return page; } @@ -2211,7 +2245,6 @@ struct page *__rmqueue_smallest(struct zone *zone, unsigned int order, return NULL; } - /* * This array describes the order lists are fallen back to when * the free lists for the desirable migrate type are depleted @@ -2277,7 +2310,7 @@ static int move_freepages(struct zone *zone, VM_BUG_ON_PAGE(page_zone(page) != zone, page); order = page_order(page); - move_to_free_area(page, &zone->free_area[order], migratetype); + move_to_free_list(page, zone, order, migratetype); page += 1 << order; pages_moved += 1 << order; } @@ -2393,7 +2426,6 @@ static void steal_suitable_fallback(struct zone *zone, struct page *page, unsigned int alloc_flags, int start_type, bool whole_block) { unsigned int current_order = page_order(page); - struct free_area *area; int free_pages, movable_pages, alike_pages; int old_block_type; @@ -2464,8 +2496,7 @@ static void steal_suitable_fallback(struct zone *zone, struct page *page, return; single_page: - area = &zone->free_area[current_order]; - move_to_free_area(page, area, start_type); + move_to_free_list(page, zone, current_order, start_type); } /* @@ -3136,7 +3167,6 @@ void split_page(struct page *page, unsigned int order) int __isolate_free_page(struct page *page, unsigned int order) { - struct free_area *area = &page_zone(page)->free_area[order]; unsigned long watermark; struct zone *zone; int mt; @@ -3162,7 +3192,7 @@ int __isolate_free_page(struct page *page, unsigned int order) /* Remove page from free list */ - del_page_from_free_area(page, area); + del_page_from_free_list(page, zone, order); /* * Set the pageblock if the isolated page is at least half of a @@ -8605,7 +8635,7 @@ void zone_pcp_reset(struct zone *zone) pr_info("remove from free list %lx %d %lx\n", pfn, 1 << order, end_pfn); #endif - del_page_from_free_area(page, &zone->free_area[order]); + del_page_from_free_list(page, zone, order); for (i = 0; i < (1 << order); i++) SetPageReserved((page+i)); pfn += (1 << order);