Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp446595lqb; Wed, 17 Apr 2024 00:35:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUkUnxZlyuluvZKNFHLhLdWzn2K/LDEpU03wMYStVH2zn9BhjS+YZJEQfeso0kLljvWfB2FTo0vz4OpHGbuFOryaYeeS+RKmkPpNbN88Q== X-Google-Smtp-Source: AGHT+IHvqMwfy5uNSMsZZJ/6lCJUw6njUId/nTA+3ps1VrkMbgXSRQX2VzKe4sIedaWKNT66brdK X-Received: by 2002:a17:906:dac1:b0:a52:241b:b450 with SMTP id xi1-20020a170906dac100b00a52241bb450mr10205742ejb.36.1713339335672; Wed, 17 Apr 2024 00:35:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713339335; cv=pass; d=google.com; s=arc-20160816; b=is9Ahq0I4pR3/AHbQL2smJfOdTbqM1LrZAZm/5MgP7KQFubiRNgmK59uQKRHPFgTZJ RGmsZ4v4PI7wK62D1k9A8xgj6128XNyYQp/ZD//aEBOELZe2UKAI0Xn8WyGPtrYoQzjl Xd2sgtBAzvIU2EzK1SSxDBpaZZ4JrbeRQfxf7oy0daPAipFyBtkvCdK4e8l86yS2BnxF 95L69eDMBNrktOC6aEZBmNsNq6O7wg61vqZMF5+P07k+iAaKMQYSDxPJi7tDbJz9PfiL 94AnjUsbJanphxXdGd+BtG1ZUN7AcdEi/xaIRR2fplzfh4dmeORrFIVp0mjFr4K0rdnK yBMQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from; bh=oVNWWG+0CQkcyA+DIk7yFlw00zmRrOMdSG4j4afHB8k=; fh=ZH+M10KtJZRqSjFjp1+uAYTvsWtGX6qxh/YkifVvH1o=; b=BT+ORfwGCf8R4XbvNsh4AlZ34Wc72/bpxyzo8BSHY6wwxgEU72xKl4Kp0cBDITiZjJ Pww1p+2lB1R+oEjsJUWw0FUjDgtb2ogebZutx4xZOz0Khx3k6BXOnHkNgIL5QY+69kV/ JeThJinyXUtzhwtQBpzAwxf+XLehfBmks90kiwF2JyWxfLryUZ5pNTedMskQjlZik/Fi c35wJu4uB9UA+0BssNytnj2Xcl6oLi/pFdZDOBUr+Cy9G0WlA755YIUzdLxdEcptJXQZ 6VVWvTI+RfmQu+O+XboEBnc+I79nQP7lrb1NinXkIVmvKWlBjFif97tS2PcecsqpBT+n UsVQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=sk.com); spf=pass (google.com: domain of linux-kernel+bounces-148059-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148059-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id e23-20020a170906081700b00a553b58443asi1729783ejd.735.2024.04.17.00.35.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 00:35:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-148059-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=sk.com); spf=pass (google.com: domain of linux-kernel+bounces-148059-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148059-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0E4731F2227B for ; Wed, 17 Apr 2024 07:35:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 13FBA7D410; Wed, 17 Apr 2024 07:34:27 +0000 (UTC) Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 18A2E7441F for ; Wed, 17 Apr 2024 07:34:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=166.125.252.92 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713339266; cv=none; b=hkRm8cxCL2tHngh7AgmbxhQNOmqtvH+5TA4iXuO460Nnv5aZMVF/CYh3kOf7zN+IjogHk7iuqQ6a36LFYhJuX/f8V/xg8MlqKBsO8Ph1orB5yL9b5dKvoatn4RC45SFVI2G4GEyCld350GqYKKSa9eSKO3J2NKKqAWVvstJOcIc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713339266; c=relaxed/simple; bh=6UBLhiqsl7goEJIikM/TmWWuVZKMJGHJBKBpatkJWiI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=S8tGoUAhQ6CpFbZp6EOCE8ZIvSEKhglhT2mfrT+H136v/GryXHj+nNFpzZQkxIXGoQTYhabH+TEdNFa99jcdobPRqMQFb8pD/ZvbcyQADHUWPzm/8Y3uLHbK50ZSKH4a/KMSkhvezO1aKXgGXu1RSsRaQd8j2YzG5RUlg6ygvIM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sk.com; spf=pass smtp.mailfrom=sk.com; arc=none smtp.client-ip=166.125.252.92 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sk.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sk.com X-AuditID: a67dfc5b-d6dff70000001748-ac-661f77e2f414 From: Byungchul Park To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: kernel_team@skhynix.com, akpm@linux-foundation.org, ying.huang@intel.com, vernhao@tencent.com, mgorman@techsingularity.net, hughd@google.com, willy@infradead.org, david@redhat.com, peterz@infradead.org, luto@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, rjgolo@gmail.com Subject: [PATCH v9 6/8] mm: buddy: make room for a new variable, mgen, in struct page Date: Wed, 17 Apr 2024 16:18:45 +0900 Message-Id: <20240417071847.29584-7-byungchul@sk.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240417071847.29584-1-byungchul@sk.com> References: <20240417071847.29584-1-byungchul@sk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCLMWRmVeSWpSXmKPExsXC9ZZnke6jcvk0g5dflSzmrF/DZvF5wz82 ixcb2hktvq7/xWzx9FMfi8XlXXPYLO6t+c9qcX7XWlaLHUv3MVlcOrCAyeJ47wEmi/n3PrNZ bN40ldni+JSpjBa/fwAVn5w1mcVBwON7ax+Lx85Zd9k9Fmwq9di8Qstj8Z6XTB6bVnWyeWz6 NInd4925c+weJ2b8ZvGYdzLQ4/2+q2weW3/ZeTROvcbm8XmTXABfFJdNSmpOZllqkb5dAlfG v1kX2AquK1c8fuzZwLhIpouRk0NCwESi+fFKdhj7VuMaRhCbTUBd4saNn8wgtoiAmcTB1j9g NcwCd5kkDvSzgdjCAqESsz7NZwWxWQRUJV49XgtUz8HBK2AqMaOxBmKkvMTqDQfAxnACjdnc vAasVQio5PuJj0A2F1DNZzaJV+fes0I0SEocXHGDZQIj7wJGhlWMQpl5ZbmJmTkmehmVeZkV esn5uZsYgWG/rPZP9A7GTxeCDzEKcDAq8fAaRMmlCbEmlhVX5h5ilOBgVhLhbRGWTRPiTUms rEotyo8vKs1JLT7EKM3BoiTOa/StPEVIID2xJDU7NbUgtQgmy8TBKdXAuHhWdVnnz+yK0n0y p5g0kk3sdm1K3yxft1qYb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ger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Functionally, no change. This is a preparation for migrc mechanism that tracks need of tlb flush for each page residing in buddy, using a generation number in struct page. Fortunately, since the private field in struct page is used only to store page order in buddy, ranging from 0 to MAX_PAGE_ORDER, that can be covered with unsigned short int. So splitted it into two smaller ones, order and mgen, so that the both can be used in buddy at the same time. Signed-off-by: Byungchul Park --- include/linux/mm_types.h | 39 ++++++++++++++++++++++++++++++++------- mm/internal.h | 4 ++-- mm/page_alloc.c | 13 ++++++++----- 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 5240bd7bca33..4130d22977d6 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -108,13 +108,24 @@ struct page { pgoff_t index; /* Our offset within mapping. */ unsigned long share; /* share count for fsdax */ }; - /** - * @private: Mapping-private opaque data. - * Usually used for buffer_heads if PagePrivate. - * Used for swp_entry_t if PageSwapCache. - * Indicates order in the buddy system if PageBuddy. - */ - unsigned long private; + union { + /** + * @private: Mapping-private opaque data. + * Usually used for buffer_heads if PagePrivate. + * Used for swp_entry_t if PageSwapCache. + */ + unsigned long private; + struct { + /* + * Indicates order in the buddy system if PageBuddy. + */ + unsigned short int order; + /* + * Tracks need of tlb flush used by migrc + */ + unsigned short int mgen; + }; + }; }; struct { /* page_pool used by netstack */ /** @@ -520,6 +531,20 @@ static inline void set_page_private(struct page *page, unsigned long private) page->private = private; } +#define page_buddy_order(page) ((page)->order) + +static inline void set_page_buddy_order(struct page *page, unsigned int order) +{ + page->order = (unsigned short int)order; +} + +#define page_buddy_mgen(page) ((page)->mgen) + +static inline void set_page_buddy_mgen(struct page *page, unsigned short int mgen) +{ + page->mgen = mgen; +} + static inline void *folio_get_private(struct folio *folio) { return folio->private; diff --git a/mm/internal.h b/mm/internal.h index bbaf1fd97b1c..e3a8b77b58ca 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -364,7 +364,7 @@ struct alloc_context { static inline unsigned int buddy_order(struct page *page) { /* PageBuddy() must be checked by the caller */ - return page_private(page); + return page_buddy_order(page); } /* @@ -378,7 +378,7 @@ static inline unsigned int buddy_order(struct page *page) * times, potentially observing different values in the tests and the actual * use of the result. */ -#define buddy_order_unsafe(page) READ_ONCE(page_private(page)) +#define buddy_order_unsafe(page) READ_ONCE(page_buddy_order(page)) /* * This function checks whether a page is free && is the buddy diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 14d39f34d336..555f6d2e33ea 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -604,9 +604,12 @@ void destroy_large_folio(struct folio *folio) free_the_page(&folio->page, folio_order(folio)); } -static inline void set_buddy_order(struct page *page, unsigned int order) +static inline void set_buddy_order_mgen(struct page *page, + unsigned int order, + unsigned short int mgen) { - set_page_private(page, order); + set_page_buddy_order(page, order); + set_page_buddy_mgen(page, order); __SetPageBuddy(page); } @@ -824,7 +827,7 @@ static inline void __free_one_page(struct page *page, } done_merging: - set_buddy_order(page, order); + set_buddy_order_mgen(page, order, 0); if (fpi_flags & FPI_TO_TAIL) to_tail = true; @@ -1404,7 +1407,7 @@ static inline void expand(struct zone *zone, struct page *page, continue; add_to_free_list(&page[size], zone, high, migratetype); - set_buddy_order(&page[size], high); + set_buddy_order_mgen(&page[size], high, 0); } } @@ -6710,7 +6713,7 @@ static void break_down_buddy_pages(struct zone *zone, struct page *page, continue; add_to_free_list(current_buddy, zone, high, migratetype); - set_buddy_order(current_buddy, high); + set_buddy_order_mgen(current_buddy, high, 0); } } -- 2.17.1