From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 882B6E7719E for ; Mon, 13 Jan 2025 07:00:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1CBC46B0085; Mon, 13 Jan 2025 02:00:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 17BB36B0088; Mon, 13 Jan 2025 02:00:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 06B6E6B0089; Mon, 13 Jan 2025 02:00:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id DB2166B0085 for ; Mon, 13 Jan 2025 02:00:43 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 66EBB1A1BD5 for ; Mon, 13 Jan 2025 07:00:43 +0000 (UTC) X-FDA: 83001530766.26.BF4A240 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by imf15.hostedemail.com (Postfix) with ESMTP id C6CCFA001A for ; Mon, 13 Jan 2025 07:00:40 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=aOjQkkKi; spf=pass (imf15.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736751641; a=rsa-sha256; cv=none; b=0LbH65UlTQeO6z+ucWZHZltR7YnrMHaMn4lVEpzqa47e6Mev7wlv0Pqck6GZqFAbDXlrB1 VUOcCWlQHB0N32OQdqTVcPDiNGysulCTMqPIuRMr1yTPm24EIpS2saSiYCdNfuCZ0xI0h+ 6Wv7IYAVgoH3cSuh7LNYAe6176bYXPM= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=aOjQkkKi; spf=pass (imf15.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736751641; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=CYlTVnFaSqtVQm0GJy1QXf1k66JEw/OIg3wL+iPfpow=; b=l8DCQEQWVftDhSTIK3QN+boxjHqiQsd61kRuaAQ8OqZScD2IsUR6DddK01GdmMOHxvKsSJ x94TT7YdmfP1g92V6eHbaSPa6KQMdljtWDLhwXJAIF53M18jSwaK3HQfr9OBwEBa2CLF7a sMzq2G+TyWmsGKfKdTZG6VQIszBaDHY= DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1736751637; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=CYlTVnFaSqtVQm0GJy1QXf1k66JEw/OIg3wL+iPfpow=; b=aOjQkkKiLb+Yxly9UFgHcvpoD2aen8HTBgwESS8+R8NrPDY9NGMzHBQx5WlZo3gGsXbJvrq+jHcq9KnXZLEH0i1Cl1qWaauSOwnID/ghQDnPkKppQsW9gQiMeyUJ7ke5Y7xWGqIC5Y9PgNL0pdLTfQhNGtOInShJ91+umtUMz7M= Received: from 30.74.144.122(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WNUciYq_1736751635 cluster:ay36) by smtp.aliyun-inc.com; Mon, 13 Jan 2025 15:00:36 +0800 Message-ID: Date: Mon, 13 Jan 2025 15:00:35 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 3/6] mm/migrate: don't call folio_putback_active_hugetlb() on dst hugetlb folio To: David Hildenbrand , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Andrew Morton , Muchun Song , "Matthew Wilcox (Oracle)" References: <20250110182149.746551-1-david@redhat.com> <20250110182149.746551-4-david@redhat.com> From: Baolin Wang In-Reply-To: <20250110182149.746551-4-david@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: C6CCFA001A X-Stat-Signature: q98q9e73r7bqqbaxopsz95ezkm71sxe7 X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1736751640-397805 X-HE-Meta: U2FsdGVkX18P5WXS86fOiMrArLSXTmnh9oWywqd1sd5K5I8kTWQOmU35pOy6EChLwqoGQ9ZaTUXxn3JY3+2yPwDO9MNHwCJ1E7YVrmYffSZVrej40vH2tsbpyfjOgQOCsuCtJP/reSOgf+BdUvGbUpW4n+9hULz/nd7WzIqzTmPxLLtqB2MKn/UHnv32ypVSeXAkoWjxNUDTDpTRaB37XMiyusvVg4mLjXiSEt+jv98C54k0gt3rOfepXDXVdu7YsMn8BmYZ0oFoiahOsIxwUaGCryR49tkx+L4h0/rObgkrf8/v9LwqRrVSSkLaL9EucP6kPmheq3mVPKeqX9MaMBbMbHyA9zWIvNsbjs8tP80F86qo/Uusdnoa9he5+NGVKZBScds8jFg6bnQ1eY+I3MrM+GGqjmmJlsxxV3q/g84plgk1ukG21PcJ4QJ/GZu73eNq/LmLUVddtHPKfR5nV8kUA3TEVqXU6PWdYx/nLkuV572wJlG9nCuEb20v4d41lGbSfFpC8ku9Urnq98AlF4PM4v8KuaNNM7KON1sBeeZ0V63pYwSHXH7MctNaXPk3dxkHBf6rpWtkfsI3NIxJSIfEXHExW+QzZDaTYXSM0n+PF07JtdJHhJs5TqHGer0Etg5h1taIMoeZvNi6u5MlRkqZR3aBFFhf87tD6Qr7Ziwuw9LcoA+/jOO1q5e+jj5MJtN619qm+VBer9aGK4DagsvE77sC6pdfuztVsa2QTwRrABbTlrr3ZvMDgzxZw4igMvwkJk6GjOYU2UmnhIrue70PeX5HDRUA7y80Lko3NooY8p1dtPvY+XCYq+iFaVA23pgxUhk9UR22qiNowjsDPDC6/a+UO8Nn5HWj47mdLVmvsPcj2ZIWnkc22jzMjtqgcpwMjXAjqqHHlD92wamcFCYv101vER547YYT3P1aNQxqWMvS5txcAdFyujsjihbDR8w4W6aRdp6XaokuYbW o8Vs94cB +Kh77PmLnPN5+W7VRNzDX5TGvaSnFuO1+JWQGuDG5DF7ZS9VS2vBt6jcl0TLkyBoSPxudEjkkPyjw2Kq3vPVIRgSto/mSGay0N2eUBCdyqzGXpt0D4aXjS2w8XzvPnJFJN2a39P7OqabFuywXcpPjuWznH6zKmqW2kVD8fK+hE86kcj6nRhjm30hAPJSkl0pS5U0SOHhP5b8jXnTF82QaKYEqbz8RfTR4jhQRjJzF/UWDGI780ZiIQIhJyeC/5Bc6djOfdvLRNE63AkPL4sViYL7u0V2wyG+1VEDoOddteKwb4mglS1H7KJ6iZ6VfkeOY7org 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: List-Subscribe: List-Unsubscribe: On 2025/1/11 02:21, David Hildenbrand wrote: > We replaced a simple put_page() by a putback_active_hugepage() call in > commit 3aaa76e125c1 ("mm: migrate: hugetlb: putback destination hugepage > to active list"), to set the "active" flag on the dst hugetlb folio. > > Nowadays, we decoupled the "active" list from the flag, by calling the > flag "migratable". > > Calling "putback" on something that wasn't allocated is weird and not > future proof, especially if we might reach that path when migration failed > and we just want to free the freshly allocated hugetlb folio. > > Let's simply set the "migratable" flag in move_hugetlb_state(), where we > know that allocation succeeded, and use simple folio_put() to return > our reference. > > Do we need the hugetlb_lock for setting that flag? Staring at other > users of folio_set_hugetlb_migratable(), it does not look like it. After > all, the dst folio should already be on the active list, and we are not > modifying that list. > > Signed-off-by: David Hildenbrand > --- > mm/hugetlb.c | 5 +++++ > mm/migrate.c | 8 ++++---- > 2 files changed, 9 insertions(+), 4 deletions(-) > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index da98d671088d0..b24ccf8ecbf38 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -7529,6 +7529,11 @@ void move_hugetlb_state(struct folio *old_folio, struct folio *new_folio, int re > } > spin_unlock_irq(&hugetlb_lock); > } > + /* > + * Our old folio is isolated and has "migratable" cleared until it > + * is putback. As migration succeeded, set the new folio "migratable". > + */ > + folio_set_hugetlb_migratable(new_folio); > } > > static void hugetlb_unshare_pmds(struct vm_area_struct *vma, > diff --git a/mm/migrate.c b/mm/migrate.c > index 80887cadb2774..7e23e78f1e57b 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -1542,14 +1542,14 @@ static int unmap_and_move_huge_page(new_folio_t get_new_folio, > list_move_tail(&src->lru, ret); > > /* > - * If migration was not successful and there's a freeing callback, use > - * it. Otherwise, put_page() will drop the reference grabbed during > - * isolation. > + * If migration was not successful and there's a freeing callback, > + * return the folio to that special allocator. Otherwise, simply drop > + * our additional reference. > */ > if (put_new_folio) > put_new_folio(dst, private); > else > - folio_putback_active_hugetlb(dst); > + folio_put(dst); IIUC, after the changes, so the 'dst' folio might not be added into the 'h->hugepage_activelist' list (if the 'dst' is temporarily allocated), Could this cause any side effects?