From nobody Sun Feb 8 17:37:46 2026 Received: from mail-ej1-f74.google.com (mail-ej1-f74.google.com [209.85.218.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D477830BF60 for ; Tue, 23 Dec 2025 16:18:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766506707; cv=none; b=RiAI3fHd8SFFUza3zk+pHHfLQjqtzNJ2+nqvUeSsZSFR503jK9WIskkzZY8/guOMpMFSBa+e/EF3TYQqBpkahjF3buN18Itxd8MG39TbNGABEGX8qYcveSCgfOE4yHi6DXp5FE9bxuZht1EtKhvs7lceD5rENYQ9vrLwBkfFXv0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766506707; c=relaxed/simple; bh=s9uG3y0OEfewAV0wFIr6ZC5yVfYH9oBTmmtdzG+B/5o=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=GjLVah/VeDJ+kING0VCUEJTxi9ERQWiwajNOBtcQh2WR+M/QXbMaR7+UW27cdu5h3jqWYuFWrWqw07gisJy9KwuvRSCV44StCCKmkL1T7iSM6KL4aVzGr0sXtz8LvKWJLqWJBbh0+kEJFAguCCIbzihYiQrrh+ldVTAxNdIjzss= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=FF/9fvCn; arc=none smtp.client-ip=209.85.218.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="FF/9fvCn" Received: by mail-ej1-f74.google.com with SMTP id a640c23a62f3a-b7387d9bbb2so391326566b.0 for ; Tue, 23 Dec 2025 08:18:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1766506704; x=1767111504; darn=vger.kernel.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=/0Hzxx2WqJaEHIGdZr2YZs1v307yu6j+9XrMYnyKbj4=; b=FF/9fvCnc2heZYNxaHme9ql97pjM1OeXrBbiC00EKYlV0ueLPJ1TA/1Xd5/dFFztQC 19OE0FmanBAU9LeBzrDz6DebuEEXS6dZz0Oh6E12UVUr7SGgDZaCJ61/fMIICKk/xZCd tmIRVkUWI+Gu6thXnTnkw+7OA9UAr0OhLuBx35gwdG3GmJgn0sstoZ3vA72TUHLv6lwR wHuSOPq4Csaya8F7NZ4r8bu1rQecXzn5hsN8keoslAG3NsGuiFxjMh16TOR7mv/RBzAi ygbYi1n9B2NHIxOKRM8kGwmC5DfiCBIBZdaEeVtR9puDjoZLFOqc1SArTlndutVOujHk o7+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766506704; x=1767111504; 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=/0Hzxx2WqJaEHIGdZr2YZs1v307yu6j+9XrMYnyKbj4=; b=dJKy+GOFY1sCzyuxa89yh2lfWyBZcrnLZVW+4/7meebzgf8OTRx8qHF8taBpR+xcsx y4YJgkZLUuKjJHdou/roetWpRw6s1KheBTg5UdttdLYoPTxbOvrho24gptE5qxXjxEDN DIYYhCyfJPZde8HGwYnpWtB6u7xk3FvJGxj2P0aM1nDIzGIG/oTDVSFNsQDyDZRAokre Kyl/c1OXSdZmFct8aOVFzqpJI1AQ9wSdTv+1xWnsTW9Yic6x9dhvU+Gz55Td5mAQwkij w/rs5XJXJDLCKAuPB+NwPgLYHL4GEUMe6pCUk53v5C0r+JvFD4f2U45XB51XIK6O+zDv nGNw== X-Forwarded-Encrypted: i=1; AJvYcCXwJZBv/U3qg1s7YGsuKYhSvhC7gCxrWdRoY7gcVvM1gPja9QPHe7IK4BIUWYYf9CjDc/qUWmeKN+c8Ylw=@vger.kernel.org X-Gm-Message-State: AOJu0YxBwjw6wDylA3mTBOvuCHuwsATBqJMRa0wfKpBNb8qQ74NLPzFf k77N2a0K/ao+UhUqXQ4mr+sNncVmv0+HnpIr58WCZOMdCP2JJXDr3bGNsybXGOrB2oVRUbwilWY ld008QIYNjye61A== X-Google-Smtp-Source: AGHT+IEtFcjxrDkWqyDW1Yh13A/N/vCOq+YRPV+smnuFFZgDp9YtoqP/3PaSXx1PlTrP2mudWqxqGIkWyOQF1g== X-Received: from edxn2.prod.google.com ([2002:a05:6402:5c2:b0:640:f53e:dd40]) (user=jackmanb job=prod-delivery.src-stubby-dispatcher) by 2002:a17:906:f58f:b0:b80:50b:6c8f with SMTP id a640c23a62f3a-b8036f5ac89mr1727469766b.27.1766506704176; Tue, 23 Dec 2025 08:18:24 -0800 (PST) Date: Tue, 23 Dec 2025 16:18:10 +0000 In-Reply-To: <20251223-b4-kunit-user-alloc-v1-0-fb910ae0e50c@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251223-b4-kunit-user-alloc-v1-0-fb910ae0e50c@google.com> X-Mailer: b4 0.14.3 Message-ID: <20251223-b4-kunit-user-alloc-v1-1-fb910ae0e50c@google.com> Subject: [PATCH 1/3] kunit: test: Delete pointless resource API usage From: Brendan Jackman To: Brendan Higgins , David Gow , Rae Moar , Kees Cook , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko Cc: linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Brendan Jackman Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable This code uses the low-level resource API to track parameters of the vm_mmap call, but it doesn't do anything with them, because the mm teardown code takes care of tearing down the mmaps. Delete it. Signed-off-by: Brendan Jackman Reviewed-by: David Gow --- lib/kunit/user_alloc.c | 76 ++++------------------------------------------= ---- 1 file changed, 6 insertions(+), 70 deletions(-) diff --git a/lib/kunit/user_alloc.c b/lib/kunit/user_alloc.c index b8cac765e6204..564f5566641d5 100644 --- a/lib/kunit/user_alloc.c +++ b/lib/kunit/user_alloc.c @@ -7,21 +7,6 @@ #include #include =20 -struct kunit_vm_mmap_resource { - unsigned long addr; - size_t size; -}; - -/* vm_mmap() arguments */ -struct kunit_vm_mmap_params { - struct file *file; - unsigned long addr; - unsigned long len; - unsigned long prot; - unsigned long flag; - unsigned long offset; -}; - int kunit_attach_mm(void) { struct mm_struct *mm; @@ -50,67 +35,18 @@ int kunit_attach_mm(void) } EXPORT_SYMBOL_GPL(kunit_attach_mm); =20 -static int kunit_vm_mmap_init(struct kunit_resource *res, void *context) -{ - struct kunit_vm_mmap_params *p =3D context; - struct kunit_vm_mmap_resource vres; - int ret; - - ret =3D kunit_attach_mm(); - if (ret) - return ret; - - vres.size =3D p->len; - vres.addr =3D vm_mmap(p->file, p->addr, p->len, p->prot, p->flag, p->offs= et); - if (!vres.addr) - return -ENOMEM; - res->data =3D kmemdup(&vres, sizeof(vres), GFP_KERNEL); - if (!res->data) { - vm_munmap(vres.addr, vres.size); - return -ENOMEM; - } - - return 0; -} - -static void kunit_vm_mmap_free(struct kunit_resource *res) -{ - struct kunit_vm_mmap_resource *vres =3D res->data; - - /* - * Since this is executed from the test monitoring process, - * the test's mm has already been torn down. We don't need - * to run vm_munmap(vres->addr, vres->size), only clean up - * the vres. - */ - - kfree(vres); - res->data =3D NULL; -} - unsigned long kunit_vm_mmap(struct kunit *test, struct file *file, unsigned long addr, unsigned long len, unsigned long prot, unsigned long flag, unsigned long offset) { - struct kunit_vm_mmap_params params =3D { - .file =3D file, - .addr =3D addr, - .len =3D len, - .prot =3D prot, - .flag =3D flag, - .offset =3D offset, - }; - struct kunit_vm_mmap_resource *vres; + int err; =20 - vres =3D kunit_alloc_resource(test, - kunit_vm_mmap_init, - kunit_vm_mmap_free, - GFP_KERNEL, - ¶ms); - if (vres) - return vres->addr; - return 0; + err =3D kunit_attach_mm(); + if (err) + return err; + + return vm_mmap(file, addr, len, prot, flag, offset); } EXPORT_SYMBOL_GPL(kunit_vm_mmap); =20 --=20 2.51.2