Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp5734305rwe; Tue, 18 Apr 2023 10:39:48 -0700 (PDT) X-Google-Smtp-Source: AKy350abUH7tZhHGkl5HlamcJ7FjmzRao/i+ZAHZiBYtq3bxMX/dCcsF9cHfiSShiiw+abU15F4X X-Received: by 2002:a17:902:e891:b0:1a1:80ea:4352 with SMTP id w17-20020a170902e89100b001a180ea4352mr3525837plg.0.1681839587707; Tue, 18 Apr 2023 10:39:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681839587; cv=none; d=google.com; s=arc-20160816; b=HJCv4OANlfFC1ix812Ib9VcqGV/5sONXAyRAzUPewCibPTlfVhm5/IksWmrBUSsQR1 FK1XzsUUPbfO86dpGt3pqNrqRnN9MwGf0JYjeKQzRb9TEuthi4BLtzSBBkXXIc6+9NLj DBN7pudisvgHnG3OtGk8Fd56Pt7/NOQaP26Tz4p2AzoQuHKU3YYG7ePKip4jWyuUwn3y OBAvJcbcFTkpZZLK5zYxvATAH1ZDeo4knl3o/kjxe4UT5TDvmIjGP0T8amSLIBCcmP34 /IIIv53f4RW4ppGWzFTPo1eLJMQaEVbr8zceYpsaZpvBBs4EjpZ75QNzG2u+ZlJLoZjI PLFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=8Q8SFl2ULkIvm8UXfuATBUNzL9reEo3S5ggP65kxjqk=; b=1AJbQJu+R6yFd4MP/xRQow1ML1PRFtg+YPCE/vp+BZmV12/pgC2VNscq+0sfpyNzI6 NZCJj95Mok1En2Bst1xfT7J5RHyEwSYwU9S+gbMgXnk9PYKezdBySZfNC388410N6G/y Sh4h5RkNG7kiLn13U+zsMcC/RmBtI7np6J2XEX4OK+mW5r9xIl3/8Ay5xNkGjJH2icP4 /HvTCM7l/UAKmUdHNbE5eHItHtJBAsPGW9Cb6yFz76HssoUKn6LQr+o5TKAjrfBf/cIn m11Bsvwa6fO+eckyrHJsgTGL/nfwA6+4tv+GaekKtr6Vm4j75y2pfFFUy7CMlcp58E3R ybOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=GSZdVVEt; 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 jh7-20020a170903328700b001a64786ed1csi14265761plb.572.2023.04.18.10.39.32; Tue, 18 Apr 2023 10:39:47 -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=google header.b=GSZdVVEt; 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 S232689AbjDRRhI (ORCPT + 99 others); Tue, 18 Apr 2023 13:37:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232332AbjDRRhF (ORCPT ); Tue, 18 Apr 2023 13:37:05 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C851293D9 for ; Tue, 18 Apr 2023 10:36:54 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-94f7a7a3351so158944366b.2 for ; Tue, 18 Apr 2023 10:36:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1681839413; x=1684431413; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=8Q8SFl2ULkIvm8UXfuATBUNzL9reEo3S5ggP65kxjqk=; b=GSZdVVEt1lfl8sp96Vt7492JQfCpH5jKib5smE+5R34WwS9qBdzCLIY8Hf86Wcmn5W WfMPUOxJu+AWYIsuMcPetFseZVPpjeX1SXkVA0ZzWSMgOsOeQfg1ddJqAnEE85lxL3H0 /o4UUTj+Kd5lL4L+L3K38H+0gp8aZi5cVcZmI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681839413; x=1684431413; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8Q8SFl2ULkIvm8UXfuATBUNzL9reEo3S5ggP65kxjqk=; b=XVp7nuLROspwT42QvHFmSB6Na1WWUa8hnhKg5CmJTM4jXFnhq6XG2vb7R+92qXE1GV EBqQVDPw4Uawwh1bBB+5hnnemYjMZ3W8BjQiBDgmbJhTOFoHRDLQgU83RblCIHDrRtG7 JySoAVzenPaomN8KeDnuQnthJFtrL7wqHN0K6M+f265XsQuLNULqa8HfkEUEI28px/FG HBQaoZkd4W2S4OvTjOVnKSzH9vjfyc8AH2pfREySK1W1KX8YcQ+tuyGtvyxqwnI7W0xf 1VIMQblJRlhMAjK0vmz+/XxTbbVWR62tg0MnsVQ/5koCrJTKbwN/8MuEK8+xGNr4Rt2s Z3gQ== X-Gm-Message-State: AAQBX9eS4lKkJz1qmWv4ueNvMaZqtr1IgFFxxCfhSXbkTFrWwAmZz9k7 omkpzM5D3J4nldhi4Fa5nqsyh+9v88I+y6B2pXU6jQ== X-Received: by 2002:a50:ef01:0:b0:500:46f2:e7db with SMTP id m1-20020a50ef01000000b0050046f2e7dbmr3156636eds.15.1681839412776; Tue, 18 Apr 2023 10:36:52 -0700 (PDT) Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com. [209.85.218.43]) by smtp.gmail.com with ESMTPSA id c18-20020aa7c752000000b00501d73cfc86sm7271971eds.9.2023.04.18.10.36.51 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 18 Apr 2023 10:36:52 -0700 (PDT) Received: by mail-ej1-f43.google.com with SMTP id xi5so75212341ejb.13 for ; Tue, 18 Apr 2023 10:36:51 -0700 (PDT) X-Received: by 2002:a17:906:7b52:b0:94a:597f:30ee with SMTP id n18-20020a1709067b5200b0094a597f30eemr5082326ejo.15.1681839411548; Tue, 18 Apr 2023 10:36:51 -0700 (PDT) MIME-Version: 1.0 References: <21e49cd7-ee15-5ebd-7805-37d5f347635f@amd.com> <6b14b2a0-cf1c-fbfb-5028-d7a6974ef39f@oracle.com> In-Reply-To: <6b14b2a0-cf1c-fbfb-5028-d7a6974ef39f@oracle.com> From: Linus Torvalds Date: Tue, 18 Apr 2023 10:36:34 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4] iommu: Optimise PCI SAC address trick To: John Garry Cc: Vasant Hegde , Robin Murphy , joro@8bytes.org, will@kernel.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Jakub Kicinski Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no 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 Tue, Apr 18, 2023 at 3:20=E2=80=AFAM John Garry wrote: > > JFYI, Since you are using NVMe, you could also alternatively try > something like which I did for some SCSI storage controller drivers to > limit the request_queue max_sectors soft limit, like: That patch is not only whitespace-damaged, it's randomly missing one '+' character so it makes no sense even ignoring the whitespace problems. _and_ it has a nonsensical cast to 'unsigned int' which makes that 'min()' possibly do crazy and invalid things (ie imagine dma_opt_mapping_size() returning 4GB). You can't cast things to the smaller size just to get rid of a warning, for chrissake! In fact, even without the cast, it seems entirely broken, since the fallback for dma_opt_mapping_size() is to return 0 (admittedly _that_ case only happens with HAS_DMA=3Dn). Finally, doing this inside the if (ctrl->max_hw_sectors) { conditional seems entirely wrong, since any dma mapping limits would be entirely independent of any driver maximum hw size, and in fact *easier* to hit if the block device itself doesn't have any max limits. So please burn that patch in the darkest pits of hell and let's try to forget it ever existed. Ok? Also, shouldn't any possible dma mapping size affect not 'max_sectors', but 'max_segment_size'? At least the docs imply that dma_opt_mapping_size() is about the max size of a _single_ mapping, not of the whole thing? Anyway, if this is actually an issue, to the point that it's now being discussed for a _second_ block driver subsystem, then shouldn't the queue handling just do this all automatically, instead of adding random crap to random block driver architectures? And no, I don't know this code, so maybe I'm entirely missing something, but that patch just raised my hackles enough that I had to say something. Linus