Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp500082ybi; Thu, 1 Aug 2019 23:20:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8PPWaduXH8ak2j+SNKzGZiCPFixGyiKp7YNIioHMKeyFVuNrpAhmW4DuQWOQUxeA71u8P X-Received: by 2002:aa7:8dcc:: with SMTP id j12mr58281877pfr.137.1564726826455; Thu, 01 Aug 2019 23:20:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564726826; cv=none; d=google.com; s=arc-20160816; b=Y8M0ReLE2ogz+1+qDDfk9BAxY2EZ9u8H2BTUdrp19rnX8vuEJfI7kA83x8rDE2Rk5N nZQrBN02piLWvN7R4ztUCondAA+NvGrKc/K6yhVZ/9FRnH5dgLBFojzmHx1ldSUZbiwK NenRSw7v8ByQ8AwLyQKu28hHycHh3vgHlNctoiFVmIUIPs9fvWiuqkrxLrRoyEETZYPG MIYF9yHJI09JwObKi1RbaDJknfOP0Kw5IvhVK7qCipLcXnMr5hxpApb+gPofPB/DZLdh NtMokY0yrmY/RWGsXO5yyOuU3CrVfV70YmCQaCD+eJssCb/4xBMKlbl8y7wi40ZYQu7P sYOw== 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=/ALyy5tBTJRj9deFR87ZUlllw72TrmFyWSdgPjQp4rM=; b=Qqa4m/iSFcS/526Ojz6thc2sBdhlMDUZMe14p181ruRzzDAYvQUqN3yDf/aaNQgp6s eNBK7w+4ZM5Xlf4Dc1FAOhjAawvPM3Ts+E5ItlLgs8rGE/u9guSfE6KeYri3NvZQfSdP 5gj7bxgIN0NOpqDerZYE0I9HLjv6DLkbTciSnzIwhCgCf70VOLRxISV3Sm5fP6e3S2+o z4QwIRmIz7KCIobouvI4jpjxS2JfReL1D5cUuNXgNP1/YLjQVvDrZWkICHVWNUc76KVK FneBV0WcjikFzmnJUfGFfibbjrWilGa5IwgU2k2f8sFUPRXBmd/IXs3Lu8BvedF0kSMJ 5cgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZBtpkVwz; 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 y192si38125686pfg.172.2019.08.01.23.19.40; Thu, 01 Aug 2019 23:20:26 -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=ZBtpkVwz; 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 S2387827AbfHAWdz (ORCPT + 99 others); Thu, 1 Aug 2019 18:33:55 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:33654 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726716AbfHAWdz (ORCPT ); Thu, 1 Aug 2019 18:33:55 -0400 Received: by mail-pl1-f194.google.com with SMTP id c14so32739476plo.0; Thu, 01 Aug 2019 15:33:54 -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=/ALyy5tBTJRj9deFR87ZUlllw72TrmFyWSdgPjQp4rM=; b=ZBtpkVwzOe4eyGoq9QPqUpxtiZRKtqzBH/tyBWE8UnrimostlvcQjvVc/SXZMgbk9N DYil48OxFec1bR3QcSym0HQF290WYdsxjQrKwJXFI7LkKkgljotO2z7gnhVmFcGw0q4W RkcNEAOwyFAHZFD2x0fSSd5S048yDyryAyMpI/Tkf82RXjFdu4NHYfhK7lJPOOO83o7j YgGxggzrRW1L//7xkten1pa/cAZ29ibGzFALKw6Oy5gBAU72fwwEJdrje9WIssnpI1qz e4z+iprUrsN+jdd8nQcP0RVuSU6/DGQvYlI3GBZ7Ry9TuIc6mQiJjm2BhRjHgZrkPKPj GB7w== 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=/ALyy5tBTJRj9deFR87ZUlllw72TrmFyWSdgPjQp4rM=; b=OSs5DnaJgV3YgmYdlxYnA+WRLLsFxC2qqSzKYuFyHWfXkJHoBiXegHLHUbpO9mYbvt Y+Ywq+jBmJYSxELpxMBM1uYiH3+x673T/eVBFfKbGeCgwfcnw4/SYweL+pRrT5nM/Xod sonIxH/C5WAdWWzJDg/m8s4r2RoeWYZChk+yBLPEU1b+uhF/TVXCxSDbBd90G5kHx6BZ GH/UF6hk3gSGozv5eDFcxs2/hbj27MDbheLYv85GqChD0S2IXCZHXC5Ghfm9uKSiU+ep Nx+0QrKw/CUKz4f8kcyOfR4TGYsYXTq1EeAHbV7WKtGJDrIT5lmX61Z2QbywbHvLXiRt apTA== X-Gm-Message-State: APjAAAXGoI8ezMZRcHzKhD44G2YIXi3SCFhqLmpQgapJxFpYik+BW5Pv Nccd4XWsMuyEXoPK50h9/vs= X-Received: by 2002:a17:902:2ae7:: with SMTP id j94mr128150310plb.270.1564698834276; Thu, 01 Aug 2019 15:33:54 -0700 (PDT) Received: from localhost.localdomain (50-39-177-61.bvtn.or.frontiernet.net. [50.39.177.61]) by smtp.gmail.com with ESMTPSA id x25sm104397434pfa.90.2019.08.01.15.33.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Aug 2019 15:33:53 -0700 (PDT) Subject: [PATCH v3 3/6] mm: Use zone and order instead of free area in free_list manipulators From: Alexander Duyck To: nitesh@redhat.com, kvm@vger.kernel.org, david@redhat.com, mst@redhat.com, dave.hansen@intel.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org Cc: yang.zhang.wz@gmail.com, pagupta@redhat.com, riel@surriel.com, konrad.wilk@oracle.com, willy@infradead.org, 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: Thu, 01 Aug 2019 15:31:44 -0700 Message-ID: <20190801223144.22190.30566.stgit@localhost.localdomain> In-Reply-To: <20190801222158.22190.96964.stgit@localhost.localdomain> References: <20190801222158.22190.96964.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. Signed-off-by: Alexander Duyck --- include/linux/mmzone.h | 70 ++++++++++++++++++++++++++---------------------- mm/page_alloc.c | 30 ++++++++------------- 2 files changed, 49 insertions(+), 51 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 738e9c758135..f0c68b6b6154 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]); @@ -787,6 +755,44 @@ static inline bool pgdat_is_empty(pg_data_t *pgdat) return !pgdat->node_start_pfn && !pgdat->node_spanned_pages; } +/* 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--; +} + #include void build_all_zonelists(pg_data_t *pgdat); diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 7cedc73953fd..71aadc7d5ff6 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -920,7 +920,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; @@ -957,7 +956,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; @@ -991,12 +990,11 @@ 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) ? shuffle_add_to_tail() : buddy_merge_likely(pfn, buddy_pfn, page, order)) - 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); } /* @@ -2000,13 +1998,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]); @@ -2020,7 +2016,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); } } @@ -2178,8 +2174,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; } @@ -2187,7 +2183,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 @@ -2264,7 +2259,7 @@ static int move_freepages(struct zone *zone, } 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; } @@ -2380,7 +2375,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; @@ -2451,8 +2445,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); } /* @@ -3123,7 +3116,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; @@ -3149,7 +3141,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 @@ -8560,7 +8552,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);