Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp623004rdg; Thu, 10 Aug 2023 13:51:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEq6cqTW0XFRLWb2moCs8YVBE8BhPfgx4rbYIaM7CXjZX/kG9+S/VXgVrdwJ2jKTCtn3w8U X-Received: by 2002:a05:6a20:12d2:b0:132:86ea:4725 with SMTP id v18-20020a056a2012d200b0013286ea4725mr106500pzg.45.1691700701427; Thu, 10 Aug 2023 13:51:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691700701; cv=none; d=google.com; s=arc-20160816; b=YyhA5wuSLfuTIoTgBJVK3uUMbEca6H8ceQ+2KFeXJKrb+IJbl3i6YXlrn2ln6Sn97R DDwpl0BG8CX1TGvqukO93wv472ZTk6Q2+bvPHpIIrl1nfL0uRlJDFigQ3M6GiiRgpkaq cJwigoNGSYG1QgUknPLxnEX8Im9gZM4P4K635s9Epy0cx98FdvvEoNEJd4o+LMH4rRz8 /c1B95a4C2YDnwR+fcct04Ra0xsgrEoVWldeGD7jd/cBUqv45RKBBgHF90RJyUgbConV 1fHVYR4oQfK1lCo72S+dwn1AVUOfLSJ5a/eTjNcP0M/wqbmSYiCz+bbWrDztT3ZRGaBu Ju8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=CsoST8P+iWgWsPf7zElyRhjW/tMFYzbMLrZME8gLp0k=; fh=xltAmSPd/yLdUi9FHi45DAi3RH3y0htPE7VC5DZecA8=; b=lfz8p1gD98GZOQ7enWnpbzAwx1aOHX7MySp72wEafGqfCqll+tPqADC1CVJkiAoRFT rzwX2DM1LCgDTgYcfI6q2m/GCd0gkx/9X/UuIHUVj43f0+LQzPzFGNtOWsGNE9jkhius ApZr76OXmyaqzSvJVkNZIe0+ocBqy/ZyX6Oxwxgoyr5dbuu6D2xm8zxZemvpuiQXEBvb y4jhqsbHCBU+XZrKNUt3z10w8/lvJZIFkENF/ZhjwrbLwjuDeIVceGZf6IRgCP3GlH5f ZrD5xxMfDcmo/qV+DDbJZU4dlgX5Vaa0162h3ynUCIqx7k8tg4QODnOmCd4f91Mtk/AG cN1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=ZQuJWn0V; 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 ay5-20020a056a00300500b0068795f00997si2122235pfb.108.2023.08.10.13.51.29; Thu, 10 Aug 2023 13:51:41 -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=@ziepe.ca header.s=google header.b=ZQuJWn0V; 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 S236095AbjHJSqc (ORCPT + 99 others); Thu, 10 Aug 2023 14:46:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236060AbjHJSq3 (ORCPT ); Thu, 10 Aug 2023 14:46:29 -0400 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAFD626B7 for ; Thu, 10 Aug 2023 11:46:28 -0700 (PDT) Received: by mail-qk1-x729.google.com with SMTP id af79cd13be357-76cded293e8so91288885a.2 for ; Thu, 10 Aug 2023 11:46:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1691693188; x=1692297988; 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=CsoST8P+iWgWsPf7zElyRhjW/tMFYzbMLrZME8gLp0k=; b=ZQuJWn0VK80YzZIuNKmUCDAUJyL23bBqNMH3chTgGERDaScHJ91A/4qUj8OER1DJp3 FTo0SenhTP9f/Wp1KasdzdKIhxmg0nFDABfMdgEzvxjclYa5EpNPrHD+Fq5yVnYA6lPz mGROrMGyzjOAWo9EX119rHRhiiyuzHCXYkPf40rGTGxKnA9YyTFhz2l0o1Rk+AgTWNje iF/aRV5gcTGfo+6WSKoByrBFOIwP9vBi1ICE4ZW4GsLKkimFA40XrquhIXCZB3nzMzDL EIK6wmZchjpDYxB7Gg4LoL0g0sBdlwUW4j5ZZgoIV33NPrhIugEVVP23j+1bqa2AYUoT ESLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691693188; x=1692297988; 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=CsoST8P+iWgWsPf7zElyRhjW/tMFYzbMLrZME8gLp0k=; b=W4NBkaEga8AAhqPR9g9jZolRPBmNUoir3Qcy5LNvfgiGAhnu4p90NBjl60orQ3FkFo sjEshGOi9h+i9yUuUfcWMFHcozsMyIhM8Ov8B3Tx3hRgtyh+fdMwd57rRgBDyLFps7i0 xCy/g8rUQDdOIq5zvPGvJ04nL42TvYq+FdZWRlC9B8kr557C00BagN+i4oaGUD23ZoT8 gflRnjiGvfkHt1NPkzp8isdnaNzYnJK0CHEOs8I6yf1MxHyxI+XIkqEnvTNSMbS+sPZH exTHW/LdM2d3M3TA2VcYB5nb6EvxdVO82JGZP+Or+RbhIJQnLrG8q5rDVSkZBvPkPVI9 mBcw== X-Gm-Message-State: AOJu0YxTAebl0I2afKRtYMRzH1AubAdXuJOk0e9a/G3WjkN7++EC20gq brUvAdtaAn4hHHnsRZoxF0zQQw== X-Received: by 2002:a05:620a:28c1:b0:765:7a1e:a456 with SMTP id l1-20020a05620a28c100b007657a1ea456mr3504767qkp.54.1691693188098; Thu, 10 Aug 2023 11:46:28 -0700 (PDT) Received: from ziepe.ca ([206.223.160.26]) by smtp.gmail.com with ESMTPSA id i15-20020a05620a074f00b0076c60b95b87sm671044qki.96.2023.08.10.11.46.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Aug 2023 11:46:27 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1qUAfy-005IYu-Qe; Thu, 10 Aug 2023 15:46:26 -0300 Date: Thu, 10 Aug 2023 15:46:26 -0300 From: Jason Gunthorpe To: Lu Baolu Cc: Joerg Roedel , Will Deacon , Robin Murphy , Kevin Tian , Jean-Philippe Brucker , Nicolin Chen , Yi Liu , Jacob Pan , iommu@lists.linux.dev, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 06/12] iommu: Make dev->fault_param static Message-ID: References: <20230727054837.147050-1-baolu.lu@linux.intel.com> <20230727054837.147050-7-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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 Thu, Aug 10, 2023 at 03:20:07PM -0300, Jason Gunthorpe wrote: > On Thu, Jul 27, 2023 at 01:48:31PM +0800, Lu Baolu wrote: > > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > > index 4ba3bb692993..3e4ff984aa85 100644 > > --- a/drivers/iommu/iommu.c > > +++ b/drivers/iommu/iommu.c > > @@ -302,7 +302,15 @@ static int dev_iommu_get(struct device *dev) > > return -ENOMEM; > > > > mutex_init(¶m->lock); > > + param->fault_param = kzalloc(sizeof(*param->fault_param), GFP_KERNEL); > > + if (!param->fault_param) { > > + kfree(param); > > + return -ENOMEM; > > + } > > + mutex_init(¶m->fault_param->lock); > > + INIT_LIST_HEAD(¶m->fault_param->faults); > > dev->iommu = param; > > This allocation seems pointless? > > If we always allocate the fault param then just don't make it a > pointer in the first place. > > The appeal of allocation would be to save a few bytes in the common > case that the driver doesn't support faulting. > > Which means the driver needs to make some call to enable faulting for > a device. In this case I'd continue to lazy free on release like this > patch does. For instance allocate the fault_param in iopf_queue_add_device() which is the only thing that needs it. Actually probably just merge struct iopf_device_param and iommu_fault_param ? When you call iopf_queue_add_device() it enables page faulting mode, does 1 additional allocation for all additional required per-device memory and thats it. Jason