Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp2625426rdb; Mon, 25 Dec 2023 22:10:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IG6jGCj1v/pJJ2+00awi0n3QyvPrCHyCSw8PbFwWw9mZcXInG+wCMz74Yite8LXF5A9fZYV X-Received: by 2002:aa7:854b:0:b0:6d9:915f:3669 with SMTP id y11-20020aa7854b000000b006d9915f3669mr1940757pfn.49.1703571029518; Mon, 25 Dec 2023 22:10:29 -0800 (PST) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id jw36-20020a056a0092a400b006d9d2ba8557si1193473pfb.308.2023.12.25.22.10.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Dec 2023 22:10:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-11383-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UOkQSOjW; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-11383-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11383-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 244C1282276 for ; Tue, 26 Dec 2023 06:10:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AA75A4C3C6; Tue, 26 Dec 2023 06:10:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="UOkQSOjW" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) (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 B62094BA90; Tue, 26 Dec 2023 06:10:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1703571010; x=1735107010; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=2lKbUdAbSm5osvNJ8Bp5ISAXxNNC0OReoDWQ8yp4XHs=; b=UOkQSOjWyEfOpdjWvsJSBSOHbwugMjcBK6ePhCc97ZdB92opRa2JZSSQ 3H3X0/NEyDwNO3BNGn+Ydw81MfeOjzLuv1BKeGi/+/dtQV9yjhAq8zmVq uiSqlZ0rUZNHtffDaY2ngx1+ySGphiD4d3tIbCTZklvgU1+iuK/GNE7rU SlQf2jW1vmoUKkdDkWsWKH2WDBh7DufU/UzvWCXhQi2VKXO6z9fwwXPiq w3FjJbW8CSPmGO4zsd4UpYu9kV/KT2Z940Kj8M0gTmHjEYfd4pI7NU5vQ pbBP3oWHORkhwnTax1qdeXtvOXBK9vflc+Fj1hqt6wPkK5VysHvFLjmKl w==; X-IronPort-AV: E=McAfee;i="6600,9927,10934"; a="482502715" X-IronPort-AV: E=Sophos;i="6.04,304,1695711600"; d="scan'208";a="482502715" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Dec 2023 22:10:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10934"; a="777869547" X-IronPort-AV: E=Sophos;i="6.04,304,1695711600"; d="scan'208";a="777869547" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga002.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 25 Dec 2023 22:10:09 -0800 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 25 Dec 2023 22:10:08 -0800 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Mon, 25 Dec 2023 22:10:08 -0800 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.168) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 25 Dec 2023 22:10:08 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O1C+0BkZEFrmuYETHAzQKuqqsgQKfr7/i3b2q2stc6IpeoIdVvDr1gHM+uEWINDZv6TZhEFHRJET6giKS/du8IZLX0wARk8UJgr9KTBOR2/z/PW/edsu8bnqc6i500mFyEf4OZYFKpLIFQmG1uP+BV//i8TjcLWVY1+hAE4voSKc/W0AmNqxJzn2KqNPKDlG5n47f2w/YZ2ZLeCebwXLxvuYWWfKQBb9uBO8xeX5L28t5VkIM0XBfTYTV+NdpsS/GYj7UUE3rJXvV9Ymh+gl9y/5vlMCRmBTrlaUG4ka0gwNIySZQ09RKxqHeGWAVWNDsSim+hj6bM6E+pqW08HiVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=d/CoNFLgp8NOG6gG628As4E8YwhC7rKK6yPBvIEXyZU=; b=f/Z/C+Xx5Z62CZ2oq6oPOkVcjp5D9Y0lurClQOGMGJ4zOnejYgDlN5dgr35OeDvfahHzNI8J6wH9IjTNHPqz+U2rSGMWEz0lBonXdiWg+zThphFfJ1fxzpX6/GqwV8T0OU+DVfAt7/2jTSj/bU7fVvcp6YJcUQtBhzdvytPhcMK3P2jpz/RjFF7bnyKatqYbvp2uLKZF8xvL2wScGk7tJ4Zxp3kKO5gm5LOi7smKYPhzr1q/ZTqdT0Lq3D0qV6O+yO4sqKcK79Fp3qs2KrpdPZ6CqKGLeMm2FSVKfz9wv/Q0sjEDLYvU5oV2OUK/6NTJq7qjqErrMX2twMPEKK0vVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DM4PR11MB5469.namprd11.prod.outlook.com (2603:10b6:5:399::13) by BN9PR11MB5451.namprd11.prod.outlook.com (2603:10b6:408:100::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.27; Tue, 26 Dec 2023 06:10:06 +0000 Received: from DM4PR11MB5469.namprd11.prod.outlook.com ([fe80::ab4c:76d3:b700:26fb]) by DM4PR11MB5469.namprd11.prod.outlook.com ([fe80::ab4c:76d3:b700:26fb%7]) with mapi id 15.20.7113.027; Tue, 26 Dec 2023 06:10:05 +0000 Message-ID: <0ba8e579-2b6f-4e9f-a38c-097694f14d3c@intel.com> Date: Tue, 26 Dec 2023 14:09:29 +0800 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 01/10] iommu/vt-d: add wrapper functions for page allocations Content-Language: en-US To: Pasha Tatashin , David Rientjes CC: Andrew Morton , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , References: <20231130201504.2322355-1-pasha.tatashin@soleen.com> <20231130201504.2322355-2-pasha.tatashin@soleen.com> <776e17af-ae25-16a0-f443-66f3972b00c0@google.com> From: "Liu, Jingqi" In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI2PR06CA0018.apcprd06.prod.outlook.com (2603:1096:4:186::8) To DM4PR11MB5469.namprd11.prod.outlook.com (2603:10b6:5:399::13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5469:EE_|BN9PR11MB5451:EE_ X-MS-Office365-Filtering-Correlation-Id: ce551948-3a19-45fd-81e9-08dc05d94db8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j3Bj7lyRwi1Wd/4Kk0pOSrSG8+VpPZm3mmb14U0PRJgCr3aCUMFtRCkM3iSPIADy5UIdEhRElev2topzuCdLGAgpZo2mAXq49YwzYTDLgmqHLbCRm81FHd2zgEw/x8t503I9NQzEmpWAKDHnaD7cIZQjzD1/3jZ/sME/jh+utoHx8sqqxiSioYh1/heqK7uVWBVdFeUyqcvLKe3eAhesgxQLoX+q/upiwLEEetedhDSI0Mkdm+6uggPDCuq/O6mn0h07MFD1yu7nM4FlMP4mlz9fyatrX/+6oiy83/fnAGmKRqteCqKDKNJ0kXEpm4J/lpKVBrk6wQ1wCTYKCdZBZ0AeqFDXQuna2OkDJg+QvG8JVzRcsobDoTvHCpvckMr1JQm9XtFIHr6hQRxjLE3hGOY0Ye6Jq1RVyETFohaH8b0nItjoGVfSZCDu9wZJQxtCt+b+O6ewUTa6YFRYsggA1oQF02zsknWkie1Xpepk4Nbt1bqFBd2L6lZFAkG5B/CicMZNKa9hx5uMGQ2KZrPA3uqNFvU4NANJ9wydVTyaFs6qxyJe+qMp8OJVusw7PGkOjokAxupTwiqfGNg23zhnk8rFw7mxt/ihcNLrDVikaztCz4JZBRheJsbnIgmQDPCD8rgHDgSZKNjG8qjtWBZ2tQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR11MB5469.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(39860400002)(136003)(396003)(346002)(366004)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(83380400001)(82960400001)(36756003)(31696002)(86362001)(41300700001)(38100700002)(5660300002)(7406005)(7416002)(8936002)(66556008)(66476007)(316002)(66946007)(4326008)(8676002)(53546011)(110136005)(2616005)(6512007)(6506007)(26005)(478600001)(6486002)(2906002)(6666004)(31686004)(45980500001)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?ajBrQm9tK3JYNEh6Zkd2d2p6aVpWWDBMTWdxNHBQN0JGV3VqOE9HZlBldkVV?= =?utf-8?B?NnFGNUpBdENRVGFNZ1hqZjlhcVByMDdEektqb3U0SHgzV1RhWUNQYUIwY0xF?= =?utf-8?B?cFZZMFplbW90d241eno1WTZRWlo2SHFiQmpYdW94TktOSUNXVWRjYm9tNW8v?= =?utf-8?B?Z0V1aTQxUjRpbklkNTBUeEhsMnF2QlhDbmNVdmRBRTBlWVlJRmNsY0Exb2Iz?= =?utf-8?B?SGx6TG9YTGw1UTF4Q3hCOGtjVExwT3Zhc3Q3V0ViRFNVeFJkQ2lORUZ2RVZi?= =?utf-8?B?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hFN0h0ZGFXU0Er?= =?utf-8?Q?3y9OqVlNLA5Ur3SmszelvsZuF?= X-MS-Exchange-CrossTenant-Network-Message-Id: ce551948-3a19-45fd-81e9-08dc05d94db8 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5469.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Dec 2023 06:10:05.3321 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qy7TaEZXs462FSdSWGMKIBTyc88uxEEGAC2WAd+kvyqlkPZ2boaR78CyO+ZFoxEk8WItl0kK7BWkW5fm1d6lTw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR11MB5451 X-OriginatorOrg: intel.com On 12/15/2023 3:16 AM, Pasha Tatashin wrote: > On Thu, Dec 14, 2023 at 12:58 PM David Rientjes wrote: >> >> On Thu, 30 Nov 2023, Pasha Tatashin wrote: >> >>> diff --git a/drivers/iommu/iommu-pages.h b/drivers/iommu/iommu-pages.h >>> new file mode 100644 >>> index 000000000000..2332f807d514 >>> --- /dev/null >>> +++ b/drivers/iommu/iommu-pages.h >>> @@ -0,0 +1,199 @@ >>> +/* SPDX-License-Identifier: GPL-2.0-only */ >>> +/* >>> + * Copyright (c) 2023, Google LLC. >>> + * Pasha Tatashin >>> + */ >>> + >>> +#ifndef __IOMMU_PAGES_H >>> +#define __IOMMU_PAGES_H >>> + >>> +#include >>> +#include >>> +#include >>> + >>> +/* >>> + * All page allocation that are performed in the IOMMU subsystem must use one of >>> + * the functions below. This is necessary for the proper accounting as IOMMU >>> + * state can be rather large, i.e. multiple gigabytes in size. >>> + */ >>> + >>> +/** >>> + * __iommu_alloc_pages_node - allocate a zeroed page of a given order from >>> + * specific NUMA node. >>> + * @nid: memory NUMA node id >> >> NUMA_NO_NODE if no locality requirements? > > If no locality is required, there is a better interface: > __iommu_alloc_pages(). That one will also take a look at the calling > process policies to determine the proper NUMA node when nothing is > specified. However, when policies should be ignored, and no locality > required, NUMA_NO_NODE can be passed. > >> >>> + * @gfp: buddy allocator flags >>> + * @order: page order >>> + * >>> + * returns the head struct page of the allocated page. >>> + */ >>> +static inline struct page *__iommu_alloc_pages_node(int nid, gfp_t gfp, >>> + int order) >>> +{ >>> + struct page *pages; >> >> s/pages/page/ here and later in this file. > > In this file, where there a page with an "order", I reference it with > "pages", when no order (i.e. order = 0), I reference it with "page" > > I.e.: __iommu_alloc_page vs. __iommu_alloc_pages > >> >>> + >>> + pages = alloc_pages_node(nid, gfp | __GFP_ZERO, order); >>> + if (!pages) >> >> unlikely()? > > Will add it. > >> >>> + return NULL; >>> + >>> + return pages; >>> +} >>> + >>> +/** >>> + * __iommu_alloc_pages - allocate a zeroed page of a given order. >>> + * @gfp: buddy allocator flags >>> + * @order: page order >>> + * >>> + * returns the head struct page of the allocated page. >>> + */ >>> +static inline struct page *__iommu_alloc_pages(gfp_t gfp, int order) >>> +{ >>> + struct page *pages; >>> + >>> + pages = alloc_pages(gfp | __GFP_ZERO, order); >>> + if (!pages) >>> + return NULL; >>> + >>> + return pages; >>> +} >>> + >>> +/** >>> + * __iommu_alloc_page_node - allocate a zeroed page at specific NUMA node. >>> + * @nid: memory NUMA node id >>> + * @gfp: buddy allocator flags >>> + * >>> + * returns the struct page of the allocated page. >>> + */ >>> +static inline struct page *__iommu_alloc_page_node(int nid, gfp_t gfp) >>> +{ >>> + return __iommu_alloc_pages_node(nid, gfp, 0); >>> +} >>> + >>> +/** >>> + * __iommu_alloc_page - allocate a zeroed page >>> + * @gfp: buddy allocator flags >>> + * >>> + * returns the struct page of the allocated page. >>> + */ >>> +static inline struct page *__iommu_alloc_page(gfp_t gfp) >>> +{ >>> + return __iommu_alloc_pages(gfp, 0); >>> +} >>> + >>> +/** >>> + * __iommu_free_pages - free page of a given order >>> + * @pages: head struct page of the page >> >> I think "pages" implies more than one page, this is just a (potentially >> compound) page? > > Yes, more than one page, basically, when order may be > 0. > >>> +/** >>> + * iommu_free_page - free page >>> + * @virt: virtual address of the page to be freed. >>> + */ >>> +static inline void iommu_free_page(void *virt) >>> +{ >>> + iommu_free_pages(virt, 0); >>> +} >>> + >>> +/** >>> + * iommu_free_pages_list - free a list of pages. >>> + * @pages: the head of the lru list to be freed. >> >> Document the locking requirements for this? > > Thank you for the review. I will add info about locking requirements, > in fact they are very relaxed. > > These pages are added to the list by unmaps or remaps operation in > Intel IOMMU implementation. These calls assume that whoever is doing > those operations has exclusive access to the VA range in the page > table of that operation. The pages in this freelist only belong to the > former page-tables from the IOVA range for those operations. These pages maybe be accessed concurrently by thread contexts other than the IOMMU driver (such as debugfs). Thanks, Jingqi > >>> + */ >>> +static inline void iommu_free_pages_list(struct list_head *pages) >>> +{ >>> + while (!list_empty(pages)) { >>> + struct page *p = list_entry(pages->prev, struct page, lru); >>> + >>> + list_del(&p->lru); >>> + put_page(p); >>> + } >>> +} >