From patchwork Fri Jan 10 18:21:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13935195 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 EA279E77188 for ; Fri, 10 Jan 2025 18:22:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 572206B009E; Fri, 10 Jan 2025 13:22:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 521DB6B00AB; Fri, 10 Jan 2025 13:22:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3751C6B00AC; Fri, 10 Jan 2025 13:22:08 -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 162806B009E for ; Fri, 10 Jan 2025 13:22:08 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 83960140D71 for ; Fri, 10 Jan 2025 18:22:07 +0000 (UTC) X-FDA: 82992361494.19.E9D93A8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf03.hostedemail.com (Postfix) with ESMTP id 5621520009 for ; Fri, 10 Jan 2025 18:22:05 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TmsdtC98; spf=pass (imf03.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736533325; a=rsa-sha256; cv=none; b=oQy1F4WC051k7BiQUGXIoFDdbDl/Otr+48CGyzEQJJwgDFYsaCrCq231DpYvjXR6Mb2YA9 Xv6L8hFc6DIn+org4fKPhZO+0oweBb7xuhQtMliCBPEXIAkJqMUMAe/5W70/o1MoWRwysE H1/1S6Q7v7E+pmwYjHy71pWThx1PA3o= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TmsdtC98; spf=pass (imf03.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.129.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=1736533325; 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=v8hq4g4DhybxUwRn0BKWdtx8BUqV1Iw/Qc0FsV0dDNg=; b=tvDu+oFjsG5WPlTHHIe0QNRoT6OBVvvfuYerRczHRY85ONsk6Y9KaLYFxUHfdFSIQrPb6+ 7TiAicFOM2lZppRN9JMEjDocm1xOvYhfSWgigCMkDAQL0gqbbQS3eLlViT3XYcEEcBNEVf OaHn1S6AuwEQevleWEHTcPcJDTCke7Y= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736533324; 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=v8hq4g4DhybxUwRn0BKWdtx8BUqV1Iw/Qc0FsV0dDNg=; b=TmsdtC98/7EgPUcLWdfykzomIRsDMpWhqn/BfUe2i0DZgCCjTSzsHuJLNwNGolCE23VzkM JqOLQGwZ9eAifEEMcWZHLW52BgB0VUHmanRvr63w3MgjMyv+MGVulnpavjiS1sBEwsLQhf 0sZ+5RJa5ppuy/PglTgXfdoVtq6Uzcg= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-5-VRo1bWPjMzy2uOKlhvB6fg-1; Fri, 10 Jan 2025 13:22:03 -0500 X-MC-Unique: VRo1bWPjMzy2uOKlhvB6fg-1 X-Mimecast-MFC-AGG-ID: VRo1bWPjMzy2uOKlhvB6fg Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-436219070b4so11425945e9.1 for ; Fri, 10 Jan 2025 10:22:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736533321; x=1737138121; 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=v8hq4g4DhybxUwRn0BKWdtx8BUqV1Iw/Qc0FsV0dDNg=; b=RpYBxAC64W+YC4z15z8i06DLKL4SgiIETakrv/eMzsSgGRcxrKJlH7wxHd7ABceNkB VTFWXqe8qcI3w84ZMmL4VG9FpkMcQCRH63Z/R5DZiForZWF36nkkKdMZjjml7fk5vRpK G2SVDScXAY8vdiEVf9J8lAWDbl4cPYuTajGRo1iWdq76Gwj/flm/0lYQv+NmOtBVXDYt z5JxQEBnj+Eu3CPOTLtiy+iAImYje1KgiOSMRdUWkIMTi4qDymRomqntz8lUHdYEHeS7 5dRBA5HqRnO25oY9QqyUj4oY1e2iTGMZPzMSq0O28G/2mVncm4tnGqS1CTCWN31EJYrO 7mJg== X-Gm-Message-State: AOJu0Yyfjw7h5RCSLQSljbRODtdvWegI8/dV2t27NP2O98aFE56iFx1g 8gJfO1pOd6L4q7S+LUnpSqKRCB3bnv/FTSynGgMtWnYGZh7qX1c+6ZruiH0WiQrGiy4vyYXSYlr EPg0zhv0deNWgKEywEnPmyCSYs1DXDDH3N9GBzLupzd/0qIeP X-Gm-Gg: ASbGncs1SzuP92BXhLvIgVFkKBrdtTQDcsqXQ5iDMXTMwL7RNAspsSSm8F/Ns3SIBzg Bo51ACRHBAMMDuroBrIbEufY6+X2TczhluJG2wrswm230xM3fVOk6ymJHARWhiZ/BpOfo7wCwQl 1cyjo1g2BUEq8hyi9HPwKmmLPMT1FZG6bRw7cJkSO7Tvss3qbEf/M2piP0DZJyJGGjmZEDe5IeO OLmXL2D/0Vv0smQ/mlJzrnQWfLWw0w+EfY3FeAl38kufXO2egB26Zbr5W9aG/EU0STTV3IlLiN3 TUX0Dsha/KfbvKgmgqpdKGQLgJXen2rNUzRdwJuuTw== X-Received: by 2002:a5d:648b:0:b0:386:3e3c:ef1 with SMTP id ffacd0b85a97d-38a87312f36mr11978772f8f.35.1736533320869; Fri, 10 Jan 2025 10:22:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IHsNI1nT/mSiB4lNoNG7hpy+n586x8LDR/iUFuGNavqE1Zjg9u3TYOy+Hd2kEulLAgwJ82EoA== X-Received: by 2002:a5d:648b:0:b0:386:3e3c:ef1 with SMTP id ffacd0b85a97d-38a87312f36mr11978752f8f.35.1736533320488; Fri, 10 Jan 2025 10:22:00 -0800 (PST) Received: from localhost (p200300cbc708e1004f41ff29a59f8c7a.dip0.t-ipconnect.de. [2003:cb:c708:e100:4f41:ff29:a59f:8c7a]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-436e2da66d9sm95077415e9.1.2025.01.10.10.21.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 10 Jan 2025 10:21:59 -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)" Subject: [PATCH v1 3/6] mm/migrate: don't call folio_putback_active_hugetlb() on dst hugetlb folio Date: Fri, 10 Jan 2025 19:21:46 +0100 Message-ID: <20250110182149.746551-4-david@redhat.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250110182149.746551-1-david@redhat.com> References: <20250110182149.746551-1-david@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: kljD0gmhiXJd7mMP7MY3jeaKE1AtOIu8EfyYSGEK3NE_1736533321 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Rspamd-Queue-Id: 5621520009 X-Stat-Signature: dnjxpwjsq895rbx1mcbfk3xtej3zyzsj X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1736533325-416111 X-HE-Meta: U2FsdGVkX19tKsH+hW6LHJq2pd2Put8LExpaI/sGL9j6iryM/uPyLhXEHgpYKs7oAmt/p0OyINGHYkm17mkroMHnTz1V8qij71QMkgall5VZh4kDO8kikwRvErBLPkO4Z9Kr9ox/hcUfvQi5M7lyBzNMj+Lp0IWtIs7XhOXgVN76rHu+4WvW+Ldb8rEcxyOkDE9pJxfuIYIbexcQ7XacI5mJlqANFCSWYlQthCbOisquU2YisPD7Y2C89tc6ZIWdzuIA9/6IB/JkBidLd4oCYedOotS0mAqiRfoEjqoyxXU42u8SNS0cBE1NYzyhmkN1q12lT6j06SjVCBMwtPJgt/wGi1lv6xqI1UyMOEWMJ2uzJIkV+c6RbnHZykF6c6mwXV51KKRXZgcm1U/gpuCaCPRLJu01g97/AIvoBJo/gIFchWxZbVT6zfHLHzMRqrnNjYfhDperS6D1lV7CodtfscG6xO9no7JK5WcUh/xzhrWd5eRg7bnI2yqXVYTBogWHs6BmfBh7A+BgMdh9eLatnuyPp0BtYJa6MBlpzDN8X5EYik0FgDi0xvvg4moM1LvNEA3LrX9k5srQIMC/5RWXKCUh/EXw+YLxrfQ1tOhJMRhlgyF1QMCVIDLxFEo18oc+CCaVDY838QSc7sqUW99n0rKKLtqEXFLWvk1+VuD7MHf10duwwWejFfuydhjPsybX+PV40kmF1nmW5/Lmg3N8nyjF3tli/Jb8e9dHDz3tuX5ZxhQg1NbUUbr5DNZK8uHInOaj+CAqGXmmXGLrcJpy+pbCYOxQptt79Q0V1JvFGfgwelQGlGdwOvd9a1vlgKRa2lkaYFr666+aaAOI4xX6/jiDgczUuxYP2bF0v/Ypg5pmxMeVtJcxEHyCgYU36WYw7KPc8vEnX/SwCmKvKBsr7jRwj0q9es2BwDiR9OT9hO0XksTq4GiNa2c2xRzTALH/C/ooKdfZKdRM5F7tWsU xlpq2EF8 4XpBMj4jXExicKfOYyHBWQmKXerre3nBK2O7ULKeXNS8D9bUocFAmMW5FiGlyrm9206kKgUF6gMuWRdIdSY/bBkerNYRZOEZS0xTyeVlR33ZFn0pMBa+cNKiEN8sjIN2MgGeEAjey7YBXastc5fGCjZJSBI1IYxWmnR+flooWy88B9UxovoL1d+L22/6HEzjWY7qSPbq6mNy6iOFkLCYiX/MpNBYedgUyzLHZ8eKpZvvsd1OjdOzFuSbTp8FGS4ccVBEJS0Z8WzR6kRtYAjwzjcgDcW4jQSyf+dA/8vvDN+8pJCHA+yqAvqIg8+TfKel+DxblwhfgPyt4jKk6eTXw0hp8vQqcONdxpC4SdPK5+laSibX1MJNWa1IYeJO1XUlXJa3eIgWrieGiMcItmgrOjhTPcPj76bQaQEA+l2oRWyBdY/grnZX/9dnsHpMcGw2UzAkRURT59tzOHG1e6QphR2QHhgx+zNgjtpOn 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 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); return rc; }