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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F55AC46CD2 for ; Sun, 24 Dec 2023 21:30:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E15C18E0002; Sun, 24 Dec 2023 16:30:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DC56C8E0001; Sun, 24 Dec 2023 16:30:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C8CA48E0002; Sun, 24 Dec 2023 16:30:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B85C58E0001 for ; Sun, 24 Dec 2023 16:30:54 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 85F8440219 for ; Sun, 24 Dec 2023 21:30:54 +0000 (UTC) X-FDA: 81603006828.19.0841343 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by imf30.hostedemail.com (Postfix) with ESMTP id B96DB8001C for ; Sun, 24 Dec 2023 21:30:52 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="fF1uJ1I/"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf30.hostedemail.com: domain of rientjes@google.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=rientjes@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703453452; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=7/MCgJrzTYbobYDGPWMaxVSPHC8aF5GoN3HBnQNC1yE=; b=0LBBw0bhSP71E4yVWLEmZfv9I7wR5zONTWbLCs5t3DpgFtnRE53rWX29cTFR8xvOZ1GmLC /7lX/LW2xvG4Y/lTGPwGltBHXllXRIl4kMYJ208i3vNHvPTTMDaACwIGm+l1ikW74+XWUa 43qHEc9jwU9ekOSyYtHmpye8xBqnH0c= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="fF1uJ1I/"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf30.hostedemail.com: domain of rientjes@google.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=rientjes@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703453452; a=rsa-sha256; cv=none; b=m9ni9L3Xz0JPRhJqKFYN0Nt7Uop15rGL3U790+KFA8XxmN20LFd30OGs+T4RtaZuzXKv6o oPhm6EWVUUU2lt98npHD6huaxCVbEAO7t6pxGGOtqtUkap6MMuc8HwEtI2wr3ujHZVe4Th QJ2XE04qSoqKjGqxZFlJHAt4FwkPn3A= Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1d42ed4cdc7so134995ad.0 for ; Sun, 24 Dec 2023 13:30:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1703453452; x=1704058252; darn=kvack.org; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=7/MCgJrzTYbobYDGPWMaxVSPHC8aF5GoN3HBnQNC1yE=; b=fF1uJ1I/lmeBUMUIxo8HvYJfVkX0NbCeko8+e9fCVBxRk3qK/juyqiFGtzKz8V9BQP bbFuVEnJ1ypEoli8ultQOJ17B4GE/+E0B0P6wv8cjxiKK8RdyfPIj08k7QCOytW0LnwW VG9W2Yv2xvSA4U8GBMFqrURMhizV2w0Be8f4kclX/BuM7jSvI9wJHdxEAFuUrwYZ7hsS xaZOosnUbA9BThAybxrdfwfkhS0Evi8Qx3wDOE/nxwsLOFqFqdBFabQDcySDZs+IKki0 b69QSJEGGgyYYCQw9Kxx058liwJV3GFmlrm1h2GYPch8qJUHgXWaOj7rItGCbZcx9Ade IxNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703453452; x=1704058252; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7/MCgJrzTYbobYDGPWMaxVSPHC8aF5GoN3HBnQNC1yE=; b=n7b/T1s7rLC+Bug49MhaUiWQ3yhl4qK1MX1oTWM+EI9g8ZE5rDJ02w/sS2U/8b4z8X MclwRg41yC2Gi5zpO0/c5sdvNh4XR6CX6pCam85U1RpBi7jPj3EkdPvUKlbhXjsbGCMh DHuED5wzst0d9vWJRWzRREs4yipNmZvXcpju2H3CLP1+tXpPAVCnX2Bs46EA6bhDIixc 7wcEIKZQJVT1r/T7V/iaxE9UVFp74RcRoQjadeXBz2tsDqYlBqzwUwUGHEbTn/kuyoez 6cMVHfEWBKjPM8QclvQRY0BeAEysZDmciJghxNPhwqQXohkKtQ5GE0pAKC0IAmWO0kzK jfkw== X-Gm-Message-State: AOJu0YxzcffKbnlqiCQrUn4m0YEwmjL1UPA1PDac5yUeCrZz5fiV21RG P0Wesjls0IB4u+wsc6r8Dj8OhB5+NnR4 X-Google-Smtp-Source: AGHT+IGEdm29d6jmw+nANphFK7SbhaR7mM9JSy5/jGKgQinKhgDaZxXLk5PDheL/k90mn9Ft6aU5hg== X-Received: by 2002:a17:902:bb84:b0:1d4:55b3:45d9 with SMTP id m4-20020a170902bb8400b001d455b345d9mr28530pls.6.1703453451456; Sun, 24 Dec 2023 13:30:51 -0800 (PST) Received: from [2620:0:1008:15:c723:e11e:854b:ac88] ([2620:0:1008:15:c723:e11e:854b:ac88]) by smtp.gmail.com with ESMTPSA id b14-20020a170902d50e00b001d3dacffde3sm6890413plg.226.2023.12.24.13.30.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 13:30:50 -0800 (PST) Date: Sun, 24 Dec 2023 13:30:50 -0800 (PST) From: David Rientjes To: Pasha Tatashin cc: Andrew Morton , alim.akhtar@samsung.com, alyssa@rosenzweig.io, asahi@lists.linux.dev, baolu.lu@linux.intel.com, bhelgaas@google.com, cgroups@vger.kernel.org, corbet@lwn.net, david@redhat.com, dwmw2@infradead.org, hannes@cmpxchg.org, heiko@sntech.de, iommu@lists.linux.dev, jernej.skrabec@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, krzysztof.kozlowski@linaro.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, lizefan.x@bytedance.com, marcan@marcan.st, mhiramat@kernel.org, m.szyprowski@samsung.com, paulmck@kernel.org, rdunlap@infradead.org, robin.murphy@arm.com, samuel@sholland.org, suravee.suthikulpanit@amd.com, sven@svenpeter.dev, thierry.reding@gmail.com, tj@kernel.org, tomas.mudrunka@gmail.com, vdumpa@nvidia.com, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com Subject: Re: [PATCH v2 01/10] iommu/vt-d: add wrapper functions for page allocations In-Reply-To: Message-ID: <1fd66377-030c-2e48-e658-4669bbf037e9@google.com> References: <20231130201504.2322355-1-pasha.tatashin@soleen.com> <20231130201504.2322355-2-pasha.tatashin@soleen.com> <776e17af-ae25-16a0-f443-66f3972b00c0@google.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="2003067076-655310594-1703453450=:2163178" X-Rspamd-Queue-Id: B96DB8001C X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: sk6w4dfzz6md9owg486benhd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CsqjZyOBGwGrH9A7t5fOsRT2Z4TtxwNoXQymh3b9uFKt1WRIf5XmXn8XnqhusppjV0AAMvdpuspEQMtnDMLfeoinAIyk6tIOiRrgAY2y41ICiI7N3QweircvWqmvkADJhRt4GUAM0nWaRO+oI8Ywb8TjEaOg2vNLbOWt74v37fdyM5CT/yYn6JMqgUxHmku0A+3+KEHAcMelnO6FW9Gm/BU6iESdY4IToS83wE+YyHaB03n7N3jGW+max9AICPWlp6mRdT1SR649yzLxkb+5NtflPFXP/dA75x3uEtSS4zODzVKdTEscoHUiZFl+EQjakFQAl/W4SXOGncM/0CWGbf2FcQxz2RXsGrK2FIb1DWsRAmC0oPqjd10FoT04RvTFUILLgKeukZNbFKBcsf49JA8CAJ42p2VpnT6OnRF9djEXXGcYfIgyTMvpmNI6vCeQ0UdD3jyjfuN3MzfE8nlvqGoWRxGdCbz8gB09NTkLwvyOeXy2qoAcfVMLFNWQzkn5Ra7w+/HRI1CUP6k8SmRk7p/02AOjH6X8aJA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --2003067076-655310594-1703453450=:2163178 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT On Thu, 14 Dec 2023, 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. > Gotcha, thanks! > > > > > + * @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 > Eh, the struct page points to a (potentially compound) page, not a set or list of pages. I won't bikeshed on it, but "struct page *pages" never makes sense unless it's **pages or *pages[] :) --2003067076-655310594-1703453450=:2163178--