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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBE86C001DE for ; Thu, 10 Aug 2023 18:46:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236110AbjHJSqd (ORCPT ); Thu, 10 Aug 2023 14:46:33 -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-Google-Smtp-Source: AGHT+IET1W3e6hO+x22N7pS0nUJ4fA6rmvxXCmowFm1HbIzbrqrYGlj1RXiVnna0iMsgpBXs2XE+ug== 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: 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