Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp680882rwe; Thu, 1 Sep 2022 06:12:59 -0700 (PDT) X-Google-Smtp-Source: AA6agR7qWli6jnHsj0E5s40qssS3NbHySZ/Rq2h3LmGXRC9dsAaQy3+fJZfCwGfIBeYi5WGL+xys X-Received: by 2002:a05:6402:156:b0:440:b458:93df with SMTP id s22-20020a056402015600b00440b45893dfmr29869070edu.337.1662037979325; Thu, 01 Sep 2022 06:12:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662037979; cv=none; d=google.com; s=arc-20160816; b=WVLTXvXVTC/6q20mbryxEjozeSEX6Iu+3V0ZJWMvseOamHxfZ+H0HiyyiVFSxNXPti cMV+Q16wTYFpRUdC/+LHBQNpR6NpVnoXg+D8AZh4Elfk9PfKFZT9NS5FEWbNXzlg2E98 nXwkmDt5nZ3Rl2aL3sO9bgjos6Rn+aKAUUXG+q1hSpakYEJLp8oTs1MG6FtE19dD62At rEUJQNuxEm7fauGsvbT4APH+X+V5p3aoNskwkjZh2iNvHDsvLw8SLdJqddO8Ai91YVxT TorfRbJTBy8XtnGA6XAS2dG0WOy4BK3OWWmwBaEWEOCNjPrRojrnz+T7bQYRdLhOJsxu L4bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=qjRZQk4/F2uGXVHxmynU2p5bCszNsVUXf5I08oFe0aU=; b=vYVA8PbAbeOmsGnBMbwPfM+xWlGG2b+EHfsCZKriN7menLlAQSl01g5TaFaSB9E/WT kVg5k+7F5Xs0VsroXXABu2nEt9BitzH7VaoRmWAmowcSJgahQSUPAOnPmpDVp4ZWQN4q tT2CJSIe3QrnWKNLV5VKS/+opODFb1O4CHWdYgawwgA3EnNMEgjNzSWvTeoHY2eVrNG8 /Ogd90na0Q9aKbk50jwS3M98NTzyiOIRvT8ZQ+wkkM5KXKZJ1+CChgsbkKS++OyKaSmO MTZo3D0vdwmkoUE+jydFuR46PsAw+D7m/c0ijFXQB8uJ3cS5jjkRMzr18l7xd8tAI0Dm ctOQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id js12-20020a17090797cc00b0073d8e16fd75si15394200ejc.567.2022.09.01.06.12.16; Thu, 01 Sep 2022 06:12:59 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233441AbiIAMYa (ORCPT + 99 others); Thu, 1 Sep 2022 08:24:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233401AbiIAMY1 (ORCPT ); Thu, 1 Sep 2022 08:24:27 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9453C1223B2; Thu, 1 Sep 2022 05:24:26 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6248BD6E; Thu, 1 Sep 2022 05:24:32 -0700 (PDT) Received: from [10.57.18.92] (unknown [10.57.18.92]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2B9643F7B4; Thu, 1 Sep 2022 05:24:53 -0700 (PDT) Message-ID: Date: Thu, 1 Sep 2022 13:24:18 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 Subject: Re: [PATCH v2] Revert "swiotlb: panic if nslabs is too small" Content-Language: en-GB To: Dongli Zhang , Yu Zhao Cc: Christoph Hellwig , Marek Szyprowski , iommu@lists.linux.dev, linux-mips@vger.kernel.org, linux-kernel , kernel test robot , Dan Carpenter References: <20220829232934.3277747-1-yuzhao@google.com> <20220831063818.3902572-1-yuzhao@google.com> <747f76e1-a5ec-150c-311e-a60396f6f7ab@oracle.com> <982a4b95-0ab5-f18e-cbaf-1f503a35ada7@oracle.com> From: Robin Murphy In-Reply-To: <982a4b95-0ab5-f18e-cbaf-1f503a35ada7@oracle.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE,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 2022-09-01 03:18, Dongli Zhang wrote: > Hi Yu, > > On 8/31/22 5:24 PM, Yu Zhao wrote: >> On Wed, Aug 31, 2022 at 4:20 PM Dongli Zhang wrote: >>> >>> Hi Yu, >>> >>> As we discussed in the past, the swiotlb panic on purpose >> >> We should not panic() at all, especially on a platform that has been >> working well since at least 4.14. >> >> Did you check out this link I previously shared with you? >> https://urldefense.com/v3/__https://lore.kernel.org/r/CAHk-=wit-DmhMfQErY29JSPjFgebx_Ld*pnerc4J2Ag990WwAA@mail.gmail.com/__;Kw!!ACWV5N9M2RV99hQ!PXzSLurBv7VqxI1451TV4zO3_-BYj4grk-HYBsXzSnA6nZcXaBzdsQ-rF2DAqlICSRPMt-efYv_Uu2A2CQ$ > > Thanks for sharing! I used to read that in the past. To be honest I am still > confused on when to use BUG/panic and when to not, as I still see many usage in > some patches. > > Just about swiotlb, it may panic in many cases during boot, e.g.,: > > https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1955655 That's really a different thing, but frankly that panic is also bogus anyway - there is no good reason to have different behaviour for failing to allocate a buffer slot because the buffer is full vs. failing to allocate a buffer slot because there is no buffer. If we can fail gracefully some of the time we should fail gracefully all of the time. Yes, there's a slight difference in that one case has a chance of succeeding if retried in future while the other definitely doesn't, but it's not SWIOTLB's place to decide that the entire system is terminally unusable just because some device can't make a DMA mapping. Similarly for the other panics at init time, which seem to have originated from a mechanical refactoring of the memblock API with the expectation of preserving the existing behaviour at the time. Those have then just been moved around without anyone thinking to question why they're there, and if memblock *does* now return usable error information, why don't we start handling that error properly like we do in other init paths? Really there is no reason to panic anywhere in SWIOTLB. This is old code, things have moved on over the last 20 years, and we can and should do much better. I'll add this to my list of things to look at for cleanup once I find a bit of free time, unless anyone else fancies taking it on. Thanks, Robin.