From patchwork Thu Jun 20 21:29:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13706416 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 CAD7DC2BBCA for ; Thu, 20 Jun 2024 21:29:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 53EB38D00E8; Thu, 20 Jun 2024 17:29:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4C77A8D00D5; Thu, 20 Jun 2024 17:29:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 342368D00E8; Thu, 20 Jun 2024 17:29:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 132D58D00D5 for ; Thu, 20 Jun 2024 17:29:48 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id B7D64A0606 for ; Thu, 20 Jun 2024 21:29:47 +0000 (UTC) X-FDA: 82252559214.16.1A0D8B8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf01.hostedemail.com (Postfix) with ESMTP id EF50440004 for ; Thu, 20 Jun 2024 21:29:45 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=h96+xstX; spf=pass (imf01.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@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=1718918976; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WR8fADU+tpn7PNLzSRE304F4HQd7gYSTzoHkzIPIJxw=; b=eaYaUDqB5LNSkV2Zw3gk3wIIYfshV03vGtbE864pfD99Ef26uz1FTgzbTFZSffTgQbL3Zd d3ycCBFUJhCERTHJnH0cO9nL2Dyj3hSM9qBLgbzqPMjIqI4qUHmUfpXVU/Qw5lLVfXD/Uz 7CiSIN0X2W7pQsO5BAn+YytQSwuRrYo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718918976; a=rsa-sha256; cv=none; b=B+XJ4Tq/9PQ39VmJ41tX9MB8BFv1mzsDA7bglJewJrtrY5uAxMfnTf2pB+qgQ+p07GgQNa x17YnTEOrCN1sChWYRIvkXPw2fplQHfUGCNXgAf+OdwG8C36E5Jm8IAcpKUeFHV1cgTjdF ChqA0muqGKlmEoekRO8SZaymTwVR6qQ= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=h96+xstX; spf=pass (imf01.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@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=1718918985; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WR8fADU+tpn7PNLzSRE304F4HQd7gYSTzoHkzIPIJxw=; b=h96+xstXMLt2ONHDgoMupvl6s8tSsUkgZOPOWEh13z8x7AxJrj589Nwiyz1R8/VIizp4Fc sJU6sIJskh5o/MsvdpNQUY4Ncyr9/9y00nTcE50VoLGdtSMNG3pfLfdw7wk4OuHcE5c5jB oYRyxFLFf0YmMPaAr4Q8oV1H/G0oZi4= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-631-k-WL8-eDOdiUBrpc2x04QQ-1; Thu, 20 Jun 2024 17:29:42 -0400 X-MC-Unique: k-WL8-eDOdiUBrpc2x04QQ-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 19D7F19560B9; Thu, 20 Jun 2024 21:29:41 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.192.54]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3AA4E19560AF; Thu, 20 Jun 2024 21:29:38 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton Subject: [PATCH v1 1/2] mm/migrate: make migrate_misplaced_folio() return 0 on success Date: Thu, 20 Jun 2024 23:29:34 +0200 Message-ID: <20240620212935.656243-2-david@redhat.com> In-Reply-To: <20240620212935.656243-1-david@redhat.com> References: <20240620212935.656243-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Stat-Signature: 7m4kepdgpwkzmptgzt13bsh5rez4dwdn X-Rspamd-Queue-Id: EF50440004 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1718918985-409421 X-HE-Meta: U2FsdGVkX199p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d5Wl8sPHqJpalU/YA5XWWUZLsOdAWEaVAhg1uePVmmEL5+hrzf+Cpu0wYmYzeD1zn09QAjUf9aYFt5nsUAbv+vWHcdP/ax7fS8SCV3yxSfNIKyFaDqwvQeN99oI5mDKJHYubHKMZDrooPpzg/S5q8Gw+2cQX0hFBl9NJyd2ksA2UoyTl/h/N7QLADVpjBUbhUCbhY8jkhSNU8dbRRFu3HrFYXqBPiBKwDp2G1H6XyIwMWni2rSmmdqcA== 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: Let's just return 0 on success, which is less confusing. ... especially because we got it wrong in the migrate.h stub where we have "return -EAGAIN; /* can't migrate now */" instead of "return 0;". Likely this wrong return value doesn't currently matter, but it certainly adds confusion. We'll add migrate_misplaced_folio_prepare() next, where we want to use the same "return 0 on success" approach, so let's just clean this up. Signed-off-by: David Hildenbrand Reviewed-by: Baolin Wang --- mm/huge_memory.c | 5 ++--- mm/memory.c | 2 +- mm/migrate.c | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 0fffaa58a47a..fc27dabcd8e3 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1652,7 +1652,7 @@ vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf) unsigned long haddr = vmf->address & HPAGE_PMD_MASK; int nid = NUMA_NO_NODE; int target_nid, last_cpupid = (-1 & LAST_CPUPID_MASK); - bool migrated = false, writable = false; + bool writable = false; int flags = 0; vmf->ptl = pmd_lock(vma->vm_mm, vmf->pmd); @@ -1696,8 +1696,7 @@ vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf) spin_unlock(vmf->ptl); writable = false; - migrated = migrate_misplaced_folio(folio, vma, target_nid); - if (migrated) { + if (!migrate_misplaced_folio(folio, vma, target_nid)) { flags |= TNF_MIGRATED; nid = target_nid; } else { diff --git a/mm/memory.c b/mm/memory.c index 00728ea95583..118660de5bcc 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -5354,7 +5354,7 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf) ignore_writable = true; /* Migrate to the requested node */ - if (migrate_misplaced_folio(folio, vma, target_nid)) { + if (!migrate_misplaced_folio(folio, vma, target_nid)) { nid = target_nid; flags |= TNF_MIGRATED; } else { diff --git a/mm/migrate.c b/mm/migrate.c index 781979567f64..0307b54879a0 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2629,11 +2629,11 @@ int migrate_misplaced_folio(struct folio *folio, struct vm_area_struct *vma, nr_succeeded); } BUG_ON(!list_empty(&migratepages)); - return isolated; + return isolated ? 0 : -EAGAIN; out: folio_put(folio); - return 0; + return -EAGAIN; } #endif /* CONFIG_NUMA_BALANCING */ #endif /* CONFIG_NUMA */