From patchwork Fri Nov 8 16:20:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 13868436 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 5FC15D5D69A for ; Fri, 8 Nov 2024 16:20:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 965816B0085; Fri, 8 Nov 2024 11:20:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 91D7B6B0099; Fri, 8 Nov 2024 11:20:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6F5816B009A; Fri, 8 Nov 2024 11:20: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 46CBE6B0085 for ; Fri, 8 Nov 2024 11:20:51 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B023B80E4F for ; Fri, 8 Nov 2024 16:20:50 +0000 (UTC) X-FDA: 82763440368.30.035B63C Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) by imf16.hostedemail.com (Postfix) with ESMTP id 27E5C180017 for ; Fri, 8 Nov 2024 16:20:11 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=vrY2rH3C; spf=pass (imf16.hostedemail.com: domain of 3XzouZwUKCMwBsttsy66y3w.u64305CF-442Dsu2.69y@flex--tabba.bounces.google.com designates 209.85.128.73 as permitted sender) smtp.mailfrom=3XzouZwUKCMwBsttsy66y3w.u64305CF-442Dsu2.69y@flex--tabba.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731082621; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=YSD3xsyZZCSV87kyUY/RPMIHEZzslYpSJkMBD8vjd+E=; b=AWOynkDdA3LiIc85OPSCq1unmAGmtO5K132w0q0ebnbGlf2CXM5XfXrcA+Cuuh6y/dcgnE zJ6QHYw21VX+AQwYIgjOQvUyqrbPAIwcaovcIXrKm6qBgdiFgsutuhOX57jYVsYtKkvEPW dn994uTOTYWMAGCmb1lzx7XsAFSQLhQ= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=vrY2rH3C; spf=pass (imf16.hostedemail.com: domain of 3XzouZwUKCMwBsttsy66y3w.u64305CF-442Dsu2.69y@flex--tabba.bounces.google.com designates 209.85.128.73 as permitted sender) smtp.mailfrom=3XzouZwUKCMwBsttsy66y3w.u64305CF-442Dsu2.69y@flex--tabba.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731082621; a=rsa-sha256; cv=none; b=6PBnPWHGOkiELYX+yeAEf2XHkYvoom79ZhFowOmnR3ifvzKPx3T7T5mmjqqctZ3KJrafUs 70/njqhNzuJQ4NkiiKLtNkAzEN0ed9KsRePg8dzBhhT6INH99AFZRi7fcBGXcQw9eSj7lf g2hfh+MvKq9ZnkG5yFG06Ng6BPfKncM= Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-431ad45828aso15922945e9.3 for ; Fri, 08 Nov 2024 08:20:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1731082847; x=1731687647; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=YSD3xsyZZCSV87kyUY/RPMIHEZzslYpSJkMBD8vjd+E=; b=vrY2rH3CHvyZhuSHqczdg++IzTt2Qk6lgVaCcHKJneI4x2OIgcSMAgbEkEDK8TidYD Lp5AVvaGkuTHLVC7pKAhmszGb15eQFgWfHsIw0t6/pgB8Ys2gPGuzlsw1wVyQ4oFiuXL kxoXsYEGYuFqjbx7u3EDD3PTkKqWBeT09pswkTWqgojy51AwDEF+WZxkkJbz8nGqDAEb 9RzXS1PVYp1lHf/5MqrVkK/kWyixtpN50nqlYHYX45Z9QaPb3FKThphonaAv0vUwpjII l2EzCz8djlF9ctD3mnKeRL4xoXr5/nbVVIMOU73o5UUwkflePijqQn3fexBVLU2OLdJq bPmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731082847; x=1731687647; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YSD3xsyZZCSV87kyUY/RPMIHEZzslYpSJkMBD8vjd+E=; b=UABZkuhNNxY9PXCgLae33kLNvgFlwqZV5aGGUHTInXtYp3APtkgfqbUiaCNNmQe52v eUi34kPYguO9NCE84eKjM/eFVZ8SqEzxk7eZa2DL7acJBv0IWXdbiMRYbpQZ+wPLOBIx KSAYZpAekI6PeRwKXBXoR5kHf75y1/saU4CMbjRcRQSzxXXtd1Jhn8ooGzq288Qw+i4d YMBPp0wqpPqwji+lejxpT/ywSjl6ZEO4db1twkVPForUclAur+6RH9mUqn6jQ5GNPfVr dY0dkkErHXITwh8pze30lZ1PgQR0ENgGf3qWTSuZkKneDsXYN1xLjmPJk9yluQj9gPj0 6R/g== X-Gm-Message-State: AOJu0YyMq2Bu9ivexl6t/fQmLcQtULx0T2fndVyIm3qZPaBnJJHjxZvv uz/EmX7fWLZlSkn61ByQ/nTP50bPVH9XaP21BUY3aApGBWU6jfzLzQEvHFaUd97GdDX3Le494vk YWowgcyNStX6KsBVqHBmVvTnKIXBjSLBdXvGBLcw260Hpf6PwHoOkpt21iBjksxLVMecrnppmd5 sN9cBvgODxdZdq3mMqhH/ENw== X-Google-Smtp-Source: AGHT+IFgJCvqHUnZF2sVggmAky7vOXqPzIu1h0GscO2JqqplWhQ8XkVaucC9oHlByVAHMi0UBju5RAkHJw== X-Received: from fuad.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1613]) (user=tabba job=sendgmr) by 2002:a05:600c:6a84:b0:42c:a8b5:c26 with SMTP id 5b1f17b1804b1-432b74fc1e5mr108415e9.2.1731082847148; Fri, 08 Nov 2024 08:20:47 -0800 (PST) Date: Fri, 8 Nov 2024 16:20:32 +0000 In-Reply-To: <20241108162040.159038-1-tabba@google.com> Mime-Version: 1.0 References: <20241108162040.159038-1-tabba@google.com> X-Mailer: git-send-email 2.47.0.277.g8800431eea-goog Message-ID: <20241108162040.159038-3-tabba@google.com> Subject: [RFC PATCH v1 02/10] mm/migrate: don't call folio_putback_active_hugetlb() on dst hugetlb folio From: Fuad Tabba To: linux-mm@kvack.org Cc: kvm@vger.kernel.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, david@redhat.com, rppt@kernel.org, jglisse@redhat.com, akpm@linux-foundation.org, muchun.song@linux.dev, simona@ffwll.ch, airlied@gmail.com, pbonzini@redhat.com, seanjc@google.com, willy@infradead.org, jgg@nvidia.com, jhubbard@nvidia.com, ackerleytng@google.com, vannapurve@google.com, mail@maciej.szmigiero.name, kirill.shutemov@linux.intel.com, quic_eberman@quicinc.com, maz@kernel.org, will@kernel.org, qperret@google.com, keirf@google.com, roypat@amazon.co.uk, tabba@google.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 27E5C180017 X-Stat-Signature: bywuyen61q41fptfp4bcudu88xcprqpn X-Rspam-User: X-HE-Tag: 1731082811-492125 X-HE-Meta: U2FsdGVkX18b2VBdwenmL33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hFFPl4Sqo343ovfo0sCbvykJ9A/wB8HKAI+MX6bBd7nrnJpJP8PeBaYpdaKApzWVF/xZSjcM57z/1gt0kmXGXz179NLq34R0KPWI82zZPi8L5BU3Hp5nZ/61TBbzi19dNeKChfAkzMLBDs0iYK+Tju66ur1rMpWlvCffnQ83j1rgS1b/t1YsQeqICoonUuijKvnNmdSFNZRMua9Cd03o8teuUDJTXdEQHAtRsQPMlecydzzMw5KSXinrUPxqoCCh6btG05mGmQ+ssvIDJFojTdvyGQURk07yvijkF7zYPVc03sIyIZg63sxdSBk0fiZhU2e8QfUCMTIsKaHF2p2RoqRajEu9fkmxpEuOJbfvipW7XhqKo2dgIJjn2nsj0lVmOJbGBeUx6KJQkZVSCN6dZYrtjawBfEoFsUd0NkWKLNzhb/xCmWhy60o2K5YQ7mX1N8kmXybp7gdVx8rOH0IqNXtxiMoNCmMraQ3jWBpJqMx9+IzbAz7J/+M+u X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: David Hildenbrand 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 Signed-off-by: Fuad Tabba --- 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 e17bb2847572..da3fe1840ab8 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -7508,6 +7508,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 55585b5f57ec..b129dc41c140 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1547,14 +1547,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; }