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 X-Spam-Level: X-Spam-Status: No, score=-17.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C923C433ED for ; Tue, 11 May 2021 16:13:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 56EF0616EA for ; Tue, 11 May 2021 16:13:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231728AbhEKQOM (ORCPT ); Tue, 11 May 2021 12:14:12 -0400 Received: from ale.deltatee.com ([204.191.154.188]:53438 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231220AbhEKQOK (ORCPT ); Tue, 11 May 2021 12:14:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=deltatee.com; s=20200525; h=Subject:In-Reply-To:MIME-Version:Date: Message-ID:From:References:Cc:To:content-disposition; bh=BHBUlVYkvN7U/TbnhdmSfxdbBO7hmMx8+ZQaSS91pAY=; b=rsu7y4L6BqjnqY43bR2EjC+q8w I21N4GuEIsZtEN66HoQVR0eBUqXn9sLnhmeyjs1LmpX8ONK+4bR40It7S3HEyHUIadkFTRMjL6PnS bB0n5Fr7Zjp0fYF0PszR86jiQekrG0/YiMxjzKlvZ/EcoIT5WUU+u4BdzM71EtarOlouiAJGtNWbC OG0YRsSDn0akFPUGxxgbghzFEP500GKyJxOfhhP+VXZH6y4SdBhM2JjpjA9kGzUYu84S0WPnK8dl7 8QQukFL6DMVaPGaBHKFNGJzPQm7aOqvldJK3cdI6OmASeQ1CBV71z6pmz8w0UZUeslplJDlf0fzGw VvW5QwDQ==; Received: from guinness.priv.deltatee.com ([172.16.1.162]) by ale.deltatee.com with esmtp (Exim 4.92) (envelope-from ) id 1lgUzy-0006Xk-Lw; Tue, 11 May 2021 10:12:43 -0600 To: Don Dutile , John Hubbard , linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org Cc: Stephen Bates , Christoph Hellwig , Dan Williams , Jason Gunthorpe , =?UTF-8?Q?Christian_K=c3=b6nig?= , Matthew Wilcox , Daniel Vetter , Jakowski Andrzej , Minturn Dave B , Jason Ekstrand , Dave Hansen , Xiong Jianxin , Bjorn Helgaas , Ira Weiny , Robin Murphy , Bjorn Helgaas References: <20210408170123.8788-1-logang@deltatee.com> <20210408170123.8788-2-logang@deltatee.com> From: Logan Gunthorpe Message-ID: <36b86579-da30-0671-26e9-75977a265742@deltatee.com> Date: Tue, 11 May 2021 10:12:36 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-CA Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 172.16.1.162 X-SA-Exim-Rcpt-To: bhelgaas@google.com, robin.murphy@arm.com, ira.weiny@intel.com, helgaas@kernel.org, jianxin.xiong@intel.com, dave.hansen@linux.intel.com, jason@jlekstrand.net, dave.b.minturn@intel.com, andrzej.jakowski@intel.com, daniel.vetter@ffwll.ch, willy@infradead.org, christian.koenig@amd.com, jgg@ziepe.ca, dan.j.williams@intel.com, hch@lst.de, sbates@raithlin.com, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, jhubbard@nvidia.com, ddutile@redhat.com X-SA-Exim-Mail-From: logang@deltatee.com Subject: Re: [PATCH 01/16] PCI/P2PDMA: Pass gfp_mask flags to upstream_bridge_distance_warn() X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org On 2021-05-11 10:05 a.m., Don Dutile wrote: > On 5/1/21 11:58 PM, John Hubbard wrote: >> On 4/8/21 10:01 AM, Logan Gunthorpe wrote: >>> In order to call upstream_bridge_distance_warn() from a dma_map function, >>> it must not sleep. The only reason it does sleep is to allocate the seqbuf >>> to print which devices are within the ACS path. >>> >>> Switch the kmalloc call to use a passed in gfp_mask and don't print that >>> message if the buffer fails to be allocated. >>> >>> Signed-off-by: Logan Gunthorpe >>> Acked-by: Bjorn Helgaas >>> --- >>>   drivers/pci/p2pdma.c | 21 +++++++++++---------- >>>   1 file changed, 11 insertions(+), 10 deletions(-) >>> >>> diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c >>> index 196382630363..bd89437faf06 100644 >>> --- a/drivers/pci/p2pdma.c >>> +++ b/drivers/pci/p2pdma.c >>> @@ -267,7 +267,7 @@ static int pci_bridge_has_acs_redir(struct pci_dev *pdev) >>>     static void seq_buf_print_bus_devfn(struct seq_buf *buf, struct pci_dev *pdev) >>>   { >>> -    if (!buf) >>> +    if (!buf || !buf->buffer) >> >> This is not great, sort of from an overall design point of view, even though >> it makes the rest of the patch work. See below for other ideas, that will >> avoid the need for this sort of odd point fix. >> > +1. > In fact, I didn't see how the kmalloc was changed... you refactored the code to pass-in the > GFP_KERNEL that was originally hard-coded into upstream_bridge_distance_warn(); > I don't see how that avoided the kmalloc() call. > in fact, I also see you lost a failed kmalloc() check, so it seems to have taken a step back. I've changed this in v2 to just use some memory allocated on the stack. Avoids this argument all together. Logan