From patchwork Wed Jan 29 11:57:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13953688 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 0E088C02190 for ; Wed, 29 Jan 2025 11:58:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8AA95280060; Wed, 29 Jan 2025 06:58:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 85B1928005A; Wed, 29 Jan 2025 06:58:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6FBE0280060; Wed, 29 Jan 2025 06:58:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 4F28328005A for ; Wed, 29 Jan 2025 06:58:18 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 307961C7D5E for ; Wed, 29 Jan 2025 11:58:17 +0000 (UTC) X-FDA: 83060341434.24.AB15162 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf30.hostedemail.com (Postfix) with ESMTP id 74D7E80013 for ; Wed, 29 Jan 2025 11:58:13 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=i4V+ikB2; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf30.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738151895; a=rsa-sha256; cv=none; b=XFtBajoxSMxfnv3IVp58zLNXToD+DQ4VLp5TahUq0dLuJVUwjR1XWahdKYfjZiLiQjKVJ1 r5jAMaBhBMPW9UBL+9cKEsqsvuoQhGld9ajoqqw5Vv3xMLLUX5Ah7R8XP5QMoCHL00qZhX k9psXulZC48n4L69h/8kErFQx4kR5Ps= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=i4V+ikB2; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf30.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1738151895; 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=IvULs1yE7EOmGau/Ggivq4i0htACtoQXWVK4/nOi/M8=; b=DVldzzwdUV25BnZY8taZmfTkLwu074+WcXpU4M/ArxfPXJLuO9Z1QWewlM5EYb+aLI/c/s 74hqgxIg8E1A2E3mYepaCY3ZLB2y/GF5W0sdiSfbTIuKqnoq8fhqVrlYd2QnRFADU1bwgs b5Q4gmVKObsmiT2/9OkCLZ8BNC2c59I= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738151892; 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=IvULs1yE7EOmGau/Ggivq4i0htACtoQXWVK4/nOi/M8=; b=i4V+ikB2Gk5mBT1ntGNVcNrB8GGm/iQdKYp3hzkcgqOAZoBvTu2NU4E7txnmdd1a5wJikT npgDh1aaT+RnJVMxs48IAG3iTGUqKhLf0ebcrJCMa+JksyRR/4TaW/0HCsiKoa4pgTTlkm 1s9BVr5u6oxTsLASo8Vsa++UtvJYUvw= 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-464-LrZ6zNGYPBaxGSOBP99D3A-1; Wed, 29 Jan 2025 06:58:11 -0500 X-MC-Unique: LrZ6zNGYPBaxGSOBP99D3A-1 X-Mimecast-MFC-AGG-ID: LrZ6zNGYPBaxGSOBP99D3A Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4362552ce62so32640525e9.0 for ; Wed, 29 Jan 2025 03:58:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738151890; x=1738756690; 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=IvULs1yE7EOmGau/Ggivq4i0htACtoQXWVK4/nOi/M8=; b=XhLD47f0jLAQMcBlfbkT9os2ggL2CZDAsnKaZysVe7vciYXPgqGyxEndgywbgpCHVG 57i4K8xa0ZFsCpXZJmCeiClSYwXxp9fxom8StNsjGdgwx+Ysh9dQPmRRgbjvH+8Ywei+ qFC8WL263bcTQfrNUGgKjq5IpIuWmvRxBU3oAlD0X6jfk3Tu2NV/mNT8VlNQSfUgz3NZ l/9sG2IHW/d+ZNLrkT4kUn+Q+sNmlLsnq/fWWAwFnHO+UUhFCon3z3Kc7pFdXms6R/wE yptXDPH48vDdVEjgo+Rz0gtlF/mAkZPumEuJBOvU+j/igEHUyfbt/OwaOZgMnyW8fdJY Uarg== X-Forwarded-Encrypted: i=1; AJvYcCXKFGsfto2WHxPb4qXuT2/8yhLTI49gU0XTNDpC3M6qfg+1WGn4EYm2Ul5SfDxRd4ZPc3BGjdtulw==@kvack.org X-Gm-Message-State: AOJu0Yz6NTJUJF9l7OlL6YltcM8yOZp80pdJzqS+l2sFlvshI9m6vLSz fm2mg1pIAaALfv+PPXOTOVhJvW1jGP0KecnQmvSBC7cXg5SjLn11MHOfzFbMb9MwhbIluQC7vc0 2Z8+Lz8S4gErkSnQF9BD68qUYEEFMyyfhrCV50JCnfKtPYuxb X-Gm-Gg: ASbGncumEKguJGpA9vU1jHpG45IPD8oa0nzZUyV6JBeJinVFrpz7aumEB8SGt08cweD YCwZDZZbmp+bCjtwzJnsIGG6FVPfnDTZs7ddQQe8SdPT13d9qzXNLuqYF5a3IhiikeRlExPdzYM 1hTjMjVn0zh0UBxfbzQDwH1xlgEFIcwEOMk/5INzFC3yhrTgKnnFTtN0CsJT656b4DhBPb065th aoEU3VgmvwHZSaqnpYZwK8SIkzWK0dVDa14ieHTgvOR7d+MeYr/5XkRj2gCZwj8cS03kIMKCPfg /V3X9UXGP928oWKB5w2km6Nk3l8cAe2M1dxP4FV177/RHWaN54At9jxnZGbV8YIKFg== X-Received: by 2002:a05:600c:5252:b0:431:6153:a258 with SMTP id 5b1f17b1804b1-438dc3ca802mr23864255e9.13.1738151890445; Wed, 29 Jan 2025 03:58:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IEqM74m4ZV9IsBXW9SIKcsLoOPVNY/fxsU8Okkl94/EsEQHDya1iNUyBhUuUArF4/LgH5tlYg== X-Received: by 2002:a05:600c:5252:b0:431:6153:a258 with SMTP id 5b1f17b1804b1-438dc3ca802mr23863905e9.13.1738151890101; Wed, 29 Jan 2025 03:58:10 -0800 (PST) Received: from localhost (p200300cbc7053b0064b867195794bf13.dip0.t-ipconnect.de. [2003:cb:c705:3b00:64b8:6719:5794:bf13]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-438dcc12f88sm20420515e9.2.2025.01.29.03.58.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Jan 2025 03:58:08 -0800 (PST) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-doc@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mm@kvack.org, nouveau@lists.freedesktop.org, David Hildenbrand , Andrew Morton , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jonathan Corbet , Alex Shi , Yanteng Si , Karol Herbst , Lyude Paul , Danilo Krummrich , David Airlie , Simona Vetter , "Liam R. Howlett" , Lorenzo Stoakes , Vlastimil Babka , Jann Horn , Pasha Tatashin , Peter Xu , Alistair Popple , Jason Gunthorpe Subject: [PATCH v1 1/4] lib/test_hmm: make dmirror_atomic_map() consume a single page Date: Wed, 29 Jan 2025 12:57:59 +0100 Message-ID: <20250129115803.2084769-2-david@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250129115803.2084769-1-david@redhat.com> References: <20250129115803.2084769-1-david@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 2_y-_eAXuJ3a7IsUodGtfi8WSNh-X91MlJxjqPQexMo_1738151890 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 74D7E80013 X-Stat-Signature: kxqocq3j4tnks19bad94n1fnpjsxyouf X-HE-Tag: 1738151893-185895 X-HE-Meta: U2FsdGVkX193qUR7nkKE7qKzsAiHWtbngT34fe5zhgqNDXAoNdcfFT4r5tOAZWz+mixPjPsPCJRqor+6TqbdZ8K0cb11MptXpgwDy6HocwNG7B2jmGFN4gLxnZ3NRdv5TEcyvIEc0m2JQOhbT59//hh7aMMHDXMO+Y4xUvh6M4ROu/Upat55jpS5MrQY8Vf99J7jBnZsGJrQjdgK2WvT0sz5gQa61h+8x+juRHBBkdo6wrZl7lzPwxIdmTF24cvOdik8jkqxZPFSlWrG48znMJuChBemIhQtP3plT5Upa0a3dfTiKdsiJjsG7sgJo96rST//Jt6ICgSCq+jZIVYTUpipDdXLyvVjSP6/u/htE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8JqiA+SIIkxgrFYcDwuXFyRsNHVWPk2512afzjYyZGonZLm5FQBFV+iOpdpLcpV1wS6/Z7tPUGvhN+EWw== 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: The caller now always passes a single page; let's simplify, and return "0" on success. Signed-off-by: David Hildenbrand Reviewed-by: Alistair Popple --- lib/test_hmm.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/lib/test_hmm.c b/lib/test_hmm.c index 9e1b07a227a3..1c0a58279db9 100644 --- a/lib/test_hmm.c +++ b/lib/test_hmm.c @@ -706,34 +706,23 @@ static int dmirror_check_atomic(struct dmirror *dmirror, unsigned long start, return 0; } -static int dmirror_atomic_map(unsigned long start, unsigned long end, - struct page **pages, struct dmirror *dmirror) +static int dmirror_atomic_map(unsigned long addr, struct page *page, + struct dmirror *dmirror) { - unsigned long pfn, mapped = 0; - int i; + void *entry; /* Map the migrated pages into the device's page tables. */ mutex_lock(&dmirror->mutex); - for (i = 0, pfn = start >> PAGE_SHIFT; pfn < (end >> PAGE_SHIFT); pfn++, i++) { - void *entry; - - if (!pages[i]) - continue; - - entry = pages[i]; - entry = xa_tag_pointer(entry, DPT_XA_TAG_ATOMIC); - entry = xa_store(&dmirror->pt, pfn, entry, GFP_ATOMIC); - if (xa_is_err(entry)) { - mutex_unlock(&dmirror->mutex); - return xa_err(entry); - } - - mapped++; + entry = xa_tag_pointer(page, DPT_XA_TAG_ATOMIC); + entry = xa_store(&dmirror->pt, addr >> PAGE_SHIFT, entry, GFP_ATOMIC); + if (xa_is_err(entry)) { + mutex_unlock(&dmirror->mutex); + return xa_err(entry); } mutex_unlock(&dmirror->mutex); - return mapped; + return 0; } static int dmirror_migrate_finalize_and_map(struct migrate_vma *args, @@ -803,9 +792,7 @@ static int dmirror_exclusive(struct dmirror *dmirror, break; } - ret = dmirror_atomic_map(addr, addr + PAGE_SIZE, &page, dmirror); - if (!ret) - ret = -EBUSY; + ret = dmirror_atomic_map(addr, page, dmirror); folio_unlock(folio); folio_put(folio);