Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp37761493rwd; Tue, 11 Jul 2023 20:16:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlGYopg8RkuPjM0vAibywLTsKbAgHkC6njueFyIIhkkdV+GoMW4F3h32tkjWmKK6SCsDg2d9 X-Received: by 2002:a17:906:7056:b0:977:ecff:3367 with SMTP id r22-20020a170906705600b00977ecff3367mr15855332ejj.40.1689131813247; Tue, 11 Jul 2023 20:16:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689131813; cv=none; d=google.com; s=arc-20160816; b=ottE/lObJ7uOXSVKbFxX8R4H4HJsF1D4vmiro9sF02Efkz8umwj8HAWJuABguJ8uIF 8jYxt/PFNSHAF53khxrKSdiUuzrsA2I8LphPJuXx4C6fyCt1ago1rJlp503HtFL6b4WK 6IuGcWljp+s4lsCRxeubQ3aMU8/ERXgz6I0Q3EP3TikQom5b/3rq8/145TBYzeBKJYkE Nt9Dc+Hn30b08CrhKJPkZbpiWuWxWrqC3OmzEOUhYRB+9yLUlX6MU9VBVOUf7IZ54Lkl /P3RQ3folufBixt8oGbVJkN73MrQVg65Yl28OUwe3IoHFpjZ/DWpZ5JOnjDdcCcJf2Hi iYSA== 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:to:content-language:subject:cc:user-agent:mime-version :date:message-id:dkim-signature; bh=n+8hLObiB1rhjnQks3Kb+8m5mBxwmT0r55rniA2O9WI=; fh=lUKVdYiTv5UZoEavPARWrYLGgaq0Tzj7zaAZH6YskUw=; b=PpNEv74PGIyY2gRGkaV2MUuGLQx4HdwWY8FZEypSJtTut8xLaxeH7HO3HXgBmnoP8t Qluv0h6OIMk+WeX5QqzxnwxNh7xbnlf12rzSFozBSoAktN9c2HLWt+GvVgHC//zlpVU1 TRagsHdFxsxfhJ1YMBm1jhYy2nCwCgZ+t3zfcPI3EbYPAHrv56ys0r9JvkNnih3Yv4Qp WMZ0MujytbZaY5xuZ02cvcAdDAwHbRx45WkF+z2mlbnbL+z/cR84BAN2b3nyVAmnqr5e f0wg8QAMja2GvkBZUJVWabMGA6QJoqSFtVBJiPIBix8PpuF+U4DPThNdHoWOiBI2gAhN VK8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iR9VlQRG; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lf30-20020a170907175e00b00992c5cf17f9si3404248ejc.43.2023.07.11.20.16.28; Tue, 11 Jul 2023 20:16:53 -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=@intel.com header.s=Intel header.b=iR9VlQRG; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231977AbjGLDJn (ORCPT + 99 others); Tue, 11 Jul 2023 23:09:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231646AbjGLDJi (ORCPT ); Tue, 11 Jul 2023 23:09:38 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DC141739; Tue, 11 Jul 2023 20:09:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689131377; x=1720667377; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=EqeRPqMBCcZNqe+1FF45GoQNtxIV6ORKDRV/drrKLWg=; b=iR9VlQRGGAwT5jlDylEOLg81ms1QnISmq8EHklyWGtBLLOY9bs7Y8P4B PYPCoyo3VKUFy1tLsNo8/pINTm9d9LTa5cIHKfdOHE4x6pfTmXkG/GdAQ B88THjqCxRWJqZozPta2u8Ldy1fBQ0DPBwhz5Yrs+3Krezgq8GkBNn7bY nouuxWduE/OjsGH/5ZiKJnMZ0IhX5ZUrdZkcu3S79L0W6nTq8wpg1LRDt gje3bBGyXknbXpBs5Jk7lpXPFN7bu01Cleh4pShQTuUbxQ6aMwFOmD7E/ Ax357GGxyWgzR8+R8n3YO0UOMeF+pznVwnFPCZ2JRZZdzDr9ge4Es3F7f w==; X-IronPort-AV: E=McAfee;i="6600,9927,10768"; a="395583651" X-IronPort-AV: E=Sophos;i="6.01,198,1684825200"; d="scan'208";a="395583651" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2023 20:09:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10768"; a="724708414" X-IronPort-AV: E=Sophos;i="6.01,198,1684825200"; d="scan'208";a="724708414" Received: from blu2-mobl.ccr.corp.intel.com (HELO [10.252.187.60]) ([10.252.187.60]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2023 20:09:27 -0700 Message-ID: Date: Wed, 12 Jul 2023 11:09:25 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Cc: baolu.lu@linux.intel.com, "Liu, Yi L" , Jacob Pan , "iommu@lists.linux.dev" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 9/9] iommu: Use fault cookie to store iopf_param Content-Language: en-US To: "Tian, Kevin" , Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Jean-Philippe Brucker , Nicolin Chen References: <20230711010642.19707-1-baolu.lu@linux.intel.com> <20230711010642.19707-10-baolu.lu@linux.intel.com> From: Baolu Lu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 2023/7/11 14:26, Tian, Kevin wrote: >> From: Lu Baolu >> Sent: Tuesday, July 11, 2023 9:07 AM >> >> Remove the static iopf_param pointer from struct iommu_fault_param to >> save memory. > > why is there memory saving? you replace a single pointer with a xarray now... iopf_param is duplicate with the fault cookie. So replace it with the fault cookie to remove duplication and save memory. > >> @@ -303,16 +303,27 @@ int iopf_queue_add_device(struct iopf_queue >> *queue, struct device *dev) >> >> mutex_lock(&queue->lock); >> mutex_lock(¶m->lock); >> - if (!param->iopf_param) { >> - list_add(&iopf_param->queue_list, &queue->devices); >> - param->iopf_param = iopf_param; >> - ret = 0; >> + curr = iommu_set_device_fault_cookie(dev, 0, iopf_param); >> + if (IS_ERR(curr)) { >> + ret = PTR_ERR(curr); >> + goto err_free; >> } > > So although the new xarray is called a per-pasid storage, here only > slot#0 is used for sva which includes a list containing partial req's > for many pasid's. It doesn't sound clean... Just to make it generic so that IOMMUFD can also use it. IOMMUFD will use it to store the per-{device, pasid} object id (and possibly other data) so that it can be quickly retrieved in the critical fault delivering patch. Best regards, baolu