linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Zi Yan <ziy@nvidia.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Huang,
	Ying" <ying.huang@intel.com>, Ryan Roberts <ryan.roberts@arm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	"Matthew Wilcox (Oracle)" <willy@infradead.org>,
	David Hildenbrand <david@redhat.com>,
	"Yin, Fengwei" <fengwei.yin@intel.com>,
	Yu Zhao <yuzhao@google.com>,
	"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	Kemeng Shi <shikemeng@huaweicloud.com>,
	Mel Gorman <mgorman@techsingularity.net>,
	Rohan Puri <rohan.puri15@gmail.com>,
	Mcgrof Chamberlain <mcgrof@kernel.org>,
	Adam Manzanares <a.manzanares@samsung.com>,
	"Vishal Moola (Oracle)" <vishal.moola@gmail.com>
Subject: Re: [PATCH v5 2/3] mm/compaction: add support for >0 order folio memory compaction.
Date: Thu, 15 Feb 2024 21:02:55 +0100	[thread overview]
Message-ID: <25a80b95-93e6-4d68-a3b1-35cd3ef9c421@suse.cz> (raw)
In-Reply-To: <CA1FC23E-A652-4DD9-8E79-4956B2E11921@nvidia.com>

On 2/15/24 18:32, Zi Yan wrote:
> On 15 Feb 2024, at 11:57, Vlastimil Babka wrote:
> 
>> On 2/14/24 23:04, Zi Yan wrote:
>>> @@ -1849,10 +1857,22 @@ static struct folio *compaction_alloc(struct folio *src, unsigned long data)
>>>  static void compaction_free(struct folio *dst, unsigned long data)
>>>  {
>>>  	struct compact_control *cc = (struct compact_control *)data;
>>> +	int order = folio_order(dst);
>>> +	struct page *page = &dst->page;
>>> +
>>> +	if (folio_put_testzero(dst)) {
>>> +		free_pages_prepare_fpi_none(page, order);
>>> +
>>> +		INIT_LIST_HEAD(&dst->lru);
>>
>> (is this even needed? I think the state of first parameter of list_add() is
>> never expected to be in particular state?)
> 
> There is a __list_add_valid() performing list corruption checks.

Yes, but dst->lru becomes "new" in list_add() and __list_add_valid() and
those never check the contents of new, i.e. new->next or new->prev. We could
have done list_del(&dst->lru) which puts poison values there and then a
list_add() is fine. So dst->lru does not need the init, it's just confusing.
Init is for the list's list_head, not for the list entry.

>>>
>>> -	list_add(&dst->lru, &cc->freepages);
>>> -	cc->nr_freepages++;
>>> -	cc->nr_migratepages += 1 << folio_order(dst);
>>> +		list_add(&dst->lru, &cc->freepages[order]);
>>> +		cc->nr_freepages += 1 << order;
>>> +		cc->nr_migratepages += 1 << order;
>>
>> Hm actually this increment of nr_migratepages should happen even if we lost
>> the free page.
> 
> Because compaction_free() indicates the page is not migrated and nr_migratepages
> should be increased regardless.

Yes.

> Will fix it. Thanks.
> 
>>> +	}
>>> +	/*
>>> +	 * someone else has referenced the page, we cannot take it back to our
>>> +	 * free list.
>>> +	 */
>>>  }
> 
> 
> --
> Best Regards,
> Yan, Zi



  reply	other threads:[~2024-02-15 20:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-14 22:04 [PATCH v5 0/3] Enable >0 order folio memory compaction Zi Yan
2024-02-14 22:04 ` [PATCH v5 1/3] mm/compaction: enable compacting >0 order folios Zi Yan
2024-02-15 15:22   ` Vlastimil Babka
2024-02-14 22:04 ` [PATCH v5 2/3] mm/compaction: add support for >0 order folio memory compaction Zi Yan
2024-02-15 16:07   ` Vlastimil Babka
2024-02-15 16:13     ` Zi Yan
2024-02-15 16:57   ` Vlastimil Babka
2024-02-15 17:32     ` Zi Yan
2024-02-15 20:02       ` Vlastimil Babka [this message]
2024-02-15 20:04         ` Zi Yan
2024-02-14 22:04 ` [PATCH v5 3/3] mm/compaction: optimize >0 order folio compaction with free page split Zi Yan
2024-02-15 16:52   ` Vlastimil Babka

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=25a80b95-93e6-4d68-a3b1-35cd3ef9c421@suse.cz \
    --to=vbabka@suse.cz \
    --cc=a.manzanares@samsung.com \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=david@redhat.com \
    --cc=fengwei.yin@intel.com \
    --cc=hannes@cmpxchg.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mcgrof@kernel.org \
    --cc=mgorman@techsingularity.net \
    --cc=rohan.puri15@gmail.com \
    --cc=ryan.roberts@arm.com \
    --cc=shikemeng@huaweicloud.com \
    --cc=vishal.moola@gmail.com \
    --cc=willy@infradead.org \
    --cc=ying.huang@intel.com \
    --cc=yuzhao@google.com \
    --cc=ziy@nvidia.com \
    /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;
as well as URLs for NNTP newsgroup(s).