From patchwork Mon Jan 13 13:16:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13937328 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 BA3E2E7719F for ; Mon, 13 Jan 2025 13:16:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 495436B0092; Mon, 13 Jan 2025 08:16:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 445FB6B0093; Mon, 13 Jan 2025 08:16:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1FC5A6B0096; Mon, 13 Jan 2025 08:16:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id E958D6B0092 for ; Mon, 13 Jan 2025 08:16:50 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id AD4A4C0285 for ; Mon, 13 Jan 2025 13:16:50 +0000 (UTC) X-FDA: 83002478580.13.A60BF32 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf24.hostedemail.com (Postfix) with ESMTP id 7005B180012 for ; Mon, 13 Jan 2025 13:16:48 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=jETnr+ie; spf=pass (imf24.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736774208; 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=cv8gcZXVG0aCvRchUy6M5ty//7bnFqYv0xGdrXbuesA=; b=TSNeA6BQ6xRdCD3TnepCoyB9+WwM4TmrizueRe5qk2wyT1MkqwOvxNtUBcfRMBatCsyoKN IUVbeXubkIo7gdAz8qdkklfrRwaY+mIlBDKT+miHz22rfmNIpaqV8li2PiGuS87rI3U4wU H4sw//PPRHrKomsCG6IrqjPuYOGwlHk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736774208; a=rsa-sha256; cv=none; b=wY5MSYzKXolStDhOcPL2cTJxi8RQUi2YUeFFqkhontUwd9LqTMAPjc9thC8gIDiOdhbAyc 9vbsGQU9j8/S2uuiHsokCXsogXAe2PMRZKe9LfH3L54AdXhALMGOEGAMfA93IUFSWtfjzf sueQ5Vykin7HOcjVS8OmwYbTp1IAxQ4= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=jETnr+ie; spf=pass (imf24.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736774207; h=from:from: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; bh=cv8gcZXVG0aCvRchUy6M5ty//7bnFqYv0xGdrXbuesA=; b=jETnr+ieyEH313V+te4mgQzw726+zcCfBc6oM/eGVNUPWs+8TWldUkG9hQr3D/1GhLNV2V WLYKntJLSZ0d5ssZqT7SQj4sAKpcnRCxDzAaTMSdbVBDT+oUZ93fD/QFmQ4pFOftLNLDwu sp3ab4rzAj3Tsn5kjfV7wsnIZOtczJo= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-448-70L3ggJmMAyuhFhQqzgvrA-1; Mon, 13 Jan 2025 08:16:46 -0500 X-MC-Unique: 70L3ggJmMAyuhFhQqzgvrA-1 X-Mimecast-MFC-AGG-ID: 70L3ggJmMAyuhFhQqzgvrA Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-386321c8f4bso2704206f8f.0 for ; Mon, 13 Jan 2025 05:16:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736774205; x=1737379005; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cv8gcZXVG0aCvRchUy6M5ty//7bnFqYv0xGdrXbuesA=; b=JtMMbdpy38zWIc8NgZe8FwOyXvbO/c1duG/6TFqj1erIxTFXFvtsTT2koT2hyp9WgX eg38BmWXh/JhavvgbSkmUMD414jJPbCLqjNscqqhHTNLfNn8jZqpCMKKbt9nujQ7gtKf ux/6j0BkLI//aBDPfhFLYHM95tTDDK58RwYNBLFsZXBkW9a2+64Xmze2YJkz/ZXIXKeF SvwNFGKudHdIbvMjI1t20zRzbALacSl4YwmRs0pDQBbAxT5LM1TGXgk7i9+JnQd4NfJn Mx5nr+Mxl3+x22KlYPtBDnvoaAGFf5EVmLAc4EqZ0eHtCEk1oBH2ZHauE5sjA0StIfvA upWg== X-Gm-Message-State: AOJu0YzhvcWIR5aSz9jt6rYAYHgepkzNXAyjIUpwPiFDX6pUUjIaCMLs r+8C3eXmTE+RAJDBGrq3RMMqIlKki2vc0PJ9gbB6ij8x05b6tzyxoDIRG/SntApmzxl0qWlJm78 gZrV77H8f+sYZJ7Nd1Is5bewSx8BW6tMgjErCz1arUTdChM7X X-Gm-Gg: ASbGncvFYjcVOCPBwFznvSN1E0WPyA5Hn1tj89PHO9i6BxVFb3V6C1JWiQG283JsXfe CsMWQLPFzqPtn3UFrfdtwtDKE5vJLhMwi4zrK/u2Mf2hBjLWvIt2t+ByHr8TwU/jVSWS+2TUcsn A1tUSkP2Cw7O/KJI4qRg7vsYrmAnuzunllYqJLP1fIwBGXotP8Vo/T3oqmBtKqdH/0LeyJ+UvZ+ bHh/kQgm82n2Xh96Nl5WDvaD+9eZDqQ6itN9ssq1TA3zA6H0MZP X-Received: by 2002:a5d:47a1:0:b0:38a:a11e:7af6 with SMTP id ffacd0b85a97d-38aa11e7bbbmr5899252f8f.6.1736774205624; Mon, 13 Jan 2025 05:16:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IHQTPL422wYOOzjgEgIHFmJ3rDpDAPc/5y/ASBw+pb+O+L0PBYtTTxIRKUApv2sGAZ8bIk3sA== X-Received: by 2002:a5d:47a1:0:b0:38a:a11e:7af6 with SMTP id ffacd0b85a97d-38aa11e7bbbmr5899222f8f.6.1736774205221; Mon, 13 Jan 2025 05:16:45 -0800 (PST) Received: from localhost ([2a09:80c0:192:0:5dac:bf3d:c41:c3e7]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-436dcceb374sm165750165e9.0.2025.01.13.05.16.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Jan 2025 05:16:43 -0800 (PST) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Muchun Song , "Matthew Wilcox (Oracle)" , Baolin Wang Subject: [PATCH v2 3/6] mm/migrate: don't call folio_putback_active_hugetlb() on dst hugetlb folio Date: Mon, 13 Jan 2025 14:16:08 +0100 Message-ID: <20250113131611.2554758-4-david@redhat.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250113131611.2554758-1-david@redhat.com> References: <20250113131611.2554758-1-david@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 5sO7C5sJ8uM7PX2ftSNEDg8fo8UsXgq2-7kcri7HRck_1736774206 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Rspamd-Queue-Id: 7005B180012 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: x95c4ku1tu57zqoi4pjn6awwxtd4fkt5 X-HE-Tag: 1736774208-480125 X-HE-Meta: U2FsdGVkX1+VgIVmH1eCOKHnM0DqK1WcDpQDK9NGvgIhmRQ2PraVJ++Wkizme7Ga3JU965Jk85JckwtPHHwMzBzu9dMKEb1g55aMwLw45PwYDvTYFESRQi8sO/oiGvEA4ug2jv37GcKtfBoG3e5oVc+e+3c8tqgpl0Fbunnub2gXdocqtcQjCaLsraBGzlZ3I4KWHnUyaEuDIYBhjSIzeAGIjEf8ekwSbR4BRo11OologfV/QTpnDKYeeIf+MTJhBD1gmB8HM2b9bgf3rut6kRmMVEFxgOea+yrNyT96gs4ABMyhonaJYUwC8BK1gV2wZb+jCmXvyiuNBAGTjToFjkUgeth6IXXzSxPTkA8G+NdFPViuHWHMmcRJv3MZ44GAyg1ibTAEwGL+Nv0JIQls+WiwuBFmtVBCykJ/q9nhYAkClISdgqZFgwNMO/gY9su+gendJtWnFFzbzWGm2Mvr6cTSbUnjo+ddYpCfsqb55Bkg2bz4ojBzHQsx8nsI58iXkSaLzscZEcBr02k65szafa9YHLMXCJWHfSGYKdm74DoQJgi9S3Qk9DCsdRcJ05IF5rp5UG9B2UEzi8z7j8AkNewHMwcGtuS2X3+DagiwFVxJ6UU+cL4J/l9iYfyYiFxd8kwdCjl/5vnmA43GG3Itpr7pM+1gFrvUDt5DA0QgkUKFpgysXlZ8f2gJktJ20qYSChJ4HCbsFxu1kT1W4dRloQ8cJ+3H9Ok0MFgUrueNHKESWZUgCHwOr7qhpiOKvn+DfFF65lWSO+p5Mp6FPppQrv1unNsb2IRE1/MDbRo1DmVJoRTXbe4qSu50pOUwKBu24cPZ8zmWSeAnURsiMskgz6scryfyH7iiOb5CBisqXgyf253NA7H3S6nivb9d/Kz0Una5nGpDSo1xKnwwLBp9opAwPIl02LlW+veYhpAfv10woHOluVc9MDp32k31ZAxbLt0VNrJ54brLFAnVPXl zA3wjnV2 Qc170ZGMCFy7fSsbZEPXGF1sTBw3JsnTbPYdkha4j7S4rMApK59qRz+VJqBWYBLhL0rwILLTsLUwSopDIGEH7fvOOGU8i4IHRS0pKUmYP4147hB5vld5teuUAMugBTRjWLWJa06Ra+WdpDxNUTPja5uiS/oE1fQ9bWqQamlQfpNaPDUhBfqMLym3HGGlNlrJ94Yfi5kaARXgR3mk3Bv0vJ3UloAg1Z0oRRvAZLkIev1CL7U5zJRv92yCkqLwVm2Il7ZDs+ZlMmGy+CPDoko8Ytn8QXID9pqHU3x1wIAo3FYBsfGZdWWJ3e0zELGGxxRq0tX+axD6C5BmiQUJ0zOeG7zN0UVzkZVjZlrZYcd2MkoKBH6TtwhU2/i3Lf9/JlEdbkqUOyT2JX7j3QuRAAmhxG3Uw0loa+9bGPFfJzhN7HT+Tpfnro3pdZMHjBJDkPAjySxALkRw+F560VkA7reWODVrKLrHNiDbj7FArCd4Da7qhHVbrwTWOkbmf/ywdAUp7rNLbX05TWK8+t1suRoU1T4eYsw== 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: 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 handle the migratable flag and the active list flag in move_hugetlb_state(), where we know that allocation succeeded and already handle the temporary flag; use a simple folio_put() to return our reference. Reviewed-by: Baolin Wang Signed-off-by: David Hildenbrand --- mm/hugetlb.c | 10 ++++++++++ mm/migrate.c | 8 ++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index a93b508bc0e0e..95579bd8c4fe0 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -7529,6 +7529,16 @@ 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" + * and add it to the active list. + */ + spin_lock_irq(&hugetlb_lock); + folio_set_hugetlb_migratable(new_folio); + list_move_tail(&new_folio->lru, &(folio_hstate(new_folio))->hugepage_activelist); + spin_unlock_irq(&hugetlb_lock); } 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); return rc; }