From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8389C7EE2A for ; Mon, 22 May 2023 20:29:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232235AbjEVU3G (ORCPT ); Mon, 22 May 2023 16:29:06 -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 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(...)) ?