From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-183.mta0.migadu.com (out-183.mta0.migadu.com [91.218.175.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3129726B2DC; Thu, 20 Nov 2025 05:49:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.183 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763617756; cv=none; b=NkfvG9UVnD30u0VBxVHSy80gqB2GMv49aUgeZcrjAJDigS//tYZcRiUTrvYs10iz/T9wOa3lrSnSLPvbcLaDE8KzSLszrYMlIS7Lr44W0QfSAJ9dnK63L0oVaW3zvYXL0sFMTKFVFZ/aY7Ni+pBwQdY/uhR2tZUAYTSHbXc0pig= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763617756; c=relaxed/simple; bh=RA75ANsCFli71Nin/P/uUZERLhitDgNZaMMrwAM1Wis=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=tVXTUHWHRVS4JDke8bPfh9Duhf844sma3siYz3JksK/zddfXEl50H5dbfiyruW2jqwZwnfNKs8PjMHZrrjgPs211IXSmKFmcCkA7XIUAJysGebQyZ/brsZ2aE10l9MiLQAT7nW8id5OIewi4HTDNLZ+kDPHlsngCrI6mvmJnPBw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=GvOQbs2z; arc=none smtp.client-ip=91.218.175.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="GvOQbs2z" Message-ID: <594f5fdc-567c-443b-8bec-313986bce9be@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1763617742; 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=xHYXCj+PBmqDHq20QynsVeuFscEdivmHkOXz0KSXfp8=; b=GvOQbs2zmSPWZv/p9mDvkSsQ6fkjxisB/IeYsK00ktF6cjhDx1wOZ2BcDcuJEyqdUUanzP QeHfedJhQbV2UHkvzxh7TdAf2BD9vFqBzYQ3IMPMglOfvAlJ4zmk7w4rq1kz5ysOLkK9Ez QGFRlpNAOkuAX+IK9Yw1wiWBOa7KtJ4= Date: Thu, 20 Nov 2025 13:48:49 +0800 Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH v4 1/9] mm: introduce VM_MAYBE_GUARD and make visible in /proc/$pid/smaps Content-Language: en-US To: Lorenzo Stoakes Cc: Jonathan Corbet , David Hildenbrand , "Liam R . Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jann Horn , Pedro Falcato , Zi Yan , Baolin Wang , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Andrei Vagin , Andrew Morton References: X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Lance Yang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 2025/11/18 18:17, Lorenzo Stoakes wrote: > Currently, if a user needs to determine if guard regions are present in a > range, they have to scan all VMAs (or have knowledge of which ones might > have guard regions). > > Since commit 8e2f2aeb8b48 ("fs/proc/task_mmu: add guard region bit to > pagemap") and the related commit a516403787e0 ("fs/proc: extend the > PAGEMAP_SCAN ioctl to report guard regions"), users can use either > /proc/$pid/pagemap or the PAGEMAP_SCAN functionality to perform this > operation at a virtual address level. > > This is not ideal, and it gives no visibility at a /proc/$pid/smaps level > that guard regions exist in ranges. > > This patch remedies the situation by establishing a new VMA flag, > VM_MAYBE_GUARD, to indicate that a VMA may contain guard regions (it is > uncertain because we cannot reasonably determine whether a > MADV_GUARD_REMOVE call has removed all of the guard regions in a VMA, and > additionally VMAs may change across merge/split). > > We utilise 0x800 for this flag which makes it available to 32-bit > architectures also, a flag that was previously used by VM_DENYWRITE, which > was removed in commit 8d0920bde5eb ("mm: remove VM_DENYWRITE") and hasn't > bee reused yet. > > We also update the smaps logic and documentation to identify these VMAs. > > Another major use of this functionality is that we can use it to identify > that we ought to copy page tables on fork. > > We do not actually implement usage of this flag in mm/madvise.c yet as we > need to allow some VMA flags to be applied atomically under mmap/VMA read > lock in order to avoid the need to acquire a write lock for this purpose. > > Signed-off-by: Lorenzo Stoakes > Reviewed-by: Pedro Falcato > Reviewed-by: Vlastimil Babka > Acked-by: David Hildenbrand (Red Hat) > --- LGTM! Feel free to add: Reviewed-by: Lance Yang