From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 8C45C391E4C for ; Thu, 28 May 2026 13:10:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779973808; cv=none; b=fIqTvtUS9Q6RRCncuw47dVncT53pOVGT1PYOk6IWB1GgLUdy5TwJZdqvcsa0MvsxDKl0oy5nXU4LgVHWiYPyAy33SVtrgPqelYVDeiQx/oFPn9F5XOwNCnYOl412Ipy1Ks9yajeNoZlhzv6Q7mf31MGPRD5+4t6gzyXsCUbnCxU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779973808; c=relaxed/simple; bh=IqFx6ce3yhaROI2ilNTy9HqMK0eQASp6W6P9AnUhAGo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=cgCa6/d6HhTLaDyajRhcW9OoZ5QIqjANmPH1qt2rcxH6PuegWFQ4neDbc3WSKNBVxH0HKh217f7Gqw47rkoZZ6oVrnFPRB6dPOKd9tvVtBDaYOPI7Qmy0qML6ZpE2CdG/IYtI+E2dXXuhftjsdemkQY2uy1PTW7qo+1DN/TUzm4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UKEYhoMA; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UKEYhoMA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2CA91F000E9; Thu, 28 May 2026 13:10:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779973807; bh=vBdipJ1lWYMswZIllLQPqc/+U4TCGgVcu+lzw0tAm94=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=UKEYhoMAUhUTYRLziHClPsxubV45B0aR6fEIS4gjkQI/J/56Co9UWD4OzWY/gskhR /kcnDd/Pf4FeADSDJjHGo3s27Vwmq8j4x/iKTlSDyDXldmAWLdwi6WWoFLWva5fTBL 2yksIbSne+xYYGVhevFMn3aAe9d+ySCHxKU32F8AoM1O6NJq85k/XFeaGmKKaWnzE4 kcRR2bCgGdJIewhD7yWV4Gn8L1IiVHng+xA0DxCZuIMzhfLEz603MQFrPJAKoaAEN0 ekxmvEGetTIygEs4nMWjI22Plc9vceAWDpB8ZKwgVPUKYl9hYX3zOmAwiAg9nPy9sG 1XKjViiPExe9w== Date: Thu, 28 May 2026 14:10:01 +0100 From: Lorenzo Stoakes To: Mike Rapoport Cc: Andrew Morton , David Carlier , David Hildenbrand , Heechan Kang , "Liam R. Howlett" , Michael Bommarito , Peter Xu , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 3/3] userfaultfd: remove redundant check in vm_uffd_ops() Message-ID: References: <20260527184751.4147364-1-rppt@kernel.org> <20260527184751.4147364-4-rppt@kernel.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=us-ascii Content-Disposition: inline In-Reply-To: <20260527184751.4147364-4-rppt@kernel.org> On Wed, May 27, 2026 at 09:47:51PM +0300, Mike Rapoport wrote: > From: "Mike Rapoport (Microsoft)" > > Lorenzo says: > > static const struct vm_uffd_ops *vma_uffd_ops(struct vm_area_struct *vma) > { > if (vma_is_anonymous(vma)) > return &anon_uffd_ops; > return vma->vm_ops ? vma->vm_ops->uffd_ops : NULL; > } > > This is doing a redundant check _and_ making life confusing, as if > !vma->vm_ops is a condition that can be reached there, it can't, as > vma_is_anonymous() is literally a !vma->vm_ops check :) > > Remove the redundant check. > > Suggested-by: Lorenzo Stoakes > Fixes: 0f48947c4232 ("userfaultfd: introduce vm_uffd_ops") > Signed-off-by: Mike Rapoport (Microsoft) :) thanks! LGTM so: Reviewed-by: Lorenzo Stoakes > --- > mm/userfaultfd.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c > index 2872c71bbf36..80cc8be5725f 100644 > --- a/mm/userfaultfd.c > +++ b/mm/userfaultfd.c > @@ -68,7 +68,7 @@ static const struct vm_uffd_ops *vma_uffd_ops(struct vm_area_struct *vma) > { > if (vma_is_anonymous(vma)) > return &anon_uffd_ops; > - return vma->vm_ops ? vma->vm_ops->uffd_ops : NULL; > + return vma->vm_ops->uffd_ops; > } > > static __always_inline > -- > 2.53.0 > Cheers, Lorenzo