Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp2788359rwa; Mon, 22 Aug 2022 13:57:36 -0700 (PDT) X-Google-Smtp-Source: AA6agR5du8eUa6OtiR+BrASc7a76uwmg5Bmh9uoHDAeWbnWWS2RVztF5dp9YlIh4Gc+i69hvB2Bs X-Received: by 2002:a17:906:c10:b0:6f4:6c70:b00f with SMTP id s16-20020a1709060c1000b006f46c70b00fmr14661712ejf.660.1661201856396; Mon, 22 Aug 2022 13:57:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661201856; cv=none; d=google.com; s=arc-20160816; b=jod/qRmHL2DVZkhhua4DAyHhfVeTpd7uSY6pQQEFXbk3jw4QDTBaq8GsFTESE/fVC+ tBZ93bY//6aG+tPRkNO5HQLZEd9rYWUkGjIZXrbfiKbj4tjXJxCnK4bH8MDk6wZpEyGd zZRMJSgS8kigVbGAP/fLd20+xnXcNBrYY9UT6ZNuil2pIsYeZDo6fVvERirKG3XjNFuV nQ7+W3YGTBqzvLOQtYYm28Tc0wnY7K68nAzqI3lqJ/wAz47vja3Gni4ijqn7ndRN6nQg ZHtiYnsMS8Fdvcnw0teYwAgW4y8qeLDIl5Kqt7/wrEvz8ooLJgVqCHZVtmP/+GQfPxcI Yyvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=yBteOSxkvww9KUzjV1iXMiUqKa+qSLWTOh5s76WQQ/M=; b=vSshu0iZFU0OI6WE1jjFSPkInJFtDbewYPk6RazafgY9LQFUFUmpY0yWzpb/GqlUI/ gPD6lMcpyoYlEIfoT0IfUiNsA7MqVcAU6alOMgT9pyqdqoPxDmV/L/2EleOokKHNMt/J cF46vafZyfcoOQfN2Q4+rYgr+vAttXVL5a54xMdPlTNkmDFzFPPlqaw9Vo/Ngv3aezbn IhhWb6EKa5/x4nN9T0MlxavtKPS7z5wCqKDSlEZEmoCIStDQ9hJUxoCX6cycZNrNG1sE A8caKEvM4Iu6QDXuh+HKU8s9lKhUE7w4dGZdSGNVTfmO/9n7OEgMS5uOeQIbp4TblPkv YAiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=raKsoKUJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s13-20020a056402520d00b0043d37773dbasi512365edd.90.2022.08.22.13.57.10; Mon, 22 Aug 2022 13:57:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=raKsoKUJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231669AbiHVUxV (ORCPT + 99 others); Mon, 22 Aug 2022 16:53:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232383AbiHVUxU (ORCPT ); Mon, 22 Aug 2022 16:53:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1336EF76 for ; Mon, 22 Aug 2022 13:53:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AA29D61291 for ; Mon, 22 Aug 2022 20:53:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF223C433D6; Mon, 22 Aug 2022 20:53:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1661201597; bh=0XYtpJeYJIHTuAMCFA1D+7TBHuPnWebnHkoxH17FW/o=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=raKsoKUJ3D+YKLX5I0Fp20KUC1w4f8jQqCeSn1QA75zKUowJi/lu3eE0+/SxDaoGw IkfWtk48VuSEG1mMMlPer9zM8rLLF+Y790dYCzMbAV8R2vq7hS5px34QAy9JALT+Z7 9uCYMBdmhghHTXgGrvVEg0HIof+j5onbbYkKZVpA= Date: Mon, 22 Aug 2022 13:53:16 -0700 From: Andrew Morton To: Rolf Eike Beer Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/6] mm: pagewalk: make error checks more obvious Message-Id: <20220822135316.ee37696392ff756b1c810059@linux-foundation.org> In-Reply-To: <2203731.iZASKD2KPV@devpool047> References: <3200642.44csPzL39Z@devpool047> <2203731.iZASKD2KPV@devpool047> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 22 Aug 2022 15:00:05 +0200 Rolf Eike Beer wrote: > The err variable only needs to be checked when it was assigned directly > before, it is not carried on to any later checks. Move the checks into the > same "if" conditions where they are assigned. Also just return the error at > the relevant places. While at it move these err variables to a more local > scope at some places. > > ... > > @@ -593,16 +608,15 @@ int walk_page_mapping(struct address_space *mapping, pgoff_t first_index, > walk.mm = vma->vm_mm; > > err = walk_page_test(vma->vm_start, vma->vm_end, &walk); > - if (err > 0) { > - err = 0; > - break; > - } else if (err < 0) > - break; > + if (err > 0) > + return 0; > + else if (err < 0) > + return err; > > err = __walk_page_range(start_addr, end_addr, &walk); > if (err) > - break; > + return err; > } > > - return err; > + return 0; > } I'm not really a fan of multiple return points - it tends to lead to locking/resource leaks as the code evolves. I don't really think it's worth redoing the patch for this reason though; the rest looks good.