linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Zi Yan <ziy@nvidia.com>
To: David Hildenbrand <david@redhat.com>
Cc: linux-mm@kvack.org, Oscar Salvador <osalvador@suse.de>,
	Vlastimil Babka <vbabka@suse.cz>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Mel Gorman <mgorman@suse.de>,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 4/4] mm/page_isolation: remove migratetype parameter from more functions.
Date: Tue, 03 Sep 2024 22:02:32 -0400	[thread overview]
Message-ID: <BDD48C59-0C42-4B1E-A4F3-FF97744FCF6D@nvidia.com> (raw)
In-Reply-To: <dff8fa34-9099-46f9-b39a-1a986af2b022@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 4620 bytes --]

On 2 Sep 2024, at 12:42, David Hildenbrand wrote:

> On 02.09.24 17:34, Zi Yan wrote:
>> On 2 Sep 2024, at 5:06, David Hildenbrand wrote:
>>
>>> On 28.08.24 22:22, Zi Yan wrote:
>>>> migratetype is no longer overwritten during pageblock isolation,
>>>> start_isolate_page_range(), has_unmovable_pages(), and
>>>> set_migratetype_isolate() no longer need which migratetype to restore
>>>> during isolation failure. For has_unmoable_pages(), it needs to know if
>>>> the isolation is for CMA allocation, so adding CMA_ALLOCATION to isolation
>>>> flags to provide the information.
>>>>
>>>> Signed-off-by: Zi Yan <ziy@nvidia.com>
>>>> ---
>>>>    include/linux/page-isolation.h |  3 ++-
>>>>    mm/memory_hotplug.c            |  1 -
>>>>    mm/page_alloc.c                |  4 +++-
>>>>    mm/page_isolation.c            | 27 +++++++++++----------------
>>>>    4 files changed, 16 insertions(+), 19 deletions(-)
>>>>
>>>> diff --git a/include/linux/page-isolation.h b/include/linux/page-isolation.h
>>>> index c2a1bd621561..e94117101b6c 100644
>>>> --- a/include/linux/page-isolation.h
>>>> +++ b/include/linux/page-isolation.h
>>>> @@ -32,13 +32,14 @@ static inline bool is_migrate_isolate(int migratetype)
>>>>     #define MEMORY_OFFLINE	0x1
>>>>    #define REPORT_FAILURE	0x2
>>>> +#define CMA_ALLOCATION	0x4
>>>>     void set_pageblock_migratetype(struct page *page, int migratetype);
>>>>     bool move_freepages_block_isolate(struct zone *zone, struct page *page);
>>>>     int start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn,
>>>> -			     int migratetype, int flags, gfp_t gfp_flags);
>>>> +			     int flags, gfp_t gfp_flags);
>>>>     void undo_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn);
>>>>   diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
>>>> index 4265272faf4c..fe0b71e0f307 100644
>>>> --- a/mm/memory_hotplug.c
>>>> +++ b/mm/memory_hotplug.c
>>>> @@ -1993,7 +1993,6 @@ int offline_pages(unsigned long start_pfn, unsigned long nr_pages,
>>>>     	/* set above range as isolated */
>>>>    	ret = start_isolate_page_range(start_pfn, end_pfn,
>>>> -				       MIGRATE_MOVABLE,
>>>>    				       MEMORY_OFFLINE | REPORT_FAILURE,
>>>>    				       GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL);
>>>>    	if (ret) {
>>>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>>>> index 4d06932ba69a..c60bb95d7e65 100644
>>>> --- a/mm/page_alloc.c
>>>> +++ b/mm/page_alloc.c
>>>> @@ -6607,7 +6607,9 @@ int alloc_contig_range_noprof(unsigned long start, unsigned long end,
>>>>    	 * put back to page allocator so that buddy can use them.
>>>>    	 */
>>>>   -	ret = start_isolate_page_range(start, end, migratetype, 0, gfp_mask);
>>>> +	ret = start_isolate_page_range(start, end,
>>>> +			migratetype == MIGRATE_CMA ? CMA_ALLOCATION : 0,
>>>
>>> Can we have flags for alloc_contig_range() instead of passing in a (weird) migratetype?
>>>
>>> Then, we should make sure that we warn if we try a CMA allocation on any pageblock that is not of type CMA.
>>
>> Sure. I will expose the existing isolation flags (MEMORY_OFFLINE, REPORT_FAILURE,
>> and CMA_ALLOCATION) as alloc_contig_range() parameter to replace migratetype one.
>>
>
> Maybe we want some proper, distinct alloc_contig_range() falgs "acr_flags_t". Might be cleanest, to express anything that doesn't fall into the gfp_t flag category.
>
> Exposing MEMORY_OFFLINE feels wrong, for example.

OK, it seems that I mixed up of start_isolate_page_range() flags with
alloc_contig_range() flags. Let me clarify them below.

For start_isolate_page_range(), memory offline calls it separately and
needs MEMORY_OFFLINE and REPORT_FAILURE; CMA allocation uses it via
alloc_contig_range() and needs a flag (like CMA_ALLOCATION) for its
own checks.

BTW, it seems to me that MEMORY_OFFLINE and REPORT_FAILURE can be merged,
since they are always used together. Let me know if you disagree.

For alloc_contig_range(), migratetype parameter is what you are talking about
above. There are two callers: cma_alloc() and alloc_contig_pages().
The acr_flags_t is basically a caller id. Something like?
enum acr_flags_t {
	ACR_CMA_ALLOC,
	ACR_CONTIG_PAGES,
};

And ACR_CMA_ALLOC needs to be translated to CMA_ALLOCATION when
start_isolate_page_range() is called.

BTW, after removing migratetype parameter from alloc_contig_range(),
the tracepoint in __alloc_contig_migrate_range() needs to be changed to
use acr_flags_t, since I do not think we want to convert acr_flags_t
back to migratetype.


Best Regards,
Yan, Zi

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 854 bytes --]

  reply	other threads:[~2024-09-04  2:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-28 20:22 [RFC PATCH 0/4] Make MIGRATE_ISOLATE a standalone bit Zi Yan
2024-08-28 20:22 ` [RFC PATCH 1/4] mm/page_isolation: make page isolation " Zi Yan
2024-08-28 20:22 ` [RFC PATCH 2/4] mm/page_isolation: remove migratetype from move_freepages_block_isolate() Zi Yan
2024-09-02 14:42   ` David Hildenbrand
2024-09-02 15:30     ` Zi Yan
2024-08-28 20:22 ` [RFC PATCH 3/4] mm/page_isolation: remove migratetype from undo_isolate_page_range() Zi Yan
2024-09-02  9:00   ` David Hildenbrand
2024-09-02 15:34     ` Zi Yan
2024-08-28 20:22 ` [RFC PATCH 4/4] mm/page_isolation: remove migratetype parameter from more functions Zi Yan
2024-09-02  9:06   ` David Hildenbrand
2024-09-02 15:34     ` Zi Yan
2024-09-02 16:42       ` David Hildenbrand
2024-09-04  2:02         ` Zi Yan [this message]
2024-09-04  8:50           ` David Hildenbrand
2024-09-04 13:53             ` Zi Yan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BDD48C59-0C42-4B1E-A4F3-FF97744FCF6D@nvidia.com \
    --to=ziy@nvidia.com \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=david@redhat.com \
    --cc=hannes@cmpxchg.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=osalvador@suse.de \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox