From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09A731DA0E1 for ; Fri, 5 Dec 2025 05:03:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764911006; cv=none; b=CokpmK7pRAVASSKVoJc9W1+ZC/oYhFcUtP1a31Uirr69JXxl4xeqo4d06YUKn8f/In+GR77pbb0Fij6lAF3SzeohG0PikGPQvzcKq+cEWcOj368r92uh1IEEaKbfLCP2lg+SJx7hMLwtiytvEiG00cs3MCNyKYF3Q3RjFI0pwjM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764911006; c=relaxed/simple; bh=P9ACxseVxndCzyFcedtf2xxFk9JrvXhWjiFJS4EbzVI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=BKFzI0dCnxovFVqY+mAX1RGZq02UJMQWsbqAANfK3G73+foZYmClgnUlXpVjgn1rp6s/FMfq+dG20PzjhqOp8IUNf4tFByGX0cQPpG1chzGQoWyhzPDcHfdv3/NedDBvsoBvk9386OXCqJybimfl+XxqGgNvRMWxqc4aLkrYqL8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=i36jRYKx; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="i36jRYKx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764911004; x=1796447004; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=P9ACxseVxndCzyFcedtf2xxFk9JrvXhWjiFJS4EbzVI=; b=i36jRYKx2/7m9V4rUoNJZwCzo9E2+T9R0URUn8RlVlMy3kJqRzliTed0 WBMthgAKyUPu4S9TtVNLDIF595O2IZRBYLXtQy2iEfb2ut5UbqoETUrkI M1uxr9JLqfs5wRu+QdxC1e5Vfw7e1d8Xmb/u4CO3r8APJmwKcFBGOfsY6 fW5Sv/IFaHcwiai9JjHnJlWTRy/eYk5Kn9/rZvfwMWxisU+AzeETGsG17 Y42cKK/JQBxLFh1ym5vKLb176ADg8e5eYLMSHquEr9mx6No2nUzC9dhb6 LbLig9xwymVBi+NHHvzMEmFdlhE66uZEzFRiLby1DXGsxS+KHHpL66ZjU Q==; X-CSE-ConnectionGUID: CBsOY6wnQDSgxMHfJKjuYw== X-CSE-MsgGUID: fhoSPV+QTrihIvbfgbdufw== X-IronPort-AV: E=McAfee;i="6800,10657,11632"; a="77629300" X-IronPort-AV: E=Sophos;i="6.20,251,1758610800"; d="scan'208";a="77629300" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2025 21:03:23 -0800 X-CSE-ConnectionGUID: o+8WIpPMTOulJj5+btZRbA== X-CSE-MsgGUID: do2uYsH2RkGed507ZswgSg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,251,1758610800"; d="scan'208";a="195230298" Received: from allen-sbox.sh.intel.com (HELO [10.239.159.30]) ([10.239.159.30]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2025 21:03:18 -0800 Message-ID: Date: Fri, 5 Dec 2025 12:58:48 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH v2 11/32] iommu/pages: Add APIs to preserve/unpreserve/restore iommu pages To: Samiullah Khawaja Cc: David Woodhouse , Joerg Roedel , Will Deacon , Pasha Tatashin , Jason Gunthorpe , iommu@lists.linux.dev, Robin Murphy , Pratyush Yadav , Kevin Tian , Alex Williamson , linux-kernel@vger.kernel.org, Saeed Mahameed , Adithya Jayachandran , Parav Pandit , Leon Romanovsky , William Tu , Vipin Sharma , dmatlack@google.com, YiFei Zhu , Chris Li , praan@google.com References: <20251202230303.1017519-1-skhawaja@google.com> <20251202230303.1017519-12-skhawaja@google.com> Content-Language: en-US From: Baolu Lu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 12/5/25 01:39, Samiullah Khawaja wrote: > On Wed, Dec 3, 2025 at 6:30 PM Baolu Lu wrote: >> On 12/3/25 07:02, Samiullah Khawaja wrote: >>> +int iommu_preserve_pages(struct iommu_pages_list *list) >>> +{ >>> + struct ioptdesc *iopt; >>> + int count = 0; >>> + int ret; >>> + >>> + list_for_each_entry(iopt, &list->pages, iopt_freelist_elm) { >>> + ret = kho_preserve_folio(ioptdesc_folio(iopt)); >>> + if (ret) { >>> + iommu_unpreserve_pages(list, count); >>> + return ret; >>> + } >>> + >>> + ++count; >>> + } >>> + >>> + return 0; >>> +} >>> +EXPORT_SYMBOL_GPL(iommu_preserve_pages); >> What is the purpose of "count"? > Thanks for reviewing. > > The count is there to unpreserve only the preserved pages if an error > occurs during preservation. For example if 4 pages (from the start of > the list) were preserved out of 10 pages in the list, the unpreserve > function will unpreserve the first 4 pages from the start of the list. > Please take a look at the implementation of iommu_unpreserve_pages for > details. Oh, I see now. Thanks!