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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 35FDAC77B7A for ; Fri, 19 May 2023 15:31:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ifzwIrn49Fju6nBYe66ghH7/r6bkMX6/cEnnze2hBqk=; b=dAuD1YMYvVGPvl Vqxevw5V+h1+asltxvjtzge3hWny33RETLYO6pqq99Kl7tQOhlX0o+8DutATfZ9i6lArgfHJEyKE9 MZypfeDuR9y5JWremqS0XqLEPmFypluFjL7ZNQH6r5734w8B7IULdQBHSJ4iC6CGJYExW2dSLp12J fAjl0RbtPB7iLU3Ng75MwIND1AzYMIWgs1I319TCKR1jC7SOJ2Jg2zH6CvcCTRQX7hxKAVw7pV0g9 49idU5igiKdEq/IFf1XlOXC/DAvaxhrKGU+k6T4DZ+lXY9E21erRQExwi73s6APUEMEyNpygCN4fV 7H9NZdBBlMOhbfEEXV3g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q0245-00GbV3-10; Fri, 19 May 2023 15:30:45 +0000 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q023u-00GbQt-31 for linux-arm-kernel@lists.infradead.org; Fri, 19 May 2023 15:30:36 +0000 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-309438004a6so2122122f8f.2 for ; Fri, 19 May 2023 08:30:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684510230; x=1687102230; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=TtZZ6uUexd434AXLFIEIjI9JV/0k8tvwBbLdbRsCUXo=; b=PyR/EY842cKASD9G5w9Gq5/xB1KS97ac+lQU4cAzAlxoj7KZlKDqCPwqmHMjeOMOrv qcPIMvBWfeGMzdQ6uqpPs7Ovr6H/QpVogtdEuAJeR8EEDuSP00E0zPQmt+sDz45MbHoG h0kGWCHRaScH8OnixMhUfOPLGNy5N+Fm/6k6tUuqAETTdmhapR1JzXIvcJQN8IqjsfhD BN05ocwmxjqhDaTG9fFNA17KoNHz6wltqe3eoEvpHuBZFioRz9/9h7TdSrdIEGrh4FgZ OrNhmOZJPAf5ov1mPsV22peVwn5Z9VU8rEUKfSCFrhom7AcG9I8uL5U5v0cGS77oxsvB Ejfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684510230; x=1687102230; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=TtZZ6uUexd434AXLFIEIjI9JV/0k8tvwBbLdbRsCUXo=; b=iFf7KoEyotzl+wPJhq6OuMw3RtD8V2rZJ15a6TVKgTU9SLouq4t5VdDkenWAFCfP1h wWLTuNXktVNwEHBVAxVzxjPklhps0rrCsWOQnc7qCqgkvusaFHGwVXTwfU4VEmbCHjt4 zCWu+OnLwItnk5Ynx/nIv7mEhh2RddX/ZNQZaPuI2ac+iN+BpWx59CfJa7w3DzCoXYcD 009ncqoP6a3sc9o2MRlLVi0bwgQJHAokBtlFhhMLQ0wnX+z02ZuRYa4xaeLtkNoSZveH VSVYjFSNYhhm7uZDvkW9qzbHwbuNNvQbTGAmiJVkd2CURJoID8fZEN7lPoQhx3+V6cH3 XOlA== X-Gm-Message-State: AC+VfDzambPrSbTg/NC23ZRVvnhITu66tSsDo7PZz6ufvQpx8KwMXvO0 rLe/O3xYZk278EvZGCP6MRE= X-Google-Smtp-Source: ACHHUZ52sgG6ZH6RefRvJGJis8biM2vI62TUrGHb64k5WVVmM+Y/pWEsCgexr9KGJ5ZJFH8IZVILjQ== X-Received: by 2002:a5d:544c:0:b0:2f9:61d4:1183 with SMTP id w12-20020a5d544c000000b002f961d41183mr2017687wrv.45.1684510229844; Fri, 19 May 2023 08:30:29 -0700 (PDT) Received: from localhost (host81-154-179-160.range81-154.btcentralplus.com. [81.154.179.160]) by smtp.gmail.com with ESMTPSA id y18-20020adff152000000b002feea065cc9sm5563195wro.111.2023.05.19.08.30.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 08:30:28 -0700 (PDT) Date: Fri, 19 May 2023 16:30:27 +0100 From: Lorenzo Stoakes To: Arnd Bergmann Cc: Arnd Bergmann , 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 Message-ID: <26e20ec3-51ec-43d0-8fdb-880e4343a77f@lucifer.local> References: <20230519093953.10972-1-arnd@kernel.org> <5b071f65-7f87-4a7b-a76a-f4a1c1568ae7@lucifer.local> <7d7ddc48-5985-4678-9f87-6e9b574a24d9@app.fastmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <7d7ddc48-5985-4678-9f87-6e9b574a24d9@app.fastmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230519_083034_975560_3802DF59 X-CRM114-Status: GOOD ( 34.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, May 19, 2023 at 05:09:35PM +0200, Arnd Bergmann wrote: > 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. > OK no worries, it's often the way that something is purely accidental but seems ruder than intended (or even rude at all) because text is a terrible format :) > > 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? Yeah I see your point, in the majority of cases failing to pin is an error, I just wonder if something like adding another parameter wouldn't just add more noise/confusion here than it saves? Sadly I think aspects of this are C sucking at dealing with multiple return values sanely, and there probably isn't a totally nice way of dealing with this. > > Arnd _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel