From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (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 3D0583E8C61 for ; Wed, 20 May 2026 14:12:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779286332; cv=none; b=Al0KNS1TzbJif9CjrViFW9gSCeD1RrAy/JwTl8zlUMlQtsYWcBoLQmv2fJaXj+TGIxTBu/gjGWHLieT9rHevZgG9LFMX3t0yDxILdrb+TZPeIvVGaE+IzafzzMipf6baIHWscqNe/ezGLgNiGIvRkzhvUJbE7lZQcw2RlSHeUPY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779286332; c=relaxed/simple; bh=2N1sMKTzNJnEbxKXP67LDZnmahmTf3OBuRzLjC/o+Z4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hUhjYAT6hzFfCBGiLKWzejEod9OHaf7y8tLiYgYKkUZ76HYS/9pflMULZYDS5L2iP/1rEv6fmLgcYnassXRlnZNtH/fCIX+aHmxa0s4P8Qul9ZGtOQluZN9lmmgPXLaNC4Jeo66sXjG1kvApFDx6MJgi4/WgKtnn6qDWseTjp20= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DaqOJAE1; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DaqOJAE1" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2bd2051167eso21691845ad.1 for ; Wed, 20 May 2026 07:12:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779286329; x=1779891129; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=zGS4g7trviZuWuV8kj9ji3KsBnr4BymorUPX2qH0oeg=; b=DaqOJAE167OL0IAiIBHFqqHTEbsb/qSLd3RCutK56IIKSnd05WXKORoFNLt8qJWquY ad9z+eUuBn4NUw3OCQU+x0drVRaXywhBMD+1XE8JRCSqgtLJw06fRZ9Ma8VUYlOc1dkA a65Po2Jzqs3M77W+ZqBkPNzFrQeF6v1bwB9CQUiFkbHX10riOyotWgz0uxtJWtsKbvQS RBFVAeSabl/QK+rBfCvkfHHeXPtTST30niyTtd4h2gh/xQ+uubU1/7X7Fs7aaiPEomKO bRHoo79tu+fev0SdMm453y9d0JyBzIQD5mbBV010qZ3/H1mxsfDT4K59b0J/DqRk8GAX h/4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779286329; x=1779891129; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zGS4g7trviZuWuV8kj9ji3KsBnr4BymorUPX2qH0oeg=; b=XrJpxsvRIazao48GjPKmNxEQ8OKPkCccEcfE5L/Pu5BBwnzxB61zRiDP97vPzIH6/R MtqfJf/DCxj0jcVjAaLI9C5AXDfk41XnSNqIVvX+YG5D5oCp3uy6Xd9FqWnLGkDn0CeL cxvMRIzd48neYWJyalfrHwK8aevQlpyBLoXr3zcTm4VIevxzSjGCZDQYN8E3bhMfT6tk L2eGcxdxOT/vnSHJBUOZD0WRICSUjRg+XKuVWuOjoJpGWcU7uLE8JJJiZW39iryFDDMG fLYGMhJE0qxbNU32RAuECLdQEomqow/IGHb6N2KQFbfI6p3JCutz2thuVnbK4GOZX8bQ +NyA== X-Forwarded-Encrypted: i=1; AFNElJ8UlfiEFLIELngEibc3Xt02FucJ7HCl5IHkvVEwbii9GhRUb9k0W3xYorsSOvRMDgATj/l4jaObjNh8Tp0=@vger.kernel.org X-Gm-Message-State: AOJu0Yw2J0+AHWqyEt5YkWFpjCPo1dzUsGddMO7lI58EKy+6MwwjvQtn JhRMYpXNFxPtM0yTPcql0uShKRcM1eo5uZ0YQgv8JYwWSjaQ1FZfuazX X-Gm-Gg: Acq92OGhgLUWtIB1WbHGAkaICAkMVlQef+CLzwD/BvODuzyNy8Uaj3soRVEmxDPJ/tD 1adrfWcd3DjCgqdpLcABjuRp7DVEf6lIwkjdnzuxhFMh0aB7hhyzbZ3jhQlDNVZNs1Q7mBiVpub lBhjuc40YWe/AWpbIYmtXzfcjeRQ/5HDw1ptEzJ0CNEmObE7odicsDjBLZzBtcSy+T8Ho+NwRIn xEDEh9xNe5eelfBDbys0ZisL1IdPu1gD5K2Zx5kND3ZtTVL9bLBoJO/8hAdGQ+6v/S+n54kjAYy GeSHA4X7MEHi1DUuxetr+G3ToUaO6vPshp5icUZAP9gMutUPJ4PmP/vQAM2dljQNrxnoKLDPeI4 JRg4kpaK+CDt6c2ObH1RiAa7MoAtbRO+xHO3XceA3btXHD+thRCgM0gQE0zrffHkx81SawowPBB E01SswHx1+8bneZ6+Qf3PZ7mFFLAydq4QDCueVHvbh+dOAy/wEgCU7uGZNYO9CL8GJ8Q== X-Received: by 2002:a17:903:2907:b0:2b7:a350:463f with SMTP id d9443c01a7336-2bd7e8883d8mr164318035ad.10.1779286329405; Wed, 20 May 2026 07:12:09 -0700 (PDT) Received: from skinsburskii (c-98-225-44-182.hsd1.wa.comcast.net. [98.225.44.182]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2bd5d11ce67sm227565595ad.74.2026.05.20.07.12.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2026 07:12:08 -0700 (PDT) Date: Wed, 20 May 2026 07:12:06 -0700 From: Stanislav Kinsburskii To: Andrew Morton Cc: Stanislav Kinsburskii , kys@microsoft.com, Liam.Howlett@oracle.com, david@kernel.org, jgg@ziepe.ca, corbet@lwn.net, leon@kernel.org, ljs@kernel.org, mhocko@suse.com, rppt@kernel.org, shuah@kernel.org, skhan@linuxfoundation.org, surenb@google.com, vbabka@kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2 0/3] mm/hmm: Add mmap lock-drop support for userfaultfd-backed mappings Message-ID: References: <177863991557.82528.15288076059759579141.stgit@skinsburskii-cloud-desktop.internal.cloudapp.net> <20260518104808.ba773348f8564303c4330a33@linux-foundation.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260518104808.ba773348f8564303c4330a33@linux-foundation.org> On Mon, May 18, 2026 at 10:48:08AM -0700, Andrew Morton wrote: > On Wed, 13 May 2026 02:40:11 +0000 Stanislav Kinsburskii wrote: > > > This series extends the HMM framework to support userfaultfd-backed memory > > by allowing the mmap read lock to be dropped during hmm_range_fault(). > > > > Some page fault handlers — most notably userfaultfd — require the mmap lock > > to be released so that userspace can resolve the fault. The current HMM > > interface never sets FAULT_FLAG_ALLOW_RETRY, making it impossible to fault > > in pages from userfaultfd-registered regions. > > > > This series follows the established int *locked pattern from > > get_user_pages_remote() in mm/gup.c. A new entry point, > > hmm_range_fault_unlockable(), accepts an int *locked parameter. When the > > mmap lock is dropped during fault resolution (VM_FAULT_RETRY or > > VM_FAULT_COMPLETED), the function returns 0 with *locked = 0, signalling > > the caller to restart its walk. The existing hmm_range_fault() is > > refactored into a thin wrapper that passes NULL, preserving current > > behavior for all existing callers. > > > > Faulting hugetlb pages on the unlockable path is not supported because > > walk_hugetlb_range() unconditionally holds and releases > > hugetlb_vma_lock_read across the callback; if the mmap lock is dropped > > inside the callback, the VMA may be freed before the walk framework's > > unlock. Hugetlb pages already present in page tables are handled normally. > > Possible approaches to lift this limitation are documented in > > Documentation/mm/hmm.rst. > > Thanks. AI review asked some questions: > https://sashiko.dev/#/patchset/177863991557.82528.15288076059759579141.stgit@skinsburskii-cloud-desktop.internal.cloudapp.net > > I'd ignore the fist one: don't write buggy fault handlers! > > Thank you for the review. I addressed the issues found in the new self test in v3 of this series. Please, take a look. Thanks, Stanislav