Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp141690rdh; Tue, 13 Feb 2024 11:55:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWJeJJNchgg4sLo0+7O2Gx41EaxiZ3Y0KQdXPsf1bqqrYtxbxlyNsNvPYSdmfgeSPuksj6z8QjhLu6ZQISQ+Ep2K4Fk45W3LR25CBIbnw== X-Google-Smtp-Source: AGHT+IE0AzKfV6wdByquoRt+BQGYHbbUCLRM5S7UnJpj/JX8cmA6bZNsWMTbLNAQpuA6NhhUdd/d X-Received: by 2002:a05:622a:1356:b0:42c:6686:6231 with SMTP id w22-20020a05622a135600b0042c66866231mr553234qtk.0.1707854139095; Tue, 13 Feb 2024 11:55:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707854139; cv=pass; d=google.com; s=arc-20160816; b=1G135oxD7LHXMFsGXXzXdVGv994HAxMeTAm6C/wZrJ45UuOEjHqtJ9ovTVbRBn7xWM Ya53CgoY26YzQNtM4zcnvF0ZWtnMPYZDYsc0S/cV9gtNU5VqjvCbF0fJ95lBpv/pzX9Y d4VSFp3ngg5flDfAW2S6H/ddW2m7B5TMS5Bm2nW2IkzYTsCdpmnwijdS1QNBxigNgJhE 2Thter3ThdPIxDtVWkhy1llZx+Wtoao95Kste0pPUotBRGPDt8d5sJ+sPZODigMyP5+w RbxyLwd8ratIhKG1bcDy/7PBfef9LrkIfEZ4qCoRPQRCVMkFDEvNVj/4u1RCUNmeiIEr sGyA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=K4FCa1V10al25x2H6TCYXD+ZgK9d/r75JguWzXT91NQ=; fh=dgMJynr7MMW4rw/jwzDwo/Wuy7jocK/oAqrZjbbt6BU=; b=WqAo6Y7P2O/jgiCUXDYGaloKn7HvTJmUEZKZ3Ga2rOGHJBloUsa43qTie7/xKZNr3M vAOnXFkm7XhQ/B8a+/NC2mj+8Mfb71wHjNiv8F70ZgagjCdv3TwvQ4krGvWWvqkrzfZ2 fjBwIzMigG6BG/IViylIJu6YJZMkY5oG/hTL7YTD1GHzJ6x/SDko+HAbxUHtSnBBMbht CwoFT73L1z1dlpfHEda5so4+fxnuVot55s1M/enXfaF7w2upsl3zVWPn7xtxASBqKba5 X+ltPuaVrjFZDGca6nYkZBynsXbHa/xPXhAaGMuVMV6/TI4rvC6CMwNFzDWvRb+7BpBi XBTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=z0jk3FZU; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-64198-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64198-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCUPZi4bzlJnoV8yrlSdhoTavie9PueV4Cjo9xeLx3HuVlCSrEpW20ibIEuKBnzswim35xs9gNWOCPJrl6XM4vGThfDxs2JLkHfZ54Yv8Q== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id s19-20020a05622a1a9300b0042aadd56214si3940996qtc.92.2024.02.13.11.55.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 11:55:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64198-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=z0jk3FZU; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-64198-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64198-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D64DA1C267DE for ; Tue, 13 Feb 2024 19:55:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 63CDFC2E6; Tue, 13 Feb 2024 19:55:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="z0jk3FZU" Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 F0DB260885 for ; Tue, 13 Feb 2024 19:55:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707854126; cv=none; b=gu/4jRt/3BkHuqhgGJJzXpmObOxjWqL8yF5AQCsuKX7z9eIpuA+YnJw4qO2X7Vpv1IXfVWOKOlAEtgkRNDjSjx0Xq0YlNNFSQXsh827NLLmJTbCBRoRQL92ieYEx0ba7me4xUixTgYxf92i8LKrE3pwRArtT6bI2AbETFlugO8k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707854126; c=relaxed/simple; bh=wCNV3+N+xUXw6aiO9cmWCuAOUAtC1r54THKKfvL6V50=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Content-Type; b=mcs1umtrPZFE9b3S8MKgdWAAThfCD0f/Y7LdWRGk+bq9oarZ29xUD0gKAxPcUiQOAMY8V2PRn737BZ4TIyjOC0qyAgHc3qDgbKjhs01sCquCU1PsmmvVRlVVZrTqssWh9DxWYEF40n4NZiKCBzAOYluxYSs+SX9g9H7hUu2BCNQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=z0jk3FZU; arc=none smtp.client-ip=209.85.128.44 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=google.com Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-411dd149bd9so1141275e9.1 for ; Tue, 13 Feb 2024 11:55:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707854123; x=1708458923; darn=vger.kernel.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=K4FCa1V10al25x2H6TCYXD+ZgK9d/r75JguWzXT91NQ=; b=z0jk3FZUMPyV1u8Imb+DIBEQF1DEpBE3EGMKEHAY4HToz/jDHQ6EItUfVjAFuCrQ8/ 7flweKN0VPkVaOc4F1ui43oAh4U1jZBQuEiIsk/1onU9HZie+nRVdHRTez+c6YofvFn4 O6NunSR/FXAxDrA2KD3jzBnhPVORcTXwrEFSjVEhnXnGApfbD+IDCrtFcq2IQcBwjuYQ rgpgoAeJEob0hDvWnTOppewLswvKmNlpRn2keU59BT2TUDHq/UQniBuKgLfYAlkLYnIJ 0s+wXYfp0yWRfNQ8Mpi1xUDLmOKJPWEFyWF3AbyS99VnfdF3T0IZosR+cm+iUQ5ubf+d x1hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707854123; x=1708458923; h=content-transfer-encoding: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=K4FCa1V10al25x2H6TCYXD+ZgK9d/r75JguWzXT91NQ=; b=OfGdA5zjw3IVdzZbFbLYg30SRHl3kH8Jylux6e1GHzDaKPP+iuT8fChANHRFUSiBQG aJZdwFDzlaV+FbFxjTmvTIgRMUr1yaVh71a6/KMFtG/NKWHedt+cnSnAUJ2NddXjX3JE 6AEl6LvkJ+Dae4PW/bXYblqoEbKW0VxxMNpetQ2mPpZ285yyJZSf/N2aQCKOWNi2Na7j O+1dnjIILYJKfpt91QM9xfpo6zCplRKfhzndVv9CQXRpUgOxCUgEzU5EPGkDEnrm8U3M lNXBPzaoq9DVx6j6SeYc/0EyI0ARcz03IE5pwxljwVOzrSFG2VL9/ZZAaJNL52pi3uEs mkrw== X-Forwarded-Encrypted: i=1; AJvYcCVxF/8LeOx64tleCa+eyqZkioyUrSU0FD9DjFXE4BVU7u28FrxwDG6+Pdg6m/lTLKeChm0r509gcCp/4CBa2WU8m4Ya7Wqe9tPdzG8y X-Gm-Message-State: AOJu0YxPfzW6Kcbf2hWYqSlkk42EUb/q5PqhY1aiyr4T8D7MZNeHcFoC TFzER7sW66sVP8cDp7Hm5N5oFqb/3fSsKcX6lCeilT2g8S09ZdwsJP7WmXRlWYc6yHdaQmscpse v4n8aHQYSsXunwLJb9OgWA8QOerQB3gJuuo1x X-Received: by 2002:a5d:6ac5:0:b0:33a:e2d3:c3ec with SMTP id u5-20020a5d6ac5000000b0033ae2d3c3ecmr210990wrw.60.1707854123043; Tue, 13 Feb 2024 11:55:23 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240213170609.s3queephdyxzrz7j@revolver> <20240213184905.tp4i2ifbglfzlwi6@revolver> <20240213192744.5fqwrlqz5bbvqtf5@revolver> <20240213195125.yhg5ti6qrchpela6@revolver> In-Reply-To: <20240213195125.yhg5ti6qrchpela6@revolver> From: Lokesh Gidra Date: Tue, 13 Feb 2024 11:55:11 -0800 Message-ID: Subject: Re: [PATCH v5 3/3] userfaultfd: use per-vma locks in userfaultfd operations To: "Liam R. Howlett" , Lokesh Gidra , Suren Baghdasaryan , akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, selinux@vger.kernel.org, kernel-team@android.com, aarcange@redhat.com, peterx@redhat.com, david@redhat.com, axelrasmussen@google.com, bgeffon@google.com, willy@infradead.org, jannh@google.com, kaleshsingh@google.com, ngeoffray@google.com, timmurray@google.com, rppt@kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Feb 13, 2024 at 11:51=E2=80=AFAM Liam R. Howlett wrote: > > * Lokesh Gidra [240213 14:37]: > ... > > > Asking to avoid any more iterations: these functions should call the > > currently defined ones or should replace them. For instance, should I > > do the following: > > > > #ifdef CONFIG_PER_VMA_LOCK > > ... uffd_mfill_lock() > > { > > return find_and_lock_dst_vma(...); > > } > > #else > > ...uffd_mfill_lock() > > { > > return lock_mm_and_find_dst_vma(...); > > } > > #endif > > > > or have the function replace > > find_and_lock_dst_vma()/lock_mm_and_find_dst_vma() ? > > Since the two have the same prototype, then you can replace the function > names directly. > > The other side should take the vma and use vma->vm_mm to get the mm to > unlock the mmap_lock in the !CONFIG_PER_VMA_LOCK. That way those > prototypes also match and can use the same names directly. > > move_pages() requires unlocking two VMAs or one, so pass both VMAs > through and do the check in there. This, unfortunately means that one > of the VMAs will not be used in the !CONFIG_PER_VMA_LOCK case. You > could add an assert to ensure src_vma is locked prior to using dst_vma > to unlock the mmap_lock(), to avoid potential bot emails. > Perfect. Will do that and address the other comments you had on v5 as well. Regarding int vs long for 'err' type, I'm assuming you are ok with my explanation and I should keep long? > Thanks, > Liam