All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jacob Pan <jacob.jun.pan@linux.intel.com>
To: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Mel Gorman <mgorman@suse.de>, Vlastimil Babka <vbabka@suse.cz>,
	David Hildenbrand <david@redhat.com>,
	linux-mm@kvack.org, linux-arch@vger.kernel.org,
	linux-kernel@vger.kernel.org, Robin Murphy <robin.murphy@arm.com>,
	jacob.jun.pan@linux.intel.com
Subject: Re: [PATCH 09/10] iommu: Fix MAX_ORDER usage in __iommu_dma_alloc_pages()
Date: Wed, 15 Mar 2023 09:07:39 -0700	[thread overview]
Message-ID: <20230315090739.128d4341@jacob-builder> (raw)
In-Reply-To: <20230315113133.11326-10-kirill.shutemov@linux.intel.com>

Hi Kirill,

On Wed, 15 Mar 2023 14:31:32 +0300, "Kirill A. Shutemov"
<kirill.shutemov@linux.intel.com> wrote:

> MAX_ORDER is not inclusive: the maximum allocation order buddy allocator
> can deliver is MAX_ORDER-1.
> 
> Fix MAX_ORDER usage in __iommu_dma_alloc_pages().
> 
> Also use GENMASK() instead of hard to read "(2U << order) - 1" magic.
> 
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Cc: Robin Murphy <robin.murphy@arm.com>
> Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
> ---
>  drivers/iommu/dma-iommu.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
> index 99b2646cb5c7..ac996fd6bd9c 100644
> --- a/drivers/iommu/dma-iommu.c
> +++ b/drivers/iommu/dma-iommu.c
> @@ -736,7 +736,7 @@ static struct page **__iommu_dma_alloc_pages(struct
> device *dev, struct page **pages;
>  	unsigned int i = 0, nid = dev_to_node(dev);
>  
> -	order_mask &= (2U << MAX_ORDER) - 1;
> +	order_mask &= GENMASK(MAX_ORDER - 1, 0);
>  	if (!order_mask)
>  		return NULL;
>  
> @@ -756,7 +756,7 @@ static struct page **__iommu_dma_alloc_pages(struct
> device *dev,
>  		 * than a necessity, hence using __GFP_NORETRY until
>  		 * falling back to minimum-order allocations.
>  		 */
> -		for (order_mask &= (2U << __fls(count)) - 1;
> +		for (order_mask &= GENMASK(__fls(count), 0);
>  		     order_mask; order_mask &= ~order_size) {
>  			unsigned int order = __fls(order_mask);
>  			gfp_t alloc_flags = gfp;
Reviewed-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
(For VT-d part, there is no functional impact at all. We only have 2M and 1G
page sizes, no SZ_8M page)

Thanks,

Jacob

  parent reply	other threads:[~2023-03-15 16:08 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-15 11:31 [PATCH 00/10] Fix confusion around MAX_ORDER Kirill A. Shutemov
2023-03-15 11:31 ` [PATCH 01/10] sparc/mm: Fix MAX_ORDER usage in tsb_grow() Kirill A. Shutemov
2023-03-16  3:04   ` Mike Kravetz
2023-03-17  8:46     ` Mike Rapoport
2023-03-17  8:35   ` Mike Rapoport
2023-03-21  7:48   ` Vlastimil Babka
2023-03-15 11:31 ` [PATCH 02/10] um: Fix MAX_ORDER usage in linux_main() Kirill A. Shutemov
2023-03-17  8:49   ` Mike Rapoport
2023-03-21  7:49   ` Vlastimil Babka
2023-03-15 11:31 ` [PATCH 03/10] floppy: Fix MAX_ORDER usage Kirill A. Shutemov
2023-03-17  8:53   ` Mike Rapoport
2023-03-21  7:53   ` Vlastimil Babka
2023-03-15 11:31 ` [PATCH 04/10] drm/i915: Fix MAX_ORDER usage in i915_gem_object_get_pages_internal() Kirill A. Shutemov
2023-03-15 14:18   ` Tvrtko Ursulin
2023-03-15 15:28     ` Kirill A. Shutemov
2023-03-15 15:35       ` Tvrtko Ursulin
2023-03-15 15:38         ` Kirill A. Shutemov
2023-03-16  8:55           ` Tvrtko Ursulin
2023-03-21  7:57             ` Vlastimil Babka
2023-03-21  7:55   ` Vlastimil Babka
2023-03-15 11:31 ` [PATCH 05/10] genwqe: Fix MAX_ORDER usage Kirill A. Shutemov
2023-03-21  7:59   ` Vlastimil Babka
2023-03-15 11:31 ` [PATCH 06/10] perf/core: Fix MAX_ORDER usage in rb_alloc_aux_page() Kirill A. Shutemov
2023-03-21  8:00   ` Vlastimil Babka
2023-03-15 11:31 ` [PATCH 07/10] mm/page_reporting: Fix MAX_ORDER usage in page_reporting_register() Kirill A. Shutemov
2023-03-21  8:01   ` Vlastimil Babka
2023-03-15 11:31 ` [PATCH 08/10] mm/slub: Fix MAX_ORDER usage in calculate_order() Kirill A. Shutemov
2023-03-16 11:18   ` Vlastimil Babka
2023-03-15 11:31 ` [PATCH 09/10] iommu: Fix MAX_ORDER usage in __iommu_dma_alloc_pages() Kirill A. Shutemov
2023-03-15 12:18   ` Robin Murphy
2023-03-22 12:20     ` Joerg Roedel
2023-03-15 16:07   ` Jacob Pan [this message]
2023-03-21  8:05   ` Vlastimil Babka
2023-03-15 11:31 ` [PATCH 10/10] mm, treewide: Redefine MAX_ORDER sanely Kirill A. Shutemov
2023-03-15 15:06   ` kernel test robot
2023-03-15 15:26     ` Kirill A. Shutemov
2023-03-15 15:26   ` kernel test robot
2023-03-15 15:38     ` Kirill A. Shutemov
2023-03-16 17:09   ` Zi Yan
2023-03-16 23:21     ` Kirill A. Shutemov
2023-03-17 13:17       ` Zi Yan
2023-03-16 18:15   ` Mike Kravetz
2023-03-16 23:00     ` Mike Kravetz
2023-03-16 23:30     ` Kirill A. Shutemov
2023-03-17  1:57       ` Vineet Gupta
2023-03-21 11:22   ` Vlastimil Babka
2023-03-22  3:26   ` Michael Ellerman
2023-03-21 16:38 ` [PATCH 00/10] Fix confusion around MAX_ORDER Mel Gorman
2023-03-23 15:03   ` David Laight
2023-09-27 17:11 ` Paolo Bonzini
2023-09-27 17:11   ` [dm-devel] " Paolo Bonzini
2023-09-28  7:50   ` Mikulas Patocka
2023-09-28  7:50     ` [dm-devel] " Mikulas Patocka
2023-09-28 16:57     ` Paolo Bonzini
2023-09-28 16:57       ` [dm-devel] " Paolo Bonzini
2023-10-17 10:46       ` Pavel Machek
2023-10-17 10:46         ` Pavel Machek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230315090739.128d4341@jacob-builder \
    --to=jacob.jun.pan@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=robin.murphy@arm.com \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.