Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2640565rwd; Fri, 19 May 2023 08:18:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4XrBqEY3uxLsFsrf8IJDcDncoiNazoJAOxLeWp0A5Z7TH9evk6zY9xAkFR6kJ72q69THpp X-Received: by 2002:a17:902:ba8c:b0:1ae:6290:26d with SMTP id k12-20020a170902ba8c00b001ae6290026dmr2919783pls.7.1684509492441; Fri, 19 May 2023 08:18:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684509492; cv=none; d=google.com; s=arc-20160816; b=G+KQmxRV5n0CSwcwzLQAy7Pd6/rLvoGHPI1VBpTK/sGjWN3l9ecE567lLMY3Q6A+ek f6CS8NrDGZD+fA8jnXAwzsD0BiqKgEpycJ2VNEaaw/2U6z+ifJMl6r5N/dQFHzOpDHMY H32fmutHKSQFJpqnYQ5kNMBkR/yQN9JzcghzVSPDjgzoUk3KZ0SORn21/Y8WnaBp8AX4 ZwSiZ1ea87tNaOX5DwD6QKjv5QKLhisPPWHbHcayx3u7J5O7ggX5GDASUt9wo/06xV6R I3FU/XGyo7hF4+Ay3ALpDKJ4Q/esbq8OkOxCXEpJHx9VEljMcEX6UfEn8j61n7fk9fom i9ZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:feedback-id:dkim-signature :dkim-signature; bh=HdAFOpP4Mmpj8sP8nf+XQRyuNt5e1ngGbSBEuPLR87Y=; b=xyml1NJrN0S8FmrFc+G07wuDex0fhxRtkXcIG2wNkXt9VesX27ggF2v+gzj1AdYB+Q OQTdVQTjAZYY7TqBFYZpyH5kwmE4cyOSqAh9WBvMKDASAmTzp2b76r/fxtVkSmTunCIj jQqhA0y+tHoopdqLb7+dNkxHSvrQ0sRDai0otpZIAuGY0PzSdepXFtZjhIph/5H2oa1/ hc5Sj7KWQZr8kxMRdGqj8uy5UBvFMtBlwXTzU7H+VA850CeG1tkMqcOeoTDFr5G5a1z2 wk66qb6YEJI0lq7lTDeaDb1xaQDR8tYV6VfQpE4rEvjdouij8/wZTBfshDAd3CUpEV+h LOhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm3 header.b=K78d4ZcA; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=ftIfzBI9; 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 iz4-20020a170902ef8400b001ac706a7b85si1058893plb.90.2023.05.19.08.17.58; Fri, 19 May 2023 08:18:12 -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=@arndb.de header.s=fm3 header.b=K78d4ZcA; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=ftIfzBI9; 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 S232196AbjESPKC (ORCPT + 99 others); Fri, 19 May 2023 11:10:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231893AbjESPKB (ORCPT ); Fri, 19 May 2023 11:10:01 -0400 Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8E1E109; Fri, 19 May 2023 08:09:59 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 78D6E5C01E4; Fri, 19 May 2023 11:09:57 -0400 (EDT) Received: from imap51 ([10.202.2.101]) by compute6.internal (MEProxy); Fri, 19 May 2023 11:09:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1684508997; x=1684595397; bh=Hd AFOpP4Mmpj8sP8nf+XQRyuNt5e1ngGbSBEuPLR87Y=; b=K78d4ZcA+QFwcBlStc cQQ4iYXDop4aIpgBuKqwKvLt25kPy3BtCpKOgNfoIFMw7PGm8cZ9BjQmPuHlVBt5 MUihYz2EDPttZvPEQKzYhWoFzJ4osztmjl6rOwuW4eXQuP/YMYZ2XCZNSxU2iyaU Sxil6LPHtoVjM+CoOmHmqU6k++qMY10ZHJK4jwT2iSt9Hupfr+wuAIEuhsycZwFV 8EcUoeeZ7INOot/zOejk2HazHxI7B+Lop4oIoyVU0isx1e+bhUbHj1yFQlYZPacW XuuqUeaAEoqNaydIRHBXL0Y2QO8UfG7SJ1Hva14MAtfxfdJ7vsrurQFbhz5OG7Y7 XIvA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1684508997; x=1684595397; bh=HdAFOpP4Mmpj8 sP8nf+XQRyuNt5e1ngGbSBEuPLR87Y=; b=ftIfzBI9DALcM4R1kBB4Wvk+fT0eA jH509uhYkuKVC234j+xnAggzTeQXyOFTKSYxQBSlHbEKI7HrZECONql3zCZ/nEzK OO52dzJKuab34buXQH2Kq1smsfapoWBdYToodvYgdZig7e0v3/2G5isnIvmoXXwy 802paETXLUhfJcfK+kgpNIQK4ZJDJulv+UxTjapN+L+jHfYTHOVXskB+dE1/eOF9 lZdtNDgfCdNvuFOF11obm4BnzWPRjUHTCS5wvp+RBTgjBA8yy6tC2a2GCdTHoYuo OIe8U2MCwqLwM2JigAoGdxDvb0BWamTTzjJ7d09CsN8bCcgIyYjVXyvgQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeihedgkeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsehttdertderredtnecuhfhrohhmpedftehr nhguuceuvghrghhmrghnnhdfuceorghrnhgusegrrhhnuggsrdguvgeqnecuggftrfgrth htvghrnhepffehueegteeihfegtefhjefgtdeugfegjeelheejueethfefgeeghfektdek teffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hrnhgusegrrhhnuggsrdguvg X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 39E83B6008D; Fri, 19 May 2023 11:09:56 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-431-g1d6a3ebb56-fm-20230511.001-g1d6a3ebb Mime-Version: 1.0 Message-Id: <7d7ddc48-5985-4678-9f87-6e9b574a24d9@app.fastmail.com> In-Reply-To: <5b071f65-7f87-4a7b-a76a-f4a1c1568ae7@lucifer.local> References: <20230519093953.10972-1-arnd@kernel.org> <5b071f65-7f87-4a7b-a76a-f4a1c1568ae7@lucifer.local> Date: Fri, 19 May 2023 17:09:35 +0200 From: "Arnd Bergmann" To: "Lorenzo Stoakes" , "Arnd Bergmann" Cc: "Andrew Morton" , "Catalin Marinas" , "Will Deacon" , "Peter Zijlstra" , "Ingo Molnar" , "Arnaldo Carvalho de Melo" , "Mark Rutland" , "Alexander Shishkin" , "Jiri Olsa" , "Namhyung Kim" , "Ian Rogers" , "Adrian Hunter" , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-perf-users@vger.kernel.org Subject: Re: [PATCH] [suggestion] mm/gup: avoid IS_ERR_OR_NULL Content-Type: text/plain X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Fri, May 19, 2023, at 16:51, Lorenzo Stoakes wrote: > Given you are sharply criticising the code I authored here, is it too much > to ask for you to cc- me, the author on commentaries like this? Thanks. My mistake, I expected this to get added automatically based on the "Fixes:" tag, I probably dropped you by accident in the end. > On Fri, May 19, 2023 at 11:39:13AM +0200, Arnd Bergmann wrote: >> From: Arnd Bergmann >> >> While looking at an unused-variable warning, I noticed a new interface coming >> in that requires the use of IS_ERR_OR_NULL(), which tends to indicate bad >> interface design and is usually surprising to users. > > I am not sure I understand your reasoning, why does it 'tend to indicate > bad interface design'? You say that as if it is an obvious truth. Not > obvious to me at all. > > There are 3 possible outcomes from the function - an error, the function > failing to pin a page, or it succeeding in doing so. For some of the > callers that results in an error, for others it is not an error. > > Overloading EIO on the assumption that gup will never, ever return this > indicating an error seems to me a worse solution. The problem is that we have inconsistent error handling in functions that return an object, about half of them use NULL to indicate an error, and the other half use ERR_PTR(), and users frequently get those wrong by picking the wrong one. Functions that can return both make this worse because whichever of the two normal ways a user expects, they still get it wrong. > Not a fan at all of this patch, it doesn't achieve anything useful, is in > service of some theoretical improvement, and actually introduces a new > class of bug (differentiating EIO and failing to pin). Having another -EIO return code is a problem, so I agree that my patch wouldn't be good either. Maybe separating the error return from the page pointer by passing a 'struct page **p' argument that gets filled would help? Arnd