From patchwork Tue Feb 11 22:46:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 11377031 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EAE5A13A4 for ; Tue, 11 Feb 2020 22:46:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9C31D20842 for ; Tue, 11 Feb 2020 22:46:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SZBtOXIk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9C31D20842 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C93186B034D; Tue, 11 Feb 2020 17:46:21 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BF3F26B034F; Tue, 11 Feb 2020 17:46:21 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A20F56B0350; Tue, 11 Feb 2020 17:46:21 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0145.hostedemail.com [216.40.44.145]) by kanga.kvack.org (Postfix) with ESMTP id 831EC6B034D for ; Tue, 11 Feb 2020 17:46:21 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 2A8D0181AEF15 for ; Tue, 11 Feb 2020 22:46:21 +0000 (UTC) X-FDA: 76479331362.30.book25_1a4f90665ee34 X-Spam-Summary: 2,0,0,6f713325d0da6742,d41d8cd98f00b204,alexander.duyck@gmail.com,:kvm@vger.kernel.org:david@redhat.com:mst@redhat.com:linux-kernel@vger.kernel.org::akpm@linux-foundation.org:mgorman@techsingularity.net:yang.zhang.wz@gmail.com:pagupta@redhat.com:konrad.wilk@oracle.com:nitesh@redhat.com:riel@surriel.com:willy@infradead.org:lcapitulino@redhat.com:dave.hansen@intel.com:wei.w.wang@intel.com:aarcange@redhat.com:pbonzini@redhat.com:dan.j.williams@intel.com:mhocko@kernel.org:alexander.h.duyck@linux.intel.com:vbabka@suse.cz:osalvador@suse.de,RULES_HIT:1:2:41:69:152:355:379:560:800:960:965:966:968:973:988:989:1260:1277:1311:1313:1314:1345:1359:1431:1437:1515:1516:1518:1593:1594:1605:1730:1747:1777:1792:2196:2198:2199:2200:2393:2559:2562:2693:2731:2898:2901:3138:3139:3140:3141:3142:3865:3866:3867:3868:3870:3871:3872:3874:4051:4321:4385:4390:4395:4605:5007:6119:6261:6653:6742:7576:7974:8603:8957:9010:9036:9413:9592:10004:11026:11473:11658:11914:12043:12048:12291:12296:12 297:1243 X-HE-Tag: book25_1a4f90665ee34 X-Filterd-Recvd-Size: 12083 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Tue, 11 Feb 2020 22:46:20 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id z3so14618977wru.3 for ; Tue, 11 Feb 2020 14:46:20 -0800 (PST) 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=FKwyNx/K/GSbowl553AHvg5lyi4wmF1Qu/nz0HdQBeQ=; b=SZBtOXIkXN3WRz4Ihc9BSccA4uXkvW0RTTpkdEijK8b5arpc9WElPYzquTdSAymsb9 2teJFawD01aBVlbn13kWX7XfmMc3raMiLbp/zT6CfTdLpGTQG0MbJeTfILXJZlTeKHyd KSOkk1l/fQRkc0CPQSPcNta1qmiObk1ejLK3ylN+moj0IuPIi2Y/TFKx11LplGYbsYu5 w9pqL2GcWJKL4qG2r5kD8csH4JA05Hty95n6CEnQzuH9YRdDKQbW8IX19C41eGsb2h+u lu70JviTmPC8K+XYDWbz6JCITSlnHexKP/mJo/tsnkVvOIL18UsS0vhJA162SvSsKBVH eWVw== 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=FKwyNx/K/GSbowl553AHvg5lyi4wmF1Qu/nz0HdQBeQ=; b=eAqOT9N/X8u7Z33725ttOYzeUXndL5bULVElQbuMd0F87JfNm6BepjNe1pxpGZf6LB qVzEZO9aJWU2FB168SxVRQ86B2Gk1/nedIzkAdus+m/OMB7I1OcWqLYrPEfKT3ADNRJF GRW9MTU1K/uEVD2djZt2b/0Y5M95VZqJwLEuHcuoTzjYrpVTKub1rK7NT5LDY1hjKRYE 4Po4ucemAeNlEbD3zCplTJaXPoPP3RrvJ9E7MHrqCMAdDuM0VYXhT8Q654XT3QAbkuTG aQ81ZnMx5m11bkoRhlKhNbyyGZGkA48XDrzD/jMnvTif6oYMAsCP7KVfxyHqfo92ImPC Ld+A== X-Gm-Message-State: APjAAAUUR+Y6kr7zSG4zo3YqzsuSYHSrTx7C6gm6Bxhqz7mTyatD83FA /fzXPt+ULKOSIawuSYWYzjs= X-Google-Smtp-Source: APXvYqwB++Zzzzzcqj7j7dIAgSOfhLqTqo5yzXnZ23UeqI5P4ZMiUReL6Ywixe3R3JcdHZYOyUm2ew== X-Received: by 2002:a5d:4bd0:: with SMTP id l16mr2186428wrt.271.1581461179549; Tue, 11 Feb 2020 14:46:19 -0800 (PST) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id h13sm8178974wrw.54.2020.02.11.14.46.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Feb 2020 14:46:19 -0800 (PST) Subject: [PATCH v17 2/9] mm: Use zone and order instead of free area in free_list manipulators From: Alexander Duyck To: kvm@vger.kernel.org, david@redhat.com, mst@redhat.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, mgorman@techsingularity.net Cc: yang.zhang.wz@gmail.com, pagupta@redhat.com, konrad.wilk@oracle.com, nitesh@redhat.com, riel@surriel.com, willy@infradead.org, lcapitulino@redhat.com, dave.hansen@intel.com, wei.w.wang@intel.com, aarcange@redhat.com, pbonzini@redhat.com, dan.j.williams@intel.com, mhocko@kernel.org, alexander.h.duyck@linux.intel.com, vbabka@suse.cz, osalvador@suse.de Date: Tue, 11 Feb 2020 14:46:13 -0800 Message-ID: <20200211224613.29318.43080.stgit@localhost.localdomain> In-Reply-To: <20200211224416.29318.44077.stgit@localhost.localdomain> References: <20200211224416.29318.44077.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 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: 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. Acked-by: Mel Gorman 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 | 67 +++++++++++++++++++++++++++++++++++------------- 2 files changed, 49 insertions(+), 50 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index bdcd071ab67f..a32bd503b9fc 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 bf36cdfea07a..de916aa06a27 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -870,6 +870,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 @@ -932,7 +970,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; @@ -970,7 +1007,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; @@ -1004,16 +1041,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); } /* @@ -2027,13 +2063,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]); @@ -2047,7 +2081,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); } } @@ -2205,8 +2239,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; } @@ -2280,7 +2314,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; } @@ -2396,7 +2430,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; @@ -2467,8 +2500,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); } /* @@ -3139,7 +3171,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; @@ -3165,7 +3196,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 @@ -8722,7 +8753,7 @@ void zone_pcp_reset(struct zone *zone) BUG_ON(!PageBuddy(page)); order = page_order(page); offlined_pages += 1 << order; - del_page_from_free_area(page, &zone->free_area[order]); + del_page_from_free_list(page, zone, order); pfn += (1 << order); } spin_unlock_irqrestore(&zone->lock, flags);