From patchwork Tue Jun 16 11:52:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 11607233 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 DD4C692A for ; Tue, 16 Jun 2020 11:52:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A7C2120B1F for ; Tue, 16 Jun 2020 11:52:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ijthp803" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A7C2120B1F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 774356B009A; Tue, 16 Jun 2020 07:52:29 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6FC266B009C; Tue, 16 Jun 2020 07:52:29 -0400 (EDT) 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 411978D0006; Tue, 16 Jun 2020 07:52:29 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0037.hostedemail.com [216.40.44.37]) by kanga.kvack.org (Postfix) with ESMTP id 1AB3C6B009A for ; Tue, 16 Jun 2020 07:52:29 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id BFCF2181AC9CB for ; Tue, 16 Jun 2020 11:52:28 +0000 (UTC) X-FDA: 76934912376.15.farm20_5b097ab26dfe Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id 52F131814B0CC for ; Tue, 16 Jun 2020 11:52:28 +0000 (UTC) X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,david@redhat.com,,RULES_HIT:30054:30064:30070,0,RBL:207.211.31.120:@redhat.com:.lbl8.mailshell.net-66.10.201.10 62.18.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: farm20_5b097ab26dfe X-Filterd-Recvd-Size: 5557 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Tue, 16 Jun 2020 11:52:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592308347; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nC4omS0wZXEwgJ3j/b3OR0MRArgteyLwgrhrykedSUg=; b=ijthp803vWOhoLch7kyIuxN4MIGLKy9gQftf7U78IodEU4citWciNlaPKxit03O6NGXtdV B1at2KKla3nAx4iZPy8E0BpiwnL4E1GV3jdQ2BfUYq9FGwxNeYPUDkMvl6WWucD96W27+L 2vGdFvjiD4MmGqBEzaPQ+bi6pHbDME4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-477-ldIpgm-fPC2e1l1xNjvZ9g-1; Tue, 16 Jun 2020 07:52:25 -0400 X-MC-Unique: ldIpgm-fPC2e1l1xNjvZ9g-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9300F18585BC; Tue, 16 Jun 2020 11:52:23 +0000 (UTC) Received: from t480s.redhat.com (ovpn-114-106.ams2.redhat.com [10.36.114.106]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6255E7CAA5; Tue, 16 Jun 2020 11:52:21 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , stable@vger.kernel.org, Andrew Morton , Johannes Weiner , Michal Hocko , Minchan Kim , Huang Ying , Wei Yang , Mel Gorman Subject: [PATCH v1 1/3] mm/shuffle: don't move pages between zones and don't read garbage memmaps Date: Tue, 16 Jun 2020 13:52:11 +0200 Message-Id: <20200616115213.13109-2-david@redhat.com> In-Reply-To: <20200616115213.13109-1-david@redhat.com> References: <20200616115213.13109-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Rspamd-Queue-Id: 52F131814B0CC X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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: Especially with memory hotplug, we can have offline sections (with a garbage memmap) and overlapping zones. We have to make sure to only touch initialized memmaps (online sections managed by the buddy) and that the zone matches, to not move pages between zones. To test if this can actually happen, I added a simple BUG_ON(page_zone(page_i) != page_zone(page_j)); right before the swap. When hotplugging a 256M DIMM to a 4G x86-64 VM and onlining the first memory block "online_movable" and the second memory block "online_kernel", it will trigger the BUG, as both zones (NORMAL and MOVABLE) overlap. This might result in all kinds of weird situations (e.g., double allocations, list corruptions, unmovable allocations ending up in the movable zone). Fixes: e900a918b098 ("mm: shuffle initial free memory to improve memory-side-cache utilization") Cc: stable@vger.kernel.org # v5.2+ Cc: Andrew Morton Cc: Johannes Weiner Cc: Michal Hocko Cc: Minchan Kim Cc: Huang Ying Cc: Wei Yang Cc: Mel Gorman Signed-off-by: David Hildenbrand Acked-by: Michal Hocko --- mm/shuffle.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mm/shuffle.c b/mm/shuffle.c index 44406d9977c77..dd13ab851b3ee 100644 --- a/mm/shuffle.c +++ b/mm/shuffle.c @@ -58,25 +58,25 @@ module_param_call(shuffle, shuffle_store, shuffle_show, &shuffle_param, 0400); * For two pages to be swapped in the shuffle, they must be free (on a * 'free_area' lru), have the same order, and have the same migratetype. */ -static struct page * __meminit shuffle_valid_page(unsigned long pfn, int order) +static struct page * __meminit shuffle_valid_page(struct zone *zone, + unsigned long pfn, int order) { - struct page *page; + struct page *page = pfn_to_online_page(pfn); /* * Given we're dealing with randomly selected pfns in a zone we * need to ask questions like... */ - /* ...is the pfn even in the memmap? */ - if (!pfn_valid_within(pfn)) + /* ... is the page managed by the buddy? */ + if (!page) return NULL; - /* ...is the pfn in a present section or a hole? */ - if (!pfn_in_present_section(pfn)) + /* ... is the page assigned to the same zone? */ + if (page_zone(page) != zone) return NULL; /* ...is the page free and currently on a free_area list? */ - page = pfn_to_page(pfn); if (!PageBuddy(page)) return NULL; @@ -123,7 +123,7 @@ void __meminit __shuffle_zone(struct zone *z) * page_j randomly selected in the span @zone_start_pfn to * @spanned_pages. */ - page_i = shuffle_valid_page(i, order); + page_i = shuffle_valid_page(z, i, order); if (!page_i) continue; @@ -137,7 +137,7 @@ void __meminit __shuffle_zone(struct zone *z) j = z->zone_start_pfn + ALIGN_DOWN(get_random_long() % z->spanned_pages, order_pages); - page_j = shuffle_valid_page(j, order); + page_j = shuffle_valid_page(z, j, order); if (page_j && page_j != page_i) break; } From patchwork Tue Jun 16 11:52:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 11607235 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 A9524912 for ; Tue, 16 Jun 2020 11:52:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7678420A8B for ; Tue, 16 Jun 2020 11:52:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AK7evnOd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7678420A8B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 54B786B009D; Tue, 16 Jun 2020 07:52:34 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4FDF86B009E; Tue, 16 Jun 2020 07:52:34 -0400 (EDT) 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 3C32C8D0006; Tue, 16 Jun 2020 07:52:34 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0177.hostedemail.com [216.40.44.177]) by kanga.kvack.org (Postfix) with ESMTP id 15F9A6B009D for ; Tue, 16 Jun 2020 07:52:34 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id CBC74349B for ; Tue, 16 Jun 2020 11:52:33 +0000 (UTC) X-FDA: 76934912586.18.self87_1c10afc26dfe Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id B1053100EDBE8 for ; Tue, 16 Jun 2020 11:52:33 +0000 (UTC) X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,david@redhat.com,,RULES_HIT:30054:30064,0,RBL:207.211.31.81:@redhat.com:.lbl8.mailshell.net-66.10.201.10 62.18.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: self87_1c10afc26dfe X-Filterd-Recvd-Size: 5472 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Tue, 16 Jun 2020 11:52:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592308352; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ugu/lz/Ohiem/N+G3mekJ5cFi/CkmO5XsY98FkVNogA=; b=AK7evnOd3/eBlsCi7OydPjn43TJzmXOW5qleDlB1QGdCNDRk8w6qorWuuWbExbh3Zquy/f PILZJ0yMXsUhnDPLQQTMT8kSYMeLyDruRiZK4NihBMa04OvZuK/QpZ+kISFqsj8/F8ZCFl LTAkjkAWFFdJJmSZo/HNBnr1++uPzm0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-303-3ERa-NW9N6ufK_1HQfPbtg-1; Tue, 16 Jun 2020 07:52:29 -0400 X-MC-Unique: 3ERa-NW9N6ufK_1HQfPbtg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9D45580F5CD; Tue, 16 Jun 2020 11:52:27 +0000 (UTC) Received: from t480s.redhat.com (ovpn-114-106.ams2.redhat.com [10.36.114.106]) by smtp.corp.redhat.com (Postfix) with ESMTP id E0E087CAC2; Tue, 16 Jun 2020 11:52:23 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Alexander Duyck , Dan Williams , Michal Hocko , Dave Hansen , Kees Cook , Mel Gorman Subject: [PATCH v1 2/3] mm/memory_hotplug: don't shuffle complete zone when onlining memory Date: Tue, 16 Jun 2020 13:52:12 +0200 Message-Id: <20200616115213.13109-3-david@redhat.com> In-Reply-To: <20200616115213.13109-1-david@redhat.com> References: <20200616115213.13109-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Rspamd-Queue-Id: B1053100EDBE8 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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: Commit e900a918b098 ("mm: shuffle initial free memory to improve memory-side-cache utilization") introduced shuffling of free pages during system boot and whenever we online memory blocks. However, whenever we online memory blocks, all pages that will be exposed to the buddy end up getting freed via __free_one_page(). In the general case, we free these pages in MAX_ORDER - 1 chunks, which corresponds to the shuffle order. Inside __free_one_page(), we will already shuffle the newly onlined pages using "to_tail = shuffle_pick_tail();". Drop explicit zone shuffling on memory hotplug. Note: When hotplugging a DIMM, each memory block (e.g., 128MB .. 2G on x86-64) will get onlined individually, resulting in a shuffle_zone() for every memory block getting onlined. Cc: Andrew Morton Cc: Alexander Duyck Cc: Dan Williams Cc: Michal Hocko Cc: Dave Hansen Cc: Kees Cook Cc: Mel Gorman Signed-off-by: David Hildenbrand Acked-by: Michal Hocko Nacked-by: Dan Williams --- mm/memory_hotplug.c | 3 --- mm/shuffle.c | 2 +- mm/shuffle.h | 12 ------------ 3 files changed, 1 insertion(+), 16 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 9b34e03e730a4..845a517649c71 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -40,7 +40,6 @@ #include #include "internal.h" -#include "shuffle.h" /* * online_page_callback contains pointer to current page onlining function. @@ -822,8 +821,6 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, zone->zone_pgdat->node_present_pages += onlined_pages; pgdat_resize_unlock(zone->zone_pgdat, &flags); - shuffle_zone(zone); - node_states_set_node(nid, &arg); if (need_zonelists_rebuild) build_all_zonelists(NULL); diff --git a/mm/shuffle.c b/mm/shuffle.c index dd13ab851b3ee..609c26aa57db0 100644 --- a/mm/shuffle.c +++ b/mm/shuffle.c @@ -180,7 +180,7 @@ void __meminit __shuffle_free_memory(pg_data_t *pgdat) struct zone *z; for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++) - shuffle_zone(z); + __shuffle_zone(z); } bool shuffle_pick_tail(void) diff --git a/mm/shuffle.h b/mm/shuffle.h index 4d79f03b6658f..657e2b9ec38dd 100644 --- a/mm/shuffle.h +++ b/mm/shuffle.h @@ -30,14 +30,6 @@ static inline void shuffle_free_memory(pg_data_t *pgdat) __shuffle_free_memory(pgdat); } -extern void __shuffle_zone(struct zone *z); -static inline void shuffle_zone(struct zone *z) -{ - if (!static_branch_unlikely(&page_alloc_shuffle_key)) - return; - __shuffle_zone(z); -} - static inline bool is_shuffle_order(int order) { if (!static_branch_unlikely(&page_alloc_shuffle_key)) @@ -54,10 +46,6 @@ static inline void shuffle_free_memory(pg_data_t *pgdat) { } -static inline void shuffle_zone(struct zone *z) -{ -} - static inline void page_alloc_shuffle(enum mm_shuffle_ctl ctl) { } From patchwork Tue Jun 16 11:52:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 11607237 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 ABBE9912 for ; Tue, 16 Jun 2020 11:52:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 798F420A8B for ; Tue, 16 Jun 2020 11:52:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fcCyJVYq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 798F420A8B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9DEB46B009F; Tue, 16 Jun 2020 07:52:39 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 967926B00A0; Tue, 16 Jun 2020 07:52:39 -0400 (EDT) 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 82F956B00A1; Tue, 16 Jun 2020 07:52:39 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0082.hostedemail.com [216.40.44.82]) by kanga.kvack.org (Postfix) with ESMTP id 655286B009F for ; Tue, 16 Jun 2020 07:52:39 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 2C7F2824934B for ; Tue, 16 Jun 2020 11:52:39 +0000 (UTC) X-FDA: 76934912838.07.heart62_42040fd26dfe Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id F32AC1803F9A7 for ; Tue, 16 Jun 2020 11:52:38 +0000 (UTC) X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,david@redhat.com,,RULES_HIT:30054:30064:30090,0,RBL:207.211.31.81:@redhat.com:.lbl8.mailshell.net-66.10.201.10 62.18.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: heart62_42040fd26dfe X-Filterd-Recvd-Size: 6424 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Tue, 16 Jun 2020 11:52:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592308357; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0u70X+6091ldYMfR0Lh17cf24icfwEIvRCnUc/IkzSM=; b=fcCyJVYqZJRRKtwvU8SrO0KdIx1pPbN6oYLgEKBcf5I2GiXyjSSYShJo9XuKPmF389/IYM JYPTk38lYzcfyX4ly7A7cGeLii3fYN6qlcin5AH38qAUGmnaOni4qnEnyKOmV5p9HxBC8u 5vXLyDzABKSx+Prth7j4ZXYxyMHM07Q= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-351-RkqmAsI4OhirDalbWuG3_Q-1; Tue, 16 Jun 2020 07:52:31 -0400 X-MC-Unique: RkqmAsI4OhirDalbWuG3_Q-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 229D9803329; Tue, 16 Jun 2020 11:52:30 +0000 (UTC) Received: from t480s.redhat.com (ovpn-114-106.ams2.redhat.com [10.36.114.106]) by smtp.corp.redhat.com (Postfix) with ESMTP id F1162707C6; Tue, 16 Jun 2020 11:52:27 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Johannes Weiner , Michal Hocko , Minchan Kim , Huang Ying , Wei Yang , Keith Busch , Mel Gorman Subject: [PATCH v1 3/3] mm/shuffle: remove dynamic reconfiguration Date: Tue, 16 Jun 2020 13:52:13 +0200 Message-Id: <20200616115213.13109-4-david@redhat.com> In-Reply-To: <20200616115213.13109-1-david@redhat.com> References: <20200616115213.13109-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Rspamd-Queue-Id: F32AC1803F9A7 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: Commit e900a918b098 ("mm: shuffle initial free memory to improve memory-side-cache utilization") promised "autodetection of a memory-side-cache (to be added in a follow-on patch)" over a year ago. The original series included patches [1], however, they were dropped during review [2] to be followed-up later. Let's simplify for now and re-add when really (ever?) needed. [1] https://lkml.kernel.org/r/154510700291.1941238.817190985966612531.stgit@dwillia2-desk3.amr.corp.intel.com/ [2] https://lkml.kernel.org/r/154690326478.676627.103843791978176914.stgit@dwillia2-desk3.amr.corp.intel.com/ Cc: Andrew Morton Cc: Johannes Weiner Cc: Michal Hocko Cc: Minchan Kim Cc: Huang Ying Cc: Wei Yang Cc: Keith Busch Cc: Mel Gorman Signed-off-by: David Hildenbrand --- mm/shuffle.c | 28 ++-------------------------- mm/shuffle.h | 17 ----------------- 2 files changed, 2 insertions(+), 43 deletions(-) diff --git a/mm/shuffle.c b/mm/shuffle.c index 609c26aa57db0..702c0d5cf276c 100644 --- a/mm/shuffle.c +++ b/mm/shuffle.c @@ -10,33 +10,11 @@ #include "shuffle.h" DEFINE_STATIC_KEY_FALSE(page_alloc_shuffle_key); -static unsigned long shuffle_state __ro_after_init; - -/* - * Depending on the architecture, module parameter parsing may run - * before, or after the cache detection. SHUFFLE_FORCE_DISABLE prevents, - * or reverts the enabling of the shuffle implementation. SHUFFLE_ENABLE - * attempts to turn on the implementation, but aborts if it finds - * SHUFFLE_FORCE_DISABLE already set. - */ -__meminit void page_alloc_shuffle(enum mm_shuffle_ctl ctl) -{ - if (ctl == SHUFFLE_FORCE_DISABLE) - set_bit(SHUFFLE_FORCE_DISABLE, &shuffle_state); - - if (test_bit(SHUFFLE_FORCE_DISABLE, &shuffle_state)) { - if (test_and_clear_bit(SHUFFLE_ENABLE, &shuffle_state)) - static_branch_disable(&page_alloc_shuffle_key); - } else if (ctl == SHUFFLE_ENABLE - && !test_and_set_bit(SHUFFLE_ENABLE, &shuffle_state)) - static_branch_enable(&page_alloc_shuffle_key); -} static bool shuffle_param; static int shuffle_show(char *buffer, const struct kernel_param *kp) { - return sprintf(buffer, "%c\n", test_bit(SHUFFLE_ENABLE, &shuffle_state) - ? 'Y' : 'N'); + return sprintf(buffer, "%c\n", shuffle_param ? 'Y' : 'N'); } static __meminit int shuffle_store(const char *val, @@ -47,9 +25,7 @@ static __meminit int shuffle_store(const char *val, if (rc < 0) return rc; if (shuffle_param) - page_alloc_shuffle(SHUFFLE_ENABLE); - else - page_alloc_shuffle(SHUFFLE_FORCE_DISABLE); + static_branch_enable(&page_alloc_shuffle_key); return 0; } module_param_call(shuffle, shuffle_store, shuffle_show, &shuffle_param, 0400); diff --git a/mm/shuffle.h b/mm/shuffle.h index 657e2b9ec38dd..5574cbd4611e3 100644 --- a/mm/shuffle.h +++ b/mm/shuffle.h @@ -4,23 +4,10 @@ #define _MM_SHUFFLE_H #include -/* - * SHUFFLE_ENABLE is called from the command line enabling path, or by - * platform-firmware enabling that indicates the presence of a - * direct-mapped memory-side-cache. SHUFFLE_FORCE_DISABLE is called from - * the command line path and overrides any previous or future - * SHUFFLE_ENABLE. - */ -enum mm_shuffle_ctl { - SHUFFLE_ENABLE, - SHUFFLE_FORCE_DISABLE, -}; - #define SHUFFLE_ORDER (MAX_ORDER-1) #ifdef CONFIG_SHUFFLE_PAGE_ALLOCATOR DECLARE_STATIC_KEY_FALSE(page_alloc_shuffle_key); -extern void page_alloc_shuffle(enum mm_shuffle_ctl ctl); extern void __shuffle_free_memory(pg_data_t *pgdat); extern bool shuffle_pick_tail(void); static inline void shuffle_free_memory(pg_data_t *pgdat) @@ -46,10 +33,6 @@ static inline void shuffle_free_memory(pg_data_t *pgdat) { } -static inline void page_alloc_shuffle(enum mm_shuffle_ctl ctl) -{ -} - static inline bool is_shuffle_order(int order) { return false;