From mboxrd@z Thu Jan 1 00:00:00 1970 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 0093CC83F27 for ; Wed, 16 Jul 2025 14:20:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7A96E8D0002; Wed, 16 Jul 2025 10:20:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7810C8D0001; Wed, 16 Jul 2025 10:20:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6BD948D0002; Wed, 16 Jul 2025 10:20:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 5427B8D0001 for ; Wed, 16 Jul 2025 10:20:35 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id E866D58833 for ; Wed, 16 Jul 2025 14:20:34 +0000 (UTC) X-FDA: 83670338388.06.3E0F2DE Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) by imf25.hostedemail.com (Postfix) with ESMTP id EDFEAA0002 for ; Wed, 16 Jul 2025 14:20:32 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=vkqwWb+a; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf25.hostedemail.com: domain of surenb@google.com designates 209.85.208.54 as permitted sender) smtp.mailfrom=surenb@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1752675633; a=rsa-sha256; cv=none; b=1wssaPjOwXRfWUUOMQdAFvMAYDaSiC774Srczpe3cB1bJxjAg3FD63FtJbhEB0/RnKx8Tu 8vcwM9FmZ9jzSWHCm7WhdPTfAvDC69LkcqDEeaVjF6oY1A+msdSRtBCajgMY6v6UhrVzeD aKU2zI9Pe4B0mMYVqG12Yzbun1xJQV8= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=vkqwWb+a; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf25.hostedemail.com: domain of surenb@google.com designates 209.85.208.54 as permitted sender) smtp.mailfrom=surenb@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1752675633; 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=uIOphgqPm5lvaWbkIykektdEvrtd9usWnWnUZ8I8HvY=; b=XBzEjUb1LtSnrQllIKdWzO+bnObQKS4/rLt1rDO5wDQycfO3d7yEKDBl6Rd9Pk2n20JI+Q bK11VBG28tLqCIuse1FxHP841MUP/zxFHbwVVllAak3LULB4lZA7VCFXS41/7b7VLs87aV VV4fYgioj6M4Rwic2zp0PtRUJeU8WXk= Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-5f438523d6fso8776a12.1 for ; Wed, 16 Jul 2025 07:20:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1752675631; x=1753280431; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=uIOphgqPm5lvaWbkIykektdEvrtd9usWnWnUZ8I8HvY=; b=vkqwWb+aLV6v8UW2uAA2ArpAVNqpa6Q9bzfKDNl92HYrf8yz0DUgnNl/Nt5lKEBEby 68jRqjNv07gKeXnlnHkttkspdq4uvknbreIxuTTWcBviy9+/nj1StvKVsuIDUSbfj1rv nVBu3wwDoNT/3He9zHRUY24dZCGSeUltXBjOA8uBHLJQBKlaM2cdnjd+WnAgtTe12YEO kRe+yorMwNdsXDzUggnjnNZ0qWU5EcB3Sp8DnE16dBvdX9/TUR1VcX1AfVsghlqQCi/T 6yKNsRDTMluYdwioHuC8675EOA7y2IAprgNXVoBcR3WyWSLCLrt+pVj8vCLCDHvN+VvR nC7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752675631; x=1753280431; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uIOphgqPm5lvaWbkIykektdEvrtd9usWnWnUZ8I8HvY=; b=GOl4l8pEycfmkDafQX4fw8Tqw0MOYC1IanoWgUxJMIqSKh+eipb9Ops5ZJxocsueYw mJKWfXUF77JFYyxLYFrgPTNym9szaPhCOc2XZ2zNt361M8JRkE1kFf1P0vmIxCAcDmZ9 AvfWLmmM9pvHhN3WiUOxQjtJdsgccYORnMcFdWiyHrPZ5trz9cvrYMZqcV4h6qn4RnlM L60NWGY58S3fPM5lRv6mJQB9jddzzYC0+fJIlHBo+kqCCCh1i874AWv/p0RoIXUvcGNm QlXPiddy/Fid18cnsplDnJp/ub+cdxPfxv8QMXdWmKH7Dxx+yXGwBb0Vd20IEH5LLv10 pLWA== X-Forwarded-Encrypted: i=1; AJvYcCUXZippuaxsxLO/P6f1+PBEkKPOHDvS8vG9xDBns+tXVB1X+CRPJ42XB1XSCXHTx8K/SvqmO8Z/Hw==@kvack.org X-Gm-Message-State: AOJu0YyllJInX0hMGnOcmktyM7nO2wN8q+qVJE4BFrIDIi31UlD4tSvA b0aOgd0LftBRDf4XGJIu8xAY2qtqU8x+7aO4jQkcYSsSBqYa//nXq/bKRQogvjZa2wXpOj2QJ1c BzDDbpvwPrY3mV91tsl3fuBaV+pS6ltZ5n/AoICrz X-Gm-Gg: ASbGncsjBrzDGC4LeUFJGSaZfA/uNBDMiDGO4eSU3UQacPcH3K0VaTSFbWcV+Te1s8M 7QIGp+IFgd5I6KBrI18C60uBpMmAAQpJ+2LWXnAXdgEIXhVDGddKlYJ7oNH4b5SrLCcVlaO7M2z ofsKBIRlnuDs7i5SPsbHIdy9LnVnqcH8q+OMdD3zv8Qow6FKNuwFaj71MH2yR/UhGf9sYXwT24z R9Vg0LzwvsX3ZXM+TH+iZ8tyyxGucX64ele X-Google-Smtp-Source: AGHT+IF0KH9bDS2sqMIF1uloGs4FGACZhag7lE+PKo4FcniegeHB52YqSj5sS2l+sL+kSLOceI4mVmdKMq1e0f4po2w= X-Received: by 2002:a05:6402:b04:b0:611:ff6c:50de with SMTP id 4fb4d7f45d1cf-61287aba924mr66193a12.4.1752675630924; Wed, 16 Jul 2025 07:20:30 -0700 (PDT) MIME-Version: 1.0 References: <20250716030557.1547501-1-surenb@google.com> <20250716030557.1547501-2-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Wed, 16 Jul 2025 07:20:16 -0700 X-Gm-Features: Ac12FXwnoUYNXMD4XFIyUdZfEVH6BNOuC4bDqEgFyq4aGoHDoTIObxbq-deP8uQ Message-ID: Subject: Re: [PATCH v7 1/7] selftests/proc: add /proc/pid/maps tearing from vma split test To: Lorenzo Stoakes Cc: David Hildenbrand , akpm@linux-foundation.org, Liam.Howlett@oracle.com, vbabka@suse.cz, peterx@redhat.com, jannh@google.com, hannes@cmpxchg.org, mhocko@kernel.org, paulmck@kernel.org, shuah@kernel.org, adobriyan@gmail.com, brauner@kernel.org, josef@toxicpanda.com, yebin10@huawei.com, linux@weissschuh.net, willy@infradead.org, osalvador@suse.de, andrii@kernel.org, ryan.roberts@arm.com, christophe.leroy@csgroup.eu, tjmercier@google.com, kaleshsingh@google.com, aha310510@gmail.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-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G7O7q3ECO17G GCpmxnvG hujGftEz8caWEGyysyEGDjUjnD6f4eojkJMvtNIGt8Spkbq1E5DCv2oWlX9oU6zhu5Pd/GVdHsGHczfuxjaVivJLOy4XP5FC/BD17U6qeUUIM3nwZpA9l831GjBnWFELGU9CRSTZqhy7NaUeLuMDb4Knfm6+6RYz/4Q3pYec+a9v9yrgjDhKabtlIXhKUWCZyet14RvD8VCWDvvYiHODormySQK+NuY5jLWVODaK9ELB8DF8dDtAqvSkUWw== 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: On Wed, Jul 16, 2025 at 3:50=E2=80=AFAM Lorenzo Stoakes wrote: > > On Wed, Jul 16, 2025 at 12:44:23PM +0200, David Hildenbrand wrote: > > On 16.07.25 05:05, Suren Baghdasaryan wrote: > > > The /proc/pid/maps file is generated page by page, with the mmap_lock > > > released between pages. This can lead to inconsistent reads if the > > > underlying vmas are concurrently modified. For instance, if a vma spl= it > > > or merge occurs at a page boundary while /proc/pid/maps is being read= , > > > the same vma might be seen twice: once before and once after the chan= ge. > > > This duplication is considered acceptable for userspace handling. > > > However, observing a "hole" where a vma should be (e.g., due to a vma > > > being replaced and the space temporarily being empty) is unacceptable= . > > > > > > Implement a test that: > > > 1. Forks a child process which continuously modifies its address spac= e, > > > specifically targeting a vma at the boundary between two pages. > > > 2. The parent process repeatedly reads the child's /proc/pid/maps. > > > 3. The parent process checks the last vma of the first page and > > > the first vma of the second page for consistency, looking for the > > > effects of vma splits or merges. > > > > > > The test duration is configurable via the -d command-line parameter > > > in seconds to increase the likelihood of catching the race condition. > > > The default test duration is 5 seconds. > > > > > > Example Command: proc-maps-race -d 10 > > > > > > Signed-off-by: Suren Baghdasaryan > > > > Why is this selftest not making use of any kselftest framework? > > > > I'm sure there is a very good reason :) It used to be a part of proc-pid-vm.c and after the split I kept its overall structure. I'll look into using the kselftest framework. Thanks! > > > > Reading assert() feels very weird compared to other selftests. > > Sorry to meta-review via your review again David :P > > But just to say tools/testing/selftests/kselftest_harness.h is really goo= d, and > makes life simple. See tools/testing/selftests/mm/guard-regions.c for an = example > of how they can be used - pretty straightforward and avoids a lot of ksel= ftest > boilerplate. Thanks for the pointers. I need to figure out a way to pass command-line parameters to my test. Maybe I can use fixtures for that... Let me read more about it. > > > > > -- > > Cheers, > > > > David / dhildenb > > > >