Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3430983rwd; Mon, 22 May 2023 13:44:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7S2braSO6IjOH3sXHDydhFIhb/r/zq+ckvz8lQJUnuB2In+uKhygD466wwhnxBRUEvkSWX X-Received: by 2002:a05:6a00:2282:b0:63f:18ae:1d5f with SMTP id f2-20020a056a00228200b0063f18ae1d5fmr17054162pfe.29.1684788288292; Mon, 22 May 2023 13:44:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684788288; cv=none; d=google.com; s=arc-20160816; b=G4hSIDqz4vsw+f/Bmij+vl5z6mz9Bw990NYn2leZntKXKKmdKrNu6HCILVIvQRX3x3 mkJajqkZnAJIVopx6CN62YMkTwvxsiJ4ObbI2YHLz7wZOhyO/JRWmGZjsJa/a78tQCvM At13Vy39WP++4MV/o/D+iXOLjEd253QZqdvu47tkjCnGBoeiKr3Pk7uaKXP9Xaidqksa t8xPoRTWUzobnyB95+g//iJd5neetkqV/1oTUaCF9Y+MEYBLtmCbEx4zHKUdrzb6s3XV MbDtzLi6uSp8i0SmcbZ5YF01IrLq1LzbJhGvLiero4Py0/hjMc+LyFu1qlX3UVGxGmSS 0XFg== 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=yuNAoST1X2xjIfj2PaynTEcbw+KRl7Ku2io9NkBwo3M=; b=lP6RUqaU/kYJFQJxWYqZRZ2YjZVIEyu+OiM5voemcLI6ijKaoJP42nRvNCr9C/vNTU EWUXb6Xl7clQh7X+6ExllXs2eZx/ukZSjzCYV6rTvzXsNEP3cCigSIfuINCnYMCMu/LP 7gSgZF08LA15LFb3VBhIC8Hh0uRgI1ZkenOmvwVs+S6g4pHUeULLKrXi/4PewQZde+4M 70bNTrFkUIXExz8VUQAbsreds158ZTHyHTljDytqVkfec9b1moHuCtAaLr6z1FxcIJg+ TqmbqO2PksK9J4mDmK8sEVQdXjsdFbL3PyWQKEObzgSruurjFtc2q3G6wLyoRK0HTw1Z tgpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=bCTwi6wO; 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 f14-20020aa79d8e000000b0064d35b65bddsi5162753pfq.362.2023.05.22.13.44.36; Mon, 22 May 2023 13:44:48 -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=bCTwi6wO; 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 S232039AbjEVU3F (ORCPT + 99 others); Mon, 22 May 2023 16:29:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233318AbjEVU2x (ORCPT ); Mon, 22 May 2023 16:28:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B524B5 for ; Mon, 22 May 2023 13:28:53 -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 CC11D6270C for ; Mon, 22 May 2023 20:28:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF737C433D2; Mon, 22 May 2023 20:28:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1684787332; bh=bGU6saSjKLHRGrxa9d+ZLVwV/rjNtkPuPdSib3psZA0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=bCTwi6wOM3T/5BM17n6r42tiV2BU9to0RAZrCsCPcb6ttCyDtYMWZtVt4NQdNEkdy pSLmlDfhzxsqRfkkGUqWlN2oUQRMlc5MCC1uhH5YC9q0kHrxucNOJwramUAvPKU4va 4AfwmaD5HPOjsBd1scfVKU6DK1FEKE8BOtWqCTn8= Date: Mon, 22 May 2023 13:28:51 -0700 From: Andrew Morton To: Lorenzo Stoakes Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mike Rapoport , "Liam R . Howlett" , Vlastimil Babka Subject: Re: [PATCH] mm/mmap: refactor mlock_future_check() Message-Id: <20230522132851.ccc9fafac91d7eb9ba922e94@linux-foundation.org> In-Reply-To: <20230522082412.56685-1-lstoakes@gmail.com> References: <20230522082412.56685-1-lstoakes@gmail.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.2 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 May 2023 09:24:12 +0100 Lorenzo Stoakes wrote: > In all but one instance, mlock_future_check() is treated as a boolean > function despite returning an error code. In one instance, this error code > is ignored and replaced with -ENOMEM. > > This is confusing, and the inversion of true -> failure, false -> success > is not warranted. Convert the function to a bool, lightly refactor and > return true if the check passes, false if not. Yup. I don't think the name does a good job of conveying the function's use. > - if (mlock_future_check(mm, vm_flags, len)) > + if (!mlock_future_check(mm, vm_flags, len)) > return -EAGAIN; if (!may_mlock_future(...)) or if (!mlock_future_ok(...)) ?